| 850 | } |
| 851 | |
| 852 | static void |
| 853 | htlc_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 | |
| 881 | static u8 *prepend_length(const tal_t *ctx, const u8 *payload TAKES) |
| 882 | { |
no test coverage detected