Skip to content

Commit

Permalink
wallet: Record the received_time and resolved_time for HTLCs
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Decker <[email protected]>
  • Loading branch information
cdecker authored and rustyrussell committed Apr 10, 2019
1 parent 2ce9a1e commit 75de2e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions wallet/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ static struct migration dbmigrations[] = {
{ "ALTER TABLE channels ADD feerate_ppm INTEGER;", NULL },
{ NULL, migrate_pr2342_feerate_per_channel },
{ "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. */
Expand Down
12 changes: 11 additions & 1 deletion wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2492,14 +2492,24 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
", out_channel_scid"
", in_msatoshi"
", out_msatoshi"
", state) VALUES (?, ?, ?, ?, ?, ?, ?);");
", state"
", received_time"
", resolved_time"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
sqlite3_bind_int64(stmt, 1, in->dbid);
sqlite3_bind_int64(stmt, 2, out->dbid);
sqlite3_bind_int64(stmt, 3, in->key.channel->scid->u64);
sqlite3_bind_int64(stmt, 4, out->key.channel->scid->u64);
sqlite3_bind_amount_msat(stmt, 5, in->msat);
sqlite3_bind_amount_msat(stmt, 6, out->msat);
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);
}

Expand Down

0 comments on commit 75de2e2

Please sign in to comment.