From 126839886a0a5c2ae90c6ce9fd04116d785a2378 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 5 May 2017 13:37:02 +0200 Subject: [PATCH] routing: Use a pointer to a shared_secret htlc_end --- lightningd/htlc_end.h | 2 +- lightningd/peer_control.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lightningd/htlc_end.h b/lightningd/htlc_end.h index 2d0948eba..10628fdf4 100644 --- a/lightningd/htlc_end.h +++ b/lightningd/htlc_end.h @@ -31,7 +31,7 @@ struct htlc_end { /* If we are forwarding, remember the shared secret for an * eventual reply */ - struct sha256 shared_secret; + struct sha256 *shared_secret; /* If we are the origin, remember all shared secrets, so we * can unwrap an eventual reply */ diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 974f47168..3acb8b5f8 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -646,7 +646,7 @@ struct decoding_htlc { static void fail_htlc(struct peer *peer, struct htlc_end *hend, const u8 *msg) { - u8 *reply = wrap_onionreply(hend, hend->shared_secret.u.u8, msg); + u8 *reply = wrap_onionreply(hend, hend->shared_secret->u.u8, msg); subd_send_msg(peer->owner, take(towire_channel_fail_htlc(peer, hend->htlc_id, reply))); if (taken(msg)) @@ -660,7 +660,7 @@ static void fail_local_htlc(struct peer *peer, struct htlc_end *hend, const u8 * log_broken(peer->log, "failed htlc %"PRIu64" code 0x%04x (%s)", hend->htlc_id, failcode, onion_type_name(failcode)); - reply = create_onionreply(hend, hend->shared_secret.u.u8, msg); + reply = create_onionreply(hend, hend->shared_secret->u.u8, msg); fail_htlc(peer, hend, reply); } @@ -1088,6 +1088,7 @@ static int peer_accepted_htlc(struct peer *peer, const u8 *msg) u8 *req; hend = tal(msg, struct htlc_end); + hend->shared_secret = tal(hend, struct sha256); if (!fromwire_channel_accepted_htlc(msg, NULL, &hend->htlc_id, &hend->msatoshis, &hend->cltv_expiry, &hend->payment_hash, @@ -1095,7 +1096,7 @@ static int peer_accepted_htlc(struct peer *peer, const u8 *msg) &hend->amt_to_forward, &hend->outgoing_cltv_value, &hend->next_channel, - &hend->shared_secret)) { + hend->shared_secret)) { log_broken(peer->log, "bad fromwire_channel_accepted_htlc %s", tal_hex(peer, msg)); return -1;