Skip to content

Commit 574e3e5

Browse files
committed
openingd: don't hand redundant feature flags.
Openingd can query them itself (as dualopend already does). And move the two feature args next to each other on the wire. Signed-off-by: Rusty Russell <[email protected]>
1 parent 7e43109 commit 574e3e5

File tree

5 files changed

+36
-41
lines changed

5 files changed

+36
-41
lines changed

lightningd/opening_control.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ void peer_start_openingd(struct peer *peer, struct per_peer_state *pps)
962962
msg = towire_openingd_init(NULL,
963963
chainparams,
964964
peer->ld->our_features,
965+
peer->their_features,
965966
&uc->our_config,
966967
max_to_self_delay,
967968
min_effective_htlc_capacity,
@@ -970,13 +971,6 @@ void peer_start_openingd(struct peer *peer, struct per_peer_state *pps)
970971
uc->minimum_depth,
971972
feerate_min(peer->ld, NULL),
972973
feerate_max(peer->ld, NULL),
973-
peer->their_features,
974-
feature_negotiated(peer->ld->our_features,
975-
peer->their_features,
976-
OPT_STATIC_REMOTEKEY),
977-
feature_negotiated(peer->ld->our_features,
978-
peer->their_features,
979-
OPT_ANCHOR_OUTPUTS),
980974
IFDEV(peer->ld->dev_force_tmp_channel_id, NULL),
981975
IFDEV(peer->ld->dev_fast_gossip, false));
982976
subd_send_msg(uc->open_daemon, take(msg));

openingd/openingd.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ struct state {
114114
* as initial channels never have HTLCs. */
115115
struct channel *channel;
116116

117-
bool option_static_remotekey;
118-
bool option_anchor_outputs;
119-
120117
struct feature_set *our_features;
121118
};
122119

@@ -466,7 +463,9 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
466463
&state->remoteconf,
467464
&state->localconf,
468465
true,
469-
state->option_anchor_outputs,
466+
feature_negotiated(state->our_features,
467+
state->their_features,
468+
OPT_ANCHOR_OUTPUTS),
470469
&err_reason)) {
471470
negotiation_failed(state, true, "%s", err_reason);
472471
return NULL;
@@ -531,8 +530,12 @@ static bool funder_finalize_channel_setup(struct state *state,
531530
&state->their_points,
532531
&state->our_funding_pubkey,
533532
&state->their_funding_pubkey,
534-
state->option_static_remotekey,
535-
state->option_anchor_outputs,
533+
feature_negotiated(state->our_features,
534+
state->their_features,
535+
OPT_STATIC_REMOTEKEY),
536+
feature_negotiated(state->our_features,
537+
state->their_features,
538+
OPT_ANCHOR_OUTPUTS),
536539
/* Opener is local */
537540
LOCAL);
538541
/* We were supposed to do enough checks above, but just in case,
@@ -908,7 +911,9 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
908911
&state->remoteconf,
909912
&state->localconf,
910913
false,
911-
state->option_anchor_outputs,
914+
feature_negotiated(state->our_features,
915+
state->their_features,
916+
OPT_ANCHOR_OUTPUTS),
912917
&err_reason)) {
913918
negotiation_failed(state, false, "%s", err_reason);
914919
return NULL;
@@ -1021,8 +1026,12 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
10211026
&state->our_points, &theirs,
10221027
&state->our_funding_pubkey,
10231028
&their_funding_pubkey,
1024-
state->option_static_remotekey,
1025-
state->option_anchor_outputs,
1029+
feature_negotiated(state->our_features,
1030+
state->their_features,
1031+
OPT_STATIC_REMOTEKEY),
1032+
feature_negotiated(state->our_features,
1033+
state->their_features,
1034+
OPT_ANCHOR_OUTPUTS),
10261035
REMOTE);
10271036
/* We don't expect this to fail, but it does do some additional
10281037
* internal sanity checks. */
@@ -1353,6 +1362,7 @@ int main(int argc, char *argv[])
13531362
if (!fromwire_openingd_init(state, msg,
13541363
&chainparams,
13551364
&state->our_features,
1365+
&state->their_features,
13561366
&state->localconf,
13571367
&state->max_to_self_delay,
13581368
&state->min_effective_htlc_capacity,
@@ -1361,9 +1371,6 @@ int main(int argc, char *argv[])
13611371
&state->our_funding_pubkey,
13621372
&state->minimum_depth,
13631373
&state->min_feerate, &state->max_feerate,
1364-
&state->their_features,
1365-
&state->option_static_remotekey,
1366-
&state->option_anchor_outputs,
13671374
&force_tmp_channel_id,
13681375
&dev_fast_gossip))
13691376
master_badmsg(WIRE_OPENINGD_INIT, msg);

openingd/openingd_wire.csv

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ msgtype,openingd_init,6000
1010
# Which network are we configured for?
1111
msgdata,openingd_init,chainparams,chainparams,
1212
msgdata,openingd_init,our_features,feature_set,
13+
msgdata,openingd_init,their_init_features_len,u16,
14+
msgdata,openingd_init,their_init_features,u8,their_init_features_len
1315
# Base configuration we'll offer (channel reserve will vary with amount)
1416
msgdata,openingd_init,our_config,channel_config,
1517
# Minimum/maximum configuration values we'll accept
@@ -22,10 +24,6 @@ msgdata,openingd_init,our_funding_pubkey,pubkey,
2224
msgdata,openingd_init,minimum_depth,u32,
2325
msgdata,openingd_init,min_feerate,u32,
2426
msgdata,openingd_init,max_feerate,u32,
25-
msgdata,openingd_init,lfeatures_len,u16,
26-
msgdata,openingd_init,lfeatures,u8,lfeatures_len
27-
msgdata,openingd_init,option_static_remotekey,bool,
28-
msgdata,openingd_init,option_anchor_outputs,bool,
2927
msgdata,openingd_init,dev_temporary_channel_id,?byte,32
3028
msgdata,openingd_init,dev_fast_gossip,bool,
3129

openingd/openingd_wiregen.c

Lines changed: 11 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openingd/openingd_wiregen.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)