mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
test: remove legacy wallet functional tests
Removes all legacy wallet specific functional tests. Also removes the --descriptor and --legacy-wallet options as these are no longer necessary with the legacy wallet removed.
This commit is contained in:
@@ -56,9 +56,6 @@ import os
|
||||
|
||||
|
||||
class PSBTTest(BitcoinTestFramework):
|
||||
def add_options(self, parser):
|
||||
self.add_wallet_options(parser)
|
||||
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 3
|
||||
self.extra_args = [
|
||||
@@ -318,10 +315,6 @@ class PSBTTest(BitcoinTestFramework):
|
||||
p2sh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "legacy")['address']
|
||||
p2wsh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "bech32")['address']
|
||||
p2sh_p2wsh = wmulti.addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "p2sh-segwit")['address']
|
||||
if not self.options.descriptors:
|
||||
wmulti.importaddress(p2sh)
|
||||
wmulti.importaddress(p2wsh)
|
||||
wmulti.importaddress(p2sh_p2wsh)
|
||||
p2wpkh = self.nodes[1].getnewaddress("", "bech32")
|
||||
p2pkh = self.nodes[1].getnewaddress("", "legacy")
|
||||
p2sh_p2wpkh = self.nodes[1].getnewaddress("", "p2sh-segwit")
|
||||
@@ -655,8 +648,7 @@ class PSBTTest(BitcoinTestFramework):
|
||||
for i, signer in enumerate(signers):
|
||||
self.nodes[2].unloadwallet("wallet{}".format(i))
|
||||
|
||||
if self.options.descriptors:
|
||||
self.test_utxo_conversion()
|
||||
self.test_utxo_conversion()
|
||||
self.test_psbt_incomplete_after_invalid_modification()
|
||||
|
||||
self.test_input_confs_control()
|
||||
@@ -782,10 +774,7 @@ class PSBTTest(BitcoinTestFramework):
|
||||
|
||||
# Make a weird but signable script. sh(wsh(pkh())) descriptor accomplishes this
|
||||
desc = descsum_create("sh(wsh(pkh({})))".format(privkey))
|
||||
if self.options.descriptors:
|
||||
res = self.nodes[0].importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
else:
|
||||
res = self.nodes[0].importmulti([{"desc": desc, "timestamp": "now"}])
|
||||
res = self.nodes[0].importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
assert res[0]["success"]
|
||||
addr = self.nodes[0].deriveaddresses(desc)[0]
|
||||
addr_info = self.nodes[0].getaddressinfo(addr)
|
||||
@@ -867,10 +856,7 @@ class PSBTTest(BitcoinTestFramework):
|
||||
assert_equal(psbt2["fee"], psbt3["fee"])
|
||||
|
||||
# Import the external utxo descriptor so that we can sign for it from the test wallet
|
||||
if self.options.descriptors:
|
||||
res = wallet.importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
else:
|
||||
res = wallet.importmulti([{"desc": desc, "timestamp": "now"}])
|
||||
res = wallet.importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
assert res[0]["success"]
|
||||
# The provided weight should override the calculated weight for a wallet input
|
||||
psbt3 = wallet.walletcreatefundedpsbt(
|
||||
@@ -887,10 +873,7 @@ class PSBTTest(BitcoinTestFramework):
|
||||
privkey, pubkey = generate_keypair(wif=True)
|
||||
|
||||
desc = descsum_create("wsh(pkh({}))".format(pubkey.hex()))
|
||||
if self.options.descriptors:
|
||||
res = watchonly.importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
else:
|
||||
res = watchonly.importmulti([{"desc": desc, "timestamp": "now"}])
|
||||
res = watchonly.importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
assert res[0]["success"]
|
||||
addr = self.nodes[0].deriveaddresses(desc)[0]
|
||||
self.nodes[0].sendtoaddress(addr, 10)
|
||||
@@ -902,46 +885,45 @@ class PSBTTest(BitcoinTestFramework):
|
||||
self.nodes[0].sendrawtransaction(signed_tx["hex"])
|
||||
|
||||
# Same test but for taproot
|
||||
if self.options.descriptors:
|
||||
privkey, pubkey = generate_keypair(wif=True)
|
||||
privkey, pubkey = generate_keypair(wif=True)
|
||||
|
||||
desc = descsum_create("tr({},pk({}))".format(H_POINT, pubkey.hex()))
|
||||
res = watchonly.importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
assert res[0]["success"]
|
||||
addr = self.nodes[0].deriveaddresses(desc)[0]
|
||||
self.nodes[0].sendtoaddress(addr, 10)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.nodes[0].importdescriptors([{"desc": descsum_create("tr({})".format(privkey)), "timestamp":"now"}])
|
||||
desc = descsum_create("tr({},pk({}))".format(H_POINT, pubkey.hex()))
|
||||
res = watchonly.importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
assert res[0]["success"]
|
||||
addr = self.nodes[0].deriveaddresses(desc)[0]
|
||||
self.nodes[0].sendtoaddress(addr, 10)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.nodes[0].importdescriptors([{"desc": descsum_create("tr({})".format(privkey)), "timestamp":"now"}])
|
||||
|
||||
psbt = watchonly.sendall([wallet.getnewaddress(), addr])["psbt"]
|
||||
processed_psbt = self.nodes[0].walletprocesspsbt(psbt)
|
||||
txid = self.nodes[0].sendrawtransaction(processed_psbt["hex"])
|
||||
vout = find_vout_for_address(self.nodes[0], txid, addr)
|
||||
psbt = watchonly.sendall([wallet.getnewaddress(), addr])["psbt"]
|
||||
processed_psbt = self.nodes[0].walletprocesspsbt(psbt)
|
||||
txid = self.nodes[0].sendrawtransaction(processed_psbt["hex"])
|
||||
vout = find_vout_for_address(self.nodes[0], txid, addr)
|
||||
|
||||
# Make sure tap tree is in psbt
|
||||
parsed_psbt = PSBT.from_base64(psbt)
|
||||
assert_greater_than(len(parsed_psbt.o[vout].map[PSBT_OUT_TAP_TREE]), 0)
|
||||
assert "taproot_tree" in self.nodes[0].decodepsbt(psbt)["outputs"][vout]
|
||||
parsed_psbt.make_blank()
|
||||
comb_psbt = self.nodes[0].combinepsbt([psbt, parsed_psbt.to_base64()])
|
||||
assert_equal(comb_psbt, psbt)
|
||||
# Make sure tap tree is in psbt
|
||||
parsed_psbt = PSBT.from_base64(psbt)
|
||||
assert_greater_than(len(parsed_psbt.o[vout].map[PSBT_OUT_TAP_TREE]), 0)
|
||||
assert "taproot_tree" in self.nodes[0].decodepsbt(psbt)["outputs"][vout]
|
||||
parsed_psbt.make_blank()
|
||||
comb_psbt = self.nodes[0].combinepsbt([psbt, parsed_psbt.to_base64()])
|
||||
assert_equal(comb_psbt, psbt)
|
||||
|
||||
self.log.info("Test that walletprocesspsbt both updates and signs a non-updated psbt containing Taproot inputs")
|
||||
addr = self.nodes[0].getnewaddress("", "bech32m")
|
||||
utxo = self.create_outpoints(self.nodes[0], outputs=[{addr: 1}])[0]
|
||||
psbt = self.nodes[0].createpsbt([utxo], [{self.nodes[0].getnewaddress(): 0.9999}])
|
||||
signed = self.nodes[0].walletprocesspsbt(psbt)
|
||||
rawtx = signed["hex"]
|
||||
self.nodes[0].sendrawtransaction(rawtx)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.log.info("Test that walletprocesspsbt both updates and signs a non-updated psbt containing Taproot inputs")
|
||||
addr = self.nodes[0].getnewaddress("", "bech32m")
|
||||
utxo = self.create_outpoints(self.nodes[0], outputs=[{addr: 1}])[0]
|
||||
psbt = self.nodes[0].createpsbt([utxo], [{self.nodes[0].getnewaddress(): 0.9999}])
|
||||
signed = self.nodes[0].walletprocesspsbt(psbt)
|
||||
rawtx = signed["hex"]
|
||||
self.nodes[0].sendrawtransaction(rawtx)
|
||||
self.generate(self.nodes[0], 1)
|
||||
|
||||
# Make sure tap tree is not in psbt
|
||||
parsed_psbt = PSBT.from_base64(psbt)
|
||||
assert PSBT_OUT_TAP_TREE not in parsed_psbt.o[0].map
|
||||
assert "taproot_tree" not in self.nodes[0].decodepsbt(psbt)["outputs"][0]
|
||||
parsed_psbt.make_blank()
|
||||
comb_psbt = self.nodes[0].combinepsbt([psbt, parsed_psbt.to_base64()])
|
||||
assert_equal(comb_psbt, psbt)
|
||||
# Make sure tap tree is not in psbt
|
||||
parsed_psbt = PSBT.from_base64(psbt)
|
||||
assert PSBT_OUT_TAP_TREE not in parsed_psbt.o[0].map
|
||||
assert "taproot_tree" not in self.nodes[0].decodepsbt(psbt)["outputs"][0]
|
||||
parsed_psbt.make_blank()
|
||||
comb_psbt = self.nodes[0].combinepsbt([psbt, parsed_psbt.to_base64()])
|
||||
assert_equal(comb_psbt, psbt)
|
||||
|
||||
self.log.info("Test walletprocesspsbt raises if an invalid sighashtype is passed")
|
||||
assert_raises_rpc_error(-8, "'all' is not a valid sighash parameter.", self.nodes[0].walletprocesspsbt, psbt, sighashtype="all")
|
||||
|
||||
Reference in New Issue
Block a user