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

Function json_multiwithdraw

plugins/spender/multiwithdraw.c:161–200  ·  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 mw->id = mw_id++;
180 mw->psbt = NULL;
181
182 if (!mw->feerate)
183 mw->feerate = "normal";
184
185 /* Check if there are any 'all' amounts. */
186 mw->has_all = false;
187 for (size_t i = 0; i < tal_count(mw->outputs); ++i)
188 if (mw->outputs[i].all)
189 mw->has_all = true;
190 else if (amount_sat_less(mw->outputs[i].amount,
191 chainparams->dust_limit))
192 return command_fail(cmd, FUND_OUTPUT_IS_DUST,
193 "Output %s would be "
194 "dust.",
195 fmt_amount_sat(tmpctx,
196 mw->outputs[i].amount));
197
198 /* Begin. */
199 return start_mw(mw);
200}
201
202/*-----------------------------------------------------------------------------
203Error 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
fmt_amount_satFunction · 0.50

Tested by

no test coverage detected