Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: lucas jeffrey on August 18, 2024, 12:56:45 AM



Title: Bitcoinlib regtest issues
Post by: lucas jeffrey on August 18, 2024, 12:56:45 AM
Im looking for a way to load a regtest wallet created by bitcoinlib using a specified client but i don't know exactly how this works or even if i can. Here's my code:

>>> from bitcoinlib.wallets import wallet_create_or_open, Wallet
>>> from bitcoinlib.services.bitcoind import BitcoindClient
>>>
>>>  # Connect to a local regtest daemon
>>> base_url = 'http://user:password@127.0.0.1:18443'
>>> bitcoind_client = BitcoindClient(network='regtest', base_url=base_url)
>>>
>>> # Create or load a wallet
>>> wallet_name = 'my_regtest_wallet'
>>> wallet = wallet_create_or_open(wallet_name, network='regtest', witness_type='segwit')

What i want is to "tell" the wallet to use the bitcoind_client i provided.
Any help is welcomed!


Title: Re: Bitcoinlib regtest issues
Post by: nc50lc on August 18, 2024, 04:16:30 AM
bitcoinlib has a documentary on how to do that: https://bitcoinlib.readthedocs.io/en/latest/source/_static/manuals.setup-bitcoind-connection.html (https://bitcoinlib.readthedocs.io/en/latest/source/_static/manuals.setup-bitcoind-connection.html)

>>>  # Connect to a local regtest daemon
>>> base_url = 'http://user:password@127.0.0.1:18443'
But since you're using the deprecated RPC username and password, set "rpcuser" and "rpcpassword" in your bitcoin.conf file
instead of the "rpcauth" in the provided example in their doc.
Don't forget to restart Bitcoin Core whenever you want to apply the new config in your conf file.