MCPcopy Create free account
hub / github.com/ElementsProject/lightning / fixup_hout

Function fixup_hout

lightningd/peer_htlcs.c:3120–3163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3118
3119#ifdef COMPAT_V061
3120static void fixup_hout(struct lightningd *ld, struct htlc_out *hout)
3121{
3122 const char *fix;
3123
3124 /* We didn't save HTLC failure information to the database. So when
3125 * busy nodes restarted (y'know, our most important users!) they would
3126 * find themselves with missing fields.
3127 *
3128 * Fortunately, most of the network is honest: re-sending an old HTLC
3129 * just causes failure (though we assert() when we try to push the
3130 * failure to the incoming HTLC which has already succeeded!).
3131 */
3132
3133 /* We care about HTLCs being removed only, not those being added. */
3134 if (hout->hstate < RCVD_REMOVE_HTLC)
3135 return;
3136
3137 /* Successful ones are fine. */
3138 if (hout->preimage)
3139 return;
3140
3141 /* Failed ones (only happens after db fixed!) OK. */
3142 if (hout->failmsg || hout->failonion)
3143 return;
3144
3145 /* payment_preimage for HTLC in *was* stored, so look for that. */
3146 if (hout->in && hout->in->preimage) {
3147 hout->preimage = tal_dup(hout, struct preimage,
3148 hout->in->preimage);
3149 fix = "restoring preimage from incoming HTLC";
3150 } else {
3151 hout->failmsg = towire_temporary_node_failure(hout);
3152 fix = "subsituting temporary node failure";
3153 }
3154
3155 log_broken(ld->log, "HTLC #%"PRIu64" (%s) "
3156 " for amount %s"
3157 " to %s"
3158 " is missing a resolution: %s.",
3159 hout->key.id, htlc_state_name(hout->hstate),
3160 fmt_amount_msat(tmpctx, hout->msat),
3161 fmt_node_id(tmpctx, &hout->key.channel->peer->id),
3162 fix);
3163}
3164
3165void fixup_htlcs_out(struct lightningd *ld)
3166{

Callers 1

fixup_htlcs_outFunction · 0.85

Calls 3

fmt_node_idFunction · 0.85
htlc_state_nameFunction · 0.50
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected