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

Function json_withdraw

plugins/txprepare.c:499–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499static struct command_result *json_withdraw(struct command *cmd,
500 const char *buffer,
501 const jsmntok_t *params)
502{
503 struct txprepare *txp = tal(cmd, struct txprepare);
504 struct amount_sat *amount;
505 const u8 *scriptpubkey;
506 const char *feerate;
507 struct bitcoin_outpoint *utxos;
508 unsigned int *minconf;
509
510 if (!param(cmd, buffer, params,
511 p_req("destination", param_bitcoin_address,
512 &scriptpubkey),
513 p_req("satoshi", param_sat_or_all, &amount),
514 p_opt("feerate", param_string, &feerate),
515 p_opt_def("minconf", param_number, &minconf, 1),
516 p_opt("utxos", param_outpoint_arr, &utxos),
517 NULL))
518 return command_param_failed();
519
520 /* Convert destination/satoshi into array as txprepare expects */
521 txp->outputs = tal_arr(txp, struct tx_output, 1);
522
523 if (amount_sat_eq(*amount, AMOUNT_SAT(-1ULL))) {
524 txp->all_output_idx = 0;
525 txp->output_total = AMOUNT_SAT(0);
526 } else {
527 txp->all_output_idx = -1;
528 txp->output_total = *amount;
529 }
530 txp->outputs[0].amount = *amount;
531 txp->outputs[0].script = scriptpubkey;
532 txp->outputs[0].is_to_external = true;
533 txp->weight = bitcoin_tx_core_weight(1, tal_count(txp->outputs))
534 + bitcoin_tx_output_weight(tal_bytelen(scriptpubkey));
535
536 return txprepare_continue(cmd, txp, feerate, minconf, utxos, true);
537}
538
539static const struct plugin_command commands[] = {
540 {

Callers

nothing calls this directly

Calls 7

bitcoin_tx_core_weightFunction · 0.85
bitcoin_tx_output_weightFunction · 0.85
tal_bytelenFunction · 0.85
txprepare_continueFunction · 0.85
command_param_failedFunction · 0.70
paramFunction · 0.50
amount_sat_eqFunction · 0.50

Tested by

no test coverage detected