Targetting a specific wallet when sending commands using RPC commands to bitcoind

0

I'm very new to Bitcoin development, using its RPC API.

I created a wallet using

{
    "method": "createwallet",
    "params": {
        "wallet_name": "/wallets/walletA"
    }
}

Now I want to get info about this wallet. I try to use the getwalletinfo command.

But it seems you can't specify the wallet name/path when running this command? You have to "load" the wallet first (using loadwallet)?

This is the part I do not understand. Let's say I have created 10 wallets and I try to run a getwalletinfo command in a multithreaded environment... How can I make sure I target the right wallet? Do I really have to send a loadwallet request to specify the wallet I want to work on, before getting info about it?

What will occure if I want to get information about "walletA" so I run loadwallet walletA, but before I can run getwalletinfo to get its info, a loadwallet walletB request is made?

electrotype

Posted 2019-09-21T00:17:02.557

Reputation: 151

Answers

1

When more than one wallet is available, the wallet is selected by sending the RPC requests to <host:port>/wallet/<wallet_name>.

You might have to play around with the exact form, I suspect it might be <host:port>/wallet/wallets/walletA in your case, or <host:port>/wallets/walletA, or <host:port>/wallet/walletA.

Raghav Sood

Posted 2019-09-21T00:17:02.557

Reputation: 10 897

I have been unable to make this work. Maybe because I'm on Windows with backslahes in paths. I tried everything: url encoding, escaping backslahes, etc. I even looked at Bitcoin code, and I'm not sure paths are properly managed when following /wallet/ in urls! In the end, I decided to use the walletdir config in bitcoin.confin order to specify the directory where wallets will be created. And I only use the name of a wallet (no path) in the RPC /wallet/[wallet_name] url. This works. Hope it helps someone, one day.electrotype 2019-09-21T13:57:54.690

By the way, thanks for your help Raghav! :-)electrotype 2019-09-21T19:59:38.250