Bitcoin Forum
May 07, 2024, 03:55:58 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: how can access bitcoin rpc from laravel  (Read 125 times)
linz (OP)
Newbie
*
Offline Offline

Activity: 23
Merit: 6


View Profile
October 08, 2022, 05:24:48 PM
Last edit: October 11, 2022, 05:23:51 PM by linz
 #1

hello i try to access bitcoin rpc from laravel app.
here is env file
Code:
### 上記省略 ###
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

Code:
rpcuser=coinuser
   rpcpassword=coinpassword
   rpcallowip=127.0.0.1
   daemon=1

my laravel config file is
Code:
<?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
Code:
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

Code:
<?php

namespace App\Http\Controllers;

use 
Illuminate\Http\Request;

use 
Config;

# &#20808;&#12411;&#12393;&#12480;&#12454;&#12531;&#12525;&#12540;&#12489;&#12375;&#12383;&#12521;&#12452;&#12502;&#12521;&#12522;&#12434;use&#12377;&#12427;
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.cpp

how 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
1715054158
Hero Member
*
Offline Offline

Posts: 1715054158

View Profile Personal Message (Offline)

Ignore
1715054158
Reply with quote  #2

1715054158
Report to moderator
You get merit points when someone likes your post enough to give you some. And for every 2 merit points you receive, you can send 1 merit point to someone else!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715054158
Hero Member
*
Offline Offline

Posts: 1715054158

View Profile Personal Message (Offline)

Ignore
1715054158
Reply with quote  #2

1715054158
Report to moderator
serhack
Member
**
Offline Offline

Activity: 107
Merit: 168

Security Researcher and Writer


View Profile WWW
October 10, 2022, 03:14:42 PM
 #2

Quote
fwrite(): Write of 2123 bytes failed with errno=28 No space left on device

Sad You should not have exposed your IP to internet

n0nce
Hero Member
*****
Offline Offline

Activity: 882
Merit: 5818


not your keys, not your coins!


View Profile WWW
October 10, 2022, 07:10:46 PM
 #3

Quote
fwrite(): Write of 2123 bytes failed with errno=28 No space left on device
Sad You should not have exposed your IP to internet
They could (should) try getting a new one from their ISP; usually not a problem. But good that you guys pointed it out! Wink

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
newnft
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
October 10, 2022, 07:12:25 PM
 #4

fwrite(): Write of 2123 bytes failed with errno=28 No space left on device

you dont have more space...

try : rm -rf /var/logs
and rm -rf /tmp/*

then try again

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!