From ae1d72b97892a85710a52ed2e2d3f649ea52c5ed Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 18 Jan 2018 06:59:49 +1030 Subject: [PATCH] wallet: add routine to delete a payment. We do this instead of updating, if we've got an old failed one. Signed-off-by: Rusty Russell --- wallet/wallet.c | 14 ++++++++++++++ wallet/wallet.h | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/wallet/wallet.c b/wallet/wallet.c index 35efec6a4..5f77bd2b6 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1273,6 +1273,20 @@ bool wallet_payment_add(struct wallet *wallet, return true; } +void wallet_payment_delete(struct wallet *wallet, + const struct sha256 *payment_hash) +{ + sqlite3_stmt *stmt; + + stmt = db_prepare( + wallet->db, + "DELETE FROM payments WHERE payment_hash = ?"); + + sqlite3_bind_sha256(stmt, 1, payment_hash); + + db_exec_prepared(wallet->db, stmt); +} + static struct wallet_payment *wallet_stmt2payment(const tal_t *ctx, sqlite3_stmt *stmt) { diff --git a/wallet/wallet.h b/wallet/wallet.h index c21f8948a..a10f7c4ae 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -537,6 +537,14 @@ struct htlc_stub *wallet_htlc_stubs(const tal_t *ctx, struct wallet *wallet, bool wallet_payment_add(struct wallet *wallet, struct wallet_payment *payment); +/** + * wallet_payment_delete - Remove a payment + * + * Removes the payment from the database. + */ +void wallet_payment_delete(struct wallet *wallet, + const struct sha256 *payment_hash); + /** * wallet_payment_by_hash - Retrieve a specific payment *