| 1013 | }; |
| 1014 | |
| 1015 | static void |
| 1016 | htlc_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 | |
| 1044 | static u8 *prepend_length(const tal_t *ctx, const u8 *payload TAKES) |
| 1045 | { |
no test coverage detected