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

Function json_decode

plugins/offers.c:1830–1871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1828}
1829
1830static struct command_result *json_decode(struct command *cmd,
1831 const char *buffer,
1832 const jsmntok_t *params)
1833{
1834 struct decodable *decodable = talz(cmd, struct decodable);
1835 struct json_stream *response;
1836
1837 if (!param(cmd, buffer, params,
1838 p_req("string", param_decodable, decodable),
1839 NULL))
1840 return command_param_failed();
1841
1842 response = jsonrpc_stream_success(cmd);
1843 json_add_string(response, "type", decodable->type);
1844 if (decodable->offer)
1845 json_add_offer(cmd, response, decodable->offer);
1846 if (decodable->invreq)
1847 json_add_invoice_request(cmd, response, decodable->invreq);
1848 if (decodable->invoice)
1849 json_add_b12_invoice(cmd, response, decodable->invoice);
1850 if (decodable->payer_proof)
1851 json_add_payer_proof(response, decodable->payer_proof);
1852 if (decodable->b11) {
1853 /* The bolt11 decoder simply refuses to decode bad invs. */
1854 json_add_bolt11(response, decodable->b11);
1855 json_add_bool(response, "valid", true);
1856 }
1857 if (decodable->rune)
1858 json_add_rune(cmd, response, decodable->rune);
1859 if (decodable->emergency_recover) {
1860 struct out_req *req;
1861
1862 req = jsonrpc_request_start(cmd, "makesecret",
1863 after_makesecret, &forward_error,
1864 decodable);
1865
1866 json_add_string(req->js, "string", "scb secret");
1867 return send_outreq(req);
1868 }
1869
1870 return command_finished(cmd, response);
1871}
1872
1873static struct pubkey *json_to_pubkeys(const tal_t *ctx,
1874 const char *buffer,

Callers

nothing calls this directly

Calls 13

json_add_offerFunction · 0.85
json_add_invoice_requestFunction · 0.85
json_add_b12_invoiceFunction · 0.85
json_add_payer_proofFunction · 0.85
json_add_bolt11Function · 0.85
json_add_boolFunction · 0.85
command_param_failedFunction · 0.70
jsonrpc_stream_successFunction · 0.70
json_add_runeFunction · 0.70
send_outreqFunction · 0.70
command_finishedFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected