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

Function listfunds_success

plugins/funder.c:577–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575}
576
577static struct command_result *
578listfunds_success(struct command *cmd,
579 const char *method,
580 const char *buf,
581 const jsmntok_t *result,
582 struct open_info *info)
583{
584 struct amount_sat available_funds, committed_funds, total_fee;
585 const jsmntok_t *outputs_tok, *tok;
586 struct out_req *req;
587 struct bitcoin_outpoint **avail_prev_outs;
588 size_t i;
589 const char *funding_err;
590
591 /* We only use this for RBFs, when there's a prev_outs list */
592 struct funder_utxo **avail_utxos = tal_arr(cmd, struct funder_utxo *, 0);
593
594 outputs_tok = json_get_member(buf, result, "outputs");
595 if (!outputs_tok)
596 plugin_err(cmd->plugin,
597 "`listfunds` payload has no outputs token: %.*s",
598 json_tok_full_len(result),
599 json_tok_full(buf, result));
600
601 available_funds = AMOUNT_SAT(0);
602 committed_funds = AMOUNT_SAT(0);
603 total_fee = AMOUNT_SAT(0);
604 avail_prev_outs = tal_arr(info, struct bitcoin_outpoint *, 0);
605 json_for_each_arr(i, tok, outputs_tok) {
606 struct funder_utxo *utxo;
607 struct amount_sat est_fee;
608 bool is_reserved;
609 struct bitcoin_outpoint *prev_out;
610 char *status;
611 const char *err;
612
613 utxo = tal(cmd, struct funder_utxo);
614 err = json_scan(tmpctx, buf, tok,
615 "{amount_msat:%"
616 ",status:%"
617 ",reserved:%"
618 ",txid:%"
619 ",output:%}",
620 JSON_SCAN(json_to_msat_as_sats, &utxo->val),
621 JSON_SCAN_TAL(cmd, json_strdup, &status),
622 JSON_SCAN(json_to_bool, &is_reserved),
623 JSON_SCAN(json_to_txid, &utxo->out.txid),
624 JSON_SCAN(json_to_number, &utxo->out.n));
625 if (err)
626 plugin_err(cmd->plugin,
627 "`listfunds` payload did not scan. %s: %.*s",
628 err, json_tok_full_len(result),
629 json_tok_full(buf, result));
630
631 /* v2 opens don't support p2sh-wrapped inputs */
632 if (json_get_member(buf, tok, "redeemscript"))
633 continue;
634

Callers

nothing calls this directly

Calls 15

json_get_memberFunction · 0.85
bitcoin_tx_input_weightFunction · 0.85
previously_reservedFunction · 0.85
change_weightFunction · 0.85
calculate_our_fundingFunction · 0.85
funder_policy_descFunction · 0.85
amount_sat_is_zeroFunction · 0.85
build_utxopsbt_requestFunction · 0.85
json_add_boolFunction · 0.85
json_add_numFunction · 0.85
feerate_style_nameFunction · 0.85
plugin_errFunction · 0.70

Tested by

no test coverage detected