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

Function json_addpsbtinput

wallet/reservation.c:755–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753AUTODATA(json_command, &addpsbtoutput_command);
754
755static struct command_result *json_addpsbtinput(struct command *cmd,
756 const char *buffer,
757 const jsmntok_t *obj UNNEEDED,
758 const jsmntok_t *params)
759{
760 struct utxo **utxos;
761 const struct utxo **excluded;
762 bool all;
763 struct amount_sat *req_amount, input, emergency_sat, diff;
764 u32 current_height, *locktime, *reserve, weight, *min_feerate;
765 struct json_stream *response;
766 struct wally_psbt *psbt;
767 bool *add_initiator_serial_ids, *mark_our_inputs;
768 size_t inputs_count, psbt_locktime;
769 u64 serial_id;
770
771 if (!param_check(cmd, buffer, params,
772 p_req("satoshi", param_sat, &req_amount),
773 p_opt("initialpsbt", param_psbt, &psbt),
774 p_opt("locktime", param_number, &locktime),
775 p_opt("min_feerate", param_feerate, &min_feerate),
776 p_opt_def("add_initiator_serial_ids", param_bool,
777 &add_initiator_serial_ids, false),
778 p_opt_def("mark_our_inputs", param_bool,
779 &mark_our_inputs, false),
780 p_opt_def("reserve", param_number, &reserve,
781 RESERVATION_DEFAULT),
782 NULL))
783 return command_param_failed();
784
785 if (!psbt) {
786 if (!locktime) {
787 locktime = tal(cmd, u32);
788 *locktime = default_locktime(cmd->ld->topology);
789 }
790 psbt = create_psbt(cmd, 0, 0, *locktime);
791 } else if (locktime) {
792 return command_fail(cmd, FUNDING_PSBT_INVALID,
793 "Can't set locktime of an existing"
794 " {initialpsbt}");
795 }
796
797 if (!validate_psbt(psbt))
798 return command_fail(cmd,
799 FUNDING_PSBT_INVALID,
800 "PSBT failed to validate.");
801
802 if (!req_amount || amount_sat_is_zero(*req_amount))
803 return command_fail(cmd, FUND_INPUT_IS_ZERO, "Cannot add input"
804 " value of zero.");
805
806 if (!min_feerate) {
807 min_feerate = tal(cmd, u32);
808 *min_feerate = opening_feerate(cmd->ld->topology);
809 }
810
811 all = amount_sat_eq(*req_amount, AMOUNT_SAT(-1ULL));
812

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
default_locktimeFunction · 0.85
create_psbtFunction · 0.85
validate_psbtFunction · 0.85
amount_sat_is_zeroFunction · 0.85
inputs_sufficientFunction · 0.85
wallet_find_utxoFunction · 0.85
minconf_to_maxheightFunction · 0.85
utxo_spend_weightFunction · 0.85
utxo_is_csv_lockedFunction · 0.85
topology_syncedFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected