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

Function json_add_invoice_fields

lightningd/invoice.c:41–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 5

json_add_invoiceFunction · 0.70
tell_waiterFunction · 0.70
json_delinvoiceFunction · 0.70
fail_existsFunction · 0.70
json_createinvoiceFunction · 0.70

Calls 15

json_add_escaped_stringFunction · 0.85
json_add_invstringFunction · 0.85
json_add_sha256Function · 0.85
json_add_amount_msatFunction · 0.85
invoice_status_strFunction · 0.85
json_add_u64Function · 0.85
json_object_startFunction · 0.85
json_add_txidFunction · 0.85
json_add_numFunction · 0.85
json_object_endFunction · 0.85
json_add_preimageFunction · 0.85
invoice_decodeFunction · 0.85

Tested by

no test coverage detected