| 3001 | } |
| 3002 | |
| 3003 | static struct command_result *json_xkeysend(struct command *cmd, |
| 3004 | const char *buf, |
| 3005 | const jsmntok_t *params) |
| 3006 | { |
| 3007 | struct xpay *xpay = xpay_of(cmd->plugin); |
| 3008 | struct amount_msat *msat, *maxfee; |
| 3009 | struct pubkey *dst; |
| 3010 | u32 *maxdelay; |
| 3011 | unsigned int *retryfor; |
| 3012 | struct payment *payment; |
| 3013 | struct json_escape *label; |
| 3014 | const char *err; |
| 3015 | struct preimage preimage; |
| 3016 | struct sha256 payment_hash; |
| 3017 | const char **layers; |
| 3018 | struct tlv_field *extra_fields; |
| 3019 | u8 *tlvs; |
| 3020 | struct out_req *req; |
| 3021 | |
| 3022 | if (!param_check(cmd, buf, params, |
| 3023 | p_req("destination", param_pubkey, &dst), |
| 3024 | p_req("amount_msat", param_msat, &msat), |
| 3025 | p_opt("label", param_label, &label), |
| 3026 | p_opt("maxfee", param_msat, &maxfee), |
| 3027 | p_opt("layers", param_string_array, &layers), |
| 3028 | p_opt_def("retry_for", param_number, &retryfor, 60), |
| 3029 | p_opt_def("maxdelay", param_number, &maxdelay, 2016), |
| 3030 | p_opt("extratlvs", param_extra_tlvs, &extra_fields), |
| 3031 | NULL)) |
| 3032 | return command_param_failed(); |
| 3033 | |
| 3034 | randbytes(&preimage, sizeof(preimage)); |
| 3035 | sha256(&payment_hash, &preimage, sizeof(preimage)); |
| 3036 | |
| 3037 | /* We explicitly prohibit self-keysends */ |
| 3038 | if (pubkey_eq(&xpay->local_id, dst)) { |
| 3039 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 3040 | "We are the destination. Keysend cannot be used to send funds to yourself"); |
| 3041 | } |
| 3042 | |
| 3043 | payment = new_payment(cmd, cmd, |
| 3044 | *retryfor, |
| 3045 | *maxdelay, |
| 3046 | layers, |
| 3047 | NULL, /* NULL invstring is the marker of a keysend vs pay */ |
| 3048 | dst, |
| 3049 | &payment_hash, |
| 3050 | *msat, |
| 3051 | NULL, |
| 3052 | maxfee, |
| 3053 | NULL, NULL, |
| 3054 | // 22 is the Rust-Lightning default and the |
| 3055 | // highest minimum CLTV we know of. |
| 3056 | 22, |
| 3057 | label, |
| 3058 | NULL, |
| 3059 | false, |
| 3060 | false, |
nothing calls this directly
no test coverage detected