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

Function json_decode

plugins/offers.c:1828–1869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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