diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index 6f81c4410..db4515a21 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -1034,6 +1034,7 @@ the v2 protocol, and it has passed basic sanity checks: "max_accepted_htlcs": 483, "channel_flags": 1 "locktime": 2453, + "channel_max_msat": "16777215000msat" } } ``` diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 44a550881..f6868881b 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -241,6 +241,9 @@ struct openchannel2_payload { u8 channel_flags; u32 locktime; u8 *shutdown_scriptpubkey; + /* What's the maximum amount of funding + * this channel can hold */ + struct amount_sat channel_max; struct amount_sat accepter_funding; struct wally_psbt *psbt; @@ -278,6 +281,8 @@ openchannel2_hook_serialize(struct openchannel2_payload *payload, if (tal_bytelen(payload->shutdown_scriptpubkey) != 0) json_add_hex_talarr(stream, "shutdown_scriptpubkey", payload->shutdown_scriptpubkey); + json_add_amount_sat_only(stream, "channel_max_msat", + payload->channel_max); json_object_end(stream); } @@ -1695,6 +1700,12 @@ static void accepter_got_offer(struct subd *dualopend, payload->feerate_our_min = feerate_min(dualopend->ld, NULL); payload->feerate_our_max = feerate_max(dualopend->ld, NULL); + payload->channel_max = chainparams->max_funding; + if (feature_negotiated(dualopend->ld->our_features, + channel->peer->their_features, + OPT_LARGE_CHANNELS)) + payload->channel_max = AMOUNT_SAT(UINT64_MAX); + tal_add_destructor2(dualopend, openchannel2_remove_dualopend, payload); plugin_hook_call_openchannel2(dualopend->ld, payload); } diff --git a/tests/test_plugin.py b/tests/test_plugin.py index e4e944b68..6ea840e9d 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -606,6 +606,7 @@ def test_openchannel_hook(node_factory, bitcoind): 'feerate_our_min': '1875', 'locktime': '.*', 'their_funding': '100000000msat', + 'channel_max_msat': '16777215000msat', }) else: expected.update({