From edd27d21b54296ef4ca17d86d7fb4a43aa55a88d Mon Sep 17 00:00:00 2001
From: Rusty Russell <rusty@rustcorp.com.au>
Date: Fri, 18 Aug 2017 14:13:53 +0930
Subject: [PATCH] lightningd: save last htlc sigs.

This belongs in the db, but until then...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 lightningd/peer_control.c | 1 +
 lightningd/peer_control.h | 1 +
 lightningd/peer_htlcs.c   | 3 +++
 3 files changed, 5 insertions(+)

diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c
index facbe3dc9..bd0970f4c 100644
--- a/lightningd/peer_control.c
+++ b/lightningd/peer_control.c
@@ -522,6 +522,7 @@ void add_peer(struct lightningd *ld, u64 unique_id,
 	peer->channel_info = NULL;
 	peer->last_tx = NULL;
 	peer->last_sig = NULL;
+	peer->last_htlc_sigs = NULL;
 	peer->last_was_revoke = false;
 	peer->last_sent_commit = NULL;
 	peer->remote_shutdown_scriptpubkey = NULL;
diff --git a/lightningd/peer_control.h b/lightningd/peer_control.h
index 084512ed0..b10a26a20 100644
--- a/lightningd/peer_control.h
+++ b/lightningd/peer_control.h
@@ -79,6 +79,7 @@ struct peer {
 	/* Last tx they gave us (if any). */
 	struct bitcoin_tx *last_tx;
 	secp256k1_ecdsa_signature *last_sig;
+	secp256k1_ecdsa_signature *last_htlc_sigs;
 
 	/* Keys for channel. */
 	struct channel_info *channel_info;
diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c
index 683d3156b..999a3ac48 100644
--- a/lightningd/peer_htlcs.c
+++ b/lightningd/peer_htlcs.c
@@ -1071,6 +1071,9 @@ int peer_got_commitsig(struct peer *peer, const u8 *msg)
 		return -1;
 
 	peer_last_tx(peer, tx, &commit_sig);
+	/* FIXME: Put these straight in the db! */
+	tal_free(peer->last_htlc_sigs);
+	peer->last_htlc_sigs = tal_steal(peer, htlc_sigs);
 
 	/* Tell it we've committed, and to go ahead with revoke. */
 	msg = towire_channel_got_commitsig_reply(msg);