From d5d31864cf7e211b35ffd0d6cff6ca8b119738f5 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj Date: Wed, 21 Mar 2018 12:14:34 +0000 Subject: [PATCH] wallet: Remove onion-decoding information from db on payment success/fail. Fixes: #1177 --- wallet/db.c | 6 ++++++ wallet/wallet.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/wallet/db.c b/wallet/db.c index 0cd7df38a..99beda9b1 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -245,6 +245,12 @@ char *dbmigrations[] = { "ALTER TABLE payments ADD failchannel BLOB;", /* erring_channel */ "ALTER TABLE payments ADD failupdate BLOB;", /* channel_update - can be NULL*/ /* -- Payment routing failure information ends -- */ + /* Delete route data for already succeeded or failed payments */ + "UPDATE payments" + " SET path_secrets = NULL" + " , route_nodes = NULL" + " , route_channels = NULL" + " WHERE status <> 0;", /* PAYMENT_PENDING */ NULL, }; diff --git a/wallet/wallet.c b/wallet/wallet.c index ff469acce..655cc4a34 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1706,6 +1706,16 @@ void wallet_payment_set_status(struct wallet *wallet, sqlite3_bind_sha256(stmt, 2, payment_hash); db_exec_prepared(wallet->db, stmt); } + if (newstatus != PAYMENT_PENDING) { + stmt = db_prepare(wallet->db, + "UPDATE payments" + " SET path_secrets = NULL" + " , route_nodes = NULL" + " , route_channels = NULL" + " WHERE payment_hash = ?;"); + sqlite3_bind_sha256(stmt, 1, payment_hash); + db_exec_prepared(wallet->db, stmt); + } } void wallet_payment_get_failinfo(const tal_t *ctx,