Browse Source

cleanup: make 'u8 *features' and 'struct feature_set *fset' more explicit.

It's almost always "their_features" and "our_features" respectively, so
make those names clear.

Suggested-by: @cdecker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
parent
commit
2f1502abf4
  1. 6
      channeld/channel_wire.csv
  2. 15
      channeld/channeld.c
  3. 14
      common/bolt11.c
  4. 2
      common/bolt11.h
  5. 33
      common/features.c
  6. 11
      common/features.h
  7. 2
      connectd/connect_wire.csv
  8. 41
      connectd/connectd.c
  9. 2
      connectd/connectd.h
  10. 6
      connectd/peer_exchange_initmsg.c
  11. 2
      connectd/peer_exchange_initmsg.h
  12. 3
      gossipd/gossip_generation.c
  13. 2
      gossipd/gossip_wire.csv
  14. 2
      gossipd/gossipd.c
  15. 2
      gossipd/gossipd.h
  16. 4
      lightningd/channel_control.c
  17. 4
      lightningd/connect_control.c
  18. 2
      lightningd/gossip_control.c
  19. 4
      lightningd/invoice.c
  20. 2
      lightningd/lightningd.c
  21. 2
      lightningd/lightningd.h
  22. 17
      lightningd/opening_control.c
  23. 7
      lightningd/options.c
  24. 2
      lightningd/pay.c
  25. 19
      lightningd/peer_control.c
  26. 2
      lightningd/peer_control.h
  27. 4
      lightningd/plugin.c
  28. 2
      openingd/opening_wire.csv
  29. 22
      openingd/openingd.c
  30. 8
      plugins/fundchannel.c
  31. 6
      plugins/libplugin.c

6
channeld/channel_wire.csv

@ -8,7 +8,7 @@
# Begin! (passes gossipd-client fd) # Begin! (passes gossipd-client fd)
msgtype,channel_init,1000 msgtype,channel_init,1000
msgdata,channel_init,chainparams,chainparams, msgdata,channel_init,chainparams,chainparams,
msgdata,channel_init,feature_set,feature_set, msgdata,channel_init,our_features,feature_set,
msgdata,channel_init,funding_txid,bitcoin_txid, msgdata,channel_init,funding_txid,bitcoin_txid,
msgdata,channel_init,funding_txout,u16, msgdata,channel_init,funding_txout,u16,
msgdata,channel_init,funding_satoshi,amount_sat, msgdata,channel_init,funding_satoshi,amount_sat,
@ -64,8 +64,8 @@ msgdata,channel_init,init_peer_pkt_len,u16,
msgdata,channel_init,init_peer_pkt,u8,init_peer_pkt_len msgdata,channel_init,init_peer_pkt,u8,init_peer_pkt_len
msgdata,channel_init,reached_announce_depth,bool, msgdata,channel_init,reached_announce_depth,bool,
msgdata,channel_init,last_remote_secret,secret, msgdata,channel_init,last_remote_secret,secret,
msgdata,channel_init,lflen,u16, msgdata,channel_init,flen,u16,
msgdata,channel_init,localfeatures,u8,lflen msgdata,channel_init,their_features,u8,flen
msgdata,channel_init,upfront_shutdown_script_len,u16, msgdata,channel_init,upfront_shutdown_script_len,u16,
msgdata,channel_init,upfront_shutdown_script,u8,upfront_shutdown_script_len msgdata,channel_init,upfront_shutdown_script,u8,upfront_shutdown_script_len
msgdata,channel_init,remote_ann_node_sig,?secp256k1_ecdsa_signature, msgdata,channel_init,remote_ann_node_sig,?secp256k1_ecdsa_signature,

Can't render this file because it has a wrong number of fields in line 9.

15
channeld/channeld.c

@ -74,10 +74,10 @@ struct peer {
u64 next_index[NUM_SIDES]; u64 next_index[NUM_SIDES];
/* Features peer supports. */ /* Features peer supports. */
u8 *features; u8 *their_features;
/* Features we support. */ /* Features we support. */
struct feature_set *fset; struct feature_set *our_features;
/* Tolerable amounts for feerate (only relevant for fundee). */ /* Tolerable amounts for feerate (only relevant for fundee). */
u32 feerate_min, feerate_max; u32 feerate_min, feerate_max;
@ -418,7 +418,9 @@ static void send_announcement_signatures(struct peer *peer)
static u8 *create_channel_announcement(const tal_t *ctx, struct peer *peer) static u8 *create_channel_announcement(const tal_t *ctx, struct peer *peer)
{ {
int first, second; int first, second;
u8 *cannounce, *features = get_agreed_channelfeatures(tmpctx, peer->fset, peer->features); u8 *cannounce, *features
= get_agreed_channelfeatures(tmpctx, peer->our_features,
peer->their_features);
if (peer->channel_direction == 0) { if (peer->channel_direction == 0) {
first = LOCAL; first = LOCAL;
@ -2328,7 +2330,8 @@ static void peer_reconnect(struct peer *peer,
bool dataloss_protect, check_extra_fields; bool dataloss_protect, check_extra_fields;
const u8 **premature_msgs = tal_arr(peer, const u8 *, 0); const u8 **premature_msgs = tal_arr(peer, const u8 *, 0);
dataloss_protect = feature_negotiated(peer->fset, peer->features, dataloss_protect = feature_negotiated(peer->our_features,
peer->their_features,
OPT_DATA_LOSS_PROTECT); OPT_DATA_LOSS_PROTECT);
/* Both these options give us extra fields to check. */ /* Both these options give us extra fields to check. */
@ -3059,7 +3062,7 @@ static void init_channel(struct peer *peer)
msg = wire_sync_read(tmpctx, MASTER_FD); msg = wire_sync_read(tmpctx, MASTER_FD);
if (!fromwire_channel_init(peer, msg, if (!fromwire_channel_init(peer, msg,
&chainparams, &chainparams,
&peer->fset, &peer->our_features,
&funding_txid, &funding_txout, &funding_txid, &funding_txout,
&funding, &funding,
&minimum_depth, &minimum_depth,
@ -3105,7 +3108,7 @@ static void init_channel(struct peer *peer)
&funding_signed, &funding_signed,
&peer->announce_depth_reached, &peer->announce_depth_reached,
&last_remote_per_commit_secret, &last_remote_per_commit_secret,
&peer->features, &peer->their_features,
&peer->remote_upfront_shutdown_script, &peer->remote_upfront_shutdown_script,
&remote_ann_node_sig, &remote_ann_node_sig,
&remote_ann_bitcoin_sig, &remote_ann_bitcoin_sig,

14
common/bolt11.c

@ -489,7 +489,7 @@ static void shift_bitmap_down(u8 *bitmap, size_t bits)
* See [Feature Bits](#feature-bits). * See [Feature Bits](#feature-bits).
*/ */
static char *decode_9(struct bolt11 *b11, static char *decode_9(struct bolt11 *b11,
const struct feature_set *fset, const struct feature_set *our_features,
struct hash_u5 *hu5, struct hash_u5 *hu5,
u5 **data, size_t *data_len, u5 **data, size_t *data_len,
size_t data_length) size_t data_length)
@ -512,9 +512,10 @@ static char *decode_9(struct bolt11 *b11,
* - if the `9` field contains unknown _even_ bits that are non-zero: * - if the `9` field contains unknown _even_ bits that are non-zero:
* - MUST fail the payment. * - MUST fail the payment.
*/ */
/* We skip this check for the cli tool, which sets fset to NULL */ /* We skip this check for the cli tool, which sets our_features to NULL */
if (fset) { if (our_features) {
badf = features_unsupported(fset, b11->features, BOLT11_FEATURE); badf = features_unsupported(our_features,
b11->features, BOLT11_FEATURE);
if (badf != -1) if (badf != -1)
return tal_fmt(b11, "9: unknown feature bit %i", badf); return tal_fmt(b11, "9: unknown feature bit %i", badf);
} }
@ -545,7 +546,7 @@ struct bolt11 *new_bolt11(const tal_t *ctx,
/* Decodes and checks signature; returns NULL on error. */ /* Decodes and checks signature; returns NULL on error. */
struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str, struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
const struct feature_set *fset, const struct feature_set *our_features,
const char *description, char **fail) const char *description, char **fail)
{ {
char *hrp, *amountstr, *prefix; char *hrp, *amountstr, *prefix;
@ -740,7 +741,8 @@ struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
data_length); data_length);
break; break;
case '9': case '9':
problem = decode_9(b11, fset, &hu5, &data, &data_len, problem = decode_9(b11, our_features, &hu5,
&data, &data_len,
data_length); data_length);
break; break;
case 's': case 's':

2
common/bolt11.h

@ -80,7 +80,7 @@ struct bolt11 {
* fset is NULL to accept any features (usually not desirable!). * fset is NULL to accept any features (usually not desirable!).
*/ */
struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str, struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
const struct feature_set *fset, const struct feature_set *our_features,
const char *description, char **fail); const char *description, char **fail);
/* Initialize an empty bolt11 struct with optional amount */ /* Initialize an empty bolt11 struct with optional amount */

33
common/features.c

@ -158,17 +158,17 @@ static void clear_feature_bit(u8 *features, u32 bit)
* it sets. * it sets.
*/ */
u8 *get_agreed_channelfeatures(const tal_t *ctx, u8 *get_agreed_channelfeatures(const tal_t *ctx,
const struct feature_set *ours, const struct feature_set *our_features,
const u8 *theirfeatures) const u8 *their_features)
{ {
u8 *f = tal_dup_talarr(ctx, u8, ours->bits[CHANNEL_FEATURE]); u8 *f = tal_dup_talarr(ctx, u8, our_features->bits[CHANNEL_FEATURE]);
size_t max_len = 0; size_t max_len = 0;
/* Clear any features which they didn't offer too */ /* Clear any features which they didn't offer too */
for (size_t i = 0; i < 8 * tal_count(f); i += 2) { for (size_t i = 0; i < 8 * tal_count(f); i += 2) {
if (!feature_offered(f, i)) if (!feature_offered(f, i))
continue; continue;
if (!feature_offered(theirfeatures, i)) { if (!feature_offered(their_features, i)) {
clear_feature_bit(f, COMPULSORY_FEATURE(i)); clear_feature_bit(f, COMPULSORY_FEATURE(i));
clear_feature_bit(f, OPTIONAL_FEATURE(i)); clear_feature_bit(f, OPTIONAL_FEATURE(i));
continue; continue;
@ -197,11 +197,11 @@ bool feature_offered(const u8 *features, size_t f)
|| feature_is_set(features, OPTIONAL_FEATURE(f)); || feature_is_set(features, OPTIONAL_FEATURE(f));
} }
bool feature_negotiated(const struct feature_set *ours, bool feature_negotiated(const struct feature_set *our_features,
const u8 *lfeatures, size_t f) const u8 *their_features, size_t f)
{ {
return feature_offered(lfeatures, f) return feature_offered(their_features, f)
&& feature_offered(ours->bits[INIT_FEATURE], f); && feature_offered(our_features->bits[INIT_FEATURE], f);
} }
/** /**
@ -215,7 +215,7 @@ bool feature_negotiated(const struct feature_set *ours,
* *
* Returns -1 on success, or first unsupported feature. * Returns -1 on success, or first unsupported feature.
*/ */
static int all_supported_features(const struct feature_set *ours, static int all_supported_features(const struct feature_set *our_features,
const u8 *bitmap, const u8 *bitmap,
enum feature_place p) enum feature_place p)
{ {
@ -226,7 +226,7 @@ static int all_supported_features(const struct feature_set *ours,
if (!test_bit(bitmap, bitnum/8, bitnum%8)) if (!test_bit(bitmap, bitnum/8, bitnum%8))
continue; continue;
if (feature_offered(ours->bits[p], bitnum)) if (feature_offered(our_features->bits[p], bitnum))
continue; continue;
return bitnum; return bitnum;
@ -234,16 +234,17 @@ static int all_supported_features(const struct feature_set *ours,
return -1; return -1;
} }
int features_unsupported(const struct feature_set *ours, const u8 *theirs, int features_unsupported(const struct feature_set *our_features,
const u8 *their_features,
enum feature_place p) enum feature_place p)
{ {
/* BIT 2 would logically be "compulsory initial_routing_sync", but /* BIT 2 would logically be "compulsory initial_routing_sync", but
* that does not exist, so we special case it. */ * that does not exist, so we special case it. */
if (feature_is_set(theirs, if (feature_is_set(their_features,
COMPULSORY_FEATURE(OPT_INITIAL_ROUTING_SYNC))) COMPULSORY_FEATURE(OPT_INITIAL_ROUTING_SYNC)))
return COMPULSORY_FEATURE(OPT_INITIAL_ROUTING_SYNC); return COMPULSORY_FEATURE(OPT_INITIAL_ROUTING_SYNC);
return all_supported_features(ours, theirs, p); return all_supported_features(our_features, their_features, p);
} }
static const char *feature_name(const tal_t *ctx, size_t f) static const char *feature_name(const tal_t *ctx, size_t f)
@ -269,12 +270,12 @@ static const char *feature_name(const tal_t *ctx, size_t f)
} }
const char **list_supported_features(const tal_t *ctx, const char **list_supported_features(const tal_t *ctx,
const struct feature_set *ours) const struct feature_set *fset)
{ {
const char **list = tal_arr(ctx, const char *, 0); const char **list = tal_arr(ctx, const char *, 0);
for (size_t i = 0; i < tal_bytelen(ours->bits[INIT_FEATURE]) * 8; i++) { for (size_t i = 0; i < tal_bytelen(fset->bits[INIT_FEATURE]) * 8; i++) {
if (test_bit(ours->bits[INIT_FEATURE], i / 8, i % 8)) if (test_bit(fset->bits[INIT_FEATURE], i / 8, i % 8))
tal_arr_expand(&list, feature_name(list, i)); tal_arr_expand(&list, feature_name(list, i));
} }

11
common/features.h

@ -32,24 +32,25 @@ bool feature_set_or(struct feature_set *a,
/* Returns -1 if we're OK with all these offered features, otherwise first /* Returns -1 if we're OK with all these offered features, otherwise first
* unsupported (even) feature. */ * unsupported (even) feature. */
int features_unsupported(const struct feature_set *ours, const u8 *theirs, int features_unsupported(const struct feature_set *our_features,
const u8 *their_features,
enum feature_place p); enum feature_place p);
/* For the features in channel_announcement */ /* For the features in channel_announcement */
u8 *get_agreed_channelfeatures(const tal_t *ctx, u8 *get_agreed_channelfeatures(const tal_t *ctx,
const struct feature_set *ours, const struct feature_set *our_features,
const u8 *theirfeatures); const u8 *theirfeatures);
/* Is this feature bit requested? (Either compulsory or optional) */ /* Is this feature bit requested? (Either compulsory or optional) */
bool feature_offered(const u8 *features, size_t f); bool feature_offered(const u8 *features, size_t f);
/* Was this feature bit offered by them and us? */ /* Was this feature bit offered by them and us? */
bool feature_negotiated(const struct feature_set *ours, bool feature_negotiated(const struct feature_set *our_features,
const u8 *features, size_t f); const u8 *their_features, size_t f);
/* Return a list of what (init) features we advertize. */ /* Return a list of what (init) features we advertize. */
const char **list_supported_features(const tal_t *ctx, const char **list_supported_features(const tal_t *ctx,
const struct feature_set *ours); const struct feature_set *fset);
/* Low-level helpers to deal with big-endian bitfields. */ /* Low-level helpers to deal with big-endian bitfields. */
bool feature_is_set(const u8 *features, size_t bit); bool feature_is_set(const u8 *features, size_t bit);

2
connectd/connect_wire.csv

@ -6,7 +6,7 @@
msgtype,connectctl_init,2000 msgtype,connectctl_init,2000
msgdata,connectctl_init,chainparams,chainparams, msgdata,connectctl_init,chainparams,chainparams,
msgdata,connectctl_init,feature_set,feature_set, msgdata,connectctl_init,our_features,feature_set,
msgdata,connectctl_init,id,node_id, msgdata,connectctl_init,id,node_id,
msgdata,connectctl_init,num_wireaddrs,u16, msgdata,connectctl_init,num_wireaddrs,u16,
msgdata,connectctl_init,wireaddrs,wireaddr_internal,num_wireaddrs msgdata,connectctl_init,wireaddrs,wireaddr_internal,num_wireaddrs

Can't render this file because it has a wrong number of fields in line 7.

41
connectd/connectd.c

@ -156,7 +156,7 @@ struct daemon {
bool use_v3_autotor; bool use_v3_autotor;
/* Our features, as lightningd told us */ /* Our features, as lightningd told us */
struct feature_set *fset; struct feature_set *our_features;
}; };
/* Peers we're trying to reach: we iterate through addrs until we succeed /* Peers we're trying to reach: we iterate through addrs until we succeed
@ -294,7 +294,7 @@ static void connected_to_peer(struct daemon *daemon,
*/ */
static bool get_gossipfds(struct daemon *daemon, static bool get_gossipfds(struct daemon *daemon,
const struct node_id *id, const struct node_id *id,
const u8 *features, const u8 *their_features,
struct per_peer_state *pps) struct per_peer_state *pps)
{ {
bool gossip_queries_feature, initial_routing_sync, success; bool gossip_queries_feature, initial_routing_sync, success;
@ -303,13 +303,14 @@ static bool get_gossipfds(struct daemon *daemon,
/*~ The way features generally work is that both sides need to offer it; /*~ The way features generally work is that both sides need to offer it;
* we always offer `gossip_queries`, but this check is explicit. */ * we always offer `gossip_queries`, but this check is explicit. */
gossip_queries_feature gossip_queries_feature
= feature_negotiated(daemon->fset, features, OPT_GOSSIP_QUERIES); = feature_negotiated(daemon->our_features, their_features,
OPT_GOSSIP_QUERIES);
/*~ `initial_routing_sync` is supported by every node, since it was in /*~ `initial_routing_sync` is supported by every node, since it was in
* the initial lightning specification: it means the peer wants the * the initial lightning specification: it means the peer wants the
* backlog of existing gossip. */ * backlog of existing gossip. */
initial_routing_sync initial_routing_sync
= feature_offered(features, OPT_INITIAL_ROUTING_SYNC); = feature_offered(their_features, OPT_INITIAL_ROUTING_SYNC);
/*~ We do this communication sync, since gossipd is our friend and /*~ We do this communication sync, since gossipd is our friend and
* it's easier. If gossipd fails, we fail. */ * it's easier. If gossipd fails, we fail. */
@ -348,7 +349,7 @@ struct peer_reconnected {
struct node_id id; struct node_id id;
struct wireaddr_internal addr; struct wireaddr_internal addr;
struct crypto_state cs; struct crypto_state cs;
const u8 *features; const u8 *their_features;
}; };
/*~ For simplicity, lightningd only ever deals with a single connection per /*~ For simplicity, lightningd only ever deals with a single connection per
@ -365,7 +366,7 @@ static struct io_plan *retry_peer_connected(struct io_conn *conn,
/*~ Usually the pattern is to return this directly, but we have to free /*~ Usually the pattern is to return this directly, but we have to free
* our temporary structure. */ * our temporary structure. */
plan = peer_connected(conn, pr->daemon, &pr->id, &pr->addr, &pr->cs, plan = peer_connected(conn, pr->daemon, &pr->id, &pr->addr, &pr->cs,
take(pr->features)); take(pr->their_features));
tal_free(pr); tal_free(pr);
return plan; return plan;
} }
@ -377,7 +378,7 @@ static struct io_plan *peer_reconnected(struct io_conn *conn,
const struct node_id *id, const struct node_id *id,
const struct wireaddr_internal *addr, const struct wireaddr_internal *addr,
const struct crypto_state *cs, const struct crypto_state *cs,
const u8 *features TAKES) const u8 *their_features TAKES)
{ {
u8 *msg; u8 *msg;
struct peer_reconnected *pr; struct peer_reconnected *pr;
@ -397,7 +398,7 @@ static struct io_plan *peer_reconnected(struct io_conn *conn,
/*~ Note that tal_dup_talarr() will do handle the take() of features /*~ Note that tal_dup_talarr() will do handle the take() of features
* (turning it into a simply tal_steal() in those cases). */ * (turning it into a simply tal_steal() in those cases). */
pr->features = tal_dup_talarr(pr, u8, features); pr->their_features = tal_dup_talarr(pr, u8, their_features);
/*~ ccan/io supports waiting on an address: in this case, the key in /*~ ccan/io supports waiting on an address: in this case, the key in
* the peer set. When someone calls `io_wake()` on that address, it * the peer set. When someone calls `io_wake()` on that address, it
@ -417,18 +418,19 @@ struct io_plan *peer_connected(struct io_conn *conn,
const struct node_id *id, const struct node_id *id,
const struct wireaddr_internal *addr, const struct wireaddr_internal *addr,
struct crypto_state *cs, struct crypto_state *cs,
const u8 *features TAKES) const u8 *their_features TAKES)
{ {
u8 *msg; u8 *msg;
struct per_peer_state *pps; struct per_peer_state *pps;
int unsup; int unsup;
if (node_set_get(&daemon->peers, id)) if (node_set_get(&daemon->peers, id))
return peer_reconnected(conn, daemon, id, addr, cs, features); return peer_reconnected(conn, daemon, id, addr, cs,
their_features);
/* We promised we'd take it by marking it TAKEN above; prepare to free it. */ /* We promised we'd take it by marking it TAKEN above; prepare to free it. */
if (taken(features)) if (taken(their_features))
tal_steal(tmpctx, features); tal_steal(tmpctx, their_features);
/* BOLT #1: /* BOLT #1:
* *
@ -439,7 +441,8 @@ struct io_plan *peer_connected(struct io_conn *conn,
* - upon receiving unknown _even_ feature bits that are non-zero: * - upon receiving unknown _even_ feature bits that are non-zero:
* - MUST fail the connection. * - MUST fail the connection.
*/ */
unsup = features_unsupported(daemon->fset, features, INIT_FEATURE); unsup = features_unsupported(daemon->our_features, their_features,
INIT_FEATURE);
if (unsup != -1) { if (unsup != -1) {
msg = towire_errorfmt(NULL, NULL, "Unsupported feature %u", msg = towire_errorfmt(NULL, NULL, "Unsupported feature %u",
unsup); unsup);
@ -454,11 +457,11 @@ struct io_plan *peer_connected(struct io_conn *conn,
pps = new_per_peer_state(tmpctx, cs); pps = new_per_peer_state(tmpctx, cs);
/* If gossipd can't give us a file descriptor, we give up connecting. */ /* If gossipd can't give us a file descriptor, we give up connecting. */
if (!get_gossipfds(daemon, id, features, pps)) if (!get_gossipfds(daemon, id, their_features, pps))
return io_close(conn); return io_close(conn);
/* Create message to tell master peer has connected. */ /* Create message to tell master peer has connected. */
msg = towire_connect_peer_connected(NULL, id, addr, pps, features); msg = towire_connect_peer_connected(NULL, id, addr, pps, their_features);
/*~ daemon_conn is a message queue for inter-daemon communication: we /*~ daemon_conn is a message queue for inter-daemon communication: we
* queue up the `connect_peer_connected` message to tell lightningd * queue up the `connect_peer_connected` message to tell lightningd
@ -493,7 +496,8 @@ static struct io_plan *handshake_in_success(struct io_conn *conn,
struct node_id id; struct node_id id;
node_id_from_pubkey(&id, id_key); node_id_from_pubkey(&id, id_key);
status_peer_debug(&id, "Connect IN"); status_peer_debug(&id, "Connect IN");
return peer_exchange_initmsg(conn, daemon, daemon->fset, cs, &id, addr); return peer_exchange_initmsg(conn, daemon, daemon->our_features,
cs, &id, addr);
} }
/*~ When we get a connection in we set up its network address then call /*~ When we get a connection in we set up its network address then call
@ -554,7 +558,8 @@ static struct io_plan *handshake_out_success(struct io_conn *conn,
connect->connstate = "Exchanging init messages"; connect->connstate = "Exchanging init messages";
status_peer_debug(&id, "Connect OUT"); status_peer_debug(&id, "Connect OUT");
return peer_exchange_initmsg(conn, connect->daemon, return peer_exchange_initmsg(conn, connect->daemon,
connect->daemon->fset, cs, &id, addr); connect->daemon->our_features,
cs, &id, addr);
} }
struct io_plan *connection_out(struct io_conn *conn, struct connecting *connect) struct io_plan *connection_out(struct io_conn *conn, struct connecting *connect)
@ -1211,7 +1216,7 @@ static struct io_plan *connect_init(struct io_conn *conn,
if (!fromwire_connectctl_init( if (!fromwire_connectctl_init(
daemon, msg, daemon, msg,
&chainparams, &chainparams,
&daemon->fset, &daemon->our_features,
&daemon->id, &daemon->id,
&proposed_wireaddr, &proposed_wireaddr,
&proposed_listen_announce, &proposed_listen_announce,

2
connectd/connectd.h

@ -19,6 +19,6 @@ struct io_plan *peer_connected(struct io_conn *conn,
const struct node_id *id, const struct node_id *id,
const struct wireaddr_internal *addr, const struct wireaddr_internal *addr,
struct crypto_state *cs, struct crypto_state *cs,
const u8 *features TAKES); const u8 *their_features TAKES);
#endif /* LIGHTNING_CONNECTD_CONNECTD_H */ #endif /* LIGHTNING_CONNECTD_CONNECTD_H */

6
connectd/peer_exchange_initmsg.c

@ -135,7 +135,7 @@ static struct io_plan *peer_write_postclose(struct io_conn *conn,
struct io_plan *peer_exchange_initmsg(struct io_conn *conn, struct io_plan *peer_exchange_initmsg(struct io_conn *conn,
struct daemon *daemon, struct daemon *daemon,
const struct feature_set *fset, const struct feature_set *our_features,
const struct crypto_state *cs, const struct crypto_state *cs,
const struct node_id *id, const struct node_id *id,
const struct wireaddr_internal *addr) const struct wireaddr_internal *addr)
@ -182,8 +182,8 @@ struct io_plan *peer_exchange_initmsg(struct io_conn *conn,
* Finally, we agreed that bits below 13 could be put in both, but * Finally, we agreed that bits below 13 could be put in both, but
* from now on they'll all go in initfeatures. */ * from now on they'll all go in initfeatures. */
peer->msg = towire_init(NULL, peer->msg = towire_init(NULL,
fset->bits[GLOBAL_INIT_FEATURE], our_features->bits[GLOBAL_INIT_FEATURE],
fset->bits[INIT_FEATURE], our_features->bits[INIT_FEATURE],
tlvs); tlvs);
status_peer_io(LOG_IO_OUT, &peer->id, peer->msg); status_peer_io(LOG_IO_OUT, &peer->id, peer->msg);
peer->msg = cryptomsg_encrypt_msg(peer, &peer->cs, take(peer->msg)); peer->msg = cryptomsg_encrypt_msg(peer, &peer->cs, take(peer->msg));

2
connectd/peer_exchange_initmsg.h

@ -12,7 +12,7 @@ struct wireaddr_internal;
/* If successful, calls peer_connected() */ /* If successful, calls peer_connected() */
struct io_plan *peer_exchange_initmsg(struct io_conn *conn, struct io_plan *peer_exchange_initmsg(struct io_conn *conn,
struct daemon *daemon, struct daemon *daemon,
const struct feature_set *fset, const struct feature_set *our_features,
const struct crypto_state *cs, const struct crypto_state *cs,
const struct node_id *id, const struct node_id *id,
const struct wireaddr_internal *addr); const struct wireaddr_internal *addr);

3
gossipd/gossip_generation.c

@ -39,7 +39,8 @@ static u8 *create_node_announcement(const tal_t *ctx, struct daemon *daemon,
announcement = announcement =
towire_node_announcement(ctx, sig, towire_node_announcement(ctx, sig,
daemon->fset->bits[NODE_ANNOUNCE_FEATURE], daemon->our_features->bits
[NODE_ANNOUNCE_FEATURE],
timestamp, timestamp,
&daemon->id, daemon->rgb, daemon->alias, &daemon->id, daemon->rgb, daemon->alias,
addresses); addresses);

2
gossipd/gossip_wire.csv

@ -6,7 +6,7 @@
# Initialize the gossip daemon. # Initialize the gossip daemon.
msgtype,gossipctl_init,3000 msgtype,gossipctl_init,3000
msgdata,gossipctl_init,chainparams,chainparams, msgdata,gossipctl_init,chainparams,chainparams,
msgdata,gossipctl_init,feature_set,feature_set, msgdata,gossipctl_init,our_features,feature_set,
msgdata,gossipctl_init,id,node_id, msgdata,gossipctl_init,id,node_id,
msgdata,gossipctl_init,rgb,u8,3 msgdata,gossipctl_init,rgb,u8,3
msgdata,gossipctl_init,alias,u8,32 msgdata,gossipctl_init,alias,u8,32

Can't render this file because it has a wrong number of fields in line 7.

2
gossipd/gossipd.c

@ -834,7 +834,7 @@ static struct io_plan *gossip_init(struct io_conn *conn,
if (!fromwire_gossipctl_init(daemon, msg, if (!fromwire_gossipctl_init(daemon, msg,
&chainparams, &chainparams,
&daemon->fset, &daemon->our_features,
&daemon->id, &daemon->id,
daemon->rgb, daemon->rgb,
daemon->alias, daemon->alias,

2
gossipd/gossipd.h

@ -59,7 +59,7 @@ struct daemon {
struct seeker *seeker; struct seeker *seeker;
/* Features lightningd told us to set. */ /* Features lightningd told us to set. */
struct feature_set *fset; struct feature_set *our_features;
}; };
/* This represents each peer we're gossiping with */ /* This represents each peer we're gossiping with */

4
lightningd/channel_control.c

@ -471,7 +471,7 @@ void peer_start_channeld(struct channel *channel,
initmsg = towire_channel_init(tmpctx, initmsg = towire_channel_init(tmpctx,
chainparams, chainparams,
ld->feature_set, ld->our_features,
&channel->funding_txid, &channel->funding_txid,
channel->funding_outnum, channel->funding_outnum,
channel->funding, channel->funding,
@ -517,7 +517,7 @@ void peer_start_channeld(struct channel *channel,
funding_signed, funding_signed,
reached_announce_depth, reached_announce_depth,
&last_remote_per_commit_secret, &last_remote_per_commit_secret,
channel->peer->features, channel->peer->their_features,
channel->remote_upfront_shutdown_script, channel->remote_upfront_shutdown_script,
remote_ann_node_sig, remote_ann_node_sig,
remote_ann_bitcoin_sig, remote_ann_bitcoin_sig,

4
lightningd/connect_control.c

@ -72,7 +72,7 @@ static struct command_result *connect_cmd_succeed(struct command *cmd,
{ {
struct json_stream *response = json_stream_success(cmd); struct json_stream *response = json_stream_success(cmd);
json_add_node_id(response, "id", &peer->id); json_add_node_id(response, "id", &peer->id);
json_add_hex_talarr(response, "features", peer->features); json_add_hex_talarr(response, "features", peer->their_features);
return command_success(cmd, response); return command_success(cmd, response);
} }
@ -365,7 +365,7 @@ int connectd_init(struct lightningd *ld)
msg = towire_connectctl_init( msg = towire_connectctl_init(
tmpctx, chainparams, tmpctx, chainparams,
ld->feature_set, ld->our_features,
&ld->id, &ld->id,
wireaddrs, wireaddrs,
listen_announce, listen_announce,

2
lightningd/gossip_control.c

@ -209,7 +209,7 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
msg = towire_gossipctl_init( msg = towire_gossipctl_init(
tmpctx, tmpctx,
chainparams, chainparams,
ld->feature_set, ld->our_features,
&ld->id, &ld->id,
ld->rgb, ld->rgb,
ld->alias, ld->alias,

4
lightningd/invoice.c

@ -1014,7 +1014,7 @@ static struct command_result *json_invoice(struct command *cmd,
info->b11->payment_secret = tal_dup(info->b11, struct secret, info->b11->payment_secret = tal_dup(info->b11, struct secret,
&payment_secret); &payment_secret);
info->b11->features = tal_dup_talarr(info->b11, u8, info->b11->features = tal_dup_talarr(info->b11, u8,
cmd->ld->feature_set cmd->ld->our_features
->bits[BOLT11_FEATURE]); ->bits[BOLT11_FEATURE]);
#if DEVELOPER #if DEVELOPER
@ -1321,7 +1321,7 @@ static struct command_result *json_decodepay(struct command *cmd,
NULL)) NULL))
return command_param_failed(); return command_param_failed();
b11 = bolt11_decode(cmd, str, cmd->ld->feature_set, desc, &fail); b11 = bolt11_decode(cmd, str, cmd->ld->our_features, desc, &fail);
if (!b11) { if (!b11) {
return command_fail(cmd, LIGHTNINGD, "Invalid bolt11: %s", fail); return command_fail(cmd, LIGHTNINGD, "Invalid bolt11: %s", fail);

2
lightningd/lightningd.c

@ -785,7 +785,7 @@ int main(int argc, char *argv[])
errx(1, "Could not find daemons"); errx(1, "Could not find daemons");
/* Set up the feature bits for what we support */ /* Set up the feature bits for what we support */
ld->feature_set = default_features(ld); ld->our_features = default_features(ld);
/*~ Handle early options; this moves us into --lightning-dir. /*~ Handle early options; this moves us into --lightning-dir.
* Plugins may add new options, which is why we are splitting * Plugins may add new options, which is why we are splitting

2
lightningd/lightningd.h

@ -120,7 +120,7 @@ struct lightningd {
struct node_id id; struct node_id id;
/* Feature set we offer. */ /* Feature set we offer. */
struct feature_set *feature_set; struct feature_set *our_features;
/* My name is... my favorite color is... */ /* My name is... my favorite color is... */
u8 *alias; /* At least 32 bytes (zero-filled) */ u8 *alias; /* At least 32 bytes (zero-filled) */

17
lightningd/opening_control.c

@ -220,8 +220,9 @@ wallet_commit_channel(struct lightningd *ld,
*/ */
/* i.e. We set it now for the channel permanently. */ /* i.e. We set it now for the channel permanently. */
option_static_remotekey option_static_remotekey
= feature_negotiated(ld->feature_set, = feature_negotiated(ld->our_features,
uc->peer->features, OPT_STATIC_REMOTEKEY); uc->peer->their_features,
OPT_STATIC_REMOTEKEY);
channel = new_channel(uc->peer, uc->dbid, channel = new_channel(uc->peer, uc->dbid,
NULL, /* No shachain yet */ NULL, /* No shachain yet */
@ -1000,7 +1001,7 @@ void peer_start_openingd(struct peer *peer,
msg = towire_opening_init(NULL, msg = towire_opening_init(NULL,
chainparams, chainparams,
peer->ld->feature_set, peer->ld->our_features,
&uc->our_config, &uc->our_config,
max_to_self_delay, max_to_self_delay,
min_effective_htlc_capacity, min_effective_htlc_capacity,
@ -1009,9 +1010,9 @@ void peer_start_openingd(struct peer *peer,
uc->minimum_depth, uc->minimum_depth,
feerate_min(peer->ld, NULL), feerate_min(peer->ld, NULL),
feerate_max(peer->ld, NULL), feerate_max(peer->ld, NULL),
peer->features, peer->their_features,
feature_negotiated(peer->ld->feature_set, feature_negotiated(peer->ld->our_features,
peer->features, peer->their_features,
OPT_STATIC_REMOTEKEY), OPT_STATIC_REMOTEKEY),
send_msg, send_msg,
IFDEV(peer->ld->dev_force_tmp_channel_id, NULL), IFDEV(peer->ld->dev_force_tmp_channel_id, NULL),
@ -1199,8 +1200,8 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
* - otherwise: * - otherwise:
* - MUST set `funding_satoshis` to less than 2^24 satoshi. * - MUST set `funding_satoshis` to less than 2^24 satoshi.
*/ */
if (!feature_negotiated(cmd->ld->feature_set, if (!feature_negotiated(cmd->ld->our_features,
peer->features, OPT_LARGE_CHANNELS) peer->their_features, OPT_LARGE_CHANNELS)
&& amount_sat_greater(*amount, chainparams->max_funding)) && amount_sat_greater(*amount, chainparams->max_funding))
return command_fail(cmd, FUND_MAX_EXCEEDED, return command_fail(cmd, FUND_MAX_EXCEEDED,
"Amount exceeded %s", "Amount exceeded %s",

7
lightningd/options.c

@ -692,7 +692,7 @@ static char *test_subdaemons_and_exit(struct lightningd *ld)
static char *list_features_and_exit(struct lightningd *ld) static char *list_features_and_exit(struct lightningd *ld)
{ {
const char **features = list_supported_features(tmpctx, ld->feature_set); const char **features = list_supported_features(tmpctx, ld->our_features);
for (size_t i = 0; i < tal_count(features); i++) for (size_t i = 0; i < tal_count(features); i++)
printf("%s\n", features[i]); printf("%s\n", features[i]);
exit(0); exit(0);
@ -744,7 +744,7 @@ static char *opt_start_daemon(struct lightningd *ld)
static char *opt_set_wumbo(struct lightningd *ld) static char *opt_set_wumbo(struct lightningd *ld)
{ {
feature_set_or(ld->feature_set, feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL, take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_LARGE_CHANNELS)))); OPTIONAL_FEATURE(OPT_LARGE_CHANNELS))));
return NULL; return NULL;
@ -1203,7 +1203,8 @@ static void add_config(struct lightningd *ld,
json_add_bool(response, "encrypted-hsm", ld->encrypted_hsm); json_add_bool(response, "encrypted-hsm", ld->encrypted_hsm);
} else if (opt->cb == (void *)opt_set_wumbo) { } else if (opt->cb == (void *)opt_set_wumbo) {
json_add_bool(response, "wumbo", json_add_bool(response, "wumbo",
feature_offered(ld->feature_set->bits[INIT_FEATURE], feature_offered(ld->our_features
->bits[INIT_FEATURE],
OPT_LARGE_CHANNELS)); OPT_LARGE_CHANNELS));
} else { } else {
/* Insert more decodes here! */ /* Insert more decodes here! */

2
lightningd/pay.c

@ -1406,7 +1406,7 @@ static struct command_result *json_listsendpays(struct command *cmd,
struct bolt11 *b11; struct bolt11 *b11;
char *fail; char *fail;
b11 = bolt11_decode(cmd, b11str, cmd->ld->feature_set, NULL, &fail); b11 = bolt11_decode(cmd, b11str, cmd->ld->our_features, NULL, &fail);
if (!b11) { if (!b11) {
return command_fail(cmd, JSONRPC2_INVALID_PARAMS, return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Invalid bolt11: %s", fail); "Invalid bolt11: %s", fail);

19
lightningd/peer_control.c

@ -74,10 +74,11 @@ static void destroy_peer(struct peer *peer)
list_del_from(&peer->ld->peers, &peer->list); list_del_from(&peer->ld->peers, &peer->list);
} }
static void peer_update_features(struct peer *peer, const u8 *features TAKES) static void peer_update_features(struct peer *peer,
const u8 *their_features TAKES)
{ {
tal_free(peer->features); tal_free(peer->their_features);
peer->features = tal_dup_talarr(peer, u8, features); peer->their_features = tal_dup_talarr(peer, u8, their_features);
} }
struct peer *new_peer(struct lightningd *ld, u64 dbid, struct peer *new_peer(struct lightningd *ld, u64 dbid,
@ -92,7 +93,7 @@ struct peer *new_peer(struct lightningd *ld, u64 dbid,
peer->id = *id; peer->id = *id;
peer->uncommitted_channel = NULL; peer->uncommitted_channel = NULL;
peer->addr = *addr; peer->addr = *addr;
peer->features = NULL; peer->their_features = NULL;
list_head_init(&peer->channels); list_head_init(&peer->channels);
peer->direction = node_id_idx(&peer->ld->id, &peer->id); peer->direction = node_id_idx(&peer->ld->id, &peer->id);
#if DEVELOPER #if DEVELOPER
@ -851,7 +852,7 @@ peer_connected_serialize(struct peer_connected_hook_payload *payload,
json_add_string( json_add_string(
stream, "addr", stream, "addr",
type_to_string(stream, struct wireaddr_internal, &payload->addr)); type_to_string(stream, struct wireaddr_internal, &payload->addr));
json_add_hex_talarr(stream, "features", p->features); json_add_hex_talarr(stream, "features", p->their_features);
json_object_end(stream); /* .peer */ json_object_end(stream); /* .peer */
} }
@ -980,7 +981,7 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
int peer_fd, int gossip_fd, int gossip_store_fd) int peer_fd, int gossip_fd, int gossip_store_fd)
{ {
struct node_id id; struct node_id id;
u8 *features; u8 *their_features;
struct peer *peer; struct peer *peer;
struct peer_connected_hook_payload *hook_payload; struct peer_connected_hook_payload *hook_payload;
@ -989,7 +990,7 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
if (!fromwire_connect_peer_connected(hook_payload, msg, if (!fromwire_connect_peer_connected(hook_payload, msg,
&id, &hook_payload->addr, &id, &hook_payload->addr,
&hook_payload->pps, &hook_payload->pps,
&features)) &their_features))
fatal("Connectd gave bad CONNECT_PEER_CONNECTED message %s", fatal("Connectd gave bad CONNECT_PEER_CONNECTED message %s",
tal_hex(msg, msg)); tal_hex(msg, msg));
@ -1005,7 +1006,7 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
tal_steal(peer, hook_payload); tal_steal(peer, hook_payload);
hook_payload->peer = peer; hook_payload->peer = peer;
peer_update_features(peer, features); peer_update_features(peer, their_features);
/* Complete any outstanding connect commands. */ /* Complete any outstanding connect commands. */
connect_succeeded(ld, peer); connect_succeeded(ld, peer);
@ -1173,7 +1174,7 @@ static void json_add_peer(struct lightningd *ld,
struct wireaddr_internal, struct wireaddr_internal,
&p->addr)); &p->addr));
json_array_end(response); json_array_end(response);
json_add_hex_talarr(response, "features", p->features); json_add_hex_talarr(response, "features", p->their_features);
} }
json_array_start(response, "channels"); json_array_start(response, "channels");

2
lightningd/peer_control.h

@ -40,7 +40,7 @@ struct peer {
struct wireaddr_internal addr; struct wireaddr_internal addr;
/* We keep a copy of their feature bits */ /* We keep a copy of their feature bits */
const u8 *features; const u8 *their_features;
/* If we open a channel our direction will be this */ /* If we open a channel our direction will be this */
u8 direction; u8 direction;

4
lightningd/plugin.c

@ -916,7 +916,7 @@ bool plugin_parse_getmanifest_response(const char *buffer,
return true; return true;
} }
if (!feature_set_or(plugin->plugins->ld->feature_set, fset)) { if (!feature_set_or(plugin->plugins->ld->our_features, fset)) {
plugin_kill(plugin, plugin_kill(plugin,
"Custom featurebits already present"); "Custom featurebits already present");
return true; return true;
@ -1174,7 +1174,7 @@ plugin_populate_init_request(struct plugin *plugin, struct jsonrpc_request *req)
if (plugin_feature_place_names[fp]) { if (plugin_feature_place_names[fp]) {
json_add_hex_talarr(req->stream, json_add_hex_talarr(req->stream,
plugin_feature_place_names[fp], plugin_feature_place_names[fp],
ld->feature_set->bits[fp]); ld->our_features->bits[fp]);
} }
} }
json_object_end(req->stream); json_object_end(req->stream);

2
openingd/opening_wire.csv

@ -7,7 +7,7 @@
msgtype,opening_init,6000 msgtype,opening_init,6000
# Which network are we configured for? # Which network are we configured for?
msgdata,opening_init,chainparams,chainparams, msgdata,opening_init,chainparams,chainparams,
msgdata,opening_init,feature_set,feature_set, msgdata,opening_init,our_features,feature_set,
# Base configuration we'll offer (channel reserve will vary with amount) # Base configuration we'll offer (channel reserve will vary with amount)
msgdata,opening_init,our_config,channel_config, msgdata,opening_init,our_config,channel_config,
# Minimum/maximum configuration values we'll accept # Minimum/maximum configuration values we'll accept

Can't render this file because it has a wrong number of fields in line 7.

22
openingd/openingd.c

@ -67,7 +67,7 @@ struct state {
struct per_peer_state *pps; struct per_peer_state *pps;
/* Features they offered */ /* Features they offered */
u8 *features; u8 *their_features;
/* Constraints on a channel they open. */ /* Constraints on a channel they open. */
u32 minimum_depth; u32 minimum_depth;
@ -114,7 +114,7 @@ struct state {
bool option_static_remotekey; bool option_static_remotekey;
struct feature_set *fset; struct feature_set *our_features;
}; };
static u8 *dev_upfront_shutdown_script(const tal_t *ctx) static u8 *dev_upfront_shutdown_script(const tal_t *ctx)
@ -492,7 +492,8 @@ static bool setup_channel_funder(struct state *state)
* - otherwise: * - otherwise:
* - MUST set `funding_satoshis` to less than 2^24 satoshi. * - MUST set `funding_satoshis` to less than 2^24 satoshi.
*/ */
if (!feature_negotiated(state->fset, state->features, OPT_LARGE_CHANNELS) if (!feature_negotiated(state->our_features,
state->their_features, OPT_LARGE_CHANNELS)
&& amount_sat_greater(state->funding, chainparams->max_funding)) { && amount_sat_greater(state->funding, chainparams->max_funding)) {
status_failed(STATUS_FAIL_MASTER_IO, status_failed(STATUS_FAIL_MASTER_IO,
"funding_satoshis must be < %s, not %s", "funding_satoshis must be < %s, not %s",
@ -569,7 +570,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
* `payment_basepoint`, or `delayed_payment_basepoint` are not * `payment_basepoint`, or `delayed_payment_basepoint` are not
* valid secp256k1 pubkeys in compressed format. * valid secp256k1 pubkeys in compressed format.
*/ */
if (feature_negotiated(state->fset, state->features, if (feature_negotiated(state->our_features, state->their_features,
OPT_UPFRONT_SHUTDOWN_SCRIPT)) { OPT_UPFRONT_SHUTDOWN_SCRIPT)) {
if (!fromwire_accept_channel_option_upfront_shutdown_script(state, if (!fromwire_accept_channel_option_upfront_shutdown_script(state,
msg, &id_in, msg, &id_in,
@ -650,8 +651,8 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
return towire_opening_funder_start_reply(state, return towire_opening_funder_start_reply(state,
funding_output_script, funding_output_script,
feature_negotiated( feature_negotiated(
state->fset, state->our_features,
state->features, state->their_features,
OPT_UPFRONT_SHUTDOWN_SCRIPT)); OPT_UPFRONT_SHUTDOWN_SCRIPT));
} }
@ -911,7 +912,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
* `payment_basepoint`, or `delayed_payment_basepoint` are not valid * `payment_basepoint`, or `delayed_payment_basepoint` are not valid
* secp256k1 pubkeys in compressed format. * secp256k1 pubkeys in compressed format.
*/ */
if (feature_negotiated(state->fset, state->features, if (feature_negotiated(state->our_features, state->their_features,
OPT_UPFRONT_SHUTDOWN_SCRIPT)) { OPT_UPFRONT_SHUTDOWN_SCRIPT)) {
if (!fromwire_open_channel_option_upfront_shutdown_script(state, if (!fromwire_open_channel_option_upfront_shutdown_script(state,
open_channel_msg, &chain_hash, open_channel_msg, &chain_hash,
@ -980,7 +981,8 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
* - `funding_satoshis` is greater than or equal to 2^24 and the receiver does not support * - `funding_satoshis` is greater than or equal to 2^24 and the receiver does not support
* `option_support_large_channel`. */ * `option_support_large_channel`. */
/* We choose to require *negotiation*, not just support! */ /* We choose to require *negotiation*, not just support! */
if (!feature_negotiated(state->fset, state->features, OPT_LARGE_CHANNELS) if (!feature_negotiated(state->our_features, state->their_features,
OPT_LARGE_CHANNELS)
&& amount_sat_greater(state->funding, chainparams->max_funding)) { && amount_sat_greater(state->funding, chainparams->max_funding)) {
negotiation_failed(state, false, negotiation_failed(state, false,
"funding_satoshis %s too large", "funding_satoshis %s too large",
@ -1503,7 +1505,7 @@ int main(int argc, char *argv[])
msg = wire_sync_read(tmpctx, REQ_FD); msg = wire_sync_read(tmpctx, REQ_FD);
if (!fromwire_opening_init(state, msg, if (!fromwire_opening_init(state, msg,
&chainparams, &chainparams,
&state->fset, &state->our_features,
&state->localconf, &state->localconf,
&state->max_to_self_delay, &state->max_to_self_delay,
&state->min_effective_htlc_capacity, &state->min_effective_htlc_capacity,
@ -1512,7 +1514,7 @@ int main(int argc, char *argv[])
&state->our_funding_pubkey, &state->our_funding_pubkey,
&state->minimum_depth, &state->minimum_depth,
&state->min_feerate, &state->max_feerate, &state->min_feerate, &state->max_feerate,
&state->features, &state->their_features,
&state->option_static_remotekey, &state->option_static_remotekey,
&inner, &inner,
&force_tmp_channel_id, &force_tmp_channel_id,

8
plugins/fundchannel.c

@ -27,7 +27,7 @@ struct funding_req {
struct amount_msat *push_msat; struct amount_msat *push_msat;
/* Features offered by this peer. */ /* Features offered by this peer. */
const u8 *features; const u8 *their_features;
bool *announce_channel; bool *announce_channel;
u32 *minconf; u32 *minconf;
@ -335,7 +335,7 @@ static struct command_result *post_dryrun(struct command *cmd,
/* Update funding to actual amount */ /* Update funding to actual amount */
if (fr->funding_all if (fr->funding_all
&& !feature_negotiated(plugin_feature_set(cmd->plugin), && !feature_negotiated(plugin_feature_set(cmd->plugin),
fr->features, OPT_LARGE_CHANNELS) fr->their_features, OPT_LARGE_CHANNELS)
&& amount_sat_greater(funding, chainparams->max_funding)) && amount_sat_greater(funding, chainparams->max_funding))
funding = chainparams->max_funding; funding = chainparams->max_funding;
@ -355,8 +355,8 @@ static struct command_result *exec_dryrun(struct command *cmd,
t = json_get_member(buf, result, "features"); t = json_get_member(buf, result, "features");
if (!t) if (!t)
plugin_err(cmd->plugin, "No features found in connect response?"); plugin_err(cmd->plugin, "No features found in connect response?");
fr->features = json_tok_bin_from_hex(fr, buf, t); fr->their_features = json_tok_bin_from_hex(fr, buf, t);
if (!fr->features) if (!fr->their_features)
plugin_err(cmd->plugin, "Bad features '%.*s' in connect response?", plugin_err(cmd->plugin, "Bad features '%.*s' in connect response?",
t->end - t->start, buf + t->start); t->end - t->start, buf + t->start);

6
plugins/libplugin.c

@ -85,7 +85,7 @@ struct plugin {
size_t in_timer; size_t in_timer;
/* Feature set for lightningd */ /* Feature set for lightningd */
struct feature_set *fset; struct feature_set *our_features;
}; };
@ -154,7 +154,7 @@ jsonrpc_request_start_(struct plugin *plugin, struct command *cmd,
const struct feature_set *plugin_feature_set(const struct plugin *p) const struct feature_set *plugin_feature_set(const struct plugin *p)
{ {
return p->fset; return p->our_features;
} }
static void jsonrpc_finish_and_send(struct plugin *p, struct json_stream *js) static void jsonrpc_finish_and_send(struct plugin *p, struct json_stream *js)
@ -770,7 +770,7 @@ static struct command_result *handle_init(struct command *cmd,
chainparams = chainparams_for_network(network); chainparams = chainparams_for_network(network);
fsettok = json_delve(buf, configtok, ".feature_set"); fsettok = json_delve(buf, configtok, ".feature_set");
p->fset = json_to_feature_set(p, buf, fsettok); p->our_features = json_to_feature_set(p, buf, fsettok);
rpctok = json_delve(buf, configtok, ".rpc-file"); rpctok = json_delve(buf, configtok, ".rpc-file");
p->rpc_conn->fd = socket(AF_UNIX, SOCK_STREAM, 0); p->rpc_conn->fd = socket(AF_UNIX, SOCK_STREAM, 0);

Loading…
Cancel
Save