Skip to content
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

Upgrade to LDK 0.0.119 #214

Merged
merged 1 commit into from
Dec 19, 2023
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
44 changes: 22 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.118", features = ["std"] }
lightning-invoice = { version = "0.26.0" }
lightning-net-tokio = { version = "0.0.118" }
lightning-persister = { version = "0.0.118" }
lightning-background-processor = { version = "0.0.118", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.118" }
lightning-transaction-sync = { version = "0.0.118", features = ["esplora-async-https"] }

# lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std"] }
# lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
# lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
# lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
# lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["futures"] }
# lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
# lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["esplora-async"] }
lightning = { version = "0.0.119", features = ["std"] }
lightning-invoice = { version = "0.27.0" }
lightning-net-tokio = { version = "0.0.119" }
lightning-persister = { version = "0.0.119" }
lightning-background-processor = { version = "0.0.119", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.119" }
lightning-transaction-sync = { version = "0.0.119", features = ["esplora-async-https"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std"] }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["futures"] }
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["esplora-async"] }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
Expand All @@ -52,18 +52,18 @@ lightning-transaction-sync = { version = "0.0.118", features = ["esplora-async-h
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }

bdk = { version = "0.28.0", default-features = false, features = ["std", "async-interface", "use-esplora-async", "sqlite-bundled", "keys-bip39"]}
bdk = { version = "0.29.0", default-features = false, features = ["std", "async-interface", "use-esplora-async", "sqlite-bundled", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.28.0", features = ["bundled"] }
bitcoin = "0.29.2"
bitcoin = "0.30.2"
bip39 = "2.0.0"

rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
futures = "0.3"
tokio = { version = "1", default-features = false, features = [ "rt-multi-thread", "time", "sync" ] }
esplora-client = { version = "0.4", default-features = false }
esplora-client = { version = "0.6", default-features = false }
libc = "0.2"
uniffi = { version = "0.25.1", features = ["build"], optional = true }

Expand All @@ -74,16 +74,16 @@ vss-client = "0.1"
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.118", features = ["std", "_test_utils"] }
lightning = { version = "0.0.119", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_23_0"] }
electrum-client = "0.12.0"
electrsd = { version = "0.26.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrum-client = { version = "0.18.0", default-features = true }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
bitcoincore-rpc = { version = "0.16.0", default-features = false }
bitcoincore-rpc = { version = "0.17.0", default-features = false }

[build-dependencies]
uniffi = { version = "0.25.1", features = ["build"], optional = true }
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ LDK Node is a self-custodial Lightning node in library form. Its central goal is
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.

```rust
use ldk_node::Builder;
use ldk_node::{Builder, Network};
use ldk_node::lightning_invoice::Invoice;
use ldk_node::lightning::ln::msgs::SocketAddress;
use ldk_node::bitcoin::secp256k1::PublicKey;
use ldk_node::bitcoin::Network;
use std::str::FromStr;

fn main() {
Expand Down
18 changes: 8 additions & 10 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::peer_store::PeerStore;
use crate::sweep::OutputSweeper;
use crate::tx_broadcaster::TransactionBroadcaster;
use crate::types::{
ChainMonitor, ChannelManager, FakeMessageRouter, GossipSync, KeysManager, NetworkGraph,
OnionMessenger, PeerManager,
ChainMonitor, ChannelManager, FakeMessageRouter, GossipSync, KeysManager, Network,
NetworkGraph, OnionMessenger, PeerManager,
};
use crate::wallet::Wallet;
use crate::LogLevel;
Expand Down Expand Up @@ -47,8 +47,6 @@ use bdk::blockchain::esplora::EsploraBlockchain;
use bdk::database::SqliteDatabase;
use bdk::template::Bip84;

use bitcoin::Network;

use bip39::Mnemonic;

use bitcoin::BlockHash;
Expand Down Expand Up @@ -436,7 +434,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
logger: Arc<FilesystemLogger>, kv_store: Arc<K>,
) -> Result<Node<K>, BuildError> {
// Initialize the on-chain wallet and chain access
let xprv = bitcoin::util::bip32::ExtendedPrivKey::new_master(config.network, &seed_bytes)
let xprv = bitcoin::bip32::ExtendedPrivKey::new_master(config.network.into(), &seed_bytes)
.map_err(|e| {
log_error!(logger, "Failed to derive master secret: {}", e);
BuildError::InvalidSeedBytes
Expand All @@ -445,7 +443,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
let wallet_name = bdk::wallet::wallet_name_from_descriptor(
Bip84(xprv, bdk::KeychainKind::External),
Some(Bip84(xprv, bdk::KeychainKind::Internal)),
config.network,
config.network.into(),
&Secp256k1::new(),
)
.map_err(|e| {
Expand All @@ -459,7 +457,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
let bdk_wallet = bdk::Wallet::new(
Bip84(xprv, bdk::KeychainKind::External),
Some(Bip84(xprv, bdk::KeychainKind::Internal)),
config.network,
config.network.into(),
database,
)
.map_err(|e| {
Expand Down Expand Up @@ -537,7 +535,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
Ok(graph) => Arc::new(graph),
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
Arc::new(NetworkGraph::new(config.network, Arc::clone(&logger)))
Arc::new(NetworkGraph::new(config.network.into(), Arc::clone(&logger)))
} else {
return Err(BuildError::ReadFailed);
}
Expand Down Expand Up @@ -629,10 +627,10 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
} else {
// We're starting a fresh node.
let genesis_block_hash =
bitcoin::blockdata::constants::genesis_block(config.network).block_hash();
bitcoin::blockdata::constants::genesis_block(config.network.into()).block_hash();

let chain_params = ChainParameters {
network: config.network,
network: config.network.into(),
best_block: BestBlock::new(genesis_block_hash, 0),
};
channelmanager::ChannelManager::new(
Expand Down
4 changes: 3 additions & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ use lightning::util::errors::APIError;
use lightning::util::persist::KVStore;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::secp256k1::PublicKey;
use bitcoin::{LockTime, OutPoint};
use bitcoin::OutPoint;
use rand::{thread_rng, Rng};
use std::collections::VecDeque;
use std::ops::Deref;
Expand Down Expand Up @@ -786,6 +787,7 @@ where
LdkEvent::HTLCIntercepted { .. } => {}
LdkEvent::BumpTransaction(_) => {}
LdkEvent::InvoiceRequestFailed { .. } => {}
LdkEvent::ConnectionNeeded { .. } => {}
}
}
}
Expand Down
16 changes: 6 additions & 10 deletions src/fee_estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use lightning::chain::chaininterface::{
use bdk::FeeRate;
use esplora_client::AsyncClient as EsploraClient;

use bitcoin::blockdata::weight::Weight;

use std::collections::HashMap;
use std::ops::Deref;
use std::sync::RwLock;
Expand All @@ -33,7 +35,6 @@ where
pub(crate) async fn update_fee_estimates(&self) -> Result<(), Error> {
let confirmation_targets = vec![
ConfirmationTarget::OnChainSweep,
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee,
ConfirmationTarget::MinAllowedAnchorChannelRemoteFee,
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee,
ConfirmationTarget::AnchorChannelFee,
Expand All @@ -43,7 +44,6 @@ where
for target in confirmation_targets {
let num_blocks = match target {
ConfirmationTarget::OnChainSweep => 6,
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => 1,
ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => 1008,
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => 144,
ConfirmationTarget::AnchorChannelFee => 1008,
Expand Down Expand Up @@ -77,12 +77,9 @@ where
// 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 = fee_rate.as_sat_per_vb() * 10.0;
FeeRate::from_sat_per_vb(really_high_prio)
}
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => {
let slightly_less_than_background = fee_rate.fee_wu(1000) - 250;
let slightly_less_than_background =
fee_rate.fee_wu(Weight::from_wu(1000)) - 250;
FeeRate::from_sat_per_kwu(slightly_less_than_background as f32)
}
_ => fee_rate,
Expand All @@ -94,7 +91,7 @@ where
self.logger,
"Fee rate estimation updated for {:?}: {} sats/kwu",
target,
adjusted_fee_rate.fee_wu(1000)
adjusted_fee_rate.fee_wu(Weight::from_wu(1000))
);
}
Ok(())
Expand All @@ -105,7 +102,6 @@ where

let fallback_sats_kwu = match confirmation_target {
ConfirmationTarget::OnChainSweep => 5000,
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => 25 * 250,
ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => FEERATE_FLOOR_SATS_PER_KW,
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => FEERATE_FLOOR_SATS_PER_KW,
ConfirmationTarget::AnchorChannelFee => 500,
Expand All @@ -125,7 +121,7 @@ where
L::Target: Logger,
{
fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 {
(self.estimate_fee_rate(confirmation_target).fee_wu(1000) as u32)
(self.estimate_fee_rate(confirmation_target).fee_wu(Weight::from_wu(1000)) as u32)
.max(FEERATE_FLOOR_SATS_PER_KW)
}
}
Loading
Loading