mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
lightningd: --dev-onion-reply-length option.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
341d73fdc2
commit
75c382fe16
3 changed files with 17 additions and 2 deletions
|
@ -679,12 +679,19 @@ struct route_step *process_onionpacket(
|
|||
return step;
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
unsigned dev_onion_reply_length = ONION_REPLY_SIZE;
|
||||
#define OUR_ONION_REPLY_SIZE dev_onion_reply_length
|
||||
#else
|
||||
#define OUR_ONION_REPLY_SIZE ONION_REPLY_SIZE
|
||||
#endif
|
||||
|
||||
struct onionreply *create_onionreply(const tal_t *ctx,
|
||||
const struct secret *shared_secret,
|
||||
const u8 *failure_msg)
|
||||
{
|
||||
size_t msglen = tal_count(failure_msg);
|
||||
size_t padlen = ONION_REPLY_SIZE - msglen;
|
||||
size_t padlen = OUR_ONION_REPLY_SIZE - msglen;
|
||||
struct onionreply *reply = tal(ctx, struct onionreply);
|
||||
u8 *payload = tal_arr(ctx, u8, 0);
|
||||
struct secret key;
|
||||
|
@ -716,7 +723,7 @@ struct onionreply *create_onionreply(const tal_t *ctx,
|
|||
* - Note: this value is 118 bytes longer than the longest
|
||||
* currently-defined message.
|
||||
*/
|
||||
assert(tal_count(payload) == ONION_REPLY_SIZE + 4);
|
||||
assert(tal_count(payload) == OUR_ONION_REPLY_SIZE + 4);
|
||||
|
||||
/* BOLT #4:
|
||||
*
|
||||
|
|
|
@ -267,6 +267,9 @@ sphinx_compressed_onion_deserialize(const tal_t *ctx, const u8 *src);
|
|||
#if DEVELOPER
|
||||
/* Override to force us to reject valid onion packets */
|
||||
extern bool dev_fail_process_onionpacket;
|
||||
|
||||
/* Override to set custom onion error lengths. */
|
||||
extern unsigned dev_onion_reply_length;
|
||||
#endif
|
||||
|
||||
#endif /* LIGHTNING_COMMON_SPHINX_H */
|
||||
|
|
|
@ -752,6 +752,11 @@ static void dev_register_opts(struct lightningd *ld)
|
|||
opt_register_noarg("--dev-no-ping-timer", opt_set_bool,
|
||||
&ld->dev_no_ping_timer,
|
||||
"Don't hang up if we don't get a ping response");
|
||||
opt_register_arg("--dev-onion-reply-length",
|
||||
opt_set_uintval,
|
||||
opt_show_uintval,
|
||||
&dev_onion_reply_length,
|
||||
"Send onion errors of custom length");
|
||||
}
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue