diff --git a/lightningd/pay.c b/lightningd/pay.c index e5d853b67..81541d597 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -365,6 +365,12 @@ static void report_routing_failure(struct log *log, tal_free(tmpctx); } +void payment_store(struct lightningd *ld, + const struct sha256 *payment_hash) +{ + wallet_payment_store(ld->wallet, payment_hash); +} + void payment_failed(struct lightningd *ld, const struct htlc_out *hout, const char *localfail) { @@ -449,7 +455,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout, } /* Save to DB */ - wallet_payment_store(ld->wallet, &hout->payment_hash); + payment_store(ld, &hout->payment_hash); wallet_payment_set_status(ld->wallet, &hout->payment_hash, PAYMENT_FAILED, NULL); wallet_payment_set_failinfo(ld->wallet, diff --git a/lightningd/pay.h b/lightningd/pay.h index 38e9786f1..8793833af 100644 --- a/lightningd/pay.h +++ b/lightningd/pay.h @@ -69,4 +69,7 @@ void payment_succeeded(struct lightningd *ld, struct htlc_out *hout, void payment_failed(struct lightningd *ld, const struct htlc_out *hout, const char *localfail); +/* Inform payment system to save the payment. */ +void payment_store(struct lightningd *ld, const struct sha256 *payment_hash); + #endif /* LIGHTNING_LIGHTNINGD_PAY_H */ diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index d0914304a..f4952a6ee 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -900,8 +900,8 @@ static bool update_out_htlc(struct channel *channel, /* For our own HTLCs, we commit payment to db lazily */ if (hout->origin_htlc_id == 0) - wallet_payment_store(ld->wallet, - &hout->payment_hash); + payment_store(ld, + &hout->payment_hash); } if (!htlc_out_update_state(channel, hout, newstate))