Skip to content

Commit 3156251

Browse files
committed
chore: Update LDK v0.0.108 -> v0.0.110
- All patches upstreamed, back to using crates.io version - Remove `NodeAlias` - Fix various API-breaking changes mostly in accordance with ldk-sample v0.0.109: - https://github.com/lightningdevkit/rust-lightning/releases/tag/v0.0.109 - lightningdevkit/ldk-sample#62 v0.0.110: - https://github.com/lightningdevkit/rust-lightning/releases/tag/v0.0.110 - lightningdevkit/ldk-sample#66
1 parent c964b47 commit 3156251

File tree

8 files changed

+69
-132
lines changed

8 files changed

+69
-132
lines changed

Cargo.lock

Lines changed: 12 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/Cargo.toml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@ bitcoin-bech32 = "0.12"
1818

1919
# --- LIGHTNING --- #
2020

21-
# lightning = { version = "0.0.108", features = ["max_level_trace"] }
22-
# lightning-block-sync = { version = "0.0.108", features = [ "rpc-client" ] }
23-
# lightning-invoice = { version = "0.16" }
24-
# lightning-net-tokio = { version = "0.0.108" }
21+
# lightning = { version = "0.0.110", features = ["max_level_trace"] }
22+
# lightning-block-sync = { version = "0.0.110", features = [ "rpc-client" ] }
23+
lightning-invoice = { version = "0.18" }
24+
# lightning-net-tokio = { version = "0.0.110" }
2525

26-
# TODO Switch to back to crates.io version after LDK with lightning-net-tokio
27-
# patch is released
28-
# lightning = { git = "https://github.com/lexe-tech/rust-lightning", features = ["max_level_trace"], branch = "net-tokio-connect-v0.0.108" }
29-
# lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", features = [ "rpc-client" ], branch = "net-tokio-connect-v0.0.108" }
30-
lightning-invoice = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
31-
# lightning-net-tokio = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
26+
# lightning = { git = "https://github.com/lexe-tech/rust-lightning", features = ["max_level_trace"], branch = "main" }
27+
# lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", features = [ "rpc-client" ], branch = "main" }
28+
# lightning-invoice = { git = "https://github.com/lexe-tech/rust-lightning", branch = "main" }
29+
# lightning-net-tokio = { git = "https://github.com/lexe-tech/rust-lightning", branch = "main" }
3230

33-
# NOTE For debugging and testing patches during local development
31+
# For debugging and testing patches during local development
3432
# lightning = { path = "../../ldk/lightning", features = ["max_level_trace"]}
3533
# lightning-block-sync = { path = "../../ldk/lightning-block-sync", features = [ "rpc-client" ] }
3634
# lightning-invoice = { path = "../../ldk/lightning-invoice" }

common/src/cli.rs

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ pub struct StartArgs {
101101
#[argh(option, default = "Network::default()")]
102102
pub network: Network,
103103

104-
/// this node's Lightning Network alias
105-
#[argh(option, default = "NodeAlias::default()")]
106-
pub announced_node_name: NodeAlias,
107-
108104
/// whether the node should shut down after completing sync and other
109105
/// maintenance tasks. This only applies if no activity was detected prior
110106
/// to the completion of sync (which is usually what happens). Useful when
@@ -146,7 +142,6 @@ impl Default for StartArgs {
146142
warp_port: None,
147143
peer_port: None,
148144
network: Network::default(),
149-
announced_node_name: NodeAlias::default(),
150145
shutdown_after_sync_if_no_activity: false,
151146
inactivity_timer_sec: 3600,
152147
repl: false,
@@ -171,8 +166,6 @@ impl StartArgs {
171166
.arg(&self.inactivity_timer_sec.to_string())
172167
.arg("--network")
173168
.arg(&self.network.to_string())
174-
.arg("--announced-node-name")
175-
.arg(&self.announced_node_name.to_string())
176169
.arg("--backend-url")
177170
.arg(&self.backend_url)
178171
.arg("--runner-url")
@@ -333,56 +326,6 @@ impl Display for BitcoindRpcInfo {
333326
}
334327
}
335328

336-
// NOTE: NodeAlias isn't meaningfully used anywhere - it's only purpose is to
337-
// provide a Display impl for println! statements. Consider removing
338-
#[derive(Clone, Copy, Default, PartialEq, Eq)]
339-
pub struct NodeAlias([u8; 32]);
340-
341-
impl NodeAlias {
342-
pub fn new(inner: [u8; 32]) -> Self {
343-
Self(inner)
344-
}
345-
}
346-
347-
impl FromStr for NodeAlias {
348-
type Err = anyhow::Error;
349-
350-
fn from_str(s: &str) -> Result<Self, Self::Err> {
351-
let bytes = s.as_bytes();
352-
ensure!(
353-
bytes.len() <= 32,
354-
"node alias can't be longer than 32 bytes"
355-
);
356-
357-
let mut alias = [0_u8; 32];
358-
alias[..bytes.len()].copy_from_slice(bytes);
359-
360-
Ok(Self(alias))
361-
}
362-
}
363-
364-
impl Display for NodeAlias {
365-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
366-
for b in self.0.iter() {
367-
let c = *b as char;
368-
if c == '\0' {
369-
break;
370-
}
371-
if c.is_ascii_graphic() || c == ' ' {
372-
continue;
373-
}
374-
write!(f, "{c}")?;
375-
}
376-
Ok(())
377-
}
378-
}
379-
380-
impl fmt::Debug for NodeAlias {
381-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
382-
Display::fmt(self, f)
383-
}
384-
}
385-
386329
/// There are slight variations is how the network is represented as strings
387330
/// across bitcoind rpc calls, lightning, etc. For consistency, we use the
388331
/// mapping defined in bitcoin::Network's FromStr impl, which is:
@@ -481,14 +424,6 @@ mod test {
481424
assert_eq!(expected, actual);
482425
}
483426

484-
#[test]
485-
fn test_parse_node_alias() {
486-
let expected = NodeAlias(*b"hello, world - this is lexe\0\0\0\0\0");
487-
let actual =
488-
NodeAlias::from_str("hello, world - this is lexe").unwrap();
489-
assert_eq!(expected, actual);
490-
}
491-
492427
#[test]
493428
fn test_network_roundtrip() {
494429
// Mainnet is disabled for now

node/Cargo.toml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,17 @@ base64 = "0.13.0"
2525

2626
# --- LIGHTNING --- #
2727

28-
# lightning = { version = "0.0.108", features = ["max_level_trace"] }
29-
# lightning-block-sync = { version = "0.0.108", features = [ "rpc-client" ] }
30-
# lightning-invoice = { version = "0.16" }
31-
# lightning-net-tokio = { version = "0.0.108" }
32-
33-
# TODO Switch to back to crates.io version after LDK with lightning-net-tokio
34-
# patch is released
35-
lightning = { git = "https://github.com/lexe-tech/rust-lightning", features = ["max_level_trace"], branch = "net-tokio-connect-v0.0.108" }
36-
lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", features = [ "rpc-client" ], branch = "net-tokio-connect-v0.0.108" }
37-
lightning-invoice = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
38-
lightning-net-tokio = { git = "https://github.com/lexe-tech/rust-lightning", branch = "net-tokio-connect-v0.0.108" }
39-
40-
# NOTE For debugging and testing patches during local development
28+
lightning = { version = "0.0.110", features = ["max_level_trace"] }
29+
lightning-block-sync = { version = "0.0.110", features = [ "rpc-client" ] }
30+
lightning-invoice = { version = "0.18" }
31+
lightning-net-tokio = { version = "0.0.110" }
32+
33+
# lightning = { git = "https://github.com/lexe-tech/rust-lightning", features = # ["max_level_trace"], branch = "main" }
34+
# lightning-block-sync = { git = "https://github.com/lexe-tech/rust-lightning", # features = [ "rpc-client" ], branch = "main" }
35+
# lightning-invoice = { git = "https://github.com/lexe-tech/rust-lightning", # branch = "main" }
36+
# lightning-net-tokio = { git = "https://github.com/lexe-tech/rust-lightning", # branch = "main" }
37+
38+
# For debugging and testing patches during local development
4139
# lightning = { path = "../../ldk/lightning", features = ["max_level_trace"]}
4240
# lightning-block-sync = { path = "../../ldk/lightning-block-sync", features = [ "rpc-client" ] }
4341
# lightning-invoice = { path = "../../ldk/lightning-invoice" }

node/src/command/test/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bitcoind::bitcoincore_rpc::RpcApi;
88
use bitcoind::{self, BitcoinD, Conf};
99
use common::api::UserPk;
1010
use common::cli::{
11-
BitcoindRpcInfo, Network, NodeAlias, StartArgs, DEFAULT_BACKEND_URL,
11+
BitcoindRpcInfo, Network, StartArgs, DEFAULT_BACKEND_URL,
1212
DEFAULT_RUNNER_URL,
1313
};
1414
use common::rng::SysRng;
@@ -36,7 +36,6 @@ fn default_args_for_user(user_pk: UserPk) -> StartArgs {
3636
},
3737
user_pk,
3838
peer_port: None,
39-
announced_node_name: NodeAlias::default(),
4039
network: Network::from_str("regtest").unwrap(),
4140
warp_port: None,
4241
shutdown_after_sync_if_no_activity: false,

node/src/event_handler.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use bitcoin::blockdata::transaction::Transaction;
1010
use bitcoin::consensus::encode;
1111
use bitcoin::secp256k1::Secp256k1;
1212
use bitcoin_bech32::WitnessProgram;
13-
use common::cli::{Network, NodeAlias};
13+
use common::cli::Network;
1414
use common::hex;
1515
use lightning::chain::chaininterface::{
1616
BroadcasterInterface, ConfirmationTarget, FeeEstimator,
@@ -271,6 +271,8 @@ async fn handle_event_fallible(
271271
}
272272
Event::PaymentPathSuccessful { .. } => {}
273273
Event::PaymentPathFailed { .. } => {}
274+
Event::ProbeSuccessful { .. } => {}
275+
Event::ProbeFailed { .. } => {}
274276
Event::PaymentFailed { payment_hash, .. } => {
275277
print!(
276278
"\nEVENT: Failed to send payment to payment hash {:?}: exhausted payment retry attempts",
@@ -311,7 +313,7 @@ async fn handle_event_fallible(
311313
Some(announcement) => {
312314
format!(
313315
" from node {}",
314-
NodeAlias::new(announcement.alias)
316+
announcement.alias
315317
)
316318
}
317319
},
@@ -357,6 +359,7 @@ async fn handle_event_fallible(
357359
print!("> ");
358360
io::stdout().flush().unwrap();
359361
}
362+
Event::HTLCHandlingFailed { .. } => {}
360363
Event::PendingHTLCsForwardable { time_forwardable } => {
361364
let forwarding_channel_manager = channel_manager.clone();
362365
let millis_to_sleep = time_forwardable.as_millis() as u64;

node/src/lexe/channel_manager/mod.rs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ const TIME_TO_CONTEST_FRAUDULENT_TXNS: u16 = 6 * 24 * 7;
4949
const TIME_TO_CONTEST_FRAUDULENT_TXNS: u16 = BREAKDOWN_TIMEOUT;
5050

5151
pub const USER_CONFIG: UserConfig = UserConfig {
52-
own_channel_config: OWN_CHANNEL_CONFIG,
53-
peer_channel_config_limits: PEER_CHANNEL_CONFIG_LIMITS,
54-
channel_options: CHANNEL_OPTIONS,
52+
channel_handshake_config: CHANNEL_HANDSHAKE_CONFIG,
53+
channel_handshake_limits: CHANNEL_HANDSHAKE_LIMITS,
54+
channel_config: CHANNEL_CONFIG,
5555

5656
// Do not accept any HTLC forwarding risks
5757
accept_forwards_to_priv_channels: false,
@@ -63,24 +63,33 @@ pub const USER_CONFIG: UserConfig = UserConfig {
6363
manually_accept_inbound_channels: false,
6464
};
6565

66-
const OWN_CHANNEL_CONFIG: ChannelHandshakeConfig = ChannelHandshakeConfig {
67-
// Wait 6 confirmations for channels to be considered locked-in.
68-
minimum_depth: 6,
69-
// Require the channel counterparty (Lexe's LSPs) to wait <this param> to
70-
// claim funds in the case of a unilateral close. Specified in # of blocks.
71-
our_to_self_delay: TIME_TO_CONTEST_FRAUDULENT_TXNS,
72-
// Allow extremely small HTLCs
73-
our_htlc_minimum_msat: 1,
74-
// Allow up to 100% of our funds to be encumbered in inbound HTLCS.
75-
max_inbound_htlc_value_in_flight_percent_of_channel: 100,
76-
// Attempt to use better privacy. The LSP should have this enabled.
77-
negotiate_scid_privacy: true,
78-
};
66+
const CHANNEL_HANDSHAKE_CONFIG: ChannelHandshakeConfig =
67+
ChannelHandshakeConfig {
68+
// Wait 6 confirmations for channels to be considered locked-in.
69+
minimum_depth: 6,
70+
// Require the channel counterparty (Lexe's LSPs) to wait <this param>
71+
// to claim funds in the case of a unilateral close. Specified
72+
// in # of blocks.
73+
our_to_self_delay: TIME_TO_CONTEST_FRAUDULENT_TXNS,
74+
// Allow extremely small HTLCs
75+
our_htlc_minimum_msat: 1,
76+
// Allow up to 100% of our funds to be encumbered in inbound HTLCS.
77+
max_inbound_htlc_value_in_flight_percent_of_channel: 100,
78+
// Attempt to use better privacy. The LSP should have this enabled.
79+
negotiate_scid_privacy: true,
80+
// Do not publically announce our channels
81+
announced_channel: false,
82+
// The additional 'security' provided by setting is pointless.
83+
// Additionally, we do not want to commit to a `shutdown_pubkey`
84+
// so that it is possible to sweep all funds to an address
85+
// specified at the time of channel close.
86+
commit_upfront_shutdown_pubkey: false,
87+
};
7988

80-
const PEER_CHANNEL_CONFIG_LIMITS: ChannelHandshakeLimits =
89+
const CHANNEL_HANDSHAKE_LIMITS: ChannelHandshakeLimits =
8190
ChannelHandshakeLimits {
8291
// Force an incoming channel (from the LSP) to match the value we set
83-
// for `ChannelConfig::announced_channel` (which is false)
92+
// for `ChannelHandshakeConfig::announced_channel` (which is false)
8493
force_announced_channel_preference: true,
8594
// *We* (the node) wait a maximum of 6 * 24 blocks (1 day) to reclaim
8695
// our funds in the case of a unilateral close initiated by us.
@@ -97,19 +106,13 @@ const PEER_CHANNEL_CONFIG_LIMITS: ChannelHandshakeLimits =
97106
max_minimum_depth: 144,
98107
};
99108

100-
const CHANNEL_OPTIONS: ChannelConfig = ChannelConfig {
109+
const CHANNEL_CONFIG: ChannelConfig = ChannelConfig {
101110
// (proportional fee) We do not forward anything so this can be 0
102111
forwarding_fee_proportional_millionths: 0,
103112
// (base fee) We do not forward anything so this can be 0
104113
forwarding_fee_base_msat: 0,
105114
// We do not forward anything so this can be the minimum
106115
cltv_expiry_delta: MIN_CLTV_EXPIRY_DELTA,
107-
// Do not publically announce our channels
108-
announced_channel: false,
109-
// The additional 'security' provided by setting is pointless. Additionally,
110-
// we do not want to commit to a `shutdown_pubkey` so that it is possible to
111-
// sweep all funds to an address specified at the time of channel close.
112-
commit_upfront_shutdown_pubkey: false,
113116
// LDK default
114117
max_dust_htlc_exposure_msat: 5_000_000,
115118
// Pay up to 1000 sats (50 cents assuming $50K per BTC) to avoid waiting up

node/src/repl.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use anyhow::Context;
1111
use bitcoin::hashes::sha256::Hash as Sha256;
1212
use bitcoin::hashes::Hash;
1313
use bitcoin::secp256k1::PublicKey;
14-
use common::cli::{Network, NodeAlias};
14+
use common::cli::Network;
1515
use common::hex;
1616
use lightning::chain::keysinterface::{KeysInterface, Recipient};
1717
use lightning::ln::{PaymentHash, PaymentPreimage};
@@ -379,10 +379,7 @@ fn list_channels(
379379
.get(&NodeId::from_pubkey(&chan_info.counterparty.node_id))
380380
{
381381
if let Some(announcement) = &node_info.announcement_info {
382-
println!(
383-
"\t\tpeer_alias: {}",
384-
NodeAlias::new(announcement.alias)
385-
);
382+
println!("\t\tpeer_alias: {}", announcement.alias);
386383
}
387384
}
388385

@@ -640,7 +637,7 @@ fn force_close_channel(
640637
channel_manager: LexeChannelManager,
641638
) {
642639
match channel_manager
643-
.force_close_channel(&channel_id, &counterparty_node_id)
640+
.force_close_broadcasting_latest_txn(&channel_id, &counterparty_node_id)
644641
{
645642
Ok(()) => println!("EVENT: initiating channel force-close"),
646643
Err(e) => println!("ERROR: failed to force-close channel: {:?}", e),

0 commit comments

Comments
 (0)