Skip to content

Commit

Permalink
lightningd: fix crash when we get onchain after old db.
Browse files Browse the repository at this point in the history
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: ElementsProject#878
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Feb 20, 2018
1 parent d47d85f commit 1dc6f75
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,21 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
payment = wallet_payment_by_hash(tmpctx, ld->wallet,
&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 */
if (localfail) {
fail = local_routing_failure(tmpctx, ld, hout, payment);
Expand Down

0 comments on commit 1dc6f75

Please sign in to comment.