Skip to content

Commit 972ac39

Browse files
committed
Add MessagePaddingPrototype feature and UserConfig option
We add prototypical support for the `option_message_padding` feature while the BOLTs PR is still underway.
1 parent bb5504e commit 972ac39

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

lightning-types/src/features.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
//! (see [BOLT PR #1160](https://github.com/lightning/bolts/pull/1160) for more information).
8484
//! - `HtlcHold` - requires/supports holding HTLCs and forwarding on receipt of an onion message
8585
//! (see [BOLT-2](https://github.com/lightning/bolts/pull/989/files) for more information).
86+
//! - `MessagePaddingPrototype` - requires/supports padding of network messages for improved privacy
87+
//! (see [BOLT-1](https://github.com/lightning/bolts/pull/1304) for more information).
8688
//!
8789
//! LDK knows about the following features, but does not support them:
8890
//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be
@@ -174,7 +176,7 @@ mod sealed {
174176
// Byte 18
175177
,
176178
// Byte 19
177-
HtlcHold | SplicePrototype,
179+
HtlcHold | SplicePrototype | MessagePaddingPrototype,
178180
]
179181
);
180182
define_context!(
@@ -732,6 +734,17 @@ mod sealed {
732734
supports_splicing,
733735
requires_splicing
734736
);
737+
define_feature!(
738+
157, // BOLTs PR uses 64/65
739+
MessagePaddingPrototype,
740+
[InitContext],
741+
"Feature flags for network message padding.",
742+
set_message_padding_optional,
743+
set_message_padding_required,
744+
clear_message_padding,
745+
supports_message_padding,
746+
requires_message_padding
747+
);
735748
define_feature!(
736749
259,
737750
DnsResolver,

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15876,6 +15876,14 @@ pub fn provided_init_features(config: &UserConfig) -> InitFeatures {
1587615876
features.set_htlc_hold_optional();
1587715877
}
1587815878

15879+
if config.enable_htlc_hold {
15880+
features.set_htlc_hold_optional();
15881+
}
15882+
15883+
if config.enable_message_padding {
15884+
features.set_message_padding_optional();
15885+
}
15886+
1587915887
features
1588015888
}
1588115889

lightning/src/util/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,14 @@ pub struct UserConfig {
973973
///
974974
/// [`ChannelManager::splice_channel`]: crate::ln::channelmanager::ChannelManager::splice_channel
975975
pub reject_inbound_splices: bool,
976+
/// If this set to `true`, then we will negotiate support for padding network messages with our
977+
/// counterparty. If both parties agree, network messages will be padded to a fixed length to
978+
/// improve privacy in the face of an adversary monitoring network traffic.
979+
///
980+
/// Nodes which are heavily bandwidth-restricted might want to set this to `false`.
981+
///
982+
/// Default value: `true`
983+
pub enable_message_padding: bool,
976984
}
977985

978986
impl Default for UserConfig {
@@ -990,6 +998,7 @@ impl Default for UserConfig {
990998
enable_htlc_hold: false,
991999
hold_outbound_htlcs_at_next_hop: false,
9921000
reject_inbound_splices: true,
1001+
enable_message_padding: true,
9931002
}
9941003
}
9951004
}
@@ -1013,6 +1022,7 @@ impl Readable for UserConfig {
10131022
hold_outbound_htlcs_at_next_hop: Readable::read(reader)?,
10141023
enable_htlc_hold: Readable::read(reader)?,
10151024
reject_inbound_splices: Readable::read(reader)?,
1025+
enable_message_padding: Readable::read(reader)?,
10161026
})
10171027
}
10181028
}

0 commit comments

Comments
 (0)