Browse Source

wallet: Record the received_time and resolved_time for HTLCs

Signed-off-by: Christian Decker <decker.christian@gmail.com>
pr-2587
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
75de2e2f3c
  1. 2
      wallet/db.c
  2. 12
      wallet/wallet.c

2
wallet/db.c

@ -377,6 +377,8 @@ static struct migration dbmigrations[] = {
{ "ALTER TABLE channels ADD feerate_ppm INTEGER;", NULL }, { "ALTER TABLE channels ADD feerate_ppm INTEGER;", NULL },
{ NULL, migrate_pr2342_feerate_per_channel }, { NULL, migrate_pr2342_feerate_per_channel },
{ "ALTER TABLE channel_htlcs ADD received_time INTEGER", NULL }, { "ALTER TABLE channel_htlcs ADD received_time INTEGER", NULL },
{ "ALTER TABLE forwarded_payments ADD received_time INTEGER", NULL },
{ "ALTER TABLE forwarded_payments ADD resolved_time INTEGER", NULL },
}; };
/* Leak tracking. */ /* Leak tracking. */

12
wallet/wallet.c

@ -2492,7 +2492,10 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
", out_channel_scid" ", out_channel_scid"
", in_msatoshi" ", in_msatoshi"
", out_msatoshi" ", out_msatoshi"
", state) VALUES (?, ?, ?, ?, ?, ?, ?);"); ", state"
", received_time"
", resolved_time"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
sqlite3_bind_int64(stmt, 1, in->dbid); sqlite3_bind_int64(stmt, 1, in->dbid);
sqlite3_bind_int64(stmt, 2, out->dbid); sqlite3_bind_int64(stmt, 2, out->dbid);
sqlite3_bind_int64(stmt, 3, in->key.channel->scid->u64); sqlite3_bind_int64(stmt, 3, in->key.channel->scid->u64);
@ -2500,6 +2503,13 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
sqlite3_bind_amount_msat(stmt, 5, in->msat); sqlite3_bind_amount_msat(stmt, 5, in->msat);
sqlite3_bind_amount_msat(stmt, 6, out->msat); sqlite3_bind_amount_msat(stmt, 6, out->msat);
sqlite3_bind_int(stmt, 7, wallet_forward_status_in_db(state)); sqlite3_bind_int(stmt, 7, wallet_forward_status_in_db(state));
sqlite3_bind_timeabs(stmt, 8, in->received_time);
if (state == FORWARD_SETTLED || state == FORWARD_FAILED)
sqlite3_bind_timeabs(stmt, 9, time_now());
else
sqlite3_bind_null(stmt, 9);
db_exec_prepared(w->db, stmt); db_exec_prepared(w->db, stmt);
} }

Loading…
Cancel
Save