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

Function newaddr_sweep_done

plugins/txprepare.c:637–676  ·  view source on GitHub ↗

We've got an address for sending funds */

Source from the content-addressed store, hash-verified

635
636/* We've got an address for sending funds */
637static struct command_result *newaddr_sweep_done(struct command *cmd,
638 const char *method,
639 const char *buf,
640 const jsmntok_t *result,
641 struct listfunds_info *info)
642{
643 struct out_req *req;
644 const jsmntok_t *addr = json_get_member(buf, result, chainparams->is_elements ? "bech32" : "p2tr");
645 assert(addr);
646
647 info->txp = tal(info, struct txprepare);
648 info->txp->is_upgrade = true;
649
650 /* Add output for 'all' to txp */
651 info->txp->outputs = tal_arr(info->txp, struct tx_output, 1);
652 info->txp->all_output_idx = 0;
653 info->txp->output_total = AMOUNT_SAT(0);
654 info->txp->outputs[0].amount = AMOUNT_SAT(-1ULL);
655 info->txp->outputs[0].is_to_external = false;
656
657 if (json_to_address_scriptpubkey(info->txp, chainparams, buf, addr,
658 &info->txp->outputs[0].script)
659 != ADDRESS_PARSE_SUCCESS) {
660 return command_fail(cmd, LIGHTNINGD,
661 "Change address '%.*s' unparsable?",
662 addr->end - addr->start,
663 buf + addr->start);
664 }
665
666 info->txp->weight = bitcoin_tx_core_weight(0, 1)
667 + bitcoin_tx_output_weight(tal_bytelen(info->txp->outputs[0].script));
668
669 /* Find all the utxos we want to spend on this tx */
670 req = jsonrpc_request_start(cmd,
671 "listfunds",
672 listfunds_done,
673 forward_error,
674 info);
675 return send_outreq(req);
676}
677
678static struct command_result *json_upgradewallet(struct command *cmd,
679 const char *buffer,

Callers

nothing calls this directly

Calls 7

json_get_memberFunction · 0.85
bitcoin_tx_core_weightFunction · 0.85
bitcoin_tx_output_weightFunction · 0.85
tal_bytelenFunction · 0.85
command_failFunction · 0.70
send_outreqFunction · 0.70

Tested by

no test coverage detected