onchaind: use lightningd for spending our unilateral "to us" output.

This follows the same pattern as the "spend htlc tx" in fact.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-04-06 09:03:24 +09:30
parent 07413c20b9
commit 9d5dfa7bdd
5 changed files with 124 additions and 108 deletions

View File

@@ -3833,11 +3833,13 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
l2.start()
# They should both handle it fine.
l1.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET .* after 5 blocks')
((_, txid, blocks),) = l1.wait_for_onchaind_tx('OUR_DELAYED_RETURN_TO_WALLET',
'OUR_UNILATERAL/DELAYED_OUTPUT_TO_US')
assert blocks == 4
l2.daemon.wait_for_logs(['Ignoring output .*: THEIR_UNILATERAL/OUTPUT_TO_US',
'Ignoring output .*: THEIR_UNILATERAL/DELAYED_OUTPUT_TO_THEM'])
bitcoind.generate_block(5)
bitcoind.generate_block(100, wait_for_mempool=1)
bitcoind.generate_block(4)
bitcoind.generate_block(100, wait_for_mempool=txid)
# This works even if they disconnect and listpeerchannels() is empty:
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)
@@ -3858,12 +3860,14 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
l2.start()
# They should both handle it fine.
l1.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET .* after 5 blocks')
((_, txid, blocks),) = l1.wait_for_onchaind_tx('OUR_DELAYED_RETURN_TO_WALLET',
'OUR_UNILATERAL/DELAYED_OUTPUT_TO_US')
assert blocks == 4
l2.daemon.wait_for_logs(['Ignoring output .*: THEIR_UNILATERAL/OUTPUT_TO_US',
'Ignoring output .*: THEIR_UNILATERAL/DELAYED_OUTPUT_TO_THEM'])
bitcoind.generate_block(5)
bitcoind.generate_block(100, wait_for_mempool=1)
bitcoind.generate_block(4)
bitcoind.generate_block(100, wait_for_mempool=txid)
# This works even if they disconnect and listpeerchannels() is empty:
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)