diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index dc652028e..d6356d665 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -375,6 +375,9 @@ void notify_connect(struct lightningd *ld UNNEEDED, struct node_id *nodeid UNNEE /* Generated stub for notify_disconnect */ void notify_disconnect(struct lightningd *ld UNNEEDED, struct node_id *nodeid UNNEEDED) { fprintf(stderr, "notify_disconnect called!\n"); abort(); } +/* Generated stub for notify_forward_event */ +void notify_forward_event(struct lightningd *ld UNNEEDED, const struct htlc_in *in UNNEEDED, const struct htlc_out *out UNNEEDED, enum forward_status state UNNEEDED, enum onion_type failcode UNNEEDED, struct timeabs *resolved_time UNNEEDED) +{ fprintf(stderr, "notify_disconnect called!\n"); abort(); } /* Generated stub for onchaind_funding_spent */ enum watch_result onchaind_funding_spent(struct channel *channel UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, diff --git a/wallet/wallet.c b/wallet/wallet.c index 6100e5f8d..345b302fd 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -2655,6 +2656,7 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, enum onion_type failcode) { sqlite3_stmt *stmt; + struct timeabs *resolved_time; stmt = db_prepare( w->db, "INSERT OR REPLACE INTO forwarded_payments (" @@ -2691,10 +2693,14 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, 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 + if (state == FORWARD_SETTLED || state == FORWARD_FAILED) { + resolved_time = tal(tmpctx, struct timeabs); + *resolved_time = time_now(); + sqlite3_bind_timeabs(stmt, 9, *resolved_time); + } else { + resolved_time = NULL; sqlite3_bind_null(stmt, 9); + } if(failcode != 0) { assert(state == FORWARD_FAILED || state == FORWARD_LOCAL_FAILED); @@ -2704,6 +2710,8 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, } db_exec_prepared(w->db, stmt); + + notify_forward_event(w->ld, in, out, state, failcode, resolved_time); } struct amount_msat wallet_total_forward_fees(struct wallet *w)