What happens if a 'non-tip' RBF transaction is mined?
(node_factory, bitcoind, chainparams)
| 984 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
| 985 | @pytest.mark.openchannel('v2') |
| 986 | def test_rbf_non_last_mined(node_factory, bitcoind, chainparams): |
| 987 | """ |
| 988 | What happens if a 'non-tip' RBF transaction is mined? |
| 989 | """ |
| 990 | l1, l2 = node_factory.get_nodes(2, |
| 991 | opts={'allow_warning': True, |
| 992 | 'may_reconnect': True}) |
| 993 | |
| 994 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 995 | amount = 2**24 |
| 996 | chan_amount = 100000 |
| 997 | bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01) |
| 998 | bitcoind.generate_block(1) |
| 999 | # Wait for it to arrive. |
| 1000 | wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0) |
| 1001 | |
| 1002 | res = l1.rpc.fundchannel(l2.info['id'], chan_amount, feerate='7500perkw') |
| 1003 | chan_id = res['channel_id'] |
| 1004 | vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin'] |
| 1005 | assert(only_one(vins)) |
| 1006 | prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])] |
| 1007 | |
| 1008 | # Check that we're waiting for lockin |
| 1009 | l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN') |
| 1010 | inflights = only_one(only_one(l1.rpc.listpeers()['peers'])['channels'])['inflight'] |
| 1011 | assert inflights[-1]['funding_txid'] in bitcoind.rpc.getrawmempool() |
| 1012 | |
| 1013 | def run_retry(): |
| 1014 | startweight = 42 + 173 |
| 1015 | rate = int(find_next_feerate(l1, l2)[:-5]) |
| 1016 | # We 2x the feerate to beat the min-relay fee |
| 1017 | next_feerate = '{}perkw'.format(rate * 2) |
| 1018 | initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight, |
| 1019 | prev_utxos, reservedok=True, |
| 1020 | min_witness_weight=110, |
| 1021 | excess_as_change=True) |
| 1022 | |
| 1023 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 1024 | bump = l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt']) |
| 1025 | update = l1.rpc.openchannel_update(chan_id, bump['psbt']) |
| 1026 | assert update['commitments_secured'] |
| 1027 | |
| 1028 | return l1.rpc.signpsbt(update['psbt'])['signed_psbt'] |
| 1029 | |
| 1030 | # Make a second inflight |
| 1031 | signed_psbt = run_retry() |
| 1032 | l1.rpc.openchannel_signed(chan_id, signed_psbt) |
| 1033 | |
| 1034 | # Make it such that l1 and l2 cannot broadcast transactions |
| 1035 | # (mimics failing to reach the miner with replacement) |
| 1036 | def censoring_sendrawtx(r): |
| 1037 | return {'id': r['id'], 'result': {}} |
| 1038 | |
| 1039 | l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', censoring_sendrawtx) |
| 1040 | l2.daemon.rpcproxy.mock_rpc('sendrawtransaction', censoring_sendrawtx) |
| 1041 | |
| 1042 | # Make a 3rd inflight that won't make it into the mempool |
| 1043 | signed_psbt = run_retry() |
nothing calls this directly
no test coverage detected