mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
openchannel2: add channel_max_msat to openchannel2 hook payload
Changelog-Added: Plugins: add a `channel_max_msat` value to the `openchannel2` hook. Tells you the total max funding this channel is allowed to have.
This commit is contained in:
parent
382264e207
commit
7c76363e20
@ -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"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user