| 72 | -----------------------------------------------------------------------------*/ |
| 73 | |
| 74 | static struct command_result * |
| 75 | param_outputs_array(struct command *cmd, |
| 76 | const char *name, |
| 77 | const char *buf, |
| 78 | const jsmntok_t *t, |
| 79 | struct multiwithdraw_destination **outputs) |
| 80 | { |
| 81 | size_t i; |
| 82 | const jsmntok_t *e; |
| 83 | bool has_all = false; |
| 84 | |
| 85 | if (t->type != JSMN_ARRAY) |
| 86 | goto err; |
| 87 | if (t->size == 0) |
| 88 | goto err; |
| 89 | |
| 90 | *outputs = tal_arr(cmd, struct multiwithdraw_destination, t->size); |
| 91 | json_for_each_arr (i, e, t) { |
| 92 | struct multiwithdraw_destination *dest; |
| 93 | enum address_parse_result res; |
| 94 | |
| 95 | dest = &(*outputs)[i]; |
| 96 | dest->is_to_external = true; |
| 97 | |
| 98 | if (e->type != JSMN_OBJECT) |
| 99 | goto err; |
| 100 | if (e->size != 1) |
| 101 | goto err; |
| 102 | |
| 103 | res = json_to_address_scriptpubkey(cmd, chainparams, |
| 104 | buf, &e[1], |
| 105 | &dest->script); |
| 106 | if (res == ADDRESS_PARSE_UNRECOGNIZED) |
| 107 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 108 | "'%s' address could not be " |
| 109 | "parsed: %.*s", |
| 110 | name, |
| 111 | json_tok_full_len(&e[1]), |
| 112 | json_tok_full(buf, &e[1])); |
| 113 | else if (res == ADDRESS_PARSE_WRONG_NETWORK) |
| 114 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 115 | "'%s' address is not on network " |
| 116 | "%s: %.*s", |
| 117 | name, |
| 118 | chainparams->network_name, |
| 119 | json_tok_full_len(&e[1]), |
| 120 | json_tok_full(buf, &e[1])); |
| 121 | |
| 122 | if (!json_to_sat_or_all(buf, &e[2], &dest->amount)) |
| 123 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 124 | "'%s' amount could not be " |
| 125 | "parsed: %.*s", |
| 126 | name, |
| 127 | json_tok_full_len(&e[2]), |
| 128 | json_tok_full(buf, &e[2])); |
| 129 | |
| 130 | dest->all = amount_sat_eq(dest->amount, AMOUNT_SAT(-1ULL)); |
| 131 |
nothing calls this directly
no test coverage detected