1

I would like to new address generate with this command

bitcoin-cli -testnet getnewaddress "adr1" "p2sh-segwit" but I get this msg:

error message:
Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).
Try adding "-rpcwallet=<filename>" option to bitcoin-cli command line. 

then I added the -rpcwallet command like that: bitcoin-cli -testnet -rpcwallet=/home/bitcoin/.bitcoin/ getnewaddress "adr1" "p2sh-segwit" but I got an error again like this:

error message:
Requested wallet does not exist or is not loaded````

what should I do?

thank you

sollover
  • 13
  • 4

2 Answers2

4

-rpcwallet takes the name of the wallet, not the path to the datadir (as you appear to have done) or the path to the wallet file.

To get a list of the names of the wallets currently loaded, you can use the listwallets command.

Ava Chow
  • 70,382
  • 5
  • 81
  • 161
0

I got the same error and had a hard time trying to figure out where to pass in the -rpcwallet=<wallet_name> flag. For example, I was doing a bitcoin-cli listunspent -rpcwallet=<wallet_name> and was getting the same error, until I changed things around and passed in the flag before the listunspent rpc command.

So always use the -rpcwallet flag before the rpc command you're working with.

For example:

bitcoin-cli -rpcwallet=<wallet_name> listunspent will work, but bitcoin-cli listunspent -rpcwallet=<wallet_name> will return with the same error.