Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 161
Upgrade to LDK 0.0.118#175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,7 +4,7 @@ use crate::wallet::{Wallet, WalletKeysManager}; | ||
| use lightning::chain::chainmonitor; | ||
| use lightning::ln::channelmanager::ChannelDetails as LdkChannelDetails; | ||
| use lightning::ln::msgs::RoutingMessageHandler; | ||
| use lightning::ln::msgs::SocketAddress as LdkSocketAddress; | ||
| use lightning::ln::msgs::SocketAddress; | ||
| use lightning::ln::peer_handler::IgnoringMessageHandler; | ||
| use lightning::ln::ChannelId; | ||
| use lightning::routing::gossip; | ||
| @@ -20,9 +20,6 @@ use lightning_transaction_sync::EsploraSyncClient; | ||
| use bitcoin::secp256k1::PublicKey; | ||
| use bitcoin::OutPoint; | ||
| use std::fmt::Display; | ||
| use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs}; | ||
| use std::str::FromStr; | ||
| use std::sync::{Arc, Mutex, RwLock}; | ||
| pub(crate) type ChainMonitor<K> = chainmonitor::ChainMonitor< | ||
| @@ -320,106 +317,6 @@ pub struct PeerDetails { | ||
| pub is_connected: bool, | ||
| } | ||
| /// The network address of a Lightning node. | ||
| /// | ||
| /// Currently only IPv4, IPv6, and DNS hostnames are supported. | ||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub struct SocketAddress(pub LdkSocketAddress); | ||
tnull marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| impl Display for SocketAddress { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| match self.0 { | ||
| LdkSocketAddress::TcpIpV4 { addr, port } => { | ||
| let ip_addr = Ipv4Addr::from(addr); | ||
| write!(f, "{}:{}", ip_addr, port) | ||
| } | ||
| LdkSocketAddress::TcpIpV6 { addr, port } => { | ||
| let ip_addr = Ipv6Addr::from(addr); | ||
| write!(f, "[{}]:{}", ip_addr, port) | ||
| } | ||
| LdkSocketAddress::Hostname { ref hostname, port } => { | ||
| write!(f, "{}:{}", hostname.as_str(), port) | ||
| } | ||
| LdkSocketAddress::OnionV2(o) => { | ||
| write!(f, "OnionV2 (unsupported): {:?}", o) | ||
| } | ||
| LdkSocketAddress::OnionV3 { ed25519_pubkey, checksum, version, port } => write!( | ||
| f, | ||
| "OnionV3 (unsupported): {:?}/{:?}/{:?}/{:?}", | ||
| ed25519_pubkey, checksum, version, port | ||
| ), | ||
| } | ||
| } | ||
| } | ||
| impl FromStr for SocketAddress { | ||
| type Err = (); | ||
| fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
| Ok(Self(LdkSocketAddress::from_str(s).map_err(|_| ())?)) | ||
| } | ||
| } | ||
| impl From<SocketAddr> for SocketAddress { | ||
| fn from(value: SocketAddr) -> Self { | ||
| match value { | ||
| SocketAddr::V4(v4addr) => SocketAddress::from(v4addr), | ||
| SocketAddr::V6(v6addr) => SocketAddress::from(v6addr), | ||
| } | ||
| } | ||
| } | ||
| impl From<SocketAddrV4> for SocketAddress { | ||
| fn from(value: SocketAddrV4) -> Self { | ||
| Self(LdkSocketAddress::TcpIpV4 { addr: value.ip().octets(), port: value.port() }) | ||
| } | ||
| } | ||
| impl From<SocketAddrV6> for SocketAddress { | ||
| fn from(value: SocketAddrV6) -> Self { | ||
| Self(LdkSocketAddress::TcpIpV6 { addr: value.ip().octets(), port: value.port() }) | ||
| } | ||
| } | ||
| impl ToSocketAddrs for SocketAddress { | ||
| type Iter = std::option::IntoIter<SocketAddr>; | ||
| fn to_socket_addrs(&self) -> std::io::Result<Self::Iter> { | ||
| match self.0 { | ||
| LdkSocketAddress::TcpIpV4 { addr, port } => { | ||
| let ip_addr = Ipv4Addr::from(addr); | ||
| (ip_addr, port).to_socket_addrs() | ||
| } | ||
| LdkSocketAddress::TcpIpV6 { addr, port } => { | ||
| let ip_addr = Ipv6Addr::from(addr); | ||
| (ip_addr, port).to_socket_addrs() | ||
| } | ||
| LdkSocketAddress::Hostname { ref hostname, port } => { | ||
| Ok((hostname.as_str(), port).to_socket_addrs()?.next().into_iter()) | ||
| } | ||
| LdkSocketAddress::OnionV2(..) => { | ||
| Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) | ||
| } | ||
| LdkSocketAddress::OnionV3 { .. } => { | ||
| Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| impl Writeable for SocketAddress { | ||
| fn write<W: lightning::util::ser::Writer>(&self, writer: &mut W) -> Result<(), std::io::Error> { | ||
| self.0.write(writer) | ||
| } | ||
| } | ||
| impl Readable for SocketAddress { | ||
| fn read<R: std::io::Read>(reader: &mut R) -> Result<Self, lightning::ln::msgs::DecodeError> { | ||
| let addr: LdkSocketAddress = Readable::read(reader)?; | ||
| Ok(Self(addr)) | ||
| } | ||
| } | ||
| /// Options which apply on a per-channel basis. | ||
| /// | ||
| /// See documentation of [`LdkChannelConfig`] for details. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -116,29 +116,48 @@ where | ||
| let mut locked_fee_rate_cache = self.fee_rate_cache.write().unwrap(); | ||
| let confirmation_targets = vec![ | ||
| ConfirmationTarget::MempoolMinimum, | ||
| ConfirmationTarget::Background, | ||
| ConfirmationTarget::Normal, | ||
| ConfirmationTarget::HighPriority, | ||
| ConfirmationTarget::OnChainSweep, | ||
| ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee, | ||
| ConfirmationTarget::MinAllowedAnchorChannelRemoteFee, | ||
| ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, | ||
| ConfirmationTarget::AnchorChannelFee, | ||
| ConfirmationTarget::NonAnchorChannelFee, | ||
| ConfirmationTarget::ChannelCloseMinimum, | ||
| ]; | ||
| for target in confirmation_targets { | ||
| let num_blocks = match target { | ||
| ConfirmationTarget::MempoolMinimum => 1008, | ||
| ConfirmationTarget::Background => 12, | ||
| ConfirmationTarget::Normal => 6, | ||
| ConfirmationTarget::HighPriority => 3, | ||
| ConfirmationTarget::OnChainSweep => 6, | ||
| ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => 1, | ||
tnull marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => 1008, | ||
| ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => 144, | ||
| ConfirmationTarget::AnchorChannelFee => 1008, | ||
| ConfirmationTarget::NonAnchorChannelFee => 12, | ||
| ConfirmationTarget::ChannelCloseMinimum => 144, | ||
| }; | ||
| let est_fee_rate = self.blockchain.estimate_fee(num_blocks).await; | ||
| match est_fee_rate { | ||
| Ok(rate) => { | ||
| locked_fee_rate_cache.insert(target, rate); | ||
| // LDK 0.0.118 introduced changes to the `ConfirmationTarget` semantics that | ||
| // require some post-estimation adjustments to the fee rates, which we do here. | ||
| let adjusted_fee_rate = match target { | ||
| ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => { | ||
| let really_high_prio = rate.as_sat_per_vb() * 10.0; | ||
| FeeRate::from_sat_per_vb(really_high_prio) | ||
| } | ||
| ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => { | ||
| let slightly_less_than_background = rate.fee_wu(1000) - 250; | ||
| FeeRate::from_sat_per_kwu(slightly_less_than_background as f32) | ||
| } | ||
| _ => rate, | ||
| }; | ||
| locked_fee_rate_cache.insert(target, adjusted_fee_rate); | ||
| log_trace!( | ||
| self.logger, | ||
| "Fee rate estimation updated for {:?}: {} sats/kwu", | ||
| target, | ||
| rate.fee_wu(1000) | ||
| adjusted_fee_rate.fee_wu(1000) | ||
| ); | ||
| } | ||
| Err(e) => { | ||
| @@ -211,7 +230,7 @@ where | ||
| pub(crate) fn send_to_address( | ||
| &self, address: &bitcoin::Address, amount_msat_or_drain: Option<u64>, | ||
| ) -> Result<Txid, Error> { | ||
| let confirmation_target = ConfirmationTarget::Normal; | ||
| let confirmation_target = ConfirmationTarget::NonAnchorChannelFee; | ||
tnull marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| let fee_rate = self.estimate_fee_rate(confirmation_target); | ||
| let tx = { | ||
| @@ -284,10 +303,13 @@ where | ||
| let locked_fee_rate_cache = self.fee_rate_cache.read().unwrap(); | ||
| let fallback_sats_kwu = match confirmation_target { | ||
| ConfirmationTarget::MempoolMinimum => FEERATE_FLOOR_SATS_PER_KW, | ||
| ConfirmationTarget::Background => 500, | ||
| ConfirmationTarget::Normal => 2000, | ||
| ConfirmationTarget::HighPriority => 5000, | ||
| ConfirmationTarget::OnChainSweep => 5000, | ||
| ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => 25 * 250, | ||
| ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => FEERATE_FLOOR_SATS_PER_KW, | ||
| ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => FEERATE_FLOOR_SATS_PER_KW, | ||
| ConfirmationTarget::AnchorChannelFee => 500, | ||
| ConfirmationTarget::NonAnchorChannelFee => 1000, | ||
| ConfirmationTarget::ChannelCloseMinimum => 500, | ||
| }; | ||
| // We'll fall back on this, if we really don't have any other information. | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.