Validates the destinations input argument. Returns NULL if checking of destinations array worked, or non-NULL if it failed (and this function has already executed mfc_fail). */
| 1874 | executed mfc_fail). |
| 1875 | */ |
| 1876 | static struct command_result * |
| 1877 | param_destinations_array(struct command *cmd, const char *name, |
| 1878 | const char *buffer, const jsmntok_t *tok, |
| 1879 | struct multifundchannel_destination **dests) |
| 1880 | { |
| 1881 | size_t i; |
| 1882 | const jsmntok_t *json_dest; |
| 1883 | bool has_all = false; |
| 1884 | |
| 1885 | if (tok->type != JSMN_ARRAY) |
| 1886 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1887 | "must be an array"); |
| 1888 | if (tok->size < 1) |
| 1889 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1890 | "must have at least one entry"); |
| 1891 | |
| 1892 | *dests = tal_arr(cmd, struct multifundchannel_destination, tok->size); |
| 1893 | for (i = 0; i < tal_count(*dests); ++i) |
| 1894 | (*dests)[i].state = MULTIFUNDCHANNEL_START_NOT_YET; |
| 1895 | |
| 1896 | json_for_each_arr(i, json_dest, tok) { |
| 1897 | struct multifundchannel_destination *dest; |
| 1898 | const char *id; |
| 1899 | char *addrhint; |
| 1900 | struct amount_sat *amount, *request_amt; |
| 1901 | bool *announce; |
| 1902 | struct amount_msat *push_msat; |
| 1903 | struct lease_rates *rates; |
| 1904 | |
| 1905 | dest = &(*dests)[i]; |
| 1906 | |
| 1907 | if (!param(cmd, buffer, json_dest, |
| 1908 | p_req("id", param_string, &id), |
| 1909 | p_req("amount", param_sat_or_all, &amount), |
| 1910 | p_opt_def("announce", param_bool, &announce, true), |
| 1911 | p_opt_def("push_msat", param_msat, &push_msat, |
| 1912 | AMOUNT_MSAT(0)), |
| 1913 | /* FIXME: do address validation here? |
| 1914 | * Note that it will fail eventually (when |
| 1915 | * passed in to fundchannel_start) if invalid*/ |
| 1916 | p_opt("close_to", param_string, |
| 1917 | &dest->close_to_str), |
| 1918 | p_opt_def("request_amt", param_sat, &request_amt, |
| 1919 | AMOUNT_SAT(0)), |
| 1920 | p_opt("compact_lease", param_lease_hex, &rates), |
| 1921 | p_opt("mindepth", param_u32, &dest->mindepth), |
| 1922 | p_opt("reserve", param_sat, &dest->reserve), |
| 1923 | NULL)) |
| 1924 | return command_param_failed(); |
| 1925 | |
| 1926 | addrhint = strchr(id, '@'); |
| 1927 | if (addrhint) { |
| 1928 | /* Split at @. */ |
| 1929 | size_t idlen = (size_t) (addrhint - id); |
| 1930 | addrhint = tal_strdup(*dests, addrhint + 1); |
| 1931 | id = tal_strndup(*dests, take(id), idlen); |
| 1932 | } |
| 1933 |
nothing calls this directly
no test coverage detected