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

Function mk_failed_htlc

lightningd/peer_htlcs.c:191–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189 enum onion_wire badonion);
190
191static struct failed_htlc *mk_failed_htlc(const tal_t *ctx,
192 const struct htlc_in *hin,
193 const struct onionreply *failonion)
194{
195 struct failed_htlc *f;
196
197 if (!hin->shared_secret) {
198 log_broken(hin->key.channel->log,
199 "HTLC %"PRIu64" has no shared secret:"
200 " failing it as malformed instead",
201 hin->key.id);
202 return mk_failed_htlc_badonion(ctx, hin,
203 unparsable_onion_code(hin));
204 }
205
206 f = tal(ctx, struct failed_htlc);
207
208 /* Inside a blinded path, override return */
209 if (blind_error_return(hin)) {
210 struct sha256 sha;
211 sha256(&sha, hin->onion_routing_packet,
212 sizeof(hin->onion_routing_packet));
213 failonion = create_onionreply(tmpctx, hin->shared_secret,
214 towire_invalid_onion_blinding(tmpctx, &sha));
215 }
216
217 f->id = hin->key.id;
218 f->sha256_of_onion = NULL;
219 f->badonion = 0;
220 /* Wrap onion error */
221 f->onion = wrap_onionreply(f, hin->shared_secret, failonion);
222
223 return f;
224}
225
226static struct failed_htlc *mk_failed_htlc_badonion(const tal_t *ctx,
227 const struct htlc_in *hin,

Callers 3

mk_failed_htlc_badonionFunction · 0.85
fail_in_htlcFunction · 0.85
peer_htlcsFunction · 0.85

Calls 6

mk_failed_htlc_badonionFunction · 0.85
unparsable_onion_codeFunction · 0.85
blind_error_returnFunction · 0.85
create_onionreplyFunction · 0.85
wrap_onionreplyFunction · 0.85
sha256Class · 0.70

Tested by

no test coverage detected