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

Function param_outputs_array

plugins/spender/multiwithdraw.c:74–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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