cope with future removal of BDB wallet from bitcoin client

This commit is contained in:
scgbckbone 2023-11-01 16:56:52 +01:00 committed by doc-hex
parent 56e26d051e
commit 1b90f240b1
2 changed files with 29 additions and 10 deletions

View File

@ -30,6 +30,7 @@ class Bitcoind:
self.bitcoind_proc = None
self.userpass = None
self.supply_wallet = None
self.has_bdb = True
def start(self):
@ -85,7 +86,13 @@ class Bitcoind:
assert self.rpc.getblockchaininfo()['chain'] == 'regtest'
assert self.rpc.getnetworkinfo()['version'] >= 220000, "we require >= 22.0 of Core"
# not descriptors so that we can do dumpwallet
self.supply_wallet = self.create_wallet(wallet_name="supply", descriptors=False)
try:
self.supply_wallet = self.create_wallet(wallet_name="supply", descriptors=False)
except JSONRPCException as e:
assert "BDB wallet creation is deprecated" in str(e)
self.has_bdb = False
self.supply_wallet = self.create_wallet(wallet_name="supply", descriptors=True)
# Make sure there are blocks and coins available
self.supply_wallet.generatetoaddress(101, self.supply_wallet.getnewaddress())
@ -144,17 +151,24 @@ def match_key(bitcoind, set_master_key, reset_seed_words):
# bummer: dumpmasterprivkey RPC call was removed!
#prv = bitcoind.dumpmasterprivkey()
from tempfile import mktemp
fn = mktemp()
bitcoind.supply_wallet.dumpwallet(fn)
prv = None
# bummer: dumpwallet RPC call was removed does not work with descriptor wallets
try:
from tempfile import mktemp
fn = mktemp()
bitcoind.supply_wallet.dumpwallet(fn)
prv = None
for ln in open(fn, 'rt').readlines():
if 'extended private masterkey' in ln:
assert not prv
prv = ln.split(": ", 1)[1].strip()
for ln in open(fn, 'rt').readlines():
if 'extended private masterkey' in ln:
assert not prv
prv = ln.split(": ", 1)[1].strip()
os.unlink(fn)
os.unlink(fn)
except JSONRPCException as e:
print(str(e))
assert "Only legacy wallets are supported by this command" in str(e)
prv_descs = bitcoind.supply_wallet.listdescriptors(True) # True --> show private
prv = prv_descs["descriptors"][0]["desc"].replace("pkh(", "").split("/")[0]
assert prv.startswith('tprv')

View File

@ -1486,6 +1486,11 @@ def test_bitcoind_cosigning(cc_sign_first, dev, bitcoind, import_ms_wallet, clea
# - following text of <https://github.com/bitcoin/bitcoin/blob/master/doc/psbt.md>
# - the constructed multisig walelt will only work for a single pubkey on core side
# - before starting this test, have some funds already deposited to bitcoind testnet wallet
if not bitcoind.has_bdb:
# addmultisigaddress not supported by descriptor wallets
pytest.skip("Needs BDB legacy wallet")
from pycoin.encoding import sec_to_public_pair
from binascii import a2b_hex
use_regtest()