| 150 | } |
| 151 | |
| 152 | static struct command_result *parse_reserve_hop(struct command *cmd, |
| 153 | const char *name, |
| 154 | const char *buffer, |
| 155 | const jsmntok_t *tok, |
| 156 | struct reserve_hop *rhop) |
| 157 | { |
| 158 | const char *err; |
| 159 | const char *layername = NULL; |
| 160 | |
| 161 | err = json_scan(tmpctx, buffer, tok, "{short_channel_id_dir:%,amount_msat:%,layer?:%}", |
| 162 | JSON_SCAN(json_to_short_channel_id_dir, &rhop->scidd), |
| 163 | JSON_SCAN(json_to_msat, &rhop->amount), |
| 164 | JSON_SCAN_TAL(tmpctx, json_strdup, &layername)); |
| 165 | if (err) |
| 166 | return command_fail_badparam(cmd, name, buffer, tok, err); |
| 167 | if (layername) { |
| 168 | rhop->layer = find_layer(get_askrene(cmd->plugin), layername); |
| 169 | if (!rhop->layer) |
| 170 | return command_fail_badparam(cmd, name, buffer, tok, "Unknown layer"); |
| 171 | } else |
| 172 | rhop->layer = NULL; |
| 173 | |
| 174 | return NULL; |
| 175 | } |
| 176 | |
| 177 | static struct command_result *param_reserve_path(struct command *cmd, |
| 178 | const char *name, |
no test coverage detected