2

When calling load_wallet through json-rpc, using "wallet" param with a path to the wallet throws an error:

Commands.load_wallet() got an unexpected keyword argument 'wallet'

In the same time, electrum help load_wallet lists wallet as an acceptable option:

electrum help load_wallet

The question is, how do I specify wallet path when calling load_wallet through json-rpc.

Example payload:

{"jsonrpc":"2.0","id":"test","method":"load_wallet","params":{"wallet": "/electrum/testnet/wallets/orders001"}}
2
  • are you running electrumX ?
    – Saxtheowl
    Commented Mar 15, 2023 at 20:13
  • 1
    No, my question is about Electrum daemon and json-rpc.
    – Meglio
    Commented Mar 15, 2023 at 21:38

2 Answers 2

0

It seems that the "wallet" parameter is not recognized by the "load_wallet" method in the context of the JSON-RPC call you are making.

One solution could be to pass the wallet path as a command-line argument when starting the JSON-RPC server. For example, if you are using Electrum, you could start the server with the following command:

electrum --testnet --rpcuser=<username> --rpcpassword=<password> --rpchost=localhost --rpcport=8000 /electrum/testnet/wallets/orders001

This command starts the Electrum server in testnet mode and specifies the wallet path as the last argument.

Once the server is running, you can make JSON-RPC requests to it without including the "wallet" parameter in the payload. The server should automatically load the wallet specified in the command-line argument.

Alternatively, you could try using the "load_wallet_file" method instead of "load_wallet". According to the Electrum documentation, "load_wallet_file" takes a single argument, which is the path to the wallet file. Here is an example payload:

{"jsonrpc":"2.0","id":"test","method":"load_wallet_file","params":["/electrum/testnet/wallets/orders001"]}

Note that the wallet path is passed as an array element in the "params" field, not as a separate "wallet" parameter.

1
  • None of the solutions proposed help when working with multiple wallets via json-rpc. I need to specify the target wallet for each wallet-related command, and keep multiple wallets loader.
    – Meglio
    Commented Mar 15, 2023 at 21:37
0

You can try the select_wallet method of the Electrum JSON-RPC API to switch between wallets

for example for a wallet dat_test_wallet_01

{"jsonrpc": "2.0", "id": "test", "method": "select_wallet", "params": {"name": "dat_test_wallet_01"}} 

for multiple wallet you can use load_wallet like

{"jsonrpc": "2.0", "id": "test", "method": "load_wallet", "params": {"path": "/electrum/testnet/wallets/dat_test_wallet_01"}}
{"jsonrpc": "2.0", "id": "test", "method": "select_wallet", "params": {"name": "dat_test_wallet_01"}}
1
  • I cannot rely on "select_wallet" functionality, because there might be another "select_wallet" between my two commands, and the selected wallet gets changed in between.
    – Meglio
    Commented Mar 21, 2023 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.