diff --git a/channeld/channeld.c b/channeld/channeld.c index a59502de8..cbb4c5fbe 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -1950,11 +1950,6 @@ static void handle_onion_message(struct peer *peer, const u8 *msg) return; } - if (om->enctlv) { - status_broken("FIXME: Handle enctlv!"); - return; - } - if (rs->nextcase == ONION_END) { struct pubkey *blinding; const struct onionmsg_path **path; @@ -1969,6 +1964,7 @@ static void handle_onion_message(struct peer *peer, const u8 *msg) } wire_sync_write(MASTER_FD, take(towire_got_onionmsg_to_us(NULL, + blinding_in, blinding, path))); } else { diff --git a/channeld/channeld_wire.csv b/channeld/channeld_wire.csv index 65e7852ec..a25a5852f 100644 --- a/channeld/channeld_wire.csv +++ b/channeld/channeld_wire.csv @@ -227,6 +227,7 @@ msgtype,channeld_send_error_reply,1108 # Tell lightningd we got a onion message (for us, or to fwd) msgtype,got_onionmsg_to_us,1142 +msgdata,got_onionmsg_to_us,blinding_in,?pubkey, msgdata,got_onionmsg_to_us,reply_blinding,?pubkey, msgdata,got_onionmsg_to_us,reply_path_len,u16, msgdata,got_onionmsg_to_us,reply_path,onionmsg_path,reply_path_len diff --git a/channeld/channeld_wiregen.c b/channeld/channeld_wiregen.c index 3f8294f44..3e365f5f8 100644 --- a/channeld/channeld_wiregen.c +++ b/channeld/channeld_wiregen.c @@ -1105,12 +1105,18 @@ bool fromwire_channeld_send_error_reply(const void *p) /* WIRE: GOT_ONIONMSG_TO_US */ /* Tell lightningd we got a onion message (for us */ -u8 *towire_got_onionmsg_to_us(const tal_t *ctx, const struct pubkey *reply_blinding, const struct onionmsg_path **reply_path) +u8 *towire_got_onionmsg_to_us(const tal_t *ctx, const struct pubkey *blinding_in, const struct pubkey *reply_blinding, const struct onionmsg_path **reply_path) { u16 reply_path_len = tal_count(reply_path); u8 *p = tal_arr(ctx, u8, 0); towire_u16(&p, WIRE_GOT_ONIONMSG_TO_US); + if (!blinding_in) + towire_bool(&p, false); + else { + towire_bool(&p, true); + towire_pubkey(&p, blinding_in); + } if (!reply_blinding) towire_bool(&p, false); else { @@ -1123,7 +1129,7 @@ u8 *towire_got_onionmsg_to_us(const tal_t *ctx, const struct pubkey *reply_blind return memcheck(p, tal_count(p)); } -bool fromwire_got_onionmsg_to_us(const tal_t *ctx, const void *p, struct pubkey **reply_blinding, struct onionmsg_path ***reply_path) +bool fromwire_got_onionmsg_to_us(const tal_t *ctx, const void *p, struct pubkey **blinding_in, struct pubkey **reply_blinding, struct onionmsg_path ***reply_path) { u16 reply_path_len; @@ -1132,6 +1138,12 @@ bool fromwire_got_onionmsg_to_us(const tal_t *ctx, const void *p, struct pubkey if (fromwire_u16(&cursor, &plen) != WIRE_GOT_ONIONMSG_TO_US) return false; + if (!fromwire_bool(&cursor, &plen)) + *blinding_in = NULL; + else { + *blinding_in = tal(ctx, struct pubkey); + fromwire_pubkey(&cursor, &plen, *blinding_in); + } if (!fromwire_bool(&cursor, &plen)) *reply_blinding = NULL; else { @@ -1236,4 +1248,4 @@ bool fromwire_send_onionmsg(const tal_t *ctx, const void *p, u8 onion[1366], str } return cursor != NULL; } -// SHA256STAMP:0ddc4d686d50049ed4c8500919e415dde43baea52adc651b8a606765b09ab001 +// SHA256STAMP:c520ab3f9f3c5e7a7b1cdd7535bd95ee82a7b352602da56eb37d603a1890fd46 diff --git a/channeld/channeld_wiregen.h b/channeld/channeld_wiregen.h index 889bcfe70..87c0985e1 100644 --- a/channeld/channeld_wiregen.h +++ b/channeld/channeld_wiregen.h @@ -232,8 +232,8 @@ bool fromwire_channeld_send_error_reply(const void *p); /* WIRE: GOT_ONIONMSG_TO_US */ /* Tell lightningd we got a onion message (for us */ -u8 *towire_got_onionmsg_to_us(const tal_t *ctx, const struct pubkey *reply_blinding, const struct onionmsg_path **reply_path); -bool fromwire_got_onionmsg_to_us(const tal_t *ctx, const void *p, struct pubkey **reply_blinding, struct onionmsg_path ***reply_path); +u8 *towire_got_onionmsg_to_us(const tal_t *ctx, const struct pubkey *blinding_in, const struct pubkey *reply_blinding, const struct onionmsg_path **reply_path); +bool fromwire_got_onionmsg_to_us(const tal_t *ctx, const void *p, struct pubkey **blinding_in, struct pubkey **reply_blinding, struct onionmsg_path ***reply_path); /* WIRE: GOT_ONIONMSG_FORWARD */ u8 *towire_got_onionmsg_forward(const tal_t *ctx, const struct short_channel_id *next_scid, const struct node_id *next_node_id, const struct pubkey *next_blinding, const u8 next_onion[1366]); @@ -246,4 +246,4 @@ bool fromwire_send_onionmsg(const tal_t *ctx, const void *p, u8 onion[1366], str #endif /* LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H */ -// SHA256STAMP:0ddc4d686d50049ed4c8500919e415dde43baea52adc651b8a606765b09ab001 +// SHA256STAMP:c520ab3f9f3c5e7a7b1cdd7535bd95ee82a7b352602da56eb37d603a1890fd46 diff --git a/lightningd/onion_message.c b/lightningd/onion_message.c index 80ca34ceb..9c875f2dd 100644 --- a/lightningd/onion_message.c +++ b/lightningd/onion_message.c @@ -10,6 +10,7 @@ #if EXPERIMENTAL_FEATURES struct onion_message_hook_payload { /* Optional */ + struct pubkey *blinding_in; struct pubkey *reply_blinding; struct onionmsg_path **reply_path; @@ -21,6 +22,8 @@ onion_message_serialize(struct onion_message_hook_payload *payload, struct json_stream *stream) { json_object_start(stream, "onion_message"); + if (payload->blinding_in) + json_add_pubkey(stream, "blinding_in", payload->blinding_in); if (payload->reply_path) { json_array_start(stream, "reply_path"); for (size_t i = 0; i < tal_count(payload->reply_path); i++) { @@ -93,6 +96,7 @@ void handle_onionmsg_to_us(struct channel *channel, const u8 *msg) payload = tal(ld, struct onion_message_hook_payload); if (!fromwire_got_onionmsg_to_us(payload, msg, + &payload->blinding_in, &payload->reply_blinding, &payload->reply_path)) { channel_internal_error(channel, "bad got_onionmsg_tous: %s",