(node_factory, bitcoind, stay_withheld, mutual_close)
| 3504 | @pytest.mark.parametrize("stay_withheld", [True, False]) |
| 3505 | @pytest.mark.parametrize("mutual_close", [True, False]) |
| 3506 | def test_zeroconf_withhold(node_factory, bitcoind, stay_withheld, mutual_close): |
| 3507 | plugin_path = Path(__file__).parent / "plugins" / "zeroconf-selective.py" |
| 3508 | |
| 3509 | l1, l2 = node_factory.get_nodes(2, opts=[{'may_reconnect': True, |
| 3510 | 'dev-no-reconnect': None, |
| 3511 | }, |
| 3512 | {'plugin': str(plugin_path), |
| 3513 | 'zeroconf_allow': '038194b5f32bdf0aa59812c86c4ef7ad2f294104fa027d1ace9b469bb6f88cf37b', |
| 3514 | 'may_reconnect': True, |
| 3515 | 'dev-no-reconnect': None, |
| 3516 | }]) |
| 3517 | # Try to open a mindepth=0 channel |
| 3518 | l1.fundwallet(10**7) |
| 3519 | |
| 3520 | l1.connect(l2) |
| 3521 | amount = 1000000 |
| 3522 | funding_addr = l1.rpc.fundchannel_start(l2.info['id'], f"{amount}sat", mindepth=0)['funding_address'] |
| 3523 | |
| 3524 | # Create the funding transaction |
| 3525 | psbt = l1.rpc.fundpsbt(amount, "1000perkw", 1000, excess_as_change=True)['psbt'] |
| 3526 | psbt = l1.rpc.addpsbtoutput(1000000, psbt, destination=funding_addr)['psbt'] |
| 3527 | |
| 3528 | # Be sure fundchannel_complete is successful |
| 3529 | assert l1.rpc.fundchannel_complete(l2.info['id'], psbt, withhold=True)['commitments_secured'] |
| 3530 | |
| 3531 | # It's withheld. |
| 3532 | assert only_one(l1.rpc.listpeerchannels()['channels'])['funding']['withheld'] is True |
| 3533 | |
| 3534 | # We can use the channel (once they send an update) |
| 3535 | wait_for(lambda: 'remote' in only_one(l1.rpc.listpeerchannels()['channels'])['updates']) |
| 3536 | l1.rpc.xpay(l2.rpc.invoice(100, "test_zeroconf_withhold", "test_zeroconf_withhold")['bolt11']) |
| 3537 | |
| 3538 | # But mempool is empty! No funding tx! |
| 3539 | assert bitcoind.rpc.getrawmempool() == [] |
| 3540 | |
| 3541 | # Restarting doesn't make it transmit! |
| 3542 | l1.restart() |
| 3543 | assert bitcoind.rpc.getrawmempool() == [] |
| 3544 | |
| 3545 | if mutual_close: |
| 3546 | l1.connect(l2) |
| 3547 | |
| 3548 | if not stay_withheld: |
| 3549 | # sendpsbt marks it as no longer withheld. |
| 3550 | l1.rpc.sendpsbt(l1.rpc.signpsbt(psbt)['signed_psbt']) |
| 3551 | assert only_one(l1.rpc.listpeerchannels()['channels'])['funding']['withheld'] is False |
| 3552 | assert l1.daemon.is_in_log(r'Funding PSBT sent, and stored for rexmit \(was withheld\)') |
| 3553 | wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == 1) |
| 3554 | |
| 3555 | if mutual_close: |
| 3556 | ret = l1.rpc.close(l2.info['id']) |
| 3557 | else: |
| 3558 | ret = l1.rpc.close(l2.info['id'], unilateraltimeout=1) |
| 3559 | |
| 3560 | if stay_withheld: |
| 3561 | assert ret['txs'] == [] |
| 3562 | assert ret['txids'] == [] |
| 3563 | assert bitcoind.rpc.getrawmempool() == [] |
nothing calls this directly
no test coverage detected