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

Function htlc_accepted_hook_try_resolve

lightningd/peer_htlcs.c:852–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

850}
851
852static void
853htlc_accepted_hook_try_resolve(struct htlc_accepted_hook_payload *request,
854 struct preimage *payment_preimage)
855{
856 struct sha256 payment_hash;
857 struct htlc_in *hin = request->hin;
858 u8 *unknown_details;
859 /* Verify that the provided secret hashes to what we need. */
860 sha256(&payment_hash, payment_preimage, sizeof(struct preimage));
861
862 if (!sha256_eq(&payment_hash, &hin->payment_hash)) {
863 log_broken(
864 request->channel->log,
865 "Plugin returned a preimage (sha256(%s) = %s) that doesn't "
866 "match the HTLC hash (%s) it tries to resolve.",
867 type_to_string(tmpctx, struct preimage, payment_preimage),
868 type_to_string(tmpctx, struct sha256, &payment_hash),
869 type_to_string(tmpctx, struct sha256, &hin->payment_hash));
870
871 unknown_details = tal_arr(NULL, u8, 0);
872 towire_u16(&unknown_details, 0x400f);
873 local_fail_in_htlc(hin, take(unknown_details));
874 } else {
875 hin->we_filled = tal(hin, bool);
876 *hin->we_filled = true;
877 fulfill_htlc(hin, payment_preimage);
878 }
879}
880
881static u8 *prepend_length(const tal_t *ctx, const u8 *payload TAKES)
882{

Callers 1

Calls 5

local_fail_in_htlcFunction · 0.85
fulfill_htlcFunction · 0.85
sha256Class · 0.70
type_to_stringClass · 0.50
towire_u16Function · 0.50

Tested by

no test coverage detected