(node_factory, bitcoind, chainparams)
| 344 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
| 345 | @pytest.mark.openchannel('v2') |
| 346 | def test_v2_rbf_liquidity_ad(node_factory, bitcoind, chainparams): |
| 347 | |
| 348 | opts = {'funder-policy': 'match', 'funder-policy-mod': 100, |
| 349 | 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, |
| 350 | 'may_reconnect': True} |
| 351 | l1, l2 = node_factory.get_nodes(2, opts=opts) |
| 352 | |
| 353 | # what happens when we RBF? |
| 354 | feerate = 2000 |
| 355 | amount = 500000 |
| 356 | l1.fundwallet(20000000) |
| 357 | l2.fundwallet(20000000) |
| 358 | |
| 359 | # l1 leases a channel from l2 |
| 360 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 361 | rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount) |
| 362 | wait_for(lambda: l1.rpc.listpeers()['peers'] == []) |
| 363 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 364 | chan_id = l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount, |
| 365 | feerate='{}perkw'.format(feerate), |
| 366 | compact_lease=rates['compact_lease'])['channel_id'] |
| 367 | |
| 368 | vins = [x for x in l1.rpc.listfunds()['outputs'] if x['reserved']] |
| 369 | assert only_one(vins) |
| 370 | prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['output'])] |
| 371 | |
| 372 | # Check that we're waiting for lockin |
| 373 | l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN') |
| 374 | |
| 375 | est_fees = calc_lease_fee(amount, feerate, rates) |
| 376 | |
| 377 | # This should be the accepter's amount |
| 378 | fundings = only_one(only_one(l1.rpc.listpeers()['peers'])['channels'])['funding'] |
| 379 | assert Millisatoshi(amount * 1000) == fundings['remote_funds_msat'] |
| 380 | assert Millisatoshi(est_fees + amount * 1000) == fundings['local_funds_msat'] |
| 381 | assert Millisatoshi(est_fees) == fundings['fee_paid_msat'] |
| 382 | assert 'fee_rcvd_msat' not in fundings |
| 383 | |
| 384 | # rbf the lease with a higher amount |
| 385 | rate = int(find_next_feerate(l1, l2)[:-5]) |
| 386 | # We 4x the feerate to beat the min-relay fee |
| 387 | next_feerate = '{}perkw'.format(rate * 4) |
| 388 | |
| 389 | # Initiate an RBF |
| 390 | startweight = 42 + 172 # base weight, funding output |
| 391 | initpsbt = l1.rpc.utxopsbt(amount, next_feerate, startweight, |
| 392 | prev_utxos, reservedok=True, |
| 393 | min_witness_weight=110, |
| 394 | excess_as_change=True)['psbt'] |
| 395 | |
| 396 | # do the bump |
| 397 | bump = l1.rpc.openchannel_bump(chan_id, amount, initpsbt, |
| 398 | funding_feerate=next_feerate) |
| 399 | update = l1.rpc.openchannel_update(chan_id, bump['psbt']) |
| 400 | assert update['commitments_secured'] |
| 401 | # Sign our inputs, and continue |
| 402 | signed_psbt = l1.rpc.signpsbt(update['psbt'])['signed_psbt'] |
| 403 | l1.rpc.openchannel_signed(chan_id, signed_psbt) |
nothing calls this directly
no test coverage detected