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

Function param_outputs_array

plugins/spender/multiwithdraw.c:77–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75-----------------------------------------------------------------------------*/
76
77static struct command_result *
78param_outputs_array(struct command *cmd,
79 const char *name,
80 const char *buf,
81 const jsmntok_t *t,
82 struct multiwithdraw_destination **outputs)
83{
84 size_t i;
85 const jsmntok_t *e;
86 bool has_all = false;
87
88 if (t->type != JSMN_ARRAY)
89 goto err;
90 if (t->size == 0)
91 goto err;
92
93 *outputs = tal_arr(cmd, struct multiwithdraw_destination, t->size);
94 json_for_each_arr (i, e, t) {
95 struct multiwithdraw_destination *dest;
96 enum address_parse_result res;
97
98 dest = &(*outputs)[i];
99 dest->is_to_external = true;
100
101 if (e->type != JSMN_OBJECT)
102 goto err;
103 if (e->size != 1)
104 goto err;
105
106 res = json_to_address_scriptpubkey(cmd, chainparams,
107 buf, &e[1],
108 &dest->script);
109 if (res == ADDRESS_PARSE_UNRECOGNIZED)
110 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
111 "'%s' address could not be "
112 "parsed: %.*s",
113 name,
114 json_tok_full_len(&e[1]),
115 json_tok_full(buf, &e[1]));
116 else if (res == ADDRESS_PARSE_WRONG_NETWORK)
117 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
118 "'%s' address is not on network "
119 "%s: %.*s",
120 name,
121 chainparams->network_name,
122 json_tok_full_len(&e[1]),
123 json_tok_full(buf, &e[1]));
124
125 if (!json_to_sat_or_all(buf, &e[2], &dest->amount))
126 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
127 "'%s' amount could not be "
128 "parsed: %.*s",
129 name,
130 json_tok_full_len(&e[2]),
131 json_tok_full(buf, &e[2]));
132
133 dest->all = amount_sat_eq(dest->amount, AMOUNT_SAT(-1ULL));
134

Callers

nothing calls this directly

Calls 6

json_to_sat_or_allFunction · 0.85
command_failFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
amount_sat_eqFunction · 0.50

Tested by

no test coverage detected