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

Function json_injectpaymentonion

lightningd/pay.c:1845–2129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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