From 3bb619fee4c0e5a0277bdd8a7f4d73901f6802a2 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 9 Feb 2018 15:44:39 +0100 Subject: [PATCH] wallet: Add primitive to store htlc_sigs in the database Signed-off-by: Christian Decker --- wallet/wallet.c | 18 ++++++++++++++++++ wallet/wallet.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/wallet/wallet.c b/wallet/wallet.c index 4dfd57639..3801aef8f 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1495,3 +1495,21 @@ wallet_payment_list(const tal_t *ctx, return payments; } + +void wallet_htlc_sigs_save(struct wallet *w, u64 channel_id, + secp256k1_ecdsa_signature *htlc_sigs) +{ + /* Clear any existing HTLC sigs for this channel */ + sqlite3_stmt *stmt = + db_prepare(w->db, "DELETE FROM htlc_sigs WHERE channelid = ?"); + sqlite3_bind_int64(stmt, 1, channel_id); + db_exec_prepared(w->db, stmt); + + /* Now insert the new ones */ + for (size_t i=0; idb, "INSERT INTO htlc_sigs (channelid, signature) VALUES (?, ?)"); + sqlite3_bind_int64(stmt, 1, channel_id); + sqlite3_bind_signature(stmt, 2, &htlc_sigs[i]); + db_exec_prepared(w->db, stmt); + } +} diff --git a/wallet/wallet.h b/wallet/wallet.h index 7a68bf62f..afb8f3c9b 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -619,4 +619,9 @@ const struct wallet_payment **wallet_payment_list(const tal_t *ctx, struct wallet *wallet, const struct sha256 *payment_hash); +/** + * wallet_htlc_sigs_save - Store the latest HTLC sigs for the channel + */ +void wallet_htlc_sigs_save(struct wallet *w, u64 channel_id, + secp256k1_ecdsa_signature *htlc_sigs); #endif /* WALLET_WALLET_H */