Skip to content

Commit cf05abf

Browse files
committed
Switch to nightly rustfmt
1 parent e4bb615 commit cf05abf

32 files changed

+758
-437
lines changed

.github/workflows/rust.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
- name: Install Rust ${{ matrix.toolchain }} toolchain
3939
run: |
4040
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
41-
rustup override set ${{ matrix.toolchain }}
4241
- name: Check formatting on Rust ${{ matrix.toolchain }}
4342
if: matrix.check-fmt
4443
run: rustup component add rustfmt && cargo fmt --all -- --check

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "nightly-2025-10-08"
3+
components = [ "rustfmt" ]
4+
profile = "minimal"

rustfmt.toml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ hard_tabs = true
44
use_field_init_shorthand = true
55
max_width = 100
66
match_block_trailing_comma = true
7-
# UNSTABLE: format_code_in_doc_comments = true
8-
# UNSTABLE: overflow_delimited_expr = true
9-
# UNSTABLE: comment_width = 100
10-
# UNSTABLE: format_macro_matchers = true
11-
# UNSTABLE: format_strings = true
12-
# UNSTABLE: group_imports = "StdExternalCrate"
13-
# UNSTABLE: reorder_imports = true
14-
# UNSTABLE: imports_granularity = "Module"
7+
format_code_in_doc_comments = true
8+
overflow_delimited_expr = true
9+
comment_width = 100
10+
format_macro_matchers = true
11+
format_strings = true
12+
group_imports = "StdExternalCrate"
13+
reorder_imports = true
14+
imports_granularity = "Module"
15+
wrap_comments = true
16+
normalize_comments = true
17+
normalize_doc_attributes = true
18+
style_edition = "2021"

src/balance.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ pub enum LightningBalance {
9494
/// [`LightningBalance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as
9595
/// any dust HTLCs which would otherwise be represented the same.
9696
///
97-
/// This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`.
97+
/// This amount (rounded up to a whole satoshi value) will not be included in
98+
/// `amount_satoshis`.
9899
outbound_payment_htlc_rounded_msat: u64,
99100
/// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound
100101
/// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part
@@ -103,16 +104,17 @@ pub enum LightningBalance {
103104
/// [`LightningBalance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as
104105
/// well as any dust HTLCs which would otherwise be represented the same.
105106
///
106-
/// This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`.
107+
/// This amount (rounded up to a whole satoshi value) will not be included in
108+
/// `amount_satoshis`.
107109
outbound_forwarded_htlc_rounded_msat: u64,
108110
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
109111
/// to us and for which we know the preimage. This is the sum of the millisatoshis part of
110112
/// all HTLCs which would be represented by [`LightningBalance::ContentiousClaimable`] on
111113
/// channel close, but whose current value is included in `amount_satoshis`, as well as any
112114
/// dust HTLCs which would otherwise be represented the same.
113115
///
114-
/// This amount (rounded up to a whole satoshi value) will not be included in the counterparty's
115-
/// `amount_satoshis`.
116+
/// This amount (rounded up to a whole satoshi value) will not be included in the
117+
/// counterparty's `amount_satoshis`.
116118
inbound_claiming_htlc_rounded_msat: u64,
117119
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
118120
/// to us and for which we do not know the preimage. This is the sum of the millisatoshis
@@ -229,7 +231,8 @@ impl LightningBalance {
229231
inbound_claiming_htlc_rounded_msat,
230232
inbound_htlc_rounded_msat,
231233
} => {
232-
// unwrap safety: confirmed_balance_candidate_index is guaranteed to index into balance_candidates
234+
// unwrap safety: confirmed_balance_candidate_index is guaranteed to index into
235+
// balance_candidates
233236
let balance = balance_candidates.get(confirmed_balance_candidate_index).unwrap();
234237

235238
Self::ClaimableOnChannelClose {
@@ -305,8 +308,8 @@ impl LightningBalance {
305308
/// Details about the status of a known balance currently being swept to our on-chain wallet.
306309
#[derive(Debug, Clone)]
307310
pub enum PendingSweepBalance {
308-
/// The spendable output is about to be swept, but a spending transaction has yet to be generated and
309-
/// broadcast.
311+
/// The spendable output is about to be swept, but a spending transaction has yet to be
312+
/// generated and broadcast.
310313
PendingBroadcast {
311314
/// The identifier of the channel this balance belongs to.
312315
channel_id: Option<ChannelId>,

src/builder.rs

Lines changed: 71 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ pub enum BuildError {
183183
LoggerSetupFailed,
184184
/// The given network does not match the node's previously configured network.
185185
NetworkMismatch,
186-
/// The role of the node in an asynchronous payments context is not compatible with the current configuration.
186+
/// The role of the node in an asynchronous payments context is not compatible with the current
187+
/// configuration.
187188
AsyncPaymentsConfigMismatch,
188189
}
189190

@@ -325,8 +326,8 @@ impl NodeBuilder {
325326

326327
/// Configures the [`Node`] instance to source its chain data from the given Esplora server.
327328
///
328-
/// The given `headers` will be included in all requests to the Esplora server, typically used for
329-
/// authentication purposes.
329+
/// The given `headers` will be included in all requests to the Esplora server, typically used
330+
/// for authentication purposes.
330331
///
331332
/// If no `sync_config` is given, default values are used. See [`EsploraSyncConfig`] for more
332333
/// information.
@@ -353,12 +354,12 @@ impl NodeBuilder {
353354

354355
/// Configures the [`Node`] instance to connect to a Bitcoin Core node via RPC.
355356
///
356-
/// This method establishes an RPC connection that enables all essential chain operations including
357-
/// transaction broadcasting and chain data synchronization.
357+
/// This method establishes an RPC connection that enables all essential chain operations
358+
/// including transaction broadcasting and chain data synchronization.
358359
///
359360
/// ## Parameters:
360-
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin Core RPC
361-
/// connection.
361+
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin
362+
/// Core RPC connection.
362363
pub fn set_chain_source_bitcoind_rpc(
363364
&mut self, rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String,
364365
) -> &mut Self {
@@ -372,15 +373,16 @@ impl NodeBuilder {
372373
self
373374
}
374375

375-
/// Configures the [`Node`] instance to synchronize chain data from a Bitcoin Core REST endpoint.
376+
/// Configures the [`Node`] instance to synchronize chain data from a Bitcoin Core REST
377+
/// endpoint.
376378
///
377379
/// This method enables chain data synchronization via Bitcoin Core's REST interface. We pass
378380
/// additional RPC configuration to non-REST-supported API calls like transaction broadcasting.
379381
///
380382
/// ## Parameters:
381383
/// * `rest_host`, `rest_port` - Required parameters for the Bitcoin Core REST connection.
382-
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin Core RPC
383-
/// connection
384+
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin
385+
/// Core RPC connection
384386
pub fn set_chain_source_bitcoind_rest(
385387
&mut self, rest_host: String, rest_port: u16, rpc_host: String, rpc_port: u16,
386388
rpc_user: String, rpc_password: String,
@@ -413,7 +415,8 @@ impl NodeBuilder {
413415
/// Configures the [`Node`] instance to source inbound liquidity from the given
414416
/// [bLIP-51 / LSPS1] service.
415417
///
416-
/// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
418+
/// Will mark the LSP as trusted for 0-confirmation channels, see
419+
/// [`Config::trusted_peers_0conf`].
417420
///
418421
/// The given `token` will be used by the LSP to authenticate the user.
419422
///
@@ -434,7 +437,8 @@ impl NodeBuilder {
434437
/// Configures the [`Node`] instance to source just-in-time inbound liquidity from the given
435438
/// [bLIP-52 / LSPS2] service.
436439
///
437-
/// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
440+
/// Will mark the LSP as trusted for 0-confirmation channels, see
441+
/// [`Config::trusted_peers_0conf`].
438442
///
439443
/// The given `token` will be used by the LSP to authenticate the user.
440444
///
@@ -507,7 +511,8 @@ impl NodeBuilder {
507511
self
508512
}
509513

510-
/// Sets the IP address and TCP port on which [`Node`] will listen for incoming network connections.
514+
/// Sets the IP address and TCP port on which [`Node`] will listen for incoming network
515+
/// connections.
511516
pub fn set_listening_addresses(
512517
&mut self, listening_addresses: Vec<SocketAddress>,
513518
) -> Result<&mut Self, BuildError> {
@@ -519,9 +524,11 @@ impl NodeBuilder {
519524
Ok(self)
520525
}
521526

522-
/// Sets the IP address and TCP port which [`Node`] will announce to the gossip network that it accepts connections on.
527+
/// Sets the IP address and TCP port which [`Node`] will announce to the gossip network that it
528+
/// accepts connections on.
523529
///
524-
/// **Note**: If unset, the [`listening_addresses`] will be used as the list of addresses to announce.
530+
/// **Note**: If unset, the [`listening_addresses`] will be used as the list of addresses to
531+
/// announce.
525532
///
526533
/// [`listening_addresses`]: Self::set_listening_addresses
527534
pub fn set_announcement_addresses(
@@ -593,11 +600,12 @@ impl NodeBuilder {
593600
/// Builds a [`Node`] instance with a [VSS] backend and according to the options
594601
/// previously configured.
595602
///
596-
/// Uses [LNURL-auth] based authentication scheme as default method for authentication/authorization.
603+
/// Uses [LNURL-auth] based authentication scheme as default method for
604+
/// authentication/authorization.
597605
///
598-
/// The LNURL challenge will be retrieved by making a request to the given `lnurl_auth_server_url`.
599-
/// The returned JWT token in response to the signed LNURL request, will be used for
600-
/// authentication/authorization of all the requests made to VSS.
606+
/// The LNURL challenge will be retrieved by making a request to the given
607+
/// `lnurl_auth_server_url`. The returned JWT token in response to the signed LNURL request,
608+
/// will be used for authentication/authorization of all the requests made to VSS.
601609
///
602610
/// `fixed_headers` are included as it is in all the requests made to VSS and LNURL auth server.
603611
///
@@ -627,10 +635,9 @@ impl NodeBuilder {
627635
derive_xprv(config, &seed_bytes, VSS_HARDENED_CHILD_INDEX, Arc::clone(&logger))?;
628636

629637
let lnurl_auth_xprv = vss_xprv
630-
.derive_priv(
631-
&Secp256k1::new(),
632-
&[ChildNumber::Hardened { index: VSS_LNURL_AUTH_HARDENED_CHILD_INDEX }],
633-
)
638+
.derive_priv(&Secp256k1::new(), &[ChildNumber::Hardened {
639+
index: VSS_LNURL_AUTH_HARDENED_CHILD_INDEX,
640+
}])
634641
.map_err(|e| {
635642
log_error!(logger, "Failed to derive VSS secret: {}", e);
636643
BuildError::KVStoreSetupFailed
@@ -829,8 +836,8 @@ impl ArcedNodeBuilder {
829836

830837
/// Configures the [`Node`] instance to source its chain data from the given Esplora server.
831838
///
832-
/// The given `headers` will be included in all requests to the Esplora server, typically used for
833-
/// authentication purposes.
839+
/// The given `headers` will be included in all requests to the Esplora server, typically used
840+
/// for authentication purposes.
834841
///
835842
/// If no `sync_config` is given, default values are used. See [`EsploraSyncConfig`] for more
836843
/// information.
@@ -857,12 +864,12 @@ impl ArcedNodeBuilder {
857864

858865
/// Configures the [`Node`] instance to connect to a Bitcoin Core node via RPC.
859866
///
860-
/// This method establishes an RPC connection that enables all essential chain operations including
861-
/// transaction broadcasting and chain data synchronization.
867+
/// This method establishes an RPC connection that enables all essential chain operations
868+
/// including transaction broadcasting and chain data synchronization.
862869
///
863870
/// ## Parameters:
864-
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin Core RPC
865-
/// connection.
871+
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin
872+
/// Core RPC connection.
866873
pub fn set_chain_source_bitcoind_rpc(
867874
&self, rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String,
868875
) {
@@ -874,15 +881,16 @@ impl ArcedNodeBuilder {
874881
);
875882
}
876883

877-
/// Configures the [`Node`] instance to synchronize chain data from a Bitcoin Core REST endpoint.
884+
/// Configures the [`Node`] instance to synchronize chain data from a Bitcoin Core REST
885+
/// endpoint.
878886
///
879887
/// This method enables chain data synchronization via Bitcoin Core's REST interface. We pass
880888
/// additional RPC configuration to non-REST-supported API calls like transaction broadcasting.
881889
///
882890
/// ## Parameters:
883891
/// * `rest_host`, `rest_port` - Required parameters for the Bitcoin Core REST connection.
884-
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin Core RPC
885-
/// connection
892+
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin
893+
/// Core RPC connection
886894
pub fn set_chain_source_bitcoind_rest(
887895
&self, rest_host: String, rest_port: u16, rpc_host: String, rpc_port: u16,
888896
rpc_user: String, rpc_password: String,
@@ -912,7 +920,8 @@ impl ArcedNodeBuilder {
912920
/// Configures the [`Node`] instance to source inbound liquidity from the given
913921
/// [bLIP-51 / LSPS1] service.
914922
///
915-
/// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
923+
/// Will mark the LSP as trusted for 0-confirmation channels, see
924+
/// [`Config::trusted_peers_0conf`].
916925
///
917926
/// The given `token` will be used by the LSP to authenticate the user.
918927
///
@@ -926,7 +935,8 @@ impl ArcedNodeBuilder {
926935
/// Configures the [`Node`] instance to source just-in-time inbound liquidity from the given
927936
/// [bLIP-52 / LSPS2] service.
928937
///
929-
/// Will mark the LSP as trusted for 0-confirmation channels, see [`Config::trusted_peers_0conf`].
938+
/// Will mark the LSP as trusted for 0-confirmation channels, see
939+
/// [`Config::trusted_peers_0conf`].
930940
///
931941
/// The given `token` will be used by the LSP to authenticate the user.
932942
///
@@ -982,16 +992,19 @@ impl ArcedNodeBuilder {
982992
self.inner.write().unwrap().set_network(network);
983993
}
984994

985-
/// Sets the IP address and TCP port on which [`Node`] will listen for incoming network connections.
995+
/// Sets the IP address and TCP port on which [`Node`] will listen for incoming network
996+
/// connections.
986997
pub fn set_listening_addresses(
987998
&self, listening_addresses: Vec<SocketAddress>,
988999
) -> Result<(), BuildError> {
9891000
self.inner.write().unwrap().set_listening_addresses(listening_addresses).map(|_| ())
9901001
}
9911002

992-
/// Sets the IP address and TCP port which [`Node`] will announce to the gossip network that it accepts connections on.
1003+
/// Sets the IP address and TCP port which [`Node`] will announce to the gossip network that it
1004+
/// accepts connections on.
9931005
///
994-
/// **Note**: If unset, the [`listening_addresses`] will be used as the list of addresses to announce.
1006+
/// **Note**: If unset, the [`listening_addresses`] will be used as the list of addresses to
1007+
/// announce.
9951008
///
9961009
/// [`listening_addresses`]: Self::set_listening_addresses
9971010
pub fn set_announcement_addresses(
@@ -1030,11 +1043,12 @@ impl ArcedNodeBuilder {
10301043
/// Builds a [`Node`] instance with a [VSS] backend and according to the options
10311044
/// previously configured.
10321045
///
1033-
/// Uses [LNURL-auth] based authentication scheme as default method for authentication/authorization.
1046+
/// Uses [LNURL-auth] based authentication scheme as default method for
1047+
/// authentication/authorization.
10341048
///
1035-
/// The LNURL challenge will be retrieved by making a request to the given `lnurl_auth_server_url`.
1036-
/// The returned JWT token in response to the signed LNURL request, will be used for
1037-
/// authentication/authorization of all the requests made to VSS.
1049+
/// The LNURL challenge will be retrieved by making a request to the given
1050+
/// `lnurl_auth_server_url`. The returned JWT token in response to the signed LNURL request,
1051+
/// will be used for authentication/authorization of all the requests made to VSS.
10381052
///
10391053
/// `fixed_headers` are included as it is in all the requests made to VSS and LNURL auth server.
10401054
///
@@ -1116,7 +1130,12 @@ fn build_with_store_internal(
11161130

11171131
if let Err(err) = may_announce_channel(&config) {
11181132
if config.announcement_addresses.is_some() {
1119-
log_error!(logger, "Announcement addresses were set but some required configuration options for node announcement are missing: {}", err);
1133+
log_error!(
1134+
logger,
1135+
"Announcement addresses were set but some required configuration options for node \
1136+
announcement are missing: {}",
1137+
err
1138+
);
11201139
let build_error = if matches!(err, AnnounceError::MissingNodeAlias) {
11211140
BuildError::InvalidNodeAlias
11221141
} else {
@@ -1126,7 +1145,12 @@ fn build_with_store_internal(
11261145
}
11271146

11281147
if config.node_alias.is_some() {
1129-
log_error!(logger, "Node alias was set but some required configuration options for node announcement are missing: {}", err);
1148+
log_error!(
1149+
logger,
1150+
"Node alias was set but some required configuration options for node announcement \
1151+
are missing: {}",
1152+
err
1153+
);
11301154
return Err(BuildError::InvalidListeningAddresses);
11311155
}
11321156
}
@@ -1747,7 +1771,8 @@ fn optionally_install_rustls_cryptoprovider() {
17471771
static INIT_CRYPTO: Once = Once::new();
17481772

17491773
INIT_CRYPTO.call_once(|| {
1750-
// Ensure we always install a `CryptoProvider` for `rustls` if it was somehow not previously installed by now.
1774+
// Ensure we always install a `CryptoProvider` for `rustls` if it was somehow not previously
1775+
// installed by now.
17511776
if rustls::crypto::CryptoProvider::get_default().is_none() {
17521777
let _ = rustls::crypto::ring::default_provider().install_default();
17531778
}
@@ -1830,7 +1855,8 @@ fn derive_xprv(
18301855
})
18311856
}
18321857

1833-
/// Sanitize the user-provided node alias to ensure that it is a valid protocol-specified UTF-8 string.
1858+
/// Sanitize the user-provided node alias to ensure that it is a valid protocol-specified UTF-8
1859+
/// string.
18341860
pub(crate) fn sanitize_alias(alias_str: &str) -> Result<NodeAlias, BuildError> {
18351861
let alias = alias_str.trim();
18361862

0 commit comments

Comments
 (0)