Skip to content

Wumbo channel support #3612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions channeld/channel_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Begin! (passes gossipd-client fd)
msgtype,channel_init,1000
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_txout,u16,
msgdata,channel_init,funding_satoshi,amount_sat,
Expand Down Expand Up @@ -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,reached_announce_depth,bool,
msgdata,channel_init,last_remote_secret,secret,
msgdata,channel_init,lflen,u16,
msgdata,channel_init,localfeatures,u8,lflen
msgdata,channel_init,flen,u16,
msgdata,channel_init,their_features,u8,flen
msgdata,channel_init,upfront_shutdown_script_len,u16,
msgdata,channel_init,upfront_shutdown_script,u8,upfront_shutdown_script_len
msgdata,channel_init,remote_ann_node_sig,?secp256k1_ecdsa_signature,
Expand Down
20 changes: 11 additions & 9 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ struct peer {
u64 next_index[NUM_SIDES];

/* Features peer supports. */
u8 *features;
u8 *their_features;

/* Features we support. */
struct feature_set *our_features;

/* Tolerable amounts for feerate (only relevant for fundee). */
u32 feerate_min, feerate_max;
Expand Down Expand Up @@ -415,7 +418,9 @@ static void send_announcement_signatures(struct peer *peer)
static u8 *create_channel_announcement(const tal_t *ctx, struct peer *peer)
{
int first, second;
u8 *cannounce, *features = get_agreed_channelfeatures(tmpctx, peer->features);
u8 *cannounce, *features
= get_agreed_channelfeatures(tmpctx, peer->our_features,
peer->their_features);

if (peer->channel_direction == 0) {
first = LOCAL;
Expand Down Expand Up @@ -2325,7 +2330,8 @@ static void peer_reconnect(struct peer *peer,
bool dataloss_protect, check_extra_fields;
const u8 **premature_msgs = tal_arr(peer, const u8 *, 0);

dataloss_protect = feature_negotiated(peer->features,
dataloss_protect = feature_negotiated(peer->our_features,
peer->their_features,
OPT_DATA_LOSS_PROTECT);

/* Both these options give us extra fields to check. */
Expand Down Expand Up @@ -3045,7 +3051,6 @@ static void init_channel(struct peer *peer)
secp256k1_ecdsa_signature *remote_ann_node_sig;
secp256k1_ecdsa_signature *remote_ann_bitcoin_sig;
bool option_static_remotekey;
struct feature_set *feature_set;
#if !DEVELOPER
bool dev_fail_process_onionpacket; /* Ignored */
#endif
Expand All @@ -3057,7 +3062,7 @@ static void init_channel(struct peer *peer)
msg = wire_sync_read(tmpctx, MASTER_FD);
if (!fromwire_channel_init(peer, msg,
&chainparams,
&feature_set,
&peer->our_features,
&funding_txid, &funding_txout,
&funding,
&minimum_depth,
Expand Down Expand Up @@ -3103,7 +3108,7 @@ static void init_channel(struct peer *peer)
&funding_signed,
&peer->announce_depth_reached,
&last_remote_per_commit_secret,
&peer->features,
&peer->their_features,
&peer->remote_upfront_shutdown_script,
&remote_ann_node_sig,
&remote_ann_bitcoin_sig,
Expand All @@ -3113,9 +3118,6 @@ static void init_channel(struct peer *peer)
master_badmsg(WIRE_CHANNEL_INIT, msg);
}

/* Now we know what features to advertize. */
features_init(take(feature_set));

/* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = HSM */
per_peer_state_set_fds(peer->pps, 3, 4, 5);

Expand Down
19 changes: 11 additions & 8 deletions common/bolt11.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ static void shift_bitmap_down(u8 *bitmap, size_t bits)
* See [Feature Bits](#feature-bits).
*/
static char *decode_9(struct bolt11 *b11,
const struct feature_set *our_features,
struct hash_u5 *hu5,
u5 **data, size_t *data_len,
size_t data_length)
Expand All @@ -511,13 +512,13 @@ static char *decode_9(struct bolt11 *b11,
* - if the `9` field contains unknown _even_ bits that are non-zero:
* - MUST fail the payment.
*/
/* BOLT #11:
* The field is big-endian. The least-significant bit is numbered 0,
* which is _even_, and the next most significant bit is numbered 1,
* which is _odd_. */
badf = features_unsupported(b11->features);
if (badf != -1)
return tal_fmt(b11, "9: unknown feature bit %i", badf);
/* We skip this check for the cli tool, which sets our_features to NULL */
if (our_features) {
badf = features_unsupported(our_features,
b11->features, BOLT11_FEATURE);
if (badf != -1)
return tal_fmt(b11, "9: unknown feature bit %i", badf);
}

return NULL;
}
Expand Down Expand Up @@ -545,6 +546,7 @@ struct bolt11 *new_bolt11(const tal_t *ctx,

/* Decodes and checks signature; returns NULL on error. */
struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
const struct feature_set *our_features,
const char *description, char **fail)
{
char *hrp, *amountstr, *prefix;
Expand Down Expand Up @@ -739,7 +741,8 @@ struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
data_length);
break;
case '9':
problem = decode_9(b11, &hu5, &data, &data_len,
problem = decode_9(b11, our_features, &hu5,
&data, &data_len,
data_length);
break;
case 's':
Expand Down
7 changes: 6 additions & 1 deletion common/bolt11.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
/* We only have 10 bits for the field length, meaning < 640 bytes */
#define BOLT11_FIELD_BYTE_LIMIT ((1 << 10) * 5 / 8)

struct feature_set;

struct bolt11_field {
struct list_node list;

Expand Down Expand Up @@ -74,8 +76,11 @@ struct bolt11 {
};

/* Decodes and checks signature; returns NULL on error; description is
* (optional) out-of-band description of payment, for `h` field. */
* (optional) out-of-band description of payment, for `h` field.
* fset is NULL to accept any features (usually not desirable!).
*/
struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
const struct feature_set *our_features,
const char *description, char **fail);

/* Initialize an empty bolt11 struct with optional amount */
Expand Down
Loading