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

Function json_renepaystatus

plugins/renepay/main.c:92–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92static struct command_result *json_renepaystatus(struct command *cmd,
93 const char *buf,
94 const jsmntok_t *params)
95{
96 const char *invstring;
97 struct json_stream *ret;
98
99 if (!param(cmd, buf, params,
100 p_opt("invstring", param_invstring, &invstring),
101 NULL))
102 return command_param_failed();
103
104 ret = jsonrpc_stream_success(cmd);
105 json_array_start(ret, "paystatus");
106 if(invstring)
107 {
108 /* select the payment that matches this invoice */
109
110 if (bolt12_has_prefix(invstring))
111 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
112 "BOLT12 invoices are not yet supported.");
113
114 const char *fail;
115 struct bolt11 *b11 =
116 bolt11_decode(tmpctx, invstring, plugin_feature_set(cmd->plugin),
117 NULL, chainparams, &fail);
118 if (b11 == NULL)
119 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
120 "Invalid bolt11: %s", fail);
121
122 struct payment *payment =
123 payment_map_get(pay_plugin->payment_map, b11->payment_hash);
124
125 if(payment)
126 {
127 json_object_start(ret, NULL);
128 json_add_payment(ret, payment);
129 json_object_end(ret);
130 }
131 }else
132 {
133 /* show all payments */
134 struct payment_map_iter it;
135 for (struct payment *p =
136 payment_map_first(pay_plugin->payment_map, &it);
137 p; p = payment_map_next(pay_plugin->payment_map, &it)) {
138 json_object_start(ret, NULL);
139 json_add_payment(ret, p);
140 json_object_end(ret);
141 }
142 }
143 json_array_end(ret);
144
145 return command_finished(cmd, ret);
146}
147
148static struct command_result * payment_start(struct payment *p)
149{

Callers

nothing calls this directly

Calls 13

json_array_startFunction · 0.85
bolt12_has_prefixFunction · 0.85
bolt11_decodeFunction · 0.85
json_object_startFunction · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85
json_add_paymentFunction · 0.70
paramFunction · 0.50
command_param_failedFunction · 0.50
jsonrpc_stream_successFunction · 0.50
command_failFunction · 0.50
plugin_feature_setFunction · 0.50

Tested by

no test coverage detected