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

Function htlc_accepted_hook_try_resolve

lightningd/peer_htlcs.c:971–998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

969};
970
971static void
972htlc_accepted_hook_try_resolve(struct htlc_accepted_hook_payload *request,
973 struct preimage *payment_preimage)
974{
975 struct sha256 payment_hash;
976 struct htlc_in *hin = request->hin;
977 u8 *unknown_details;
978 /* Verify that the provided secret hashes to what we need. */
979 sha256(&payment_hash, payment_preimage, sizeof(struct preimage));
980
981 if (!sha256_eq(&payment_hash, &hin->payment_hash)) {
982 log_broken(
983 request->channel->log,
984 "Plugin returned a preimage (sha256(%s) = %s) that doesn't "
985 "match the HTLC hash (%s) it tries to resolve.",
986 fmt_preimage(tmpctx, payment_preimage),
987 fmt_sha256(tmpctx, &payment_hash),
988 fmt_sha256(tmpctx, &hin->payment_hash));
989
990 unknown_details = tal_arr(NULL, u8, 0);
991 towire_u16(&unknown_details, 0x400f);
992 local_fail_in_htlc(hin, take(unknown_details));
993 } else {
994 hin->we_filled = tal(hin, bool);
995 *hin->we_filled = true;
996 fulfill_htlc(hin, payment_preimage);
997 }
998}
999
1000static u8 *prepend_length(const tal_t *ctx, const u8 *payload TAKES)
1001{

Callers 1

Calls 6

fmt_preimageFunction · 0.85
fmt_sha256Function · 0.85
sha256Class · 0.70
local_fail_in_htlcFunction · 0.70
fulfill_htlcFunction · 0.70
towire_u16Function · 0.50

Tested by

no test coverage detected