mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
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 <rusty@rustcorp.com.au>
This commit is contained in:
parent
cdb93eefec
commit
d12a2ec76a
5 changed files with 36 additions and 41 deletions
|
@ -968,6 +968,7 @@ void peer_start_openingd(struct peer *peer, struct per_peer_state *pps)
|
|||
msg = towire_openingd_init(NULL,
|
||||
chainparams,
|
||||
peer->ld->our_features,
|
||||
peer->their_features,
|
||||
&uc->our_config,
|
||||
max_to_self_delay,
|
||||
min_effective_htlc_capacity,
|
||||
|
@ -976,13 +977,6 @@ void peer_start_openingd(struct peer *peer, struct per_peer_state *pps)
|
|||
uc->minimum_depth,
|
||||
feerate_min(peer->ld, NULL),
|
||||
feerate_max(peer->ld, NULL),
|
||||
peer->their_features,
|
||||
feature_negotiated(peer->ld->our_features,
|
||||
peer->their_features,
|
||||
OPT_STATIC_REMOTEKEY),
|
||||
feature_negotiated(peer->ld->our_features,
|
||||
peer->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
IFDEV(peer->ld->dev_force_tmp_channel_id, NULL),
|
||||
IFDEV(peer->ld->dev_fast_gossip, false));
|
||||
subd_send_msg(uc->open_daemon, take(msg));
|
||||
|
|
|
@ -114,9 +114,6 @@ struct state {
|
|||
* as initial channels never have HTLCs. */
|
||||
struct channel *channel;
|
||||
|
||||
bool option_static_remotekey;
|
||||
bool option_anchor_outputs;
|
||||
|
||||
struct feature_set *our_features;
|
||||
};
|
||||
|
||||
|
@ -466,7 +463,9 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
|
|||
&state->remoteconf,
|
||||
&state->localconf,
|
||||
true,
|
||||
state->option_anchor_outputs,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
&err_reason)) {
|
||||
negotiation_failed(state, true, "%s", err_reason);
|
||||
return NULL;
|
||||
|
@ -531,8 +530,12 @@ static bool funder_finalize_channel_setup(struct state *state,
|
|||
&state->their_points,
|
||||
&state->our_funding_pubkey,
|
||||
&state->their_funding_pubkey,
|
||||
state->option_static_remotekey,
|
||||
state->option_anchor_outputs,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_STATIC_REMOTEKEY),
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
feature_offered(state->their_features,
|
||||
OPT_LARGE_CHANNELS),
|
||||
/* Opener is local */
|
||||
|
@ -910,7 +913,9 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
|||
&state->remoteconf,
|
||||
&state->localconf,
|
||||
false,
|
||||
state->option_anchor_outputs,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
&err_reason)) {
|
||||
negotiation_failed(state, false, "%s", err_reason);
|
||||
return NULL;
|
||||
|
@ -1023,8 +1028,12 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
|||
&state->our_points, &theirs,
|
||||
&state->our_funding_pubkey,
|
||||
&their_funding_pubkey,
|
||||
state->option_static_remotekey,
|
||||
state->option_anchor_outputs,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_STATIC_REMOTEKEY),
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
feature_offered(state->their_features,
|
||||
OPT_LARGE_CHANNELS),
|
||||
REMOTE);
|
||||
|
@ -1357,6 +1366,7 @@ int main(int argc, char *argv[])
|
|||
if (!fromwire_openingd_init(state, msg,
|
||||
&chainparams,
|
||||
&state->our_features,
|
||||
&state->their_features,
|
||||
&state->localconf,
|
||||
&state->max_to_self_delay,
|
||||
&state->min_effective_htlc_capacity,
|
||||
|
@ -1365,9 +1375,6 @@ int main(int argc, char *argv[])
|
|||
&state->our_funding_pubkey,
|
||||
&state->minimum_depth,
|
||||
&state->min_feerate, &state->max_feerate,
|
||||
&state->their_features,
|
||||
&state->option_static_remotekey,
|
||||
&state->option_anchor_outputs,
|
||||
&force_tmp_channel_id,
|
||||
&dev_fast_gossip))
|
||||
master_badmsg(WIRE_OPENINGD_INIT, msg);
|
||||
|
|
|
@ -10,6 +10,8 @@ msgtype,openingd_init,6000
|
|||
# Which network are we configured for?
|
||||
msgdata,openingd_init,chainparams,chainparams,
|
||||
msgdata,openingd_init,our_features,feature_set,
|
||||
msgdata,openingd_init,their_init_features_len,u16,
|
||||
msgdata,openingd_init,their_init_features,u8,their_init_features_len
|
||||
# Base configuration we'll offer (channel reserve will vary with amount)
|
||||
msgdata,openingd_init,our_config,channel_config,
|
||||
# Minimum/maximum configuration values we'll accept
|
||||
|
@ -22,10 +24,6 @@ msgdata,openingd_init,our_funding_pubkey,pubkey,
|
|||
msgdata,openingd_init,minimum_depth,u32,
|
||||
msgdata,openingd_init,min_feerate,u32,
|
||||
msgdata,openingd_init,max_feerate,u32,
|
||||
msgdata,openingd_init,lfeatures_len,u16,
|
||||
msgdata,openingd_init,lfeatures,u8,lfeatures_len
|
||||
msgdata,openingd_init,option_static_remotekey,bool,
|
||||
msgdata,openingd_init,option_anchor_outputs,bool,
|
||||
msgdata,openingd_init,dev_temporary_channel_id,?byte,32
|
||||
msgdata,openingd_init,dev_fast_gossip,bool,
|
||||
|
||||
|
|
|
26
openingd/openingd_wiregen.c
generated
26
openingd/openingd_wiregen.c
generated
|
@ -65,15 +65,17 @@ bool openingd_wire_is_defined(u16 type)
|
|||
|
||||
|
||||
/* WIRE: OPENINGD_INIT */
|
||||
u8 *towire_openingd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const u8 *lfeatures, bool option_static_remotekey, bool option_anchor_outputs, const struct channel_id *dev_temporary_channel_id, bool dev_fast_gossip)
|
||||
u8 *towire_openingd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const u8 *their_init_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const struct channel_id *dev_temporary_channel_id, bool dev_fast_gossip)
|
||||
{
|
||||
u16 lfeatures_len = tal_count(lfeatures);
|
||||
u16 their_init_features_len = tal_count(their_init_features);
|
||||
u8 *p = tal_arr(ctx, u8, 0);
|
||||
|
||||
towire_u16(&p, WIRE_OPENINGD_INIT);
|
||||
/* Which network are we configured for? */
|
||||
towire_chainparams(&p, chainparams);
|
||||
towire_feature_set(&p, our_features);
|
||||
towire_u16(&p, their_init_features_len);
|
||||
towire_u8_array(&p, their_init_features, their_init_features_len);
|
||||
/* Base configuration we'll offer (channel reserve will vary with amount) */
|
||||
towire_channel_config(&p, our_config);
|
||||
/* Minimum/maximum configuration values we'll accept */
|
||||
|
@ -86,10 +88,6 @@ u8 *towire_openingd_init(const tal_t *ctx, const struct chainparams *chainparams
|
|||
towire_u32(&p, minimum_depth);
|
||||
towire_u32(&p, min_feerate);
|
||||
towire_u32(&p, max_feerate);
|
||||
towire_u16(&p, lfeatures_len);
|
||||
towire_u8_array(&p, lfeatures, lfeatures_len);
|
||||
towire_bool(&p, option_static_remotekey);
|
||||
towire_bool(&p, option_anchor_outputs);
|
||||
if (!dev_temporary_channel_id)
|
||||
towire_bool(&p, false);
|
||||
else {
|
||||
|
@ -100,9 +98,9 @@ u8 *towire_openingd_init(const tal_t *ctx, const struct chainparams *chainparams
|
|||
|
||||
return memcheck(p, tal_count(p));
|
||||
}
|
||||
bool fromwire_openingd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, u8 **lfeatures, bool *option_static_remotekey, bool *option_anchor_outputs, struct channel_id **dev_temporary_channel_id, bool *dev_fast_gossip)
|
||||
bool fromwire_openingd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, u8 **their_init_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, struct channel_id **dev_temporary_channel_id, bool *dev_fast_gossip)
|
||||
{
|
||||
u16 lfeatures_len;
|
||||
u16 their_init_features_len;
|
||||
|
||||
const u8 *cursor = p;
|
||||
size_t plen = tal_count(p);
|
||||
|
@ -112,6 +110,10 @@ bool fromwire_openingd_init(const tal_t *ctx, const void *p, const struct chainp
|
|||
/* Which network are we configured for? */
|
||||
fromwire_chainparams(&cursor, &plen, chainparams);
|
||||
*our_features = fromwire_feature_set(ctx, &cursor, &plen);
|
||||
their_init_features_len = fromwire_u16(&cursor, &plen);
|
||||
// 2nd case their_init_features
|
||||
*their_init_features = their_init_features_len ? tal_arr(ctx, u8, their_init_features_len) : NULL;
|
||||
fromwire_u8_array(&cursor, &plen, *their_init_features, their_init_features_len);
|
||||
/* Base configuration we'll offer (channel reserve will vary with amount) */
|
||||
fromwire_channel_config(&cursor, &plen, our_config);
|
||||
/* Minimum/maximum configuration values we'll accept */
|
||||
|
@ -124,12 +126,6 @@ bool fromwire_openingd_init(const tal_t *ctx, const void *p, const struct chainp
|
|||
*minimum_depth = fromwire_u32(&cursor, &plen);
|
||||
*min_feerate = fromwire_u32(&cursor, &plen);
|
||||
*max_feerate = fromwire_u32(&cursor, &plen);
|
||||
lfeatures_len = fromwire_u16(&cursor, &plen);
|
||||
// 2nd case lfeatures
|
||||
*lfeatures = lfeatures_len ? tal_arr(ctx, u8, lfeatures_len) : NULL;
|
||||
fromwire_u8_array(&cursor, &plen, *lfeatures, lfeatures_len);
|
||||
*option_static_remotekey = fromwire_bool(&cursor, &plen);
|
||||
*option_anchor_outputs = fromwire_bool(&cursor, &plen);
|
||||
if (!fromwire_bool(&cursor, &plen))
|
||||
*dev_temporary_channel_id = NULL;
|
||||
else {
|
||||
|
@ -604,4 +600,4 @@ bool fromwire_openingd_dev_memleak_reply(const void *p, bool *leak)
|
|||
*leak = fromwire_bool(&cursor, &plen);
|
||||
return cursor != NULL;
|
||||
}
|
||||
// SHA256STAMP:e01a9f3e8b3c9962c9b35502d3b74977e289e61ebebf28627276e97d06bc4b35
|
||||
// SHA256STAMP:7d60f5bf289ffe8adcf1e445c9c82ef0e69438cd0e7cea47f1f2bd73727aabf2
|
||||
|
|
6
openingd/openingd_wiregen.h
generated
6
openingd/openingd_wiregen.h
generated
|
@ -60,8 +60,8 @@ bool openingd_wire_is_defined(u16 type);
|
|||
|
||||
|
||||
/* WIRE: OPENINGD_INIT */
|
||||
u8 *towire_openingd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const u8 *lfeatures, bool option_static_remotekey, bool option_anchor_outputs, const struct channel_id *dev_temporary_channel_id, bool dev_fast_gossip);
|
||||
bool fromwire_openingd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, u8 **lfeatures, bool *option_static_remotekey, bool *option_anchor_outputs, struct channel_id **dev_temporary_channel_id, bool *dev_fast_gossip);
|
||||
u8 *towire_openingd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const u8 *their_init_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const struct channel_id *dev_temporary_channel_id, bool dev_fast_gossip);
|
||||
bool fromwire_openingd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, u8 **their_init_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, struct channel_id **dev_temporary_channel_id, bool *dev_fast_gossip);
|
||||
|
||||
/* WIRE: OPENINGD_GOT_REESTABLISH */
|
||||
/* Openingd->master: they tried to reestablish a channel. */
|
||||
|
@ -128,4 +128,4 @@ bool fromwire_openingd_dev_memleak_reply(const void *p, bool *leak);
|
|||
|
||||
|
||||
#endif /* LIGHTNING_OPENINGD_OPENINGD_WIREGEN_H */
|
||||
// SHA256STAMP:e01a9f3e8b3c9962c9b35502d3b74977e289e61ebebf28627276e97d06bc4b35
|
||||
// SHA256STAMP:7d60f5bf289ffe8adcf1e445c9c82ef0e69438cd0e7cea47f1f2bd73727aabf2
|
||||
|
|
Loading…
Add table
Reference in a new issue