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

Function add_new_entry

plugins/xpay/listpays.c:145–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145static void add_new_entry(struct plugin *plugin,
146 struct json_stream *ret,
147 const char *buf,
148 const struct pay_mpp *pm)
149{
150 json_object_start(ret, NULL);
151 if (pm->invstring)
152 json_add_invstring(ret, pm->invstring);
153 if (pm->description)
154 json_add_tok(ret, "description", pm->description, buf);
155 if (pm->destination)
156 json_add_tok(ret, "destination", pm->destination, buf);
157
158 json_add_sha256(ret, "payment_hash", pm->payment_hash);
159
160 if (pm->state & PAYMENT_COMPLETE)
161 json_add_string(ret, "status", "complete");
162 else if (pm->state & PAYMENT_PENDING || attempt_ongoing(plugin, pm->payment_hash))
163 json_add_string(ret, "status", "pending");
164 else
165 json_add_string(ret, "status", "failed");
166
167 json_add_u32(ret, "created_at", pm->timestamp);
168
169 if (pm->success_at < UINT64_MAX)
170 json_add_u64(ret, "completed_at", pm->success_at);
171
172 if (pm->label)
173 json_add_tok(ret, "label", pm->label, buf);
174 if (pm->preimage)
175 json_add_tok(ret, "preimage", pm->preimage, buf);
176
177 /* This is only tallied for pending and successful payments, not
178 * failures. */
179 if (pm->amount != NULL && pm->num_nonfailed_parts > 0)
180 json_add_amount_msat(ret, "amount_msat", *pm->amount);
181
182 json_add_amount_msat(ret, "amount_sent_msat", pm->amount_sent);
183
184 if (pm->num_nonfailed_parts > 1)
185 json_add_u64(ret, "number_of_parts",
186 pm->num_nonfailed_parts);
187
188 json_add_u64(ret, "created_index", pm->created_index);
189
190 if(pm->updated_index)
191 json_add_u64(ret, "updated_index", pm->updated_index);
192 json_object_end(ret);
193}
194
195static struct command_result *listsendpays_done(struct command *cmd,
196 const char *method,

Callers 1

listsendpays_doneFunction · 0.85

Calls 10

json_object_startFunction · 0.85
json_add_invstringFunction · 0.85
json_add_tokFunction · 0.85
json_add_sha256Function · 0.85
attempt_ongoingFunction · 0.85
json_add_u32Function · 0.85
json_add_u64Function · 0.85
json_add_amount_msatFunction · 0.85
json_object_endFunction · 0.85
json_add_stringFunction · 0.50

Tested by

no test coverage detected