10

I'm currently working on a little program for backing up your Bitcoin Core wallet. I am using BitcoinLib v1.15.0 in C#.

IBitcoinService bitcoinService = new BitcoinService("http://127.0.0.1:8332", "test", "test", "", 60);
bitcoinService.BackupWallet("C:\\Users\\dominik\\OneDrive\\Desktop\\backup");

When I run this code I get following error message Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path). I am a bit confused, because the BitcoinService.backupwallet(string destination) function has only one input parameter which I assume describes the path where it should generate the backup file (or at least that's the way this command works in Bitcoin Core's terminal).

Is there anyone with experience with BitcoinLib or similar problem. I am open to any suggestions. The error is related to multiple wallets open at once in Bitcoin Core.

Mr Incognito
  • 103
  • 1
  • 6

5 Answers5

4

It worked after I've added /wallet/<wallet_name> to the RPC URL

Vassily
  • 5,263
  • 4
  • 33
  • 63
  • Thanks @Vassily, I encountered the same issue and your fix helped make this work. I'm not sure if there was a change in bitcoin core that requires an update in bitcoinlib - I added a note here to double check: https://github.com/cryptean/bitcoinlib/issues/122 Full working example: ``` POST MyRpcUserName:MyRpcPw@localhost:18332/wallet/RegTestWallet2 Body: {"jsonrpc":"1.0","id":"rpc","method":"getbalance", "params":[]} ``` – apleroy Feb 09 '22 at 05:37
0

This is just a guess at this stage but you have not specified the file extension in this path "C:\Users\dominik\OneDrive\Desktop\backup" so it does not know exactly which file to look for. In other words the filename is incorrect as it is missing the extension of ".something". Otherwise something else is wrong with your path because maybe it has to have /wallet/ then the uri path but your path does not have that. Please let me know how you go.

Soliman Soliman
  • 159
  • 1
  • 4
  • 17
0

If you willing to backup a wallet:

  1. Make sure your bitcoin node up and running
  2. Check used username & password (config file on Windows placed at %APPDATA%\bitcoin\bitcoin.conf)
  3. Use a path with slashes instead of backslashes, ie. c:/users/username/backup/bitcoin/ or c:/users/username/backup/bitcoin/wallet_backup.dat or ../backup/wallet_backup.dat
Igor Goyda
  • 1,949
  • 5
  • 10
0

For me the error was the bitcoin config file. Check the wallet name property wallet=<your_wallet_name> at bitcoin.conf is correct.

liorko
  • 1,435
  • 2
  • 24
  • 41
0

I got exactly the same error message, only because too much wallets where loaded in the same time.

With the latest client (Bitcoin Core 23.0), this can be solved using these API calls (in a kind of Python pseudo-code):

wallets_list = listwallets()
for w in wallets_list:
    unloadwallet(w)
loadwallet("my_wallet")
mountrix
  • 1,126
  • 15
  • 32