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

Function json_add_invoice_fields

lightningd/invoice.c:38–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38static void json_add_invoice_fields(struct json_stream *response,
39 const struct invoice_details *inv)
40{
41 json_add_escaped_string(response, "label", inv->label);
42 if (inv->invstring)
43 json_add_invstring(response, inv->invstring);
44 json_add_sha256(response, "payment_hash", &inv->rhash);
45 if (inv->msat)
46 json_add_amount_msat_compat(response, *inv->msat,
47 "msatoshi", "amount_msat");
48 json_add_string(response, "status", invoice_status_str(inv));
49 if (inv->state == PAID) {
50 json_add_u64(response, "pay_index", inv->pay_index);
51 json_add_amount_msat_compat(response, inv->received,
52 "msatoshi_received",
53 "amount_received_msat");
54 json_add_u64(response, "paid_at", inv->paid_timestamp);
55 json_add_preimage(response, "payment_preimage", &inv->r);
56 }
57 if (inv->description)
58 json_add_string(response, "description", inv->description);
59
60 json_add_u64(response, "expires_at", inv->expiry_time);
61 if (inv->local_offer_id) {
62 char *fail;
63 struct tlv_invoice *tinv;
64
65 json_add_sha256(response, "local_offer_id", inv->local_offer_id);
66
67 /* Everyone loves seeing their own payer notes!
68 * Well: they will. Trust me. */
69 tinv = invoice_decode(tmpctx,
70 inv->invstring, strlen(inv->invstring),
71 NULL, NULL, &fail);
72 if (tinv && tinv->payer_note)
73 json_add_stringn(response, "payer_note",
74 tinv->payer_note,
75 tal_bytelen(tinv->payer_note));
76 }
77}
78
79static void json_add_invoice(struct json_stream *response,
80 const char *fieldname,

Callers 5

json_add_invoiceFunction · 0.85
tell_waiterFunction · 0.85
json_delinvoiceFunction · 0.85
fail_existsFunction · 0.85
json_createinvoiceFunction · 0.85

Calls 11

invoice_status_strFunction · 0.85
tal_bytelenFunction · 0.85
json_add_escaped_stringFunction · 0.50
json_add_invstringFunction · 0.50
json_add_sha256Function · 0.50
json_add_stringFunction · 0.50
json_add_u64Function · 0.50
json_add_preimageFunction · 0.50
invoice_decodeFunction · 0.50
json_add_stringnFunction · 0.50

Tested by

no test coverage detected