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

Function json_injectpaymentonion

lightningd/pay.c:1848–2132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1846}
1847
1848static struct command_result *json_injectpaymentonion(struct command *cmd,
1849 const char *buffer,
1850 const jsmntok_t *obj UNNEEDED,
1851 const jsmntok_t *params)
1852{
1853 u8 *onion;
1854 enum onion_wire failcode;
1855 struct sha256 *payment_hash;
1856 struct lightningd *ld = cmd->ld;
1857 const char *label, *invstring;
1858 struct pubkey *blinding, *next_path_key;
1859 struct amount_msat *destination_msat, *msat;
1860 u32 *cltv;
1861 u64 *partid, *groupid;
1862 struct sha256 *local_invreq_id;
1863 struct secret shared_secret;
1864 struct onionpacket *op;
1865 struct onion_payload *payload;
1866 struct route_step *rs;
1867 u64 failtlvtype;
1868 size_t failtlvpos;
1869 struct channel *next;
1870 struct command_result *ret;
1871 const u8 *failmsg;
1872 struct htlc_out *hout;
1873 const struct wallet_payment *prev_payment;
1874 const char *explanation;
1875 struct node_id *destination;
1876
1877 if (!param_check(cmd, buffer, params,
1878 p_req("onion", param_bin_from_hex, &onion),
1879 p_req("payment_hash", param_sha256, &payment_hash),
1880 p_req("amount_msat", param_msat, &msat),
1881 p_req("cltv_expiry", param_u32, &cltv),
1882 p_req("partid", param_u64_nonzero, &partid),
1883 p_req("groupid", param_u64, &groupid),
1884 p_opt("blinding", param_pubkey, &blinding),
1885 p_opt("label", param_escaped_string, &label),
1886 p_opt("invstring", param_invstring, &invstring),
1887 p_opt("localinvreqid", param_sha256, &local_invreq_id),
1888 p_opt_def("destination_msat", param_msat, &destination_msat, AMOUNT_MSAT(0)),
1889 p_opt("destination", param_node_id, &destination),
1890 NULL))
1891 return command_param_failed();
1892
1893 /* Safety check: reconcile this with previous attempts, check
1894 * partid/groupid uniqueness: we don't know total. */
1895 ret = check_progress(cmd->ld, cmd, payment_hash, *destination_msat,
1896 AMOUNT_MSAT(0),
1897 *partid, *groupid, NULL, &prev_payment);
1898 if (ret)
1899 return ret;
1900
1901 if (prev_payment) {
1902 struct json_stream *js = json_stream_fail(cmd,
1903 PAY_INJECTPAYMENTONION_ALREADY_PAID,
1904 "Already paid this invoice");
1905 json_add_payment_fields(js, prev_payment);

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
check_progressFunction · 0.85
json_add_payment_fieldsFunction · 0.85
json_object_endFunction · 0.85
tal_bytelenFunction · 0.85
parse_onionpacketFunction · 0.85
process_onionpacketFunction · 0.85
onion_decodeFunction · 0.85
tal_hexFunction · 0.85
bolt11_decodeFunction · 0.85
invoice_decodeFunction · 0.85

Tested by

no test coverage detected