mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
pytest: test double-spending an opening tx input.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f24dc9173d
commit
95f77f119b
@ -246,6 +246,39 @@ def test_second_channel(node_factory):
|
||||
l1.fundchannel(l3, 10**6)
|
||||
|
||||
|
||||
def test_channel_abandon(node_factory, bitcoind):
|
||||
"""Our open tx isn't mined, we doublespend it away"""
|
||||
l1, l2 = node_factory.get_nodes(2)
|
||||
|
||||
SATS = 10**6
|
||||
|
||||
# Add some for fees
|
||||
l1.fundwallet(SATS + 10000)
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
l1.rpc.fundchannel(l2.info['id'], SATS, feerate='1875perkw')
|
||||
|
||||
opening_utxo = only_one([o for o in l1.rpc.listfunds()['outputs'] if o['reserved']])
|
||||
psbt = l1.rpc.utxopsbt(0, "253perkw", 0, [opening_utxo['txid'] + ':' + str(opening_utxo['output'])], reserve=False, reservedok=True)['psbt']
|
||||
|
||||
# Unreserve until it's considered unreserved.
|
||||
count = 0
|
||||
while only_one(l1.rpc.unreserveinputs(psbt)['reservations'])['reserved']:
|
||||
count += 1
|
||||
assert count == 1
|
||||
|
||||
# Now it's unreserved, we can doublespend it (as long as we exceed
|
||||
# previous fee to RBF!).
|
||||
withdraw = l1.rpc.withdraw(l1.rpc.newaddr()['bech32'], "all")
|
||||
|
||||
assert bitcoind.rpc.decoderawtransaction(withdraw['tx'])['vout'][0]['value'] > SATS / 10**8
|
||||
bitcoind.generate_block(1, wait_for_mempool=withdraw['txid'])
|
||||
|
||||
# FIXME: lightningd should notice channel will never now open!
|
||||
print(l1.rpc.listpeers())
|
||||
assert (only_one(only_one(l1.rpc.listpeers()['peers'])['channels'])['state']
|
||||
== 'CHANNELD_AWAITING_LOCKIN')
|
||||
|
||||
|
||||
@pytest.mark.developer
|
||||
@pytest.mark.openchannel('v1')
|
||||
@pytest.mark.openchannel('v2')
|
||||
|
Loading…
Reference in New Issue
Block a user