Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
- name: Install Rust ${{ matrix.toolchain }} toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
rustup override set ${{ matrix.toolchain }}
- name: Check formatting on Rust ${{ matrix.toolchain }}
if: matrix.check-fmt
run: rustup component add rustfmt && cargo fmt --all -- --check
Expand Down
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
Copy link
Contributor

Choose a reason for hiding this comment

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

If I simply run cargo fmt, isn't that supposed to just work?

~/repo/ldk-node (2025-10-switch-to-nightly-rustfmt ✔) cargo fmt       
Warning: can't set `format_code_in_doc_comments = true`, unstable features are only available in nightly channel.
Warning: can't set `comment_width = 100`, unstable features are only available in nightly channel.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am worried now about IDE support

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, do you happen to have set an override for LDK Node? I.e., rustup override set XXX? Otherwise it should indeed use what's inteh rust-toolchain.toml.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What happens in your case if you do:

?main ~/workspace/ldk-node> cargo fmt --version
rustfmt 1.8.0-stable (1159e78c47 2025-09-14)
?main ~/workspace/ldk-node> git checkout 2025-10-switch-to-nightly-rustfmt
Switched to branch '2025-10-switch-to-nightly-rustfmt'
Your branch is up to date with 'origin/2025-10-switch-to-nightly-rustfmt'.
?2025-10-switch-to-nightly-rustfmt ~/workspace/ldk-node> cargo fmt --version
rustfmt 1.8.0-nightly (f6aa851dba 2025-10-07)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that was it indeed. Had been reproducing issues on older rust version with the override. All good then. Farewell to the import nits 😎

channel = "nightly-2025-10-08"
components = [ "rustfmt" ]
profile = "minimal"
21 changes: 13 additions & 8 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ hard_tabs = true
use_field_init_shorthand = true
max_width = 100
match_block_trailing_comma = true
# UNSTABLE: format_code_in_doc_comments = true
# UNSTABLE: overflow_delimited_expr = true
# UNSTABLE: comment_width = 100
# UNSTABLE: format_macro_matchers = true
# UNSTABLE: format_strings = true
# UNSTABLE: group_imports = "StdExternalCrate"
# UNSTABLE: reorder_imports = true
# UNSTABLE: imports_granularity = "Module"
format_code_in_doc_comments = true
overflow_delimited_expr = true
comment_width = 100
format_macro_matchers = true
group_imports = "StdExternalCrate"
reorder_imports = true
imports_granularity = "Module"
normalize_comments = true
normalize_doc_attributes = true
style_edition = "2021"
# TBD: do we want comment and string wrapping?
#wrap_comments = true
#format_strings = true
7 changes: 3 additions & 4 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,9 @@ impl NodeBuilder {
derive_xprv(config, &seed_bytes, VSS_HARDENED_CHILD_INDEX, Arc::clone(&logger))?;

let lnurl_auth_xprv = vss_xprv
.derive_priv(
&Secp256k1::new(),
&[ChildNumber::Hardened { index: VSS_LNURL_AUTH_HARDENED_CHILD_INDEX }],
)
.derive_priv(&Secp256k1::new(), &[ChildNumber::Hardened {
index: VSS_LNURL_AUTH_HARDENED_CHILD_INDEX,
}])
.map_err(|e| {
log_error!(logger, "Failed to derive VSS secret: {}", e);
BuildError::KVStoreSetupFailed
Expand Down
10 changes: 5 additions & 5 deletions src/chain/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl BitcoindChainSource {

pub(super) async fn update_fee_rate_estimates(&self) -> Result<(), Error> {
macro_rules! get_fee_rate_update {
($estimation_fut: expr) => {{
($estimation_fut:expr) => {{
let update_res = tokio::time::timeout(
Duration::from_secs(FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS),
$estimation_fut,
Expand Down Expand Up @@ -701,10 +701,10 @@ impl BitcoindClient {
let num_blocks_json = serde_json::json!(num_blocks);
let estimation_mode_json = serde_json::json!(estimation_mode);
rpc_client
.call_method::<FeeResponse>(
"estimatesmartfee",
&[num_blocks_json, estimation_mode_json],
)
.call_method::<FeeResponse>("estimatesmartfee", &[
num_blocks_json,
estimation_mode_json,
])
.await
.map(|resp| resp.0)
}
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use lightning::ln::functional_test_utils::{
use lightning::util::persist::{
KVStoreSync, MonitorUpdatingPersister, KVSTORE_NAMESPACE_KEY_MAX_LEN,
};

use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
use rand::distributions::Alphanumeric;
Expand Down Expand Up @@ -149,7 +148,7 @@ pub(crate) fn do_test_store<K: KVStoreSync + Sync>(store_0: &K, store_1: &K) {

// Helper to make sure the channel is on the expected update ID.
macro_rules! check_persisted_data {
($expected_update_id: expr) => {
($expected_update_id:expr) => {
persisted_chan_data_0 = persister_0.read_all_channel_monitors_with_updates().unwrap();
assert_eq!(persisted_chan_data_0.len(), 1);
for (_, mon) in persisted_chan_data_0.iter() {
Expand Down
9 changes: 8 additions & 1 deletion src/io/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,14 @@ pub(crate) fn check_namespace_key_validity(
}

macro_rules! impl_read_write_change_set_type {
( $read_name: ident, $write_name: ident, $change_set_type:ty, $primary_namespace: expr, $secondary_namespace: expr, $key: expr ) => {
(
$read_name:ident,
$write_name:ident,
$change_set_type:ty,
$primary_namespace:expr,
$secondary_namespace:expr,
$key:expr
) => {
pub(crate) fn $read_name<L: Deref>(
kv_store: Arc<DynStore>, logger: L,
) -> Result<Option<$change_set_type>, std::io::Error>
Expand Down
16 changes: 9 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@
//! ```no_run
//! # #[cfg(not(feature = "uniffi"))]
//! # {
//! use ldk_node::Builder;
//! use ldk_node::lightning_invoice::Bolt11Invoice;
//! use ldk_node::lightning::ln::msgs::SocketAddress;
//! use ldk_node::bitcoin::Network;
//! use ldk_node::bitcoin::secp256k1::PublicKey;
//! use std::str::FromStr;
//!
//! use ldk_node::bitcoin::secp256k1::PublicKey;
//! use ldk_node::bitcoin::Network;
//! use ldk_node::lightning::ln::msgs::SocketAddress;
//! use ldk_node::lightning_invoice::Bolt11Invoice;
//! use ldk_node::Builder;
//!
//! fn main() {
//! let mut builder = Builder::new();
//! builder.set_network(Network::Testnet);
//! builder.set_chain_source_esplora("https://blockstream.info/testnet/api".to_string(), None);
//! builder.set_gossip_source_rgs("https://rapidsync.lightningdevkit.org/testnet/snapshot".to_string());
//! builder.set_gossip_source_rgs(
//! "https://rapidsync.lightningdevkit.org/testnet/snapshot".to_string(),
//! );
//!
//! let node = builder.build().unwrap();
//!
Expand Down Expand Up @@ -67,7 +70,6 @@
//! [`stop`]: Node::stop
//! [`open_channel`]: Node::open_channel
//! [`send`]: Bolt11Payment::send
//!
#![cfg_attr(not(feature = "uniffi"), deny(missing_docs))]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]
Expand Down
12 changes: 4 additions & 8 deletions src/payment/asynchronous/static_invoice_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,10 @@ mod tests {
}

fn blinded_path() -> BlindedMessagePath {
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
BlindedHop { blinded_node_id: pubkey(42), encrypted_payload: vec![0; 43] },
BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 44] },
],
)
BlindedMessagePath::from_blinded_path(pubkey(40), pubkey(41), vec![
BlindedHop { blinded_node_id: pubkey(42), encrypted_payload: vec![0; 43] },
BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 44] },
])
}

fn pubkey(byte: u8) -> PublicKey {
Expand Down
2 changes: 1 addition & 1 deletion src/payment/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type FeeRate = bitcoin::FeeRate;
type FeeRate = Arc<bitcoin::FeeRate>;

macro_rules! maybe_map_fee_rate_opt {
($fee_rate_opt: expr) => {{
($fee_rate_opt:expr) => {{
#[cfg(not(feature = "uniffi"))]
{
$fee_rate_opt
Expand Down
2 changes: 1 addition & 1 deletion src/payment/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl StorableObject for PaymentDetails {
let mut updated = false;

macro_rules! update_if_necessary {
($val: expr, $update: expr) => {
($val:expr, $update:expr) => {
if $val != $update {
$val = $update;
updated = true;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ impl Wallet {
script_pubkey: ScriptBuf::new_witness_program(&witness_program),
},
satisfaction_weight: 1 /* empty script_sig */ * WITNESS_SCALE_FACTOR as u64 +
1 /* witness items */ + 1 /* schnorr sig len */ + 64, /* schnorr sig */
1 /* witness items */ + 1 /* schnorr sig len */ + 64, // schnorr sig
};
utxos.push(utxo);
},
Expand Down
14 changes: 7 additions & 7 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use rand::{thread_rng, Rng};
use serde_json::{json, Value};

macro_rules! expect_event {
($node: expr, $event_type: ident) => {{
($node:expr, $event_type:ident) => {{
match $node.wait_next_event() {
ref e @ Event::$event_type { .. } => {
println!("{} got event {:?}", $node.node_id(), e);
Expand All @@ -64,7 +64,7 @@ macro_rules! expect_event {
pub(crate) use expect_event;

macro_rules! expect_channel_pending_event {
($node: expr, $counterparty_node_id: expr) => {{
($node:expr, $counterparty_node_id:expr) => {{
match $node.wait_next_event() {
ref e @ Event::ChannelPending { funding_txo, counterparty_node_id, .. } => {
println!("{} got event {:?}", $node.node_id(), e);
Expand All @@ -82,7 +82,7 @@ macro_rules! expect_channel_pending_event {
pub(crate) use expect_channel_pending_event;

macro_rules! expect_channel_ready_event {
($node: expr, $counterparty_node_id: expr) => {{
($node:expr, $counterparty_node_id:expr) => {{
match $node.wait_next_event() {
ref e @ Event::ChannelReady { user_channel_id, counterparty_node_id, .. } => {
println!("{} got event {:?}", $node.node_id(), e);
Expand All @@ -100,7 +100,7 @@ macro_rules! expect_channel_ready_event {
pub(crate) use expect_channel_ready_event;

macro_rules! expect_payment_received_event {
($node: expr, $amount_msat: expr) => {{
($node:expr, $amount_msat:expr) => {{
match $node.wait_next_event() {
ref e @ Event::PaymentReceived { payment_id, amount_msat, .. } => {
println!("{} got event {:?}", $node.node_id(), e);
Expand All @@ -122,7 +122,7 @@ macro_rules! expect_payment_received_event {
pub(crate) use expect_payment_received_event;

macro_rules! expect_payment_claimable_event {
($node: expr, $payment_id: expr, $payment_hash: expr, $claimable_amount_msat: expr) => {{
($node:expr, $payment_id:expr, $payment_hash:expr, $claimable_amount_msat:expr) => {{
match $node.wait_next_event() {
ref e @ Event::PaymentClaimable {
payment_id,
Expand All @@ -147,7 +147,7 @@ macro_rules! expect_payment_claimable_event {
pub(crate) use expect_payment_claimable_event;

macro_rules! expect_payment_successful_event {
($node: expr, $payment_id: expr, $fee_paid_msat: expr) => {{
($node:expr, $payment_id:expr, $fee_paid_msat:expr) => {{
match $node.wait_next_event() {
ref e @ Event::PaymentSuccessful { payment_id, fee_paid_msat, .. } => {
println!("{} got event {:?}", $node.node_id(), e);
Expand Down Expand Up @@ -269,7 +269,7 @@ pub(crate) struct TestConfig {
}

macro_rules! setup_builder {
($builder: ident, $config: expr) => {
($builder:ident, $config:expr) => {
#[cfg(feature = "uniffi")]
let $builder = Builder::from_config($config.clone());
#[cfg(not(feature = "uniffi"))]
Expand Down
16 changes: 8 additions & 8 deletions tests/integration_tests_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ fn run_rbf_test(is_insert_block: bool) {
let chain_source_esplora = TestChainSource::Esplora(&electrsd);

macro_rules! config_node {
($chain_source: expr, $anchor_channels: expr) => {{
($chain_source:expr, $anchor_channels:expr) => {{
let config_a = random_config($anchor_channels);
let node = setup_node(&$chain_source, config_a, None);
node
Expand Down Expand Up @@ -719,7 +719,7 @@ fn run_rbf_test(is_insert_block: bool) {
};
}
macro_rules! validate_balances {
($expected_balance_sat: expr, $is_spendable: expr) => {
($expected_balance_sat:expr, $is_spendable:expr) => {
let spend_balance = if $is_spendable { $expected_balance_sat } else { 0 };
for node in &nodes {
node.sync_wallets().unwrap();
Expand Down Expand Up @@ -972,8 +972,8 @@ fn simple_bolt12_send_receive() {
assert_eq!(offer_id, offer.id());
assert_eq!(&expected_quantity, qty);
assert_eq!(expected_payer_note.unwrap(), note.clone().unwrap().0);
//TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
//API currently doesn't allow to do that.
// TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
// API currently doesn't allow to do that.
},
_ => {
panic!("Unexpected payment kind");
Expand Down Expand Up @@ -1038,8 +1038,8 @@ fn simple_bolt12_send_receive() {
assert_eq!(offer_id, offer.id());
assert_eq!(&expected_quantity, qty);
assert_eq!(expected_payer_note.unwrap(), note.clone().unwrap().0);
//TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
//API currently doesn't allow to do that.
// TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
// API currently doesn't allow to do that.
hash.unwrap()
},
_ => {
Expand Down Expand Up @@ -1104,8 +1104,8 @@ fn simple_bolt12_send_receive() {
assert!(preimage.is_some());
assert_eq!(&expected_quantity, qty);
assert_eq!(expected_payer_note.unwrap(), note.clone().unwrap().0)
//TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
//API currently doesn't allow to do that.
// TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
// API currently doesn't allow to do that.
},
_ => {
panic!("Unexpected payment kind");
Expand Down
Loading