From 5b924a7eb7f585602150e9dd0a348ead335b1bef Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 16 Oct 2018 21:28:35 +0200 Subject: [PATCH] wallet: Add primitives to add forwarded payments to the DB Signed-off-by: Christian Decker <@cdecker> --- wallet/wallet.c | 25 +++++++++++++++++++++++++ wallet/wallet.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/wallet/wallet.c b/wallet/wallet.c index 947fbe0d6..43facb44b 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -2405,3 +2405,28 @@ struct channeltx *wallet_channeltxs_get(struct wallet *w, const tal_t *ctx, db_stmt_done(stmt); return res; } + +void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, + const struct htlc_out *out, + enum forward_status state) +{ + sqlite3_stmt *stmt; + stmt = db_prepare( + w->db, + "INSERT OR REPLACE INTO forwarded_payments (" + " in_htlc_id" + ", out_htlc_id" + ", in_channel_scid" + ", out_channel_scid" + ", in_msatoshi" + ", out_msatoshi" + ", state) VALUES (?, ?, ?, ?, ?, ?, ?);"); + sqlite3_bind_int64(stmt, 1, in->dbid); + sqlite3_bind_int64(stmt, 2, out->dbid); + sqlite3_bind_int64(stmt, 3, in->key.channel->scid->u64); + sqlite3_bind_int64(stmt, 4, out->key.channel->scid->u64); + sqlite3_bind_int64(stmt, 5, in->msatoshi); + sqlite3_bind_int64(stmt, 6, out->msatoshi); + sqlite3_bind_int(stmt, 7, state); + db_exec_prepared(w->db, stmt); +} diff --git a/wallet/wallet.h b/wallet/wallet.h index cb225b3e9..df2c5296b 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -995,4 +995,8 @@ u32 *wallet_onchaind_channels(struct wallet *w, struct channeltx *wallet_channeltxs_get(struct wallet *w, const tal_t *ctx, u32 channel_id); +void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, + const struct htlc_out *out, + enum forward_status state); + #endif /* LIGHTNING_WALLET_WALLET_H */