Our open tx isn't mined, we doublespend it away
(node_factory, bitcoind)
| 425 | |
| 426 | |
| 427 | def test_channel_abandon(node_factory, bitcoind): |
| 428 | """Our open tx isn't mined, we doublespend it away""" |
| 429 | l1, l2 = node_factory.get_nodes(2) |
| 430 | |
| 431 | SATS = 10**6 |
| 432 | |
| 433 | # Add some for fees/emergency-reserve |
| 434 | l1.fundwallet(SATS + 35000) |
| 435 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 436 | l1.rpc.fundchannel(l2.info['id'], SATS, feerate='1875perkw') |
| 437 | |
| 438 | opening_utxo = only_one([o for o in l1.rpc.listfunds()['outputs'] if o['reserved']]) |
| 439 | psbt = l1.rpc.utxopsbt(0, "253perkw", 0, [opening_utxo['txid'] + ':' + str(opening_utxo['output'])], reserve=0, reservedok=True)['psbt'] |
| 440 | |
| 441 | # We expect a reservation for 2016 blocks; unreserve it. |
| 442 | reservations = only_one(l1.rpc.unreserveinputs(psbt, reserve=2015)['reservations']) |
| 443 | assert reservations['reserved'] |
| 444 | assert reservations['reserved_to_block'] == bitcoind.rpc.getblockchaininfo()['blocks'] + 1 |
| 445 | |
| 446 | assert only_one(l1.rpc.unreserveinputs(psbt, reserve=1)['reservations'])['reserved'] is False |
| 447 | |
| 448 | # Now it's unreserved, we can doublespend it (as long as we exceed |
| 449 | # previous fee to RBF!). |
| 450 | withdraw = l1.rpc.withdraw(l1.rpc.newaddr('bech32')['bech32'], "all") |
| 451 | |
| 452 | assert bitcoind.rpc.decoderawtransaction(withdraw['tx'])['vout'][0]['value'] > SATS / 10**8 |
| 453 | bitcoind.generate_block(1, wait_for_mempool=withdraw['txid']) |
| 454 | |
| 455 | # FIXME: lightningd should notice channel will never now open! |
| 456 | assert (only_one(l1.rpc.listpeerchannels()['channels'])['state'] |
| 457 | == 'CHANNELD_AWAITING_LOCKIN') |
| 458 | |
| 459 | |
| 460 | @pytest.mark.openchannel('v1') |
nothing calls this directly
no test coverage detected