| 134 | }; |
| 135 | |
| 136 | static struct command_result *json_keysend(struct command *cmd, const char *buf, |
| 137 | const jsmntok_t *params) |
| 138 | { |
| 139 | struct payment *p; |
| 140 | const char *label; |
| 141 | struct amount_msat *exemptfee, *msat; |
| 142 | struct node_id *destination; |
| 143 | u64 *maxfee_pct_millionths; |
| 144 | u32 *maxdelay; |
| 145 | unsigned int *retryfor; |
| 146 | struct route_info **hints; |
| 147 | struct tlv_field *extra_fields; |
| 148 | |
| 149 | #if DEVELOPER |
| 150 | bool *use_shadow; |
| 151 | #endif |
| 152 | if (!param(cmd, buf, params, |
| 153 | p_req("destination", param_node_id, &destination), |
| 154 | p_req("amount_msat|msatoshi", param_msat, &msat), |
| 155 | p_opt("label", param_string, &label), |
| 156 | p_opt_def("maxfeepercent", param_millionths, |
| 157 | &maxfee_pct_millionths, 500000), |
| 158 | p_opt_def("retry_for", param_number, &retryfor, 60), |
| 159 | p_opt_def("maxdelay", param_number, &maxdelay, |
| 160 | maxdelay_default), |
| 161 | p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)), |
| 162 | p_opt("extratlvs", param_extra_tlvs, &extra_fields), |
| 163 | p_opt("routehints", param_routehint_array, &hints), |
| 164 | #if DEVELOPER |
| 165 | p_opt_def("use_shadow", param_bool, &use_shadow, true), |
| 166 | #endif |
| 167 | NULL)) |
| 168 | return command_param_failed(); |
| 169 | |
| 170 | p = payment_new(cmd, cmd, NULL /* No parent */, pay_mods); |
| 171 | p->local_id = &my_id; |
| 172 | p->json_buffer = tal_dup_talarr(p, const char, buf); |
| 173 | p->json_toks = params; |
| 174 | p->destination = tal_steal(p, destination); |
| 175 | p->payment_secret = NULL; |
| 176 | p->payment_metadata = NULL; |
| 177 | p->amount = *msat; |
| 178 | p->routes = tal_steal(p, hints); |
| 179 | // 22 is the Rust-Lightning default and the highest minimum we know of. |
| 180 | p->min_final_cltv_expiry = 22; |
| 181 | p->features = NULL; |
| 182 | p->invstring = NULL; |
| 183 | /* Don't try to use invstring to hand to sendonion! */ |
| 184 | p->invstring_used = true; |
| 185 | p->why = "Initial attempt"; |
| 186 | p->constraints.cltv_budget = *maxdelay; |
| 187 | p->deadline = timeabs_add(time_now(), time_from_sec(*retryfor)); |
| 188 | p->getroute->riskfactorppm = 10000000; |
| 189 | |
| 190 | if (node_id_eq(&my_id, p->destination)) { |
| 191 | return command_fail( |
| 192 | cmd, JSONRPC2_INVALID_PARAMS, |
| 193 | "We are the destination. Keysend cannot be used to send funds to yourself"); |
nothing calls this directly
no test coverage detected