diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index e7562d1f9..124aa1ab4 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -194,6 +194,7 @@ static void shutdown_subdaemons(struct lightningd *ld) { struct peer *p; + db_begin_transaction(ld->wallet->db); /* Let everyone shutdown cleanly. */ close(ld->hsm_fd); subd_shutdown(ld->gossip, 10); @@ -202,6 +203,7 @@ static void shutdown_subdaemons(struct lightningd *ld) while ((p = list_top(&ld->peers, struct peer, list)) != NULL) tal_free(p); + db_commit_transaction(ld->wallet->db); } struct chainparams *get_chainparams(const struct lightningd *ld) diff --git a/lightningd/pay.c b/lightningd/pay.c index a964f7c67..4e40e9850 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -68,6 +68,7 @@ void payment_succeeded(struct lightningd *ld, struct htlc_out *hout, const struct preimage *rval) { assert(!hout->pay_command->rval); + wallet_payment_set_status(ld->wallet, &hout->payment_hash, PAYMENT_COMPLETE); hout->pay_command->rval = tal_dup(hout->pay_command, struct preimage, rval); json_pay_success(hout->pay_command->cmd, rval); @@ -81,6 +82,8 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout, enum onion_type failcode; struct onionreply *reply; + wallet_payment_set_status(ld->wallet, &hout->payment_hash, PAYMENT_FAILED); + /* This gives more details than a generic failure message, * and also the failuremsg here is unencrypted */ if (localfail) {