This change allows existing RPCs to work on multiple wallets by calling those RPCs with a wallet=filename named argument. Example usage:
bitcoind -regtest -wallet=w1.dat -wallet=w2.dat
bitcoin-cli -regtest -named getwalletinfo wallet=w1.dat
bitcoin-cli -regtest -named getwalletinfo wallet=w2.dat
bitcoin-cli -regtest -named getbalance wallet=w2.dat
Individual RPCs can override handling of the wallet named argument, but if they
don’t, the GetWalletForJSONRPCRequest
function will automatically chose the
right wallet based on the argument value.
The wallet= parameter is mandatory if multiple wallets are loaded, and this change only allows JSON-RPC calls made with named arguments to access multiple wallets, so wallet RPC calls made positional arguments will not work if more than one wallet is loaded.
Multiwallet python test based on code originally written by @jonasschnelli
This PR is a simpler alternative to #10615, #10650, #10661, and #10849 that allows multiwallet RPC access from bitcoin-cli, python and any other JSON-RPC client that supports named parameters. It is compatible with these other changes and doesn’t prevent adding support for new request-uri endpoints and authorization parameters in the future, but it doesn’t require these things right now.
This PR is a newer version of #10653 which was closed (and couldn’t be reopened because the branch pointer changed).