mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
Call notification 'forward_event' when forward payment status changes
This commit is contained in:
parent
e75d8e061b
commit
294f05dc98
@ -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,
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <lightningd/bitcoind.h>
|
||||
#include <lightningd/lightningd.h>
|
||||
#include <lightningd/notification.h>
|
||||
#include <lightningd/peer_control.h>
|
||||
#include <lightningd/peer_htlcs.h>
|
||||
#include <onchaind/gen_onchain_wire.h>
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user