| 156 | static struct command_result *start_mw(struct multiwithdraw_command *mw); |
| 157 | |
| 158 | static struct command_result * |
| 159 | json_multiwithdraw(struct command *cmd, |
| 160 | const char *buf, |
| 161 | const jsmntok_t *params) |
| 162 | { |
| 163 | struct multiwithdraw_command *mw; |
| 164 | |
| 165 | mw = tal(cmd, struct multiwithdraw_command); |
| 166 | |
| 167 | if (!param(cmd, buf, params, |
| 168 | p_req("outputs", param_outputs_array, &mw->outputs), |
| 169 | p_opt("feerate", param_string, &mw->feerate), |
| 170 | p_opt_def("minconf", param_number, &mw->minconf, 1), |
| 171 | p_opt("utxos", param_string, &mw->utxos), |
| 172 | NULL)) |
| 173 | return command_param_failed(); |
| 174 | |
| 175 | mw->cmd = cmd; |
| 176 | assert(cmd->id); |
| 177 | mw->id = *cmd->id; |
| 178 | mw->psbt = NULL; |
| 179 | |
| 180 | if (!mw->feerate) |
| 181 | mw->feerate = "normal"; |
| 182 | |
| 183 | /* Check if there are any 'all' amounts. */ |
| 184 | mw->has_all = false; |
| 185 | for (size_t i = 0; i < tal_count(mw->outputs); ++i) |
| 186 | if (mw->outputs[i].all) |
| 187 | mw->has_all = true; |
| 188 | else if (amount_sat_less(mw->outputs[i].amount, |
| 189 | chainparams->dust_limit)) |
| 190 | return command_fail(cmd, FUND_OUTPUT_IS_DUST, |
| 191 | "Output %s would be " |
| 192 | "dust.", |
| 193 | fmt_amount_sat(tmpctx, |
| 194 | mw->outputs[i].amount)); |
| 195 | |
| 196 | /* Begin. */ |
| 197 | return start_mw(mw); |
| 198 | } |
| 199 | |
| 200 | /*----------------------------------------------------------------------------- |
| 201 | Error Handling |
nothing calls this directly
no test coverage detected