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

Function htlc_accepted_hook_try_resolve

lightningd/peer_htlcs.c:1015–1042  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1013};
1014
1015static void
1016htlc_accepted_hook_try_resolve(struct htlc_accepted_hook_payload *request,
1017 struct preimage *payment_preimage)
1018{
1019 struct sha256 payment_hash;
1020 struct htlc_in *hin = request->hin;
1021 u8 *unknown_details;
1022 /* Verify that the provided secret hashes to what we need. */
1023 sha256(&payment_hash, payment_preimage, sizeof(struct preimage));
1024
1025 if (!sha256_eq(&payment_hash, &hin->payment_hash)) {
1026 log_broken(
1027 request->channel->log,
1028 "Plugin returned a preimage (sha256(%s) = %s) that doesn't "
1029 "match the HTLC hash (%s) it tries to resolve.",
1030 fmt_preimage(tmpctx, payment_preimage),
1031 fmt_sha256(tmpctx, &payment_hash),
1032 fmt_sha256(tmpctx, &hin->payment_hash));
1033
1034 unknown_details = tal_arr(NULL, u8, 0);
1035 towire_u16(&unknown_details, 0x400f);
1036 local_fail_in_htlc(hin, take(unknown_details));
1037 } else {
1038 hin->we_filled = tal(hin, bool);
1039 *hin->we_filled = true;
1040 fulfill_htlc(hin, payment_preimage);
1041 }
1042}
1043
1044static u8 *prepend_length(const tal_t *ctx, const u8 *payload TAKES)
1045{

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