Skip to content

Commit

Permalink
wallet: Set the completed_at timestamp when updating the status
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Aug 3, 2022
1 parent 088d529 commit 7d06341
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3327,6 +3327,10 @@ void wallet_payment_set_status(struct wallet *wallet,
{
struct db_stmt *stmt;
struct wallet_payment *payment;
u32 completed_at = 0;

if (newstatus != PAYMENT_PENDING)
completed_at = time_now().ts.tv_sec;

/* We can only fail an unstored payment! */
payment = find_unstored_payment(wallet, payment_hash, partid);
Expand All @@ -3337,13 +3341,18 @@ void wallet_payment_set_status(struct wallet *wallet,
}

stmt = db_prepare_v2(wallet->db,
SQL("UPDATE payments SET status=? "
SQL("UPDATE payments SET status=?, completed_at=? "
"WHERE payment_hash=? AND partid=? AND groupid=?"));

db_bind_int(stmt, 0, wallet_payment_status_in_db(newstatus));
db_bind_sha256(stmt, 1, payment_hash);
db_bind_u64(stmt, 2, partid);
db_bind_u64(stmt, 3, groupid);
if (completed_at != 0) {
db_bind_u64(stmt, 1, completed_at);
} else {
db_bind_null(stmt, 1);
}
db_bind_sha256(stmt, 2, payment_hash);
db_bind_u64(stmt, 3, partid);
db_bind_u64(stmt, 4, groupid);
db_exec_prepared_v2(take(stmt));

if (preimage) {
Expand Down

0 comments on commit 7d06341

Please sign in to comment.