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

Function json_add_payment_fields

lightningd/pay.c:113–164  ·  view source on GitHub ↗

Outputs fields, not a separate object*/

Source from the content-addressed store, hash-verified

111
112/* Outputs fields, not a separate object*/
113void json_add_payment_fields(struct json_stream *response,
114 const struct wallet_payment *t)
115{
116 json_add_u64(response, "id", t->id);
117 json_add_sha256(response, "payment_hash", &t->payment_hash);
118 json_add_u64(response, "groupid", t->groupid);
119 if (t->partid)
120 json_add_u64(response, "partid", t->partid);
121 if (t->destination != NULL)
122 json_add_node_id(response, "destination", t->destination);
123
124 /* If we have a 0 amount delivered at the remote end we simply don't
125 * know since the onion was generated externally. */
126 if (amount_msat_greater(t->msatoshi, AMOUNT_MSAT(0)))
127 json_add_amount_msat_compat(response, t->msatoshi, "msatoshi",
128 "amount_msat");
129
130 json_add_amount_msat_compat(response, t->msatoshi_sent,
131 "msatoshi_sent", "amount_sent_msat");
132 json_add_u32(response, "created_at", t->timestamp);
133 if (t->completed_at)
134 json_add_u32(response, "completed_at", *t->completed_at);
135
136 switch (t->status) {
137 case PAYMENT_PENDING:
138 json_add_string(response, "status", "pending");
139 break;
140 case PAYMENT_COMPLETE:
141 json_add_string(response, "status", "complete");
142 break;
143 case PAYMENT_FAILED:
144 json_add_string(response, "status", "failed");
145 break;
146 }
147 if (t->payment_preimage)
148 json_add_preimage(response, "payment_preimage",
149 t->payment_preimage);
150 if (t->label)
151 json_add_string(response, "label", t->label);
152 if (t->invstring) {
153 if (strstarts(t->invstring, "lni"))
154 json_add_string(response, "bolt12", t->invstring);
155 else
156 json_add_string(response, "bolt11", t->invstring);
157 }
158 if (t->description)
159 json_add_string(response, "description", t->description);
160
161 if (t->failonion)
162 json_add_hex(response, "erroronion", t->failonion,
163 tal_count(t->failonion));
164}
165
166static struct command_result *sendpay_success(struct command *cmd,
167 const struct wallet_payment *payment)

Callers 6

sendpay_successFunction · 0.85
json_sendpay_fail_fieldsFunction · 0.85
json_sendpay_in_progressFunction · 0.85
json_listsendpaysFunction · 0.85
json_delpayFunction · 0.85

Calls 9

amount_msat_greaterFunction · 0.85
json_add_hexFunction · 0.85
json_add_u64Function · 0.50
json_add_sha256Function · 0.50
json_add_node_idFunction · 0.50
json_add_u32Function · 0.50
json_add_stringFunction · 0.50
json_add_preimageFunction · 0.50

Tested by

no test coverage detected