Skip to content

Commit de42fff

Browse files
committed
Upgrade to 0.0.118
1 parent 160347c commit de42fff

File tree

7 files changed

+60
-137
lines changed

7 files changed

+60
-137
lines changed

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ panic = 'abort' # Abort on panic
3232
default = []
3333

3434
[dependencies]
35-
lightning = { version = "0.0.117", features = ["max_level_trace", "std"] }
36-
lightning-invoice = { version = "0.25.0" }
37-
lightning-net-tokio = { version = "0.0.117" }
38-
lightning-persister = { version = "0.0.117" }
39-
lightning-background-processor = { version = "0.0.117", features = ["futures"] }
40-
lightning-rapid-gossip-sync = { version = "0.0.117" }
41-
lightning-transaction-sync = { version = "0.0.117", features = ["esplora-async-https"] }
35+
lightning = { version = "0.0.118", features = ["max_level_trace", "std"] }
36+
lightning-invoice = { version = "0.26.0" }
37+
lightning-net-tokio = { version = "0.0.118" }
38+
lightning-persister = { version = "0.0.118" }
39+
lightning-background-processor = { version = "0.0.118", features = ["futures"] }
40+
lightning-rapid-gossip-sync = { version = "0.0.118" }
41+
lightning-transaction-sync = { version = "0.0.118", features = ["esplora-async-https"] }
4242

4343
# lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["max_level_trace", "std"] }
4444
# lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
@@ -75,7 +75,7 @@ uniffi = { version = "0.23.0", features = ["build"], optional = true }
7575
winapi = { version = "0.3", features = ["winbase"] }
7676

7777
[dev-dependencies]
78-
lightning = { version = "0.0.117", features = ["max_level_trace", "std", "_test_utils"] }
78+
lightning = { version = "0.0.118", features = ["max_level_trace", "std", "_test_utils"] }
7979
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["max_level_trace", "std", "_test_utils"] }
8080
electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_23_0"] }
8181
electrum-client = "0.12.0"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ LDK Node is a self-custodial Lightning node in library form. Its central goal is
1111
The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_builder] to your liking and calling one of the `build` methods. `Node` can then be controlled via commands such as `start`, `stop`, `connect_open_channel`, `send_payment`, etc.
1212

1313
```rust
14-
use ldk_node::{Builder, SocketAddress};
14+
use ldk_node::Builder;
1515
use ldk_node::lightning_invoice::Invoice;
16+
use ldk_node::lightning::ln::msgs::SocketAddress;
1617
use ldk_node::bitcoin::secp256k1::PublicKey;
1718
use ldk_node::bitcoin::Network;
1819
use std::str::FromStr;

src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::payment_store::PaymentStore;
77
use crate::peer_store::PeerStore;
88
use crate::types::{
99
ChainMonitor, ChannelManager, FakeMessageRouter, GossipSync, KeysManager, NetworkGraph,
10-
OnionMessenger, PeerManager, SocketAddress,
10+
OnionMessenger, PeerManager,
1111
};
1212
use crate::wallet::Wallet;
1313
use crate::LogLevel;
@@ -18,7 +18,7 @@ use crate::{
1818

1919
use lightning::chain::{chainmonitor, BestBlock, Watch};
2020
use lightning::ln::channelmanager::{self, ChainParameters, ChannelManagerReadArgs};
21-
use lightning::ln::msgs::RoutingMessageHandler;
21+
use lightning::ln::msgs::{RoutingMessageHandler, SocketAddress};
2222
use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler};
2323
use lightning::routing::router::DefaultRouter;
2424
use lightning::routing::scoring::{

src/event.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ where
287287
} => {
288288
// Construct the raw transaction with the output that is paid the amount of the
289289
// channel.
290-
let confirmation_target = ConfirmationTarget::Normal;
290+
let confirmation_target = ConfirmationTarget::NonAnchorChannelFee;
291291

292292
// We set nLockTime to the current height to discourage fee sniping.
293293
let cur_height = self.channel_manager.current_best_block().height();
@@ -581,8 +581,9 @@ where
581581
});
582582

583583
let output_descriptors = &outputs.iter().collect::<Vec<_>>();
584-
let tx_feerate =
585-
self.wallet.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
584+
let tx_feerate = self
585+
.wallet
586+
.get_est_sat_per_1000_weight(ConfirmationTarget::NonAnchorChannelFee);
586587

587588
// We set nLockTime to the current height to discourage fee sniping.
588589
let cur_height = self.channel_manager.current_best_block().height();
@@ -781,6 +782,7 @@ where
781782
LdkEvent::DiscardFunding { .. } => {}
782783
LdkEvent::HTLCIntercepted { .. } => {}
783784
LdkEvent::BumpTransaction(_) => {}
785+
LdkEvent::InvoiceRequestFailed { .. } => {}
784786
}
785787
}
786788
}

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
//! [`send_payment`], etc.:
2727
//!
2828
//! ```no_run
29-
//! use ldk_node::{Builder, SocketAddress};
29+
//! use ldk_node::Builder;
3030
//! use ldk_node::lightning_invoice::Bolt11Invoice;
31+
//! use ldk_node::lightning::ln::msgs::SocketAddress;
3132
//! use ldk_node::bitcoin::secp256k1::PublicKey;
3233
//! use ldk_node::bitcoin::Network;
3334
//! use std::str::FromStr;
@@ -100,7 +101,6 @@ use error::Error;
100101

101102
pub use event::Event;
102103
pub use types::ChannelConfig;
103-
pub use types::SocketAddress;
104104

105105
pub use io::utils::generate_entropy_mnemonic;
106106

@@ -126,6 +126,7 @@ use logger::{log_error, log_info, log_trace, FilesystemLogger, Logger};
126126

127127
use lightning::chain::Confirm;
128128
use lightning::ln::channelmanager::{self, PaymentId, RecipientOnionFields, Retry};
129+
use lightning::ln::msgs::SocketAddress;
129130
use lightning::ln::{ChannelId, PaymentHash, PaymentPreimage};
130131
use lightning::sign::EntropySource;
131132

@@ -631,7 +632,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
631632
}
632633

633634
let addresses =
634-
bcast_config.listening_address.iter().cloned().map(|a| a.0).collect();
635+
bcast_config.listening_address.iter().cloned().collect();
635636
bcast_pm.broadcast_node_announcement([0; 3], [0; 32], addresses);
636637

637638
let unix_time_secs = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs();
@@ -1516,7 +1517,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
15161517
let stored_peer = self.peer_store.get_peer(&node_id);
15171518
let stored_addr_opt = stored_peer.as_ref().map(|p| p.address.clone());
15181519
let address = match (con_addr_opt, stored_addr_opt) {
1519-
(Some(con_addr), _) => SocketAddress(con_addr),
1520+
(Some(con_addr), _) => con_addr,
15201521
(None, Some(stored_addr)) => stored_addr,
15211522
(None, None) => continue,
15221523
};

src/types.rs

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::wallet::{Wallet, WalletKeysManager};
44
use lightning::chain::chainmonitor;
55
use lightning::ln::channelmanager::ChannelDetails as LdkChannelDetails;
66
use lightning::ln::msgs::RoutingMessageHandler;
7-
use lightning::ln::msgs::SocketAddress as LdkSocketAddress;
7+
use lightning::ln::msgs::SocketAddress;
88
use lightning::ln::peer_handler::IgnoringMessageHandler;
99
use lightning::ln::ChannelId;
1010
use lightning::routing::gossip;
@@ -20,9 +20,6 @@ use lightning_transaction_sync::EsploraSyncClient;
2020
use bitcoin::secp256k1::PublicKey;
2121
use bitcoin::OutPoint;
2222

23-
use std::fmt::Display;
24-
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
25-
use std::str::FromStr;
2623
use std::sync::{Arc, Mutex, RwLock};
2724

2825
pub(crate) type ChainMonitor<K> = chainmonitor::ChainMonitor<
@@ -320,106 +317,6 @@ pub struct PeerDetails {
320317
pub is_connected: bool,
321318
}
322319

323-
/// The network address of a Lightning node.
324-
///
325-
/// Currently only IPv4, IPv6, and DNS hostnames are supported.
326-
#[derive(Debug, Clone, PartialEq, Eq)]
327-
pub struct SocketAddress(pub LdkSocketAddress);
328-
329-
impl Display for SocketAddress {
330-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
331-
match self.0 {
332-
LdkSocketAddress::TcpIpV4 { addr, port } => {
333-
let ip_addr = Ipv4Addr::from(addr);
334-
write!(f, "{}:{}", ip_addr, port)
335-
}
336-
LdkSocketAddress::TcpIpV6 { addr, port } => {
337-
let ip_addr = Ipv6Addr::from(addr);
338-
write!(f, "[{}]:{}", ip_addr, port)
339-
}
340-
LdkSocketAddress::Hostname { ref hostname, port } => {
341-
write!(f, "{}:{}", hostname.as_str(), port)
342-
}
343-
LdkSocketAddress::OnionV2(o) => {
344-
write!(f, "OnionV2 (unsupported): {:?}", o)
345-
}
346-
LdkSocketAddress::OnionV3 { ed25519_pubkey, checksum, version, port } => write!(
347-
f,
348-
"OnionV3 (unsupported): {:?}/{:?}/{:?}/{:?}",
349-
ed25519_pubkey, checksum, version, port
350-
),
351-
}
352-
}
353-
}
354-
355-
impl FromStr for SocketAddress {
356-
type Err = ();
357-
358-
fn from_str(s: &str) -> Result<Self, Self::Err> {
359-
Ok(Self(LdkSocketAddress::from_str(s).map_err(|_| ())?))
360-
}
361-
}
362-
363-
impl From<SocketAddr> for SocketAddress {
364-
fn from(value: SocketAddr) -> Self {
365-
match value {
366-
SocketAddr::V4(v4addr) => SocketAddress::from(v4addr),
367-
SocketAddr::V6(v6addr) => SocketAddress::from(v6addr),
368-
}
369-
}
370-
}
371-
372-
impl From<SocketAddrV4> for SocketAddress {
373-
fn from(value: SocketAddrV4) -> Self {
374-
Self(LdkSocketAddress::TcpIpV4 { addr: value.ip().octets(), port: value.port() })
375-
}
376-
}
377-
378-
impl From<SocketAddrV6> for SocketAddress {
379-
fn from(value: SocketAddrV6) -> Self {
380-
Self(LdkSocketAddress::TcpIpV6 { addr: value.ip().octets(), port: value.port() })
381-
}
382-
}
383-
384-
impl ToSocketAddrs for SocketAddress {
385-
type Iter = std::option::IntoIter<SocketAddr>;
386-
387-
fn to_socket_addrs(&self) -> std::io::Result<Self::Iter> {
388-
match self.0 {
389-
LdkSocketAddress::TcpIpV4 { addr, port } => {
390-
let ip_addr = Ipv4Addr::from(addr);
391-
(ip_addr, port).to_socket_addrs()
392-
}
393-
LdkSocketAddress::TcpIpV6 { addr, port } => {
394-
let ip_addr = Ipv6Addr::from(addr);
395-
(ip_addr, port).to_socket_addrs()
396-
}
397-
LdkSocketAddress::Hostname { ref hostname, port } => {
398-
Ok((hostname.as_str(), port).to_socket_addrs()?.next().into_iter())
399-
}
400-
LdkSocketAddress::OnionV2(..) => {
401-
Err(std::io::Error::from(std::io::ErrorKind::Unsupported))
402-
}
403-
LdkSocketAddress::OnionV3 { .. } => {
404-
Err(std::io::Error::from(std::io::ErrorKind::Unsupported))
405-
}
406-
}
407-
}
408-
}
409-
410-
impl Writeable for SocketAddress {
411-
fn write<W: lightning::util::ser::Writer>(&self, writer: &mut W) -> Result<(), std::io::Error> {
412-
self.0.write(writer)
413-
}
414-
}
415-
416-
impl Readable for SocketAddress {
417-
fn read<R: std::io::Read>(reader: &mut R) -> Result<Self, lightning::ln::msgs::DecodeError> {
418-
let addr: LdkSocketAddress = Readable::read(reader)?;
419-
Ok(Self(addr))
420-
}
421-
}
422-
423320
/// Options which apply on a per-channel basis.
424321
///
425322
/// See documentation of [`LdkChannelConfig`] for details.

src/wallet.rs

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,29 +116,48 @@ where
116116
let mut locked_fee_rate_cache = self.fee_rate_cache.write().unwrap();
117117

118118
let confirmation_targets = vec![
119-
ConfirmationTarget::MempoolMinimum,
120-
ConfirmationTarget::Background,
121-
ConfirmationTarget::Normal,
122-
ConfirmationTarget::HighPriority,
119+
ConfirmationTarget::OnChainSweep,
120+
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee,
121+
ConfirmationTarget::MinAllowedAnchorChannelRemoteFee,
122+
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee,
123+
ConfirmationTarget::AnchorChannelFee,
124+
ConfirmationTarget::NonAnchorChannelFee,
125+
ConfirmationTarget::ChannelCloseMinimum,
123126
];
124127
for target in confirmation_targets {
125128
let num_blocks = match target {
126-
ConfirmationTarget::MempoolMinimum => 1008,
127-
ConfirmationTarget::Background => 12,
128-
ConfirmationTarget::Normal => 6,
129-
ConfirmationTarget::HighPriority => 3,
129+
ConfirmationTarget::OnChainSweep => 6,
130+
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => 1,
131+
ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => 1008,
132+
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => 144,
133+
ConfirmationTarget::AnchorChannelFee => 1008,
134+
ConfirmationTarget::NonAnchorChannelFee => 12,
135+
ConfirmationTarget::ChannelCloseMinimum => 144,
130136
};
131137

132138
let est_fee_rate = self.blockchain.estimate_fee(num_blocks).await;
133139

134140
match est_fee_rate {
135141
Ok(rate) => {
136-
locked_fee_rate_cache.insert(target, rate);
142+
// LDK 0.0.118 introduced changes to the `ConfirmationTarget` semantics that
143+
// require some post-estimation adjustments to the fee rates, which we do here.
144+
let adjusted_fee_rate = match target {
145+
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => {
146+
let really_high_prio = rate.as_sat_per_vb() * 10.0;
147+
FeeRate::from_sat_per_vb(really_high_prio)
148+
}
149+
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => {
150+
let slightly_less_than_background = rate.fee_wu(1000) - 250;
151+
FeeRate::from_sat_per_kwu(slightly_less_than_background as f32)
152+
}
153+
_ => rate,
154+
};
155+
locked_fee_rate_cache.insert(target, adjusted_fee_rate);
137156
log_trace!(
138157
self.logger,
139158
"Fee rate estimation updated for {:?}: {} sats/kwu",
140159
target,
141-
rate.fee_wu(1000)
160+
adjusted_fee_rate.fee_wu(1000)
142161
);
143162
}
144163
Err(e) => {
@@ -211,7 +230,7 @@ where
211230
pub(crate) fn send_to_address(
212231
&self, address: &bitcoin::Address, amount_msat_or_drain: Option<u64>,
213232
) -> Result<Txid, Error> {
214-
let confirmation_target = ConfirmationTarget::Normal;
233+
let confirmation_target = ConfirmationTarget::NonAnchorChannelFee;
215234
let fee_rate = self.estimate_fee_rate(confirmation_target);
216235

217236
let tx = {
@@ -284,10 +303,13 @@ where
284303
let locked_fee_rate_cache = self.fee_rate_cache.read().unwrap();
285304

286305
let fallback_sats_kwu = match confirmation_target {
287-
ConfirmationTarget::MempoolMinimum => FEERATE_FLOOR_SATS_PER_KW,
288-
ConfirmationTarget::Background => 500,
289-
ConfirmationTarget::Normal => 2000,
290-
ConfirmationTarget::HighPriority => 5000,
306+
ConfirmationTarget::OnChainSweep => 5000,
307+
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => 25 * 250,
308+
ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => FEERATE_FLOOR_SATS_PER_KW,
309+
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => FEERATE_FLOOR_SATS_PER_KW,
310+
ConfirmationTarget::AnchorChannelFee => 500,
311+
ConfirmationTarget::NonAnchorChannelFee => 1000,
312+
ConfirmationTarget::ChannelCloseMinimum => 500,
291313
};
292314

293315
// We'll fall back on this, if we really don't have any other information.

0 commit comments

Comments
 (0)