I'm creating a website which will generate a new BTC wallet for every user, I'm trying to get the specific wallet's balance which I know is inside an array when running getwalletinfo
. However, getwalletinfo
RPC takes no parameters and therefore I don't know how I'm going to get specific wallet info.
I've tried running the following commands in the cmd line:
bitcoin-cli getwalletinfo "http://127.0.0.1:8332/wallets/testwallet"
bitcoin-cli getwalletinfo "~/bitcoin/wallets/testwallet"
Both returning error codes. For clearance, my bitcoin data directory isn't located in my server directory.
In PHP I use this code, I use the EasyBitcoin PHP library to be clear:
$bitcoin = new Bitcoin('user', 'password');
$get_wallet_info = $bitcoin->getwalletinfo("home/user/bitcoin/wallets/testwallet");
$balance = $get_wallet_info["balance"];
I expect it to return true and show the specific wallet array, instead I receive the same error.
You have to use RPC call loadwallet before issuing walletinfo.
bitcoin-cli loadwallet <wallet-file-name>