hello i try to access bitcoin rpc from laravel app.
here is env file
### 上記省略 ###
BITCOIN_RPC_USERNAME=coinuser
BITCOIN_RPC_PASSWORD=coinpassword
BITCOIN_RPC_HOST=127.0.0.1
# regtest default port
BITCOIN_RPC_PORT=8332
my bitcoin.conf is
rpcuser=coinuser
rpcpassword=coinpassword
rpcallowip=127.0.0.1
daemon=1
my laravel config file is
<?php
return [
'bitcoin_rpc_username' => env('BITCOIN_RPC_USERNAME', 'coinuser'),
'bitcoin_rpc_password' => env('BITCOIN_RPC_PASSWORD', 'coinpassword'),
'bitcoin_rpc_host' => env('BITCOIN_RPC_HOST', '127.0.0.1'),
# mainnet default port
'bitcoin_rpc_port' => env('BITCOIN_RPC_PORT', '8332'),
];
my routes
Route::get('/btc', [App\Http\Controllers\IndexController::class, 'index']);
i have easybitcoin.php in app/Libs folder as name Bitcoin.php
i namespace it as
```
namespace App\Libs;
```
i have controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Config;
# 先ほどダウンロードしたライブラリをuseする
use App\Libs\Bitcoin;
class IndexController extends Controller
{
public function index()
{
$bitcoin = new Bitcoin(
# rpc username
Config::get('bitcoin.rpc_username'),
# rpc password
Config::get('bitcoin.rpc_password'),
# host
Config::get('bitcoin.rpc_host'),
# regtest port
Config::get('bitcoin.rpc_port')
);
print_r($bitcoin->getrawtransaction());
}
}
my ubuntu ip addresss is
```
54.196.177.134
```
i already run bitcoind in server
when i run routes
```
http://myip/btc```
show error
```
Trying to access array offset on value of type null
```
why this error happen .
bitcoin API call are different now?
here client.cpp that has api call
https://github.com/bitcoin/bitcoin/blob/master/src/rpc/client.cpphow should i get bitcoin call correctly ?
do I need to use my ubuntu ip address as rpcallowip and BITCOIN_RPC_HOST .
what am i wrong
please help me