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

Function json_withdraw

plugins/txprepare.c:515–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515static struct command_result *json_withdraw(struct command *cmd,
516 const char *buffer,
517 const jsmntok_t *params)
518{
519 struct txprepare *txp = tal(cmd, struct txprepare);
520 struct amount_sat *amount;
521 const u8 *scriptpubkey;
522 const char *feerate;
523 struct bitcoin_outpoint *utxos;
524 unsigned int *minconf;
525
526 if (!param(cmd, buffer, params,
527 p_req("destination", param_bitcoin_address,
528 &scriptpubkey),
529 p_req("satoshi", param_sat_or_all, &amount),
530 p_opt("feerate", param_string, &feerate),
531 p_opt_def("minconf", param_number, &minconf, 1),
532 p_opt("utxos", param_outpoint_arr, &utxos),
533 NULL))
534 return command_param_failed();
535
536 /* Convert destination/satoshi into array as txprepare expects */
537 txp->outputs = tal_arr(txp, struct tx_output, 1);
538
539 if (amount_sat_eq(*amount, AMOUNT_SAT(-1ULL))) {
540 txp->all_output_idx = 0;
541 txp->output_total = AMOUNT_SAT(0);
542 } else {
543 txp->all_output_idx = -1;
544 txp->output_total = *amount;
545 }
546 txp->outputs[0].amount = *amount;
547 txp->outputs[0].script = scriptpubkey;
548 txp->outputs[0].is_to_external = true;
549 txp->weight = bitcoin_tx_core_weight(1, tal_count(txp->outputs))
550 + bitcoin_tx_output_weight(tal_bytelen(scriptpubkey));
551
552 txp->is_upgrade = false;
553 return txprepare_continue(cmd, txp, feerate, minconf, utxos, true, false);
554}
555
556struct listfunds_info {
557 struct txprepare *txp;

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