Bitcoin Forum
May 02, 2024, 05:27:19 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Problems with multiple wallets on RPC in bitcoin-core  (Read 161 times)
kycklingrullen (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 1


View Profile
May 11, 2022, 06:27:49 PM
Merited by ABCbits (1)
 #1

I have been playing around a bit with Bitcoin Core (version 23.0), more specifically connecting to different wallets in Bitcoin Core through RPC in Python. I have found this library and tried to connect to my wallet(s) using this code:
--------
from bitcoinrpc.authproxy import AuthServiceProxy

conn = AuthServiceProxy("http://myusername:mypassword@127.0.0.1:18332/wallet/testingwallet")
print(conn.getwalletinfo())
--------
But when running this i get this stacktrace:
-----------
Traceback (most recent call last):
  File "/home/kebab/Desktop/pron/testing.py", line 24, in <module>
    print(a.getwalletinfo())
  File "/home/kebab/.local/lib/python3.8/site-packages/bitcoinrpc/authproxy.py", line 141, in __call__
    raise JSONRPCException(response['error'])
bitcoinrpc.authproxy.JSONRPCException: -18: Requested wallet does not exist or is not loaded
-------
Though what I have noticed is that if i load the wallet using bitcoin-cli -testnet loadwallet testingwallet. Then i can run RPC commands but only get info from that wallet!

And I have created my wallet using: bitcoin-cli -testnet createwallet testingwallet

Any help on this would really be appreciated!
1714670839
Hero Member
*
Offline Offline

Posts: 1714670839

View Profile Personal Message (Offline)

Ignore
1714670839
Reply with quote  #2

1714670839
Report to moderator
1714670839
Hero Member
*
Offline Offline

Posts: 1714670839

View Profile Personal Message (Offline)

Ignore
1714670839
Reply with quote  #2

1714670839
Report to moderator
The Bitcoin network protocol was designed to be extremely flexible. It can be used to create timed transactions, escrow transactions, multi-signature transactions, etc. The current features of the client only hint at what will be possible in the future.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714670839
Hero Member
*
Offline Offline

Posts: 1714670839

View Profile Personal Message (Offline)

Ignore
1714670839
Reply with quote  #2

1714670839
Report to moderator
nc50lc
Legendary
*
Offline Offline

Activity: 2408
Merit: 5581


Self-proclaimed Genius


View Profile
May 12, 2022, 06:26:38 AM
 #2

-snip-
Though what I have noticed is that if i load the wallet using bitcoin-cli -testnet loadwallet testingwallet. Then i can run RPC commands but only get info from that wallet!
In bitcoin-cli, you'll have to load all wallets that you want to work with,
then specify which wallet to use with each wallet command with -rpcwallet=
e.g.:
Code:
bitcoin-cli -testnet -rpcwallet=testingwallet getwalletinfo
Code:
bitcoin-cli -testnet -rpcwallet=otherwallet getwalletinfo

I don't know how to apply that to "python-bitcoinrpc" library though.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6722


bitcoincleanup.com / bitmixlist.org


View Profile WWW
May 12, 2022, 07:33:34 AM
 #3

In bitcoin-cli, you'll have to load all wallets that you want to work with,
then specify which wallet to use with each wallet command with -rpcwallet=
e.g.:
Code:
bitcoin-cli -testnet -rpcwallet=testingwallet getwalletinfo
Code:
bitcoin-cli -testnet -rpcwallet=otherwallet getwalletinfo

I don't know how to apply that to "python-bitcoinrpc" library though.
I checked the codebase on Github (a quick check) and I did not see any function for loading wallets. Therefore I don't believe python-bitcoinrpc supports this call at all.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
kycklingrullen (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 1


View Profile
May 12, 2022, 09:43:48 PM
 #4

I have been playing around a bit with Bitcoin Core (version 23.0), more specifically connecting to different wallets in Bitcoin Core through RPC in Python.

There are at least 4 Python library which name contain "bitcoinrpc". Did you mean this library https://pypi.org/project/python-bitcoinrpc/?

In bitcoin-cli, you'll have to load all wallets that you want to work with,
then specify which wallet to use with each wallet command with -rpcwallet=
e.g.:
Code:
bitcoin-cli -testnet -rpcwallet=testingwallet getwalletinfo
Code:
bitcoin-cli -testnet -rpcwallet=otherwallet getwalletinfo

I don't know how to apply that to "python-bitcoinrpc" library though.
I checked the codebase on Github (a quick check) and I did not see any function for loading wallets. Therefore I don't believe python-bitcoinrpc supports this call at all.

Looks like so, there's 0 result for keyword "wallet", "key", "hd" and "private" on the source code.

Yep thats the library im using! And if you're wondering if it's the library that's making it not work, i tried with just making normal POST requests to the RPC. Still getting the same error:

{"result":null,"error":{"code":-18,"message":"Requested wallet does not exist or is not loaded"},"id":null}

And this is my test code with requests

----
import requests, json

headers = {'content-type': 'application/json'}
payload = json.dumps({"method": "getwalletinfo", "params": [], "jsonrpc": "2.0"})
response = requests.post("http://myusername:mypassword@127.0.0.1:18332/wallet/testingwallet", headers=headers, data=payload)

print(response.text)
----
vv181
Legendary
*
Offline Offline

Activity: 1932
Merit: 1273


View Profile
May 13, 2022, 01:38:41 AM
Merited by ABCbits (1)
 #5

@kycklingrullen you have to load the wallet(s) first before you are able to use it on RPC.

Code:
bitcoin-cli loadwallet testingwallet
Use the above command to load wallets that you want to use. And to check if it's been loaded use: $ bitcoin-cli listwallets

Then i can run RPC commands but only get info from that wallet!
For multiple wallet RPC calls, you need to adjust the HTTP endpoint according to each of the wallet names.
e.g. http://myusername:mypassword@127.0.0.1:18332/wallet/{walletname}
kycklingrullen (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 1


View Profile
May 13, 2022, 04:26:05 PM
 #6

@kycklingrullen you have to load the wallet(s) first before you are able to use it on RPC.

Code:
bitcoin-cli loadwallet testingwallet
Use the above command to load wallets that you want to use. And to check if it's been loaded use: $ bitcoin-cli listwallets

Then i can run RPC commands but only get info from that wallet!
For multiple wallet RPC calls, you need to adjust the HTTP endpoint according to each of the wallet names.
e.g. http://myusername:mypassword@127.0.0.1:18332/wallet/{walletname}
Oh got it! But im working on a program which will be creating a lot of new wallets etcetera. How would i be able to load all of these when for example starting Bitcoin Core?
And how would I about loading the wallet when i create it.
All of this should be through RPC ^^.
BitMaxz
Legendary
*
Online Online

Activity: 3248
Merit: 2955


Block halving is coming.


View Profile WWW
May 13, 2022, 04:59:05 PM
Merited by ABCbits (1)
 #7

Oh got it! But im working on a program which will be creating a lot of new wallets etcetera. How would i be able to load all of these when for example starting Bitcoin Core?
And how would I about loading the wallet when i create it.
All of this should be through RPC ^^.

All RPC commands are already here https://chainquery.com/ and all wallet commands are here https://chainquery.com/bitcoin-cli#wallet

I think you are planning to create your own version of wallet?

What you want is already mentioned above to load a wallet after creating use the bitcoin-cli loadwallet "WalletName"
But if you mean to load all of the wallets you created at once I don't know if you can able to do that.

If your plan is to make a wallet(The version of yours) I think you can try to learn something about blockchain first below

- https://github.com/yjjnls/awesome-blockchain#implementation-of-blockchain

You can read the wallet under that link it might help to make a wallet program of yours or maybe it can help you to get some ideas.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
kycklingrullen (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 1


View Profile
May 13, 2022, 09:58:04 PM
 #8

Oh got it! But im working on a program which will be creating a lot of new wallets etcetera. How would i be able to load all of these when for example starting Bitcoin Core?
And how would I about loading the wallet when i create it.
All of this should be through RPC ^^.

All RPC commands are already here https://chainquery.com/ and all wallet commands are here https://chainquery.com/bitcoin-cli#wallet

I think you are planning to create your own version of wallet?

What you want is already mentioned above to load a wallet after creating use the bitcoin-cli loadwallet "WalletName"
But if you mean to load all of the wallets you created at once I don't know if you can able to do that.

If your plan is to make a wallet(The version of yours) I think you can try to learn something about blockchain first below

- https://github.com/yjjnls/awesome-blockchain#implementation-of-blockchain

You can read the wallet under that link it might help to make a wallet program of yours or maybe it can help you to get some ideas.

My plan is actually creating a transaction system on a third-party software.
Im using Bitcoin Core to be able to avoid any ratelimits, downtime, etc.

And your answer and the answers above I fixed it!

Thanks!!!
vv181
Legendary
*
Offline Offline

Activity: 1932
Merit: 1273


View Profile
May 13, 2022, 11:36:02 PM
Merited by ABCbits (1)
 #9

My plan is actually creating a transaction system on a third-party software.
What kind of transaction system?

Does BTCPay Server didn't suit your needs? https://docs.btcpayserver.org/UseCase/.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!