0

I want to create a wallet for every user. With the easybitcoin rpc, I would like to call up the balance in php. Everything runs in the testnet.

I found out that I have to adjust the initialization like:

$bitcoin = new Bitcoin('bitcoinrpc','Password','localhost','18332','wallets/user/wallet.dat');
or ...127.0.0.1:18332/wallets/user/wallet.dat);
But no option is working.

I want to implement something like this:

function getBalance($user) {
   $bitcoin = new Bitcoin('bitcoinrpc','Password','localhost','18332');
   $balance = $bitcoin->getbalance($user);
   echo $balance
}

Example wallet is located in: /root/.Bitcoin/testnet3/wallets/user/wallet.dat

This:

bitcoin-cli createwallet user
bitcion-cli -rpcwallet=user getbalance

is working, but how can i run it in php.

aynber
  • 22,380
  • 8
  • 50
  • 63
  • Would u take a look at my queston related to `json_rpc` plz: https://stackoverflow.com/questions/67605266/how-to-read-smart-contracts-from-tronscan-org-using-laravel-and-json-rpc –  May 22 '21 at 10:16

1 Answers1

0

I found out today

$bitcoin = new Bitcoin('username','Password','localhost','18332','wallet/walletname');

It's working for me for all "-rpcwallet" issues like "getwalletinfo", "dumpwallet", etc... also in curl commands "-rpcwallet=walletname"

found out by coincidence

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
  • Would u take a look at my queston related to `json_rpc` plz: https://stackoverflow.com/questions/67605266/how-to-read-smart-contracts-from-tronscan-org-using-laravel-and-json-rpc –  May 22 '21 at 10:16