| 2680 | |
| 2681 | #ifdef COMPAT_V061 |
| 2682 | static void fixup_hout(struct lightningd *ld, struct htlc_out *hout) |
| 2683 | { |
| 2684 | const char *fix; |
| 2685 | |
| 2686 | /* We didn't save HTLC failure information to the database. So when |
| 2687 | * busy nodes restarted (y'know, our most important users!) they would |
| 2688 | * find themselves with missing fields. |
| 2689 | * |
| 2690 | * Fortunately, most of the network is honest: re-sending an old HTLC |
| 2691 | * just causes failure (though we assert() when we try to push the |
| 2692 | * failure to the incoming HTLC which has already succeeded!). |
| 2693 | */ |
| 2694 | |
| 2695 | /* We care about HTLCs being removed only, not those being added. */ |
| 2696 | if (hout->hstate < RCVD_REMOVE_HTLC) |
| 2697 | return; |
| 2698 | |
| 2699 | /* Successful ones are fine. */ |
| 2700 | if (hout->preimage) |
| 2701 | return; |
| 2702 | |
| 2703 | /* Failed ones (only happens after db fixed!) OK. */ |
| 2704 | if (hout->failmsg || hout->failonion) |
| 2705 | return; |
| 2706 | |
| 2707 | /* payment_preimage for HTLC in *was* stored, so look for that. */ |
| 2708 | if (hout->in && hout->in->preimage) { |
| 2709 | hout->preimage = tal_dup(hout, struct preimage, |
| 2710 | hout->in->preimage); |
| 2711 | fix = "restoring preimage from incoming HTLC"; |
| 2712 | } else { |
| 2713 | hout->failmsg = towire_temporary_node_failure(hout); |
| 2714 | fix = "subsituting temporary node failure"; |
| 2715 | } |
| 2716 | |
| 2717 | log_broken(ld->log, "HTLC #%"PRIu64" (%s) " |
| 2718 | " for amount %s" |
| 2719 | " to %s" |
| 2720 | " is missing a resolution: %s.", |
| 2721 | hout->key.id, htlc_state_name(hout->hstate), |
| 2722 | type_to_string(tmpctx, struct amount_msat, &hout->msat), |
| 2723 | type_to_string(tmpctx, struct node_id, |
| 2724 | &hout->key.channel->peer->id), |
| 2725 | fix); |
| 2726 | } |
| 2727 | |
| 2728 | void fixup_htlcs_out(struct lightningd *ld) |
| 2729 | { |
no test coverage detected