From 881d7efd6e29fb686112976e9f5ed5ddaf210095 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 4 Aug 2023 12:49:43 +0930 Subject: [PATCH] wallet: don't BROKEN log id payments.total_msat is null. This was changed by mistake in 23fafe98e3b4f4e15cdf764e1346d813d1eb8039: if it's null we turn it into 0 (which is what the default call does, but it does log BROKEN about it!): ``` 2023-08-03T14:10:49.001Z **BROKEN** lightningd: Accessing a null column total_msat/15 in query SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, paydescription, failonionreply, total_msat, partid, local_invreq_id, groupid, completed_at FROM payments ORDER BY id; ``` Fixes: #6501 Signed-off-by: Rusty Russell --- wallet/wallet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallet/wallet.c b/wallet/wallet.c index c9610fe3d..ff9f44899 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -3444,7 +3444,7 @@ static struct wallet_payment *wallet_stmt2payment(const tal_t *ctx, take(db_col_optional(NULL, stmt, "destination", node_id)), db_col_amount_msat(stmt, "msatoshi"), db_col_amount_msat(stmt, "msatoshi_sent"), - db_col_amount_msat(stmt, "total_msat"), + db_col_is_null(stmt, "total_msat") ? AMOUNT_MSAT(0) : db_col_amount_msat(stmt, "total_msat"), take(db_col_optional(NULL, stmt, "payment_preimage", preimage)), take(db_col_secret_arr(NULL, stmt, "path_secrets")), take(db_col_node_id_arr(NULL, stmt, "route_nodes")),