Skip to content

Commit 24fb6d4

Browse files
committed
openchannel: add dual-funding fields to hook
Adds fields that are only relevant for v2 of openchannel protocol to the openchannel hook.
1 parent c959bee commit 24fb6d4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- JSON API: `txprepare` includes a parameter `zero_out_change`, which if true leaves the change value as zero. Useful for designating change output for dual-funded transactions. Defaults to false.
1515
- JSON API: `fundchannel_start` now includes `open_channel_version`, a string which indicates
1616
the protocol version used to open the channel.
17+
- Plugin: `openchannel` hook includes fields for v2 channel establishment
1718

1819
- bolt11: support for parsing feature bits (field `9`).
1920

lightningd/opening_control.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,13 @@ openchannel_hook_serialize(struct openchannel_hook_payload *payload,
981981
struct uncommitted_channel *uc = payload->openingd->channel;
982982
json_object_start(stream, "openchannel");
983983
json_add_node_id(stream, "id", &uc->peer->id);
984-
json_add_amount_sat_only(stream, "funding_satoshis",
985-
payload->opener_satoshis);
984+
json_add_string(stream, "version", payload->is_v2 ? "2" : "1");
985+
if (payload->is_v2)
986+
json_add_amount_sat_only(stream, "opener_satoshis",
987+
payload->opener_satoshis);
988+
else
989+
json_add_amount_sat_only(stream, "funding_satoshis",
990+
payload->opener_satoshis);
986991
json_add_amount_msat_only(stream, "push_msat", payload->push_msat);
987992
json_add_amount_sat_only(stream, "dust_limit_satoshis",
988993
payload->dust_limit_satoshis);
@@ -992,7 +997,13 @@ openchannel_hook_serialize(struct openchannel_hook_payload *payload,
992997
payload->channel_reserve_satoshis);
993998
json_add_amount_msat_only(stream, "htlc_minimum_msat",
994999
payload->htlc_minimum_msat);
1000+
if (payload->is_v2)
1001+
json_add_amount_sat_only(stream, "available_funds",
1002+
payload->available_funds);
9951003
json_add_num(stream, "feerate_per_kw", payload->feerate_per_kw);
1004+
if (payload->is_v2)
1005+
json_add_num(stream, "feerate_per_kw_funding",
1006+
payload->feerate_per_kw_funding);
9961007
json_add_num(stream, "to_self_delay", payload->to_self_delay);
9971008
json_add_num(stream, "max_accepted_htlcs", payload->max_accepted_htlcs);
9981009
json_add_num(stream, "channel_flags", payload->channel_flags);

0 commit comments

Comments
 (0)