mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
wallet: fix case of failed payment not yet in db.
From test_reconnect_sender_add1: lightningd(13643):BROKEN: backtrace: wallet/wallet.c:1537 (wallet_payment_set_status) 0x561c91b03080 lightningd(13643):BROKEN: backtrace: lightningd/pay.c:67 (payment_failed) 0x561c91ac4f99 lightningd(13643):BROKEN: backtrace: lightningd/peer_htlcs.c:132 (fail_out_htlc) 0x561c91acf627 lightningd(13643):BROKEN: backtrace: lightningd/peer_htlcs.c:321 (hout_subd_died) 0x561c91acfb62 When payment fails, we call wallet_payment_set_status; this is perfectly possible before it's been committed. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
38e8601cf6
commit
b81129f87e
@ -1397,9 +1397,15 @@ void wallet_payment_set_status(struct wallet *wallet,
|
||||
const struct preimage *preimage)
|
||||
{
|
||||
sqlite3_stmt *stmt;
|
||||
struct wallet_payment *payment;
|
||||
|
||||
/* We should never try this on an unstored payment! */
|
||||
assert(!find_unstored_payment(wallet, payment_hash));
|
||||
/* We can only fail an unstored payment! */
|
||||
payment = find_unstored_payment(wallet, payment_hash);
|
||||
if (payment) {
|
||||
assert(newstatus == PAYMENT_FAILED);
|
||||
tal_free(payment);
|
||||
return;
|
||||
}
|
||||
|
||||
stmt = db_prepare(wallet->db,
|
||||
"UPDATE payments SET status=? "
|
||||
|
Loading…
Reference in New Issue
Block a user