Skip to content
57 changes: 56 additions & 1 deletion .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,9 @@
"ListConfigs.configs.addr": 47,
"ListConfigs.configs.alias": 30,
"ListConfigs.configs.allow-deprecated-apis": 14,
"ListConfigs.configs.alt-addr": 71,
"ListConfigs.configs.alt-announce-addr": 73,
"ListConfigs.configs.alt-bind-addr": 72,
"ListConfigs.configs.always-use-proxy": 17,
"ListConfigs.configs.announce-addr": 48,
"ListConfigs.configs.announce-addr-discovered": 54,
Expand Down Expand Up @@ -1688,6 +1691,22 @@
"ListConfigs.configs.allow-deprecated-apis.source": 2,
"ListConfigs.configs.allow-deprecated-apis.value_bool": 1
},
"ListconfigsConfigsAlt-addr": {
"ListConfigs.configs.alt-addr.sources[]": 2,
"ListConfigs.configs.alt-addr.values_str[]": 1
},
"ListconfigsConfigsAlt-announce-addr": {
"ListConfigs.configs.alt-addr.sources[]": 2,
"ListConfigs.configs.alt-addr.values_str[]": 1,
"ListConfigs.configs.alt-announce-addr.sources[]": 2,
"ListConfigs.configs.alt-announce-addr.values_str[]": 1
},
"ListconfigsConfigsAlt-bind-addr": {
"ListConfigs.configs.alt-addr.sources[]": 2,
"ListConfigs.configs.alt-addr.values_str[]": 1,
"ListConfigs.configs.alt-bind-addr.sources[]": 2,
"ListConfigs.configs.alt-bind-addr.values_str[]": 1
},
"ListconfigsConfigsAlways-use-proxy": {
"ListConfigs.configs.always-use-proxy.source": 2,
"ListConfigs.configs.always-use-proxy.value_bool": 1
Expand Down Expand Up @@ -6746,6 +6765,42 @@
"added": "pre-v0.10.1",
"deprecated": null
},
"ListConfigs.configs.alt-addr": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.alt-addr.sources[]": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.alt-addr.values_str[]": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.alt-announce-addr": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.alt-announce-addr.sources[]": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.alt-announce-addr.values_str[]": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.alt-bind-addr": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.alt-bind-addr.sources[]": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.alt-bind-addr.values_str[]": {
"added": "v24.11",
"deprecated": false
},
"ListConfigs.configs.always-use-proxy": {
"added": "pre-v0.10.1",
"deprecated": null
Expand Down Expand Up @@ -11687,4 +11742,4 @@
"deprecated": null
}
}
}
}
10 changes: 9 additions & 1 deletion channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ struct peer {
bool channel_ready[NUM_SIDES];
u64 next_index[NUM_SIDES];

/* ID of peer */
struct node_id id;

/* --developer? */
bool developer;

Expand Down Expand Up @@ -169,6 +172,9 @@ struct peer {
u64 revocations_received;
u8 channel_flags;

/* Alt address for peer connections not publicly announced */
u8 *my_alt_addr;

/* Make sure timestamps move forward. */
u32 last_update_timestamp;

Expand Down Expand Up @@ -5847,7 +5853,9 @@ static void init_channel(struct peer *peer)
&reestablish_only,
&peer->experimental_upgrade,
&peer->splice_state->inflights,
&peer->local_alias)) {
&peer->local_alias,
&peer->my_alt_addr,
&peer->id)) {
master_badmsg(WIRE_CHANNELD_INIT, msg);
}

Expand Down
3 changes: 3 additions & 0 deletions channeld/channeld_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ msgdata,channeld_init,experimental_upgrade,bool,
msgdata,channeld_init,num_inflights,u16,
msgdata,channeld_init,inflights,inflight,num_inflights
msgdata,channeld_init,scid_alias,short_channel_id,
msgdata,channeld_init,alt_addr_len,u16,
msgdata,channeld_init,alt_addr,u8,alt_addr_len,
msgdata,channeld_init,id,node_id,

# channeld->lightningd: successfully negotated reestablishment.
msgtype,channeld_reestablished,1101
Expand Down
89 changes: 88 additions & 1 deletion contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17179,6 +17179,93 @@
}
}
},
"alt-addr": {
"type": "object",
"additionalProperties": false,
"required": [
"values_str",
"sources"
],
"properties": {
"values_str": {
"added": "v24.11",
"type": "array",
"items": {
"type": "string",
"description": [
"Field from config or cmdline."
]
}
},
"sources": {
"type": "array",
"items": {
"type": "string",
"description": [
"Source of configuration setting."
]
}
}
}
},
"alt-announce-addr": {
"type": "object",
"additionalProperties": false,
"required": [
"values_str",
"sources"
],
"properties": {
"values_str": {
"added": "v24.11",
"type": "array",
"items": {
"type": "string",
"description": [
"Field from config or cmdline."
]
}
},
"sources": {
"type": "array",
"items": {
"type": "string",
"description": [
"Source of configuration setting."
]
}
}
}
},
"alt-bind-addr": {
"type": "object",
"additionalProperties": false,
"required": [
"values_str",
"sources"
],
"properties": {
"values_str": {
"added": "v24.11",
"type": "array",
"items": {
"type": "string",
"description": [
"Field from config or cmdline."
]
}
},
"sources": {
"type": "array",
"items": {
"type": "string",
"description": [
"Source of configuration setting."
]
}
}
}
},
"autolisten": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -34924,4 +35011,4 @@
}
}
}
}
}
31 changes: 31 additions & 0 deletions doc/lightningd-config.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,37 @@ its use disables autolisten.
can be useful for maintenance and forensics, so is usually specified on
the command line. Overrides all *addr* and *bind-addr* options.

* **alt-addr**=*\[IPADDRESS\[:PORT\]]\*

Specify an alternative IP address (v4 or v6) and optionally a port,
to be used for selective private communications with established peers.
This address is used selectively, primarily for reconnections with known peers,
enhancing privacy. This address is not publicly announced.

An empty 'IPADDRESS' is a special value that clears any previously saved
alternate addresses, effectively resetting this setting. (Added in v24.11).

* **alt-bind-addr**=*\[IPADDRESS\[:PORT\]]\*

Bind an alternative IP address (v4 or v6) and optionally a port,
but hold it in reserve and do not automatically use it for peer connections.
This address can be used in specific scenarios where a non-public address is
preferred for incoming connections, offering more control over the connection process.

An empty 'IPADDRESS' is a special value that clears any previously saved
alternate bind addresses, effectively resetting this setting. (Added in v24.11).

* **alt-announce-addr**=*\[IPADDRESS\[:PORT\]]\*

Provide an alternative IP address (v4 or v6) and optionally a port,
which is bound by `alt-bind-addr`, to any established channel peers.
This address is given to peers with whom a channel is already established,
allowing for enhanced privacy. This address is not used for initial connections
but can be shared with trusted peers for future communications.

An empty 'IPADDRESS' is a special value that clears any previously saved
alternate announce addresses, effectively resetting this setting. (Added in v24.11).

* **autolisten**=*BOOL*

By default, we bind (and maybe announce) on IPv4 and IPv6 interfaces if
Expand Down
87 changes: 87 additions & 0 deletions doc/schemas/lightning-listconfigs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,93 @@
}
}
},
"alt-addr": {
"type": "object",
"additionalProperties": false,
"required": [
"values_str",
"sources"
],
"properties": {
"values_str": {
"added": "v24.11",
"type": "array",
"items": {
"type": "string",
"description": [
"Field from config or cmdline."
]
}
},
"sources": {
"type": "array",
"items": {
"type": "string",
"description": [
"Source of configuration setting."
]
}
}
}
},
"alt-announce-addr": {
"type": "object",
"additionalProperties": false,
"required": [
"values_str",
"sources"
],
"properties": {
"values_str": {
"added": "v24.11",
"type": "array",
"items": {
"type": "string",
"description": [
"Field from config or cmdline."
]
}
},
"sources": {
"type": "array",
"items": {
"type": "string",
"description": [
"Source of configuration setting."
]
}
}
}
},
"alt-bind-addr": {
"type": "object",
"additionalProperties": false,
"required": [
"values_str",
"sources"
],
"properties": {
"values_str": {
"added": "v24.11",
"type": "array",
"items": {
"type": "string",
"description": [
"Field from config or cmdline."
]
}
},
"sources": {
"type": "array",
"items": {
"type": "string",
"description": [
"Source of configuration setting."
]
}
}
}
},
"autolisten": {
"type": "object",
"additionalProperties": false,
Expand Down
4 changes: 3 additions & 1 deletion lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,9 @@ bool peer_start_channeld(struct channel *channel,
ld->experimental_upgrade_protocol,
cast_const2(const struct inflight **,
inflights),
*channel->alias[LOCAL]);
*channel->alias[LOCAL],
ld->alt_addr,
&ld->our_nodeid);

/* We don't expect a response: we are triggered by funding_depth_cb. */
subd_send_msg(channel->owner, take(initmsg));
Expand Down
2 changes: 2 additions & 0 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->recover_secret = NULL;
ld->db_upgrade_ok = NULL;
ld->num_startup_connects = 0;
ld->alt_addr = NULL;
ld->alt_bind_addr = NULL;

/* --experimental-upgrade-protocol */
ld->experimental_upgrade_protocol = false;
Expand Down
5 changes: 5 additions & 0 deletions lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ struct lightningd {
struct wireaddr_internal *binding;
struct wireaddr *announceable;

/* Alternative address for peer connections not publicly announced */
u8 *alt_addr;
/* Alternative binding address for peer connections not publicly announced */
u8 *alt_bind_addr;

Comment on lines +197 to +201
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very strange type to use! We have a struct wireaddr, which is far more convenient, and has the bonus we parse it immediately.

/* Current node announcement (if any) */
const u8 *node_announcement;

Expand Down
Loading