| 969 | }; |
| 970 | |
| 971 | static void |
| 972 | htlc_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 | |
| 1000 | static u8 *prepend_length(const tal_t *ctx, const u8 *payload TAKES) |
| 1001 | { |
no test coverage detected