pytest: don't ask for p2tr addresses on liquid.
What changed, and why it matters
This commit only changes test code. It makes Core Lightning's test suite avoid asking for taproot (p2tr) Bitcoin addresses when running on the Liquid sidechain, because Liquid does not support that address type yet. There is no change to production wallet or node code, and no security fix.
No security action needed. Treat as routine test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies tests/test_misc.py and tests/test_wallet.py. It adds a helper good_addrtype() that returns ‘p2tr’ on regtest and ‘bech32’ on liquid-regtest, swaps hard-coded ‘p2tr’ newaddr calls to use that helper, and adds @unittest.skipIf decorators for tests that are incompatible with liquid-regtest. This is purely a test compatibility/adjustment commit.
Changed components
tests/test_misc.pytests/test_wallet.pyInspect captured patch +16 / −5
diff --git a/tests/test_misc.py b/tests/test_misc.py
index 65b7ffbe..b97ba108 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -585,6 +585,7 @@ def test_p2tr_funding(node_factory, chainparams):
assert only_one(fundingtx['vin'])['txid'] == res['wallettxid']
+@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "P2TR not yet supported on Elements")
def test_withdraw_misc(node_factory, bitcoind, chainparams):
def dont_spend_outputs(n, txid):
"""Reserve both outputs (we assume there are two!) in case any our ours, so we don't spend change: wrecks accounting checks"""
diff --git a/tests/test_wallet.py b/tests/test_wallet.py
index 473bd76d..8edd8963 100644
--- a/tests/test_wallet.py
+++ b/tests/test_wallet.py
@@ -24,6 +24,13 @@ HSM_ERROR_IS_ENCRYPT = 21
HSM_BAD_PASSWORD = 22
+def good_addrtype():
+ """Elements doesn't support p2tr"""
+ if TEST_NETWORK == 'regtest':
+ return "p2tr"
+ return "bech32"
+
+
@unittest.skipIf(TEST_NETWORK != 'regtest', "Test relies on a number of example addresses valid only in regtest")
def test_withdraw(node_factory, bitcoind):
amount = 1000000
@@ -215,7 +222,7 @@ def test_minconf_withdraw(node_factory, bitcoind):
amount = 1000000
# Don't get any funds from previous runs.
l1 = node_factory.get_node(random_hsm=True)
- addr = l1.rpc.newaddr('p2tr')['p2tr']
+ addr = l1.rpc.newaddr(good_addrtype())[good_addrtype()]
# Add some funds to withdraw later
for i in range(10):
@@ -231,6 +238,7 @@ def test_minconf_withdraw(node_factory, bitcoind):
l1.rpc.withdraw(destination=addr, satoshi=10000, feerate='normal', minconf=9999999)
+@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "BIP86 random_hsm not compatible with liquid-regtest bech32")
def test_addfunds_from_block(node_factory, bitcoind):
"""Send funds to the daemon without telling it explicitly
"""
@@ -238,7 +246,7 @@ def test_addfunds_from_block(node_factory, bitcoind):
coin_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
l1 = node_factory.get_node(random_hsm=True, options={'plugin': coin_plugin})
- addr = l1.rpc.newaddr('p2tr')['p2tr']
+ addr = l1.rpc.newaddr(good_addrtype())[good_addrtype()]
bitcoind.rpc.sendtoaddress(addr, 0.1)
bitcoind.generate_block(1)
@@ -275,7 +283,7 @@ def test_txprepare_multi(node_factory, bitcoind):
amount = 10000000
l1 = node_factory.get_node(random_hsm=True)
- bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2tr')['p2tr'], amount / 10**8)
+ bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('all')[good_addrtype()], amount / 10**8)
bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1)
@@ -303,6 +311,7 @@ def feerate_from_psbt(chainparams, bitcoind, node, psbt):
return fee / weight * 1000
+@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "BIP86 random_hsm not compatible with liquid-regtest bech32")
def test_txprepare(node_factory, bitcoind, chainparams):
amount = 1000000
l1 = node_factory.get_node(random_hsm=True, options={'dev-warn-on-overgrind': None},
@@ -311,7 +320,7 @@ def test_txprepare(node_factory, bitcoind, chainparams):
# Add some funds to withdraw later
for i in range(10):
- bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2tr')['p2tr'],
+ bitcoind.rpc.sendtoaddress(l1.rpc.newaddr(good_addrtype())[good_addrtype()],
amount / 10**8)
bitcoind.generate_block(1)
@@ -1196,6 +1205,7 @@ def test_sign_and_send_psbt(node_factory, bitcoind, chainparams):
check_coin_moves(l1, 'wallet', wallet_coin_mvts, chainparams)
+@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "BIP86 random_hsm not compatible with liquid-regtest bech32")
def test_txsend(node_factory, bitcoind, chainparams):
amount = 1000000
l1 = node_factory.get_node(random_hsm=True)
@@ -1203,7 +1213,7 @@ def test_txsend(node_factory, bitcoind, chainparams):
# Add some funds to withdraw later
for i in range(10):
- bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2tr')['p2tr'],
+ bitcoind.rpc.sendtoaddress(l1.rpc.newaddr(good_addrtype())[good_addrtype()],
amount / 10**8)
bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.