MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_v2_rbf_multi

Function test_v2_rbf_multi

tests/test_opening.py:666–751  ·  view source on GitHub ↗
(node_factory, bitcoind, chainparams)

Source from the content-addressed store, hash-verified

664@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
665@pytest.mark.openchannel('v2')
666def test_v2_rbf_multi(node_factory, bitcoind, chainparams):
667 l1, l2 = node_factory.get_nodes(2,
668 opts={'may_reconnect': True,
669 'dev-no-reconnect': None,
670 'allow_warning': True})
671
672 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
673 amount = 2**24
674 chan_amount = 100000
675 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['p2tr'], amount / 10**8 + 0.01)
676 bitcoind.generate_block(1)
677 # Wait for it to arrive.
678 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
679
680 res = l1.rpc.fundchannel(l2.info['id'], chan_amount)
681 chan_id = res['channel_id']
682 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
683 assert(only_one(vins))
684 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
685
686 # Check that we're waiting for lockin
687 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
688
689 # Attempt to do abort, should fail since we've
690 # already gotten an inflight
691 with pytest.raises(RpcError):
692 l1.rpc.openchannel_abort(chan_id)
693
694 rate = int(find_next_feerate(l1, l2)[:-5])
695 # We 4x the feerate to beat the min-relay fee
696 next_feerate = '{}perkw'.format(rate * 4)
697
698 # Initiate an RBF
699 startweight = 42 + 172 # base weight, funding output
700 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
701 prev_utxos, reservedok=True,
702 excess_as_change=True)
703
704 # Do the bump
705 bump = l1.rpc.openchannel_bump(chan_id, chan_amount,
706 initpsbt['psbt'],
707 funding_feerate=next_feerate)
708
709 # Abort this open attempt! We will re-try
710 aborted = l1.rpc.openchannel_abort(chan_id)
711 assert not aborted['channel_canceled']
712 # We no longer disconnect on aborts, because magic!
713 assert only_one(l1.rpc.listpeers()['peers'])['connected']
714
715 # Do the bump, again, same feerate
716 bump = l1.rpc.openchannel_bump(chan_id, chan_amount,
717 initpsbt['psbt'],
718 funding_feerate=next_feerate)
719
720 update = l1.rpc.openchannel_update(chan_id, bump['psbt'])
721 assert update['commitments_secured']
722
723 # Sign our inputs, and continue

Callers

nothing calls this directly

Calls 15

wait_forFunction · 0.90
only_oneFunction · 0.90
sync_blockheightFunction · 0.90
find_next_feerateFunction · 0.85
get_nodesMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
openchannel_abortMethod · 0.80
utxopsbtMethod · 0.80
openchannel_bumpMethod · 0.80
openchannel_updateMethod · 0.80
signpsbtMethod · 0.80

Tested by

no test coverage detected