From adb984dd456f3ea9f380d266674ca37cb4f7bf91 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 21 Feb 2019 14:39:50 +0100 Subject: [PATCH] hooks: Add the raw payload to the htlc_accepted call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we might soon be changing the payload it is a good idea to not just expose the v0 payload, but also the raw payload for the plugin to interpret. This might also include payloads that `lightningd` itself cannot understand, but the plugin might. Signed-off-by: Christian Decker Suggested-by: Corné Plooy <@bitonic-cjp> --- common/sphinx.c | 2 ++ common/sphinx.h | 1 + lightningd/peer_htlcs.c | 1 + 3 files changed, 4 insertions(+) diff --git a/common/sphinx.c b/common/sphinx.c index 40ed4c2a0..48e4779b2 100644 --- a/common/sphinx.c +++ b/common/sphinx.c @@ -434,6 +434,8 @@ struct route_step *process_onionpacket( deserialize_hop_data(&step->hop_data, paddedheader); memcpy(&step->next->mac, step->hop_data.hmac, SECURITY_PARAMETER); + step->raw_payload = tal_dup_arr(step, u8, paddedheader + 1, + HOP_DATA_SIZE - 1 - HMAC_SIZE, 0); memcpy(&step->next->routinginfo, paddedheader + HOP_DATA_SIZE, ROUTING_INFO_SIZE); diff --git a/common/sphinx.h b/common/sphinx.h index e1f6fb5a5..e9f475b29 100644 --- a/common/sphinx.h +++ b/common/sphinx.h @@ -77,6 +77,7 @@ struct route_step { enum route_next_case nextcase; struct onionpacket *next; struct hop_data hop_data; + u8 *raw_payload; }; /** diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 76c3a20d7..22ef19d94 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -718,6 +718,7 @@ static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p, s32 expiry = hin->cltv_expiry, blockheight = p->ld->topology->tip->height; json_object_start(s, "onion"); + json_add_hex_talarr (s, "payload", rs->raw_payload); if (rs->hop_data.realm == 0x00) { json_object_start(s, "per_hop_v0"); json_add_hex(s, "realm", &rs->hop_data.realm, 1);