pytest: add test that we notice height change of sendpsbt with no change.
What changed, and why it matters
This commit only adds a new automated test to the project's test suite. It does not change any production code, so it cannot directly fix or introduce a security vulnerability. The test checks that a wallet transaction created via sendpsbt is correctly tracked from unconfirmed to confirmed status, including after a node restart. It is currently marked as expected to fail (xfail), meaning the underlying behavior may not yet work as intended.
No security action needed. This is a test-only commit. If reviewing a series, evaluate the accompanying production-code commit that the test is intended to exercise or validate.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single pytest test, test_sendpsbt_confirm, to tests/test_wallet.py. The test funds a wallet, creates and signs a PSBT, broadcasts it with sendpsbt, verifies the transaction appears unconfirmed (blockheight 0), optionally restarts the node, mines a block, and then asserts the transaction’s blockheight matches the current chain tip. The test is decorated with @pytest.mark.xfail(strict=True) and parameterized over restart=[False, True]. No application logic, RPC handlers, wallet code, or cryptographic operations are modified.
Changed components
tests/test_wallet.pyInspect captured patch +29 / −0
diff --git a/tests/test_wallet.py b/tests/test_wallet.py
index b26679b..436f14e 100644
--- a/tests/test_wallet.py
+++ b/tests/test_wallet.py
@@ -1887,6 +1887,35 @@ def test_onchain_missing_no_p2tr_migrate(node_factory, bitcoind):
l2.daemon.wait_for_log('Rescan finished! 1 outputs recovered')
+@pytest.mark.xfail(strict=True)
+@pytest.mark.parametrize("restart", [False, True])
+def test_sendpsbt_confirm(node_factory, bitcoind, restart):
+ """We should see our sendpsbt in wallet, and that it gets confirmed"""
+ l1, l2 = node_factory.get_nodes(2)
+ l1.fundwallet(100000)
+
+ psbt = l1.rpc.fundpsbt(satoshi=10000,
+ feerate=7500,
+ startweight=42)['psbt']
+ psbt = l2.rpc.addpsbtoutput(10000, psbt)['psbt']
+ psbt = l1.rpc.signpsbt(psbt)['signed_psbt']
+ sent = l1.rpc.sendpsbt(psbt)
+
+ # Unconfirmed
+ lt = only_one([t for t in l1.rpc.listtransactions()['transactions'] if t['rawtx'] == sent['tx']])
+ assert lt['blockheight'] == 0
+
+ if restart:
+ l1.restart()
+
+ bitcoind.generate_block(1, wait_for_mempool=sent['txid'])
+ sync_blockheight(bitcoind, [l1])
+
+ # Should be confirmed now!
+ lt = only_one([t for t in l1.rpc.listtransactions()['transactions'] if t['rawtx'] == sent['tx']])
+ assert lt['blockheight'] == bitcoind.rpc.getblockcount()
+
+
def test_old_htlcs_cleanup(node_factory, bitcoind):
"""We lazily delete htlcs from channel_htlcs table"""
l1, l2 = node_factory.line_graph(2)
Why this scored 12/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.