how do I use the getwalletinfo RPC?

1

I can't seem to get a firm grasp of how to use the getwalletinfo RPC in the cmd line as well as in PHP code, The documentation says getwalletinfo doesn't take any parameters, but I've seen ways to send specific requests to the daemon this RPC. So, my question is, how do I use the getwalletinfo RPC in PHP to get information of a specific wallet?

frogman578

Posted 2019-08-01T21:35:25.770

Reputation: 23

Answers

1

getwalletinfo does not take parameters.

It sounds like what you are looking for is how to send getwalletinfo to a certain wallet loaded into Bitcoin Core. The way to do this is to use that wallet's API endpoint. The endpoint is /wallet/<name> where <name> is the name of the wallet you are trying to send commands to.

So the full URL that you need to send your RPC requests to is http://<ip>:<port>/wallet/<name> where <ip> is the IP address that Bitcoin Core is listening on (probably 127.0.0.1), <port> is the port the RPC interface is bound to (probably 8333), and <name> is the name of the wallet.

Andrew Chow

Posted 2019-08-01T21:35:25.770

Reputation: 40 910

so that would be $bitcoin-&gt;getwalletinfo("http://127.0.0.1:8333/wallet/testwallet");?frogman578 2019-08-01T21:42:50.400

To be more specific, this is supposed to be automated, a new wallet is created for every user on my website. The way I see it, now that accounts are gone, wallets are the only thing to use!frogman578 2019-08-01T21:44:04.573

No, that is sending the URL as a parameter as getwalletinfo. As I said, getwalletinfo does not take parameters. You need to change $bitcoin to send RPC requests to http://127.0.0.1:8333/wallet/testwallet rather than http://127.0.0.1:8333/Andrew Chow 2019-08-01T22:17:50.110

So those changes take place in the bitcoin.conf file? Is the <ip><:port> the default URL? I can't think of anything else than parameters to use when automating the selection of wallets, this confuses me!frogman578 2019-08-01T22:32:30.620

No, they are not options to Bitcoin Core. They are something that you need to configure your RPC client to use. It's just like how for REST APIs you need to send requests to a certain URL. You need to do the same thing here; RPC is just a HTTP server where you send requests to a URL. This is something that you need to change in your PHP code. You need to look at the code for the RPC client in PHP and figure out how to set the URL it sends to.Andrew Chow 2019-08-01T23:33:08.557

Oh now I get it, it's probably about the third party class which contains the URL, thanks!frogman578 2019-08-02T05:51:55.070

Ok, I now understand what I need to do, I updated the Bitcoin connection initializer to this: $user_bitcoin = new Bitcoin('user', 'password', 'HTTP', 'localhost', '8332', '127.0.0.1:8332/wallet/');, it then didn't return true. I did a print_r($user_bitcoin-&gt;error()); which returned 1frogman578 2019-08-03T22:32:43.510