mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
"createonion" to accept an optional custom onion_size.
Changelog-Added: `createonion` RPC command now accepts an optional `onion_size`.
This commit is contained in:
parent
7bd6b5a108
commit
64199d99fd
13
doc/lightning-createonion.7
generated
13
doc/lightning-createonion.7
generated
@ -3,7 +3,7 @@
|
||||
lightning-createonion - Low-level command to create a custom onion
|
||||
.SH SYNOPSIS
|
||||
|
||||
\fBcreateonion\fR \fIhops\fR \fIassocdata\fR [\fIsession_key\fR]
|
||||
\fBcreateonion\fR \fIhops\fR \fIassocdata\fR [\fIsession_key\fR] [\fIonion_size\fR]
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
@ -75,8 +75,8 @@ which the above \fIhops\fR parameter was generated:
|
||||
Notice that the payload in the \fIhops\fR parameter is the hex-encoded version
|
||||
of the parameters in the \fBgetroute\fR response\.
|
||||
.IP \[bu]
|
||||
The payloads are shifted left by one, i\.e\., payload 0 in \fBcreateonion\fR
|
||||
corresponds to payload 1 from \fBgetroute\fR\.
|
||||
Except for the pubkey, the values are shifted left by one, i\.e\., the 1st
|
||||
payload in \fBcreateonion\fR corresponds to the 2nd set of values from \fBgetroute\fR\.
|
||||
.IP \[bu]
|
||||
The final payload is a copy of the last payload sans \fBchannel\fR
|
||||
|
||||
@ -97,6 +97,11 @@ should only be used for testing or if a specific shared secret is
|
||||
important\. If not specified it will be securely generated internally, and the
|
||||
shared secrets will be returned\.
|
||||
|
||||
|
||||
The optional \fIonion_size\fR parameter specifies a size different from the default
|
||||
payment onion (1300 bytes)\. May be used for custom protocols like trampoline
|
||||
routing\.
|
||||
|
||||
.SH RETURN VALUE
|
||||
|
||||
On success, an object containing the onion and the shared secrets will be
|
||||
@ -132,4 +137,4 @@ Christian Decker \fI<decker.christian@gmail.com\fR> is mainly responsible\.
|
||||
|
||||
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
|
||||
|
||||
\" SHA256STAMP:287d404b94d0e85eedbc6138b8e7a204723df86ad6d5f984ccfcd03e718ec514
|
||||
\" SHA256STAMP:d32334049025248f8b6088afed4e3322be75815ea6b976f79a007c619518f98a
|
||||
|
@ -4,7 +4,7 @@ lightning-createonion -- Low-level command to create a custom onion
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
**createonion** *hops* *assocdata* \[*session_key*\]
|
||||
**createonion** *hops* *assocdata* \[*session_key*\] \[*onion_size*\]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
@ -68,10 +68,10 @@ which the above *hops* parameter was generated:
|
||||
|
||||
- Notice that the payload in the *hops* parameter is the hex-encoded version
|
||||
of the parameters in the `getroute` response.
|
||||
- The payloads are shifted left by one, i.e., payload 0 in `createonion`
|
||||
corresponds to payload 1 from `getroute`.
|
||||
- Except for the pubkey, the values are shifted left by one, i.e., the 1st
|
||||
payload in `createonion` corresponds to the 2nd set of values from `getroute`.
|
||||
- The final payload is a copy of the last payload sans `channel`
|
||||
|
||||
|
||||
These rules are directly derived from the onion construction. Please refer
|
||||
[BOLT 04][bolt04] for details and rationale.
|
||||
|
||||
@ -85,6 +85,10 @@ should only be used for testing or if a specific shared secret is
|
||||
important. If not specified it will be securely generated internally, and the
|
||||
shared secrets will be returned.
|
||||
|
||||
The optional *onion_size* parameter specifies a size different from the default
|
||||
payment onion (1300 bytes). May be used for custom protocols like trampoline
|
||||
routing.
|
||||
|
||||
RETURN VALUE
|
||||
------------
|
||||
|
||||
@ -122,4 +126,3 @@ RESOURCES
|
||||
Main web site: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[bolt04]: https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md
|
||||
|
||||
|
@ -1671,6 +1671,7 @@ static struct command_result *json_createonion(struct command *cmd,
|
||||
struct secret *session_key, *shared_secrets;
|
||||
struct sphinx_path *sp;
|
||||
u8 *assocdata, *serialized;
|
||||
u32 *packet_size;
|
||||
struct onionpacket *packet;
|
||||
struct sphinx_hop *hops;
|
||||
|
||||
@ -1678,6 +1679,7 @@ static struct command_result *json_createonion(struct command *cmd,
|
||||
p_req("hops", param_hops_array, &hops),
|
||||
p_req("assocdata", param_bin_from_hex, &assocdata),
|
||||
p_opt("session_key", param_secret, &session_key),
|
||||
p_opt_def("onion_size", param_number, &packet_size, ROUTING_INFO_SIZE),
|
||||
NULL)) {
|
||||
return command_param_failed();
|
||||
}
|
||||
@ -1690,12 +1692,12 @@ static struct command_result *json_createonion(struct command *cmd,
|
||||
for (size_t i=0; i<tal_count(hops); i++)
|
||||
sphinx_add_hop(sp, &hops[i].pubkey, hops[i].raw_payload);
|
||||
|
||||
if (sphinx_path_payloads_size(sp) > ROUTING_INFO_SIZE)
|
||||
if (sphinx_path_payloads_size(sp) > *packet_size)
|
||||
return command_fail(
|
||||
cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Payloads exceed maximum onion packet size.");
|
||||
|
||||
packet = create_onionpacket(cmd, sp, ROUTING_INFO_SIZE, &shared_secrets);
|
||||
packet = create_onionpacket(cmd, sp, *packet_size, &shared_secrets);
|
||||
if (!packet)
|
||||
return command_fail(cmd, LIGHTNINGD,
|
||||
"Could not create onion packet");
|
||||
|
Loading…
Reference in New Issue
Block a user