Browse Source

lightningd: fix crash when we get onchain after old db.

lightningd(25923): lightning_onchaind(03cbf298b068300be33f06c947b9d3f00a0f0e8089da3233f5db37e81d3a596fe1): UPDATE WIRE_ONCHAIN_MISSING_HTLC_OUTPUT
lightningd(25923): FATAL SIGNAL 11 RECEIVED
lightningd(25923): backtrace: lightningd/log.c:498 (log_crash) 0x410ae8
lightningd(25923): backtrace: (null):0 ((null)) 0x7ff2ddb8e0df
lightningd(25923): backtrace: lightningd/pay.c:231 (local_routing_failure) 0x415b33
lightningd(25923): backtrace: lightningd/pay.c:383 (payment_failed) 0x41604c
lightningd(25923): backtrace: lightningd/peer_htlcs.c:783 (onchain_failed_our_htlc) 0x4225e5
lightningd(25923): backtrace: lightningd/peer_control.c:1209 (handle_missing_htlc_output) 0x41b31c
lightningd(25923): backtrace: lightningd/peer_control.c:1323 (onchain_msg) 0x41b759
lightningd(25923): backtrace: lightningd/subd.c:498 (sd_msg_read) 0x425b40

Fixes: #878
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
1dc6f7575a
  1. 15
      lightningd/pay.c

15
lightningd/pay.c

@ -382,6 +382,21 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
payment = wallet_payment_by_hash(tmpctx, ld->wallet, payment = wallet_payment_by_hash(tmpctx, ld->wallet,
&hout->payment_hash); &hout->payment_hash);
/* FIXME: Prior to 299b280f7, we didn't put route_nodes and
* route_channels in db. If this happens, it's an old payment,
* so we can simply mark it failed in db and return. */
if (!payment->route_channels) {
log_unusual(hout->key.channel->log,
"No route_channels for htlc %s:"
" was this an old database?",
type_to_string(ltmp, struct sha256,
&hout->payment_hash));
wallet_payment_set_status(ld->wallet, &hout->payment_hash,
PAYMENT_FAILED, NULL);
tal_free(tmpctx);
return;
}
/* This gives more details than a generic failure message */ /* This gives more details than a generic failure message */
if (localfail) { if (localfail) {
fail = local_routing_failure(tmpctx, ld, hout, payment); fail = local_routing_failure(tmpctx, ld, hout, payment);

Loading…
Cancel
Save