MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_multiwithdraw

Function json_multiwithdraw

plugins/spender/multiwithdraw.c:161–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

amount_sat_lessFunction · 0.85
start_mwFunction · 0.85
paramFunction · 0.50
command_param_failedFunction · 0.50
command_failFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected