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
58 changes: 32 additions & 26 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#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-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#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-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.31.0", features = ["bundled"] }
Expand All@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,8 @@ interface Event {
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
Expand All@@ -296,6 +297,7 @@ enum PaymentFailureReason {
"UnknownRequiredFeatures",
"InvoiceRequestExpired",
"InvoiceRequestRejected",
"BlindedPathCreationFailed",
};

[Enum]
Expand Down
3 changes: 2 additions & 1 deletion src/balance.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};

Expand Down
17 changes: 11 additions & 6 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,7 +907,7 @@ fn build_with_store_internal(
));

// Read ChannelMonitor state from store
let mut channel_monitors = match read_channel_monitors(
let channel_monitors = match read_channel_monitors(
Arc::clone(&kv_store),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand DownExpand Up@@ -936,6 +936,9 @@ fn build_with_store_internal(
100;
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));

// Initialize the ChannelManager
let channel_manager = {
if let Ok(res) = kv_store.read(
Expand All@@ -945,7 +948,7 @@ fn build_with_store_internal(
) {
let mut reader = Cursor::new(res);
let channel_monitor_references =
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
let read_args = ChannelManagerReadArgs::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -954,6 +957,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
user_config,
channel_monitor_references,
Expand All@@ -978,6 +982,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
})?;
}

let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));

// Initialize the PeerManager
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&channel_manager),
Arc::new(message_router),
message_router,
Arc::clone(&channel_manager),
IgnoringMessageHandler {},
IgnoringMessageHandler {},
IgnoringMessageHandler {},
));
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();

Expand DownExpand Up@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
let lsps2_client_config = Some(LSPS2ClientConfig {});
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
let liquidity_client_config =
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
let liquidity_manager = Arc::new(LiquidityManager::new(
Arc::clone(&keys_manager),
Arc::clone(&channel_manager),
Expand Down
5 changes: 1 addition & 4 deletions src/chain/bitcoind_rpc.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
let rpc_credentials =
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));

let rpc_client = Arc::new(
RpcClient::new(&rpc_credentials, http_endpoint)
.expect("RpcClient::new is actually infallible"),
);
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));

let latest_mempool_timestamp = AtomicU64::new(0);

Expand Down
16 changes: 5 additions & 11 deletions src/chain/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -787,18 +787,12 @@ impl ChainSource {
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);

// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
// yields less than that. This is mostly necessary to continue on
// `signet`/`regtest` where we might not get estimates (or bogus values).
let converted_estimate_sat_vb =
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
|e| {
log_error!(
logger,
"Failed to convert fee rate estimates for {:?}: {}",
target,
e
);
Error::FeerateEstimationUpdateFailed
},
)?;
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
.map_or(1.0, |converted| converted.max(1.0));

let fee_rate =
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);
Expand Down
23 changes: 21 additions & 2 deletions src/event.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::blockdata::locktime::absolute::LockTime;
Expand DownExpand Up@@ -120,6 +121,16 @@ pub enum Event {
/// This will be `None` if the payment was settled via an on-chain transaction. See the
/// caveat described for the `total_fee_earned_msat` field.
next_user_channel_id: Option<UserChannelId>,
/// The node id of the previous node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
prev_node_id: Option<PublicKey>,
/// The node id of the next node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
next_node_id: Option<PublicKey>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
Expand DownExpand Up@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
},
(7, PaymentForwarded) => {
(0, prev_channel_id, required),
(1, prev_node_id, option),
(2, next_channel_id, required),
(3, next_node_id, option),
(4, prev_user_channel_id, option),
(6, next_user_channel_id, option),
(8, total_fee_earned_msat, option),
Expand DownExpand Up@@ -550,6 +563,7 @@ where
claim_deadline,
onion_fields,
counterparty_skimmed_fee_msat,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
if let Some(info) = self.payment_store.get(&payment_id) {
Expand DownExpand Up@@ -812,6 +826,7 @@ where
htlcs: _,
sender_intended_total_msat: _,
onion_fields,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
log_info!(
Expand DownExpand Up@@ -1025,7 +1040,7 @@ where
counterparty_node_id,
funding_satoshis,
channel_type,
push_msat: _,
channel_negotiation_type: _,
is_announced: _,
params: _,
} => {
Expand DownExpand Up@@ -1139,6 +1154,8 @@ where
next_channel_id,
prev_user_channel_id,
next_user_channel_id,
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand All@@ -1149,6 +1166,8 @@ where
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
next_user_channel_id: next_user_channel_id.map(UserChannelId),
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
};
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};

use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Expand DownExpand Up@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
check_added_monitors!(nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
check_persisted_data!(11);
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,7 @@ pub use bip39;
pub use bitcoin;
pub use lightning;
pub use lightning_invoice;
pub use lightning_types;
pub use vss_client;

pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
Expand DownExpand Up@@ -823,7 +824,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand All@@ -841,7 +841,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Update BDK to 1.0.0 and LDK to 0.1.0 by tnull · Pull Request #426 · lightningdevkit/ldk-node · GitHub
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
58 changes: 32 additions & 26 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#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-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#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-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.31.0", features = ["bundled"] }
Expand All@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,8 @@ interface Event {
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
Expand All@@ -296,6 +297,7 @@ enum PaymentFailureReason {
"UnknownRequiredFeatures",
"InvoiceRequestExpired",
"InvoiceRequestRejected",
"BlindedPathCreationFailed",
};

[Enum]
Expand Down
3 changes: 2 additions & 1 deletion src/balance.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};

Expand Down
17 changes: 11 additions & 6 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,7 +907,7 @@ fn build_with_store_internal(
));

// Read ChannelMonitor state from store
let mut channel_monitors = match read_channel_monitors(
let channel_monitors = match read_channel_monitors(
Arc::clone(&kv_store),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand DownExpand Up@@ -936,6 +936,9 @@ fn build_with_store_internal(
100;
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));

// Initialize the ChannelManager
let channel_manager = {
if let Ok(res) = kv_store.read(
Expand All@@ -945,7 +948,7 @@ fn build_with_store_internal(
) {
let mut reader = Cursor::new(res);
let channel_monitor_references =
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
let read_args = ChannelManagerReadArgs::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -954,6 +957,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
user_config,
channel_monitor_references,
Expand All@@ -978,6 +982,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
})?;
}

let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));

// Initialize the PeerManager
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&channel_manager),
Arc::new(message_router),
message_router,
Arc::clone(&channel_manager),
IgnoringMessageHandler {},
IgnoringMessageHandler {},
IgnoringMessageHandler {},
));
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();

Expand DownExpand Up@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
let lsps2_client_config = Some(LSPS2ClientConfig {});
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
let liquidity_client_config =
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
let liquidity_manager = Arc::new(LiquidityManager::new(
Arc::clone(&keys_manager),
Arc::clone(&channel_manager),
Expand Down
5 changes: 1 addition & 4 deletions src/chain/bitcoind_rpc.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
let rpc_credentials =
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));

let rpc_client = Arc::new(
RpcClient::new(&rpc_credentials, http_endpoint)
.expect("RpcClient::new is actually infallible"),
);
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));

let latest_mempool_timestamp = AtomicU64::new(0);

Expand Down
16 changes: 5 additions & 11 deletions src/chain/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -787,18 +787,12 @@ impl ChainSource {
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);

// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
// yields less than that. This is mostly necessary to continue on
// `signet`/`regtest` where we might not get estimates (or bogus values).
let converted_estimate_sat_vb =
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
|e| {
log_error!(
logger,
"Failed to convert fee rate estimates for {:?}: {}",
target,
e
);
Error::FeerateEstimationUpdateFailed
},
)?;
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
.map_or(1.0, |converted| converted.max(1.0));

let fee_rate =
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);
Expand Down
23 changes: 21 additions & 2 deletions src/event.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::blockdata::locktime::absolute::LockTime;
Expand DownExpand Up@@ -120,6 +121,16 @@ pub enum Event {
/// This will be `None` if the payment was settled via an on-chain transaction. See the
/// caveat described for the `total_fee_earned_msat` field.
next_user_channel_id: Option<UserChannelId>,
/// The node id of the previous node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
prev_node_id: Option<PublicKey>,
/// The node id of the next node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
next_node_id: Option<PublicKey>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
Expand DownExpand Up@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
},
(7, PaymentForwarded) => {
(0, prev_channel_id, required),
(1, prev_node_id, option),
(2, next_channel_id, required),
(3, next_node_id, option),
(4, prev_user_channel_id, option),
(6, next_user_channel_id, option),
(8, total_fee_earned_msat, option),
Expand DownExpand Up@@ -550,6 +563,7 @@ where
claim_deadline,
onion_fields,
counterparty_skimmed_fee_msat,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
if let Some(info) = self.payment_store.get(&payment_id) {
Expand DownExpand Up@@ -812,6 +826,7 @@ where
htlcs: _,
sender_intended_total_msat: _,
onion_fields,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
log_info!(
Expand DownExpand Up@@ -1025,7 +1040,7 @@ where
counterparty_node_id,
funding_satoshis,
channel_type,
push_msat: _,
channel_negotiation_type: _,
is_announced: _,
params: _,
} => {
Expand DownExpand Up@@ -1139,6 +1154,8 @@ where
next_channel_id,
prev_user_channel_id,
next_user_channel_id,
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand All@@ -1149,6 +1166,8 @@ where
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
next_user_channel_id: next_user_channel_id.map(UserChannelId),
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
};
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};

use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Expand DownExpand Up@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
check_added_monitors!(nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
check_persisted_data!(11);
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,7 @@ pub use bip39;
pub use bitcoin;
pub use lightning;
pub use lightning_invoice;
pub use lightning_types;
pub use vss_client;

pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
Expand DownExpand Up@@ -823,7 +824,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand All@@ -841,7 +841,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Update BDK to 1.0.0 and LDK to 0.1.0 by tnull · Pull Request #426 · lightningdevkit/ldk-node · GitHub
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
58 changes: 32 additions & 26 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#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-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#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-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.31.0", features = ["bundled"] }
Expand All@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,8 @@ interface Event {
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
Expand All@@ -296,6 +297,7 @@ enum PaymentFailureReason {
"UnknownRequiredFeatures",
"InvoiceRequestExpired",
"InvoiceRequestRejected",
"BlindedPathCreationFailed",
};

[Enum]
Expand Down
3 changes: 2 additions & 1 deletion src/balance.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};

Expand Down
17 changes: 11 additions & 6 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,7 +907,7 @@ fn build_with_store_internal(
));

// Read ChannelMonitor state from store
let mut channel_monitors = match read_channel_monitors(
let channel_monitors = match read_channel_monitors(
Arc::clone(&kv_store),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand DownExpand Up@@ -936,6 +936,9 @@ fn build_with_store_internal(
100;
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));

// Initialize the ChannelManager
let channel_manager = {
if let Ok(res) = kv_store.read(
Expand All@@ -945,7 +948,7 @@ fn build_with_store_internal(
) {
let mut reader = Cursor::new(res);
let channel_monitor_references =
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
let read_args = ChannelManagerReadArgs::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -954,6 +957,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
user_config,
channel_monitor_references,
Expand All@@ -978,6 +982,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
})?;
}

let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));

// Initialize the PeerManager
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&channel_manager),
Arc::new(message_router),
message_router,
Arc::clone(&channel_manager),
IgnoringMessageHandler {},
IgnoringMessageHandler {},
IgnoringMessageHandler {},
));
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();

Expand DownExpand Up@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
let lsps2_client_config = Some(LSPS2ClientConfig {});
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
let liquidity_client_config =
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
let liquidity_manager = Arc::new(LiquidityManager::new(
Arc::clone(&keys_manager),
Arc::clone(&channel_manager),
Expand Down
5 changes: 1 addition & 4 deletions src/chain/bitcoind_rpc.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
let rpc_credentials =
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));

let rpc_client = Arc::new(
RpcClient::new(&rpc_credentials, http_endpoint)
.expect("RpcClient::new is actually infallible"),
);
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));

let latest_mempool_timestamp = AtomicU64::new(0);

Expand Down
16 changes: 5 additions & 11 deletions src/chain/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -787,18 +787,12 @@ impl ChainSource {
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);

// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
// yields less than that. This is mostly necessary to continue on
// `signet`/`regtest` where we might not get estimates (or bogus values).
let converted_estimate_sat_vb =
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
|e| {
log_error!(
logger,
"Failed to convert fee rate estimates for {:?}: {}",
target,
e
);
Error::FeerateEstimationUpdateFailed
},
)?;
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
.map_or(1.0, |converted| converted.max(1.0));

let fee_rate =
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);
Expand Down
23 changes: 21 additions & 2 deletions src/event.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::blockdata::locktime::absolute::LockTime;
Expand DownExpand Up@@ -120,6 +121,16 @@ pub enum Event {
/// This will be `None` if the payment was settled via an on-chain transaction. See the
/// caveat described for the `total_fee_earned_msat` field.
next_user_channel_id: Option<UserChannelId>,
/// The node id of the previous node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
prev_node_id: Option<PublicKey>,
/// The node id of the next node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
next_node_id: Option<PublicKey>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
Expand DownExpand Up@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
},
(7, PaymentForwarded) => {
(0, prev_channel_id, required),
(1, prev_node_id, option),
(2, next_channel_id, required),
(3, next_node_id, option),
(4, prev_user_channel_id, option),
(6, next_user_channel_id, option),
(8, total_fee_earned_msat, option),
Expand DownExpand Up@@ -550,6 +563,7 @@ where
claim_deadline,
onion_fields,
counterparty_skimmed_fee_msat,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
if let Some(info) = self.payment_store.get(&payment_id) {
Expand DownExpand Up@@ -812,6 +826,7 @@ where
htlcs: _,
sender_intended_total_msat: _,
onion_fields,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
log_info!(
Expand DownExpand Up@@ -1025,7 +1040,7 @@ where
counterparty_node_id,
funding_satoshis,
channel_type,
push_msat: _,
channel_negotiation_type: _,
is_announced: _,
params: _,
} => {
Expand DownExpand Up@@ -1139,6 +1154,8 @@ where
next_channel_id,
prev_user_channel_id,
next_user_channel_id,
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand All@@ -1149,6 +1166,8 @@ where
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
next_user_channel_id: next_user_channel_id.map(UserChannelId),
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
};
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};

use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Expand DownExpand Up@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
check_added_monitors!(nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
check_persisted_data!(11);
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,7 @@ pub use bip39;
pub use bitcoin;
pub use lightning;
pub use lightning_invoice;
pub use lightning_types;
pub use vss_client;

pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
Expand DownExpand Up@@ -823,7 +824,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand All@@ -841,7 +841,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Update BDK to 1.0.0 and LDK to 0.1.0 by tnull · Pull Request #426 · lightningdevkit/ldk-node · GitHub
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
58 changes: 32 additions & 26 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#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-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#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-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.31.0", features = ["bundled"] }
Expand All@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,8 @@ interface Event {
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
Expand All@@ -296,6 +297,7 @@ enum PaymentFailureReason {
"UnknownRequiredFeatures",
"InvoiceRequestExpired",
"InvoiceRequestRejected",
"BlindedPathCreationFailed",
};

[Enum]
Expand Down
3 changes: 2 additions & 1 deletion src/balance.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};

Expand Down
17 changes: 11 additions & 6 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,7 +907,7 @@ fn build_with_store_internal(
));

// Read ChannelMonitor state from store
let mut channel_monitors = match read_channel_monitors(
let channel_monitors = match read_channel_monitors(
Arc::clone(&kv_store),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand DownExpand Up@@ -936,6 +936,9 @@ fn build_with_store_internal(
100;
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));

// Initialize the ChannelManager
let channel_manager = {
if let Ok(res) = kv_store.read(
Expand All@@ -945,7 +948,7 @@ fn build_with_store_internal(
) {
let mut reader = Cursor::new(res);
let channel_monitor_references =
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
let read_args = ChannelManagerReadArgs::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -954,6 +957,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
user_config,
channel_monitor_references,
Expand All@@ -978,6 +982,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
})?;
}

let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));

// Initialize the PeerManager
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&channel_manager),
Arc::new(message_router),
message_router,
Arc::clone(&channel_manager),
IgnoringMessageHandler {},
IgnoringMessageHandler {},
IgnoringMessageHandler {},
));
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();

Expand DownExpand Up@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
let lsps2_client_config = Some(LSPS2ClientConfig {});
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
let liquidity_client_config =
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
let liquidity_manager = Arc::new(LiquidityManager::new(
Arc::clone(&keys_manager),
Arc::clone(&channel_manager),
Expand Down
5 changes: 1 addition & 4 deletions src/chain/bitcoind_rpc.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
let rpc_credentials =
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));

let rpc_client = Arc::new(
RpcClient::new(&rpc_credentials, http_endpoint)
.expect("RpcClient::new is actually infallible"),
);
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));

let latest_mempool_timestamp = AtomicU64::new(0);

Expand Down
16 changes: 5 additions & 11 deletions src/chain/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -787,18 +787,12 @@ impl ChainSource {
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);

// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
// yields less than that. This is mostly necessary to continue on
// `signet`/`regtest` where we might not get estimates (or bogus values).
let converted_estimate_sat_vb =
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
|e| {
log_error!(
logger,
"Failed to convert fee rate estimates for {:?}: {}",
target,
e
);
Error::FeerateEstimationUpdateFailed
},
)?;
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
.map_or(1.0, |converted| converted.max(1.0));

let fee_rate =
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);
Expand Down
23 changes: 21 additions & 2 deletions src/event.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::blockdata::locktime::absolute::LockTime;
Expand DownExpand Up@@ -120,6 +121,16 @@ pub enum Event {
/// This will be `None` if the payment was settled via an on-chain transaction. See the
/// caveat described for the `total_fee_earned_msat` field.
next_user_channel_id: Option<UserChannelId>,
/// The node id of the previous node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
prev_node_id: Option<PublicKey>,
/// The node id of the next node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
next_node_id: Option<PublicKey>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
Expand DownExpand Up@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
},
(7, PaymentForwarded) => {
(0, prev_channel_id, required),
(1, prev_node_id, option),
(2, next_channel_id, required),
(3, next_node_id, option),
(4, prev_user_channel_id, option),
(6, next_user_channel_id, option),
(8, total_fee_earned_msat, option),
Expand DownExpand Up@@ -550,6 +563,7 @@ where
claim_deadline,
onion_fields,
counterparty_skimmed_fee_msat,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
if let Some(info) = self.payment_store.get(&payment_id) {
Expand DownExpand Up@@ -812,6 +826,7 @@ where
htlcs: _,
sender_intended_total_msat: _,
onion_fields,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
log_info!(
Expand DownExpand Up@@ -1025,7 +1040,7 @@ where
counterparty_node_id,
funding_satoshis,
channel_type,
push_msat: _,
channel_negotiation_type: _,
is_announced: _,
params: _,
} => {
Expand DownExpand Up@@ -1139,6 +1154,8 @@ where
next_channel_id,
prev_user_channel_id,
next_user_channel_id,
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand All@@ -1149,6 +1166,8 @@ where
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
next_user_channel_id: next_user_channel_id.map(UserChannelId),
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
};
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};

use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Expand DownExpand Up@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
check_added_monitors!(nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
check_persisted_data!(11);
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,7 @@ pub use bip39;
pub use bitcoin;
pub use lightning;
pub use lightning_invoice;
pub use lightning_types;
pub use vss_client;

pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
Expand DownExpand Up@@ -823,7 +824,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand All@@ -841,7 +841,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Update BDK to 1.0.0 and LDK to 0.1.0 by tnull · Pull Request #426 · lightningdevkit/ldk-node · GitHub
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
58 changes: 32 additions & 26 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#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-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#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-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.31.0", features = ["bundled"] }
Expand All@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,8 @@ interface Event {
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
Expand All@@ -296,6 +297,7 @@ enum PaymentFailureReason {
"UnknownRequiredFeatures",
"InvoiceRequestExpired",
"InvoiceRequestRejected",
"BlindedPathCreationFailed",
};

[Enum]
Expand Down
3 changes: 2 additions & 1 deletion src/balance.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};

Expand Down
17 changes: 11 additions & 6 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,7 +907,7 @@ fn build_with_store_internal(
));

// Read ChannelMonitor state from store
let mut channel_monitors = match read_channel_monitors(
let channel_monitors = match read_channel_monitors(
Arc::clone(&kv_store),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand DownExpand Up@@ -936,6 +936,9 @@ fn build_with_store_internal(
100;
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));

// Initialize the ChannelManager
let channel_manager = {
if let Ok(res) = kv_store.read(
Expand All@@ -945,7 +948,7 @@ fn build_with_store_internal(
) {
let mut reader = Cursor::new(res);
let channel_monitor_references =
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
let read_args = ChannelManagerReadArgs::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -954,6 +957,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
user_config,
channel_monitor_references,
Expand All@@ -978,6 +982,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
})?;
}

let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));

// Initialize the PeerManager
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&channel_manager),
Arc::new(message_router),
message_router,
Arc::clone(&channel_manager),
IgnoringMessageHandler {},
IgnoringMessageHandler {},
IgnoringMessageHandler {},
));
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();

Expand DownExpand Up@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
let lsps2_client_config = Some(LSPS2ClientConfig {});
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
let liquidity_client_config =
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
let liquidity_manager = Arc::new(LiquidityManager::new(
Arc::clone(&keys_manager),
Arc::clone(&channel_manager),
Expand Down
5 changes: 1 addition & 4 deletions src/chain/bitcoind_rpc.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
let rpc_credentials =
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));

let rpc_client = Arc::new(
RpcClient::new(&rpc_credentials, http_endpoint)
.expect("RpcClient::new is actually infallible"),
);
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));

let latest_mempool_timestamp = AtomicU64::new(0);

Expand Down
16 changes: 5 additions & 11 deletions src/chain/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -787,18 +787,12 @@ impl ChainSource {
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);

// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
// yields less than that. This is mostly necessary to continue on
// `signet`/`regtest` where we might not get estimates (or bogus values).
let converted_estimate_sat_vb =
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
|e| {
log_error!(
logger,
"Failed to convert fee rate estimates for {:?}: {}",
target,
e
);
Error::FeerateEstimationUpdateFailed
},
)?;
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
.map_or(1.0, |converted| converted.max(1.0));

let fee_rate =
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);
Expand Down
23 changes: 21 additions & 2 deletions src/event.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::blockdata::locktime::absolute::LockTime;
Expand DownExpand Up@@ -120,6 +121,16 @@ pub enum Event {
/// This will be `None` if the payment was settled via an on-chain transaction. See the
/// caveat described for the `total_fee_earned_msat` field.
next_user_channel_id: Option<UserChannelId>,
/// The node id of the previous node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
prev_node_id: Option<PublicKey>,
/// The node id of the next node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
next_node_id: Option<PublicKey>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
Expand DownExpand Up@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
},
(7, PaymentForwarded) => {
(0, prev_channel_id, required),
(1, prev_node_id, option),
(2, next_channel_id, required),
(3, next_node_id, option),
(4, prev_user_channel_id, option),
(6, next_user_channel_id, option),
(8, total_fee_earned_msat, option),
Expand DownExpand Up@@ -550,6 +563,7 @@ where
claim_deadline,
onion_fields,
counterparty_skimmed_fee_msat,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
if let Some(info) = self.payment_store.get(&payment_id) {
Expand DownExpand Up@@ -812,6 +826,7 @@ where
htlcs: _,
sender_intended_total_msat: _,
onion_fields,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
log_info!(
Expand DownExpand Up@@ -1025,7 +1040,7 @@ where
counterparty_node_id,
funding_satoshis,
channel_type,
push_msat: _,
channel_negotiation_type: _,
is_announced: _,
params: _,
} => {
Expand DownExpand Up@@ -1139,6 +1154,8 @@ where
next_channel_id,
prev_user_channel_id,
next_user_channel_id,
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand All@@ -1149,6 +1166,8 @@ where
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
next_user_channel_id: next_user_channel_id.map(UserChannelId),
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
};
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};

use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Expand DownExpand Up@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
check_added_monitors!(nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
check_persisted_data!(11);
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,7 @@ pub use bip39;
pub use bitcoin;
pub use lightning;
pub use lightning_invoice;
pub use lightning_types;
pub use vss_client;

pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
Expand DownExpand Up@@ -823,7 +824,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand All@@ -841,7 +841,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Update BDK to 1.0.0 and LDK to 0.1.0 by tnull · Pull Request #426 · lightningdevkit/ldk-node · GitHub
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
58 changes: 32 additions & 26 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#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-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#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-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.31.0", features = ["bundled"] }
Expand All@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,8 @@ interface Event {
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
Expand All@@ -296,6 +297,7 @@ enum PaymentFailureReason {
"UnknownRequiredFeatures",
"InvoiceRequestExpired",
"InvoiceRequestRejected",
"BlindedPathCreationFailed",
};

[Enum]
Expand Down
3 changes: 2 additions & 1 deletion src/balance.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};

Expand Down
17 changes: 11 additions & 6 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,7 +907,7 @@ fn build_with_store_internal(
));

// Read ChannelMonitor state from store
let mut channel_monitors = match read_channel_monitors(
let channel_monitors = match read_channel_monitors(
Arc::clone(&kv_store),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand DownExpand Up@@ -936,6 +936,9 @@ fn build_with_store_internal(
100;
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));

// Initialize the ChannelManager
let channel_manager = {
if let Ok(res) = kv_store.read(
Expand All@@ -945,7 +948,7 @@ fn build_with_store_internal(
) {
let mut reader = Cursor::new(res);
let channel_monitor_references =
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
let read_args = ChannelManagerReadArgs::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -954,6 +957,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
user_config,
channel_monitor_references,
Expand All@@ -978,6 +982,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
})?;
}

let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));

// Initialize the PeerManager
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&channel_manager),
Arc::new(message_router),
message_router,
Arc::clone(&channel_manager),
IgnoringMessageHandler {},
IgnoringMessageHandler {},
IgnoringMessageHandler {},
));
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();

Expand DownExpand Up@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
let lsps2_client_config = Some(LSPS2ClientConfig {});
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
let liquidity_client_config =
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
let liquidity_manager = Arc::new(LiquidityManager::new(
Arc::clone(&keys_manager),
Arc::clone(&channel_manager),
Expand Down
5 changes: 1 addition & 4 deletions src/chain/bitcoind_rpc.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
let rpc_credentials =
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));

let rpc_client = Arc::new(
RpcClient::new(&rpc_credentials, http_endpoint)
.expect("RpcClient::new is actually infallible"),
);
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));

let latest_mempool_timestamp = AtomicU64::new(0);

Expand Down
16 changes: 5 additions & 11 deletions src/chain/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -787,18 +787,12 @@ impl ChainSource {
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);

// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
// yields less than that. This is mostly necessary to continue on
// `signet`/`regtest` where we might not get estimates (or bogus values).
let converted_estimate_sat_vb =
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
|e| {
log_error!(
logger,
"Failed to convert fee rate estimates for {:?}: {}",
target,
e
);
Error::FeerateEstimationUpdateFailed
},
)?;
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
.map_or(1.0, |converted| converted.max(1.0));

let fee_rate =
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);
Expand Down
23 changes: 21 additions & 2 deletions src/event.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::blockdata::locktime::absolute::LockTime;
Expand DownExpand Up@@ -120,6 +121,16 @@ pub enum Event {
/// This will be `None` if the payment was settled via an on-chain transaction. See the
/// caveat described for the `total_fee_earned_msat` field.
next_user_channel_id: Option<UserChannelId>,
/// The node id of the previous node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
prev_node_id: Option<PublicKey>,
/// The node id of the next node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
next_node_id: Option<PublicKey>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
Expand DownExpand Up@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
},
(7, PaymentForwarded) => {
(0, prev_channel_id, required),
(1, prev_node_id, option),
(2, next_channel_id, required),
(3, next_node_id, option),
(4, prev_user_channel_id, option),
(6, next_user_channel_id, option),
(8, total_fee_earned_msat, option),
Expand DownExpand Up@@ -550,6 +563,7 @@ where
claim_deadline,
onion_fields,
counterparty_skimmed_fee_msat,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
if let Some(info) = self.payment_store.get(&payment_id) {
Expand DownExpand Up@@ -812,6 +826,7 @@ where
htlcs: _,
sender_intended_total_msat: _,
onion_fields,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
log_info!(
Expand DownExpand Up@@ -1025,7 +1040,7 @@ where
counterparty_node_id,
funding_satoshis,
channel_type,
push_msat: _,
channel_negotiation_type: _,
is_announced: _,
params: _,
} => {
Expand DownExpand Up@@ -1139,6 +1154,8 @@ where
next_channel_id,
prev_user_channel_id,
next_user_channel_id,
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand All@@ -1149,6 +1166,8 @@ where
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
next_user_channel_id: next_user_channel_id.map(UserChannelId),
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
};
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};

use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Expand DownExpand Up@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
check_added_monitors!(nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
check_persisted_data!(11);
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,7 @@ pub use bip39;
pub use bitcoin;
pub use lightning;
pub use lightning_invoice;
pub use lightning_types;
pub use vss_client;

pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
Expand DownExpand Up@@ -823,7 +824,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand All@@ -841,7 +841,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Update BDK to 1.0.0 and LDK to 0.1.0 by tnull · Pull Request #426 · lightningdevkit/ldk-node · GitHub
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
58 changes: 32 additions & 26 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#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-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#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-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.31.0", features = ["bundled"] }
Expand All@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,8 @@ interface Event {
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
Expand All@@ -296,6 +297,7 @@ enum PaymentFailureReason {
"UnknownRequiredFeatures",
"InvoiceRequestExpired",
"InvoiceRequestRejected",
"BlindedPathCreationFailed",
};

[Enum]
Expand Down
3 changes: 2 additions & 1 deletion src/balance.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};

Expand Down
17 changes: 11 additions & 6 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,7 +907,7 @@ fn build_with_store_internal(
));

// Read ChannelMonitor state from store
let mut channel_monitors = match read_channel_monitors(
let channel_monitors = match read_channel_monitors(
Arc::clone(&kv_store),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand DownExpand Up@@ -936,6 +936,9 @@ fn build_with_store_internal(
100;
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));

// Initialize the ChannelManager
let channel_manager = {
if let Ok(res) = kv_store.read(
Expand All@@ -945,7 +948,7 @@ fn build_with_store_internal(
) {
let mut reader = Cursor::new(res);
let channel_monitor_references =
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
let read_args = ChannelManagerReadArgs::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -954,6 +957,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
user_config,
channel_monitor_references,
Expand All@@ -978,6 +982,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
})?;
}

let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));

// Initialize the PeerManager
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&channel_manager),
Arc::new(message_router),
message_router,
Arc::clone(&channel_manager),
IgnoringMessageHandler {},
IgnoringMessageHandler {},
IgnoringMessageHandler {},
));
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();

Expand DownExpand Up@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
let lsps2_client_config = Some(LSPS2ClientConfig {});
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
let liquidity_client_config =
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
let liquidity_manager = Arc::new(LiquidityManager::new(
Arc::clone(&keys_manager),
Arc::clone(&channel_manager),
Expand Down
5 changes: 1 addition & 4 deletions src/chain/bitcoind_rpc.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
let rpc_credentials =
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));

let rpc_client = Arc::new(
RpcClient::new(&rpc_credentials, http_endpoint)
.expect("RpcClient::new is actually infallible"),
);
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));

let latest_mempool_timestamp = AtomicU64::new(0);

Expand Down
16 changes: 5 additions & 11 deletions src/chain/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -787,18 +787,12 @@ impl ChainSource {
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);

// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
// yields less than that. This is mostly necessary to continue on
// `signet`/`regtest` where we might not get estimates (or bogus values).
let converted_estimate_sat_vb =
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
|e| {
log_error!(
logger,
"Failed to convert fee rate estimates for {:?}: {}",
target,
e
);
Error::FeerateEstimationUpdateFailed
},
)?;
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
.map_or(1.0, |converted| converted.max(1.0));

let fee_rate =
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);
Expand Down
23 changes: 21 additions & 2 deletions src/event.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::blockdata::locktime::absolute::LockTime;
Expand DownExpand Up@@ -120,6 +121,16 @@ pub enum Event {
/// This will be `None` if the payment was settled via an on-chain transaction. See the
/// caveat described for the `total_fee_earned_msat` field.
next_user_channel_id: Option<UserChannelId>,
/// The node id of the previous node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
prev_node_id: Option<PublicKey>,
/// The node id of the next node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
next_node_id: Option<PublicKey>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
Expand DownExpand Up@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
},
(7, PaymentForwarded) => {
(0, prev_channel_id, required),
(1, prev_node_id, option),
(2, next_channel_id, required),
(3, next_node_id, option),
(4, prev_user_channel_id, option),
(6, next_user_channel_id, option),
(8, total_fee_earned_msat, option),
Expand DownExpand Up@@ -550,6 +563,7 @@ where
claim_deadline,
onion_fields,
counterparty_skimmed_fee_msat,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
if let Some(info) = self.payment_store.get(&payment_id) {
Expand DownExpand Up@@ -812,6 +826,7 @@ where
htlcs: _,
sender_intended_total_msat: _,
onion_fields,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
log_info!(
Expand DownExpand Up@@ -1025,7 +1040,7 @@ where
counterparty_node_id,
funding_satoshis,
channel_type,
push_msat: _,
channel_negotiation_type: _,
is_announced: _,
params: _,
} => {
Expand DownExpand Up@@ -1139,6 +1154,8 @@ where
next_channel_id,
prev_user_channel_id,
next_user_channel_id,
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand All@@ -1149,6 +1166,8 @@ where
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
next_user_channel_id: next_user_channel_id.map(UserChannelId),
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
};
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};

use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Expand DownExpand Up@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
check_added_monitors!(nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
check_persisted_data!(11);
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,7 @@ pub use bip39;
pub use bitcoin;
pub use lightning;
pub use lightning_invoice;
pub use lightning_types;
pub use vss_client;

pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
Expand DownExpand Up@@ -823,7 +824,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand All@@ -841,7 +841,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Update BDK to 1.0.0 and LDK to 0.1.0 by tnull · Pull Request #426 · lightningdevkit/ldk-node · GitHub
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
58 changes: 32 additions & 26 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#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-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#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-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.31.0", features = ["bundled"] }
Expand All@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,8 @@ interface Event {
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
Expand All@@ -296,6 +297,7 @@ enum PaymentFailureReason {
"UnknownRequiredFeatures",
"InvoiceRequestExpired",
"InvoiceRequestRejected",
"BlindedPathCreationFailed",
};

[Enum]
Expand Down
3 changes: 2 additions & 1 deletion src/balance.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};

Expand Down
17 changes: 11 additions & 6 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,7 +907,7 @@ fn build_with_store_internal(
));

// Read ChannelMonitor state from store
let mut channel_monitors = match read_channel_monitors(
let channel_monitors = match read_channel_monitors(
Arc::clone(&kv_store),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand DownExpand Up@@ -936,6 +936,9 @@ fn build_with_store_internal(
100;
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));

// Initialize the ChannelManager
let channel_manager = {
if let Ok(res) = kv_store.read(
Expand All@@ -945,7 +948,7 @@ fn build_with_store_internal(
) {
let mut reader = Cursor::new(res);
let channel_monitor_references =
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
let read_args = ChannelManagerReadArgs::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -954,6 +957,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
user_config,
channel_monitor_references,
Expand All@@ -978,6 +982,7 @@ fn build_with_store_internal(
Arc::clone(&chain_monitor),
Arc::clone(&tx_broadcaster),
Arc::clone(&router),
Arc::clone(&message_router),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Expand All@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
})?;
}

let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));

// Initialize the PeerManager
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
Arc::clone(&keys_manager),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&channel_manager),
Arc::new(message_router),
message_router,
Arc::clone(&channel_manager),
IgnoringMessageHandler {},
IgnoringMessageHandler {},
IgnoringMessageHandler {},
));
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();

Expand DownExpand Up@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
let lsps2_client_config = Some(LSPS2ClientConfig {});
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
let liquidity_client_config =
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
let liquidity_manager = Arc::new(LiquidityManager::new(
Arc::clone(&keys_manager),
Arc::clone(&channel_manager),
Expand Down
5 changes: 1 addition & 4 deletions src/chain/bitcoind_rpc.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
let rpc_credentials =
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));

let rpc_client = Arc::new(
RpcClient::new(&rpc_credentials, http_endpoint)
.expect("RpcClient::new is actually infallible"),
);
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));

let latest_mempool_timestamp = AtomicU64::new(0);

Expand Down
16 changes: 5 additions & 11 deletions src/chain/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -787,18 +787,12 @@ impl ChainSource {
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);

// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
// yields less than that. This is mostly necessary to continue on
// `signet`/`regtest` where we might not get estimates (or bogus values).
let converted_estimate_sat_vb =
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
|e| {
log_error!(
logger,
"Failed to convert fee rate estimates for {:?}: {}",
target,
e
);
Error::FeerateEstimationUpdateFailed
},
)?;
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
.map_or(1.0, |converted| converted.max(1.0));

let fee_rate =
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);
Expand Down
23 changes: 21 additions & 2 deletions src/event.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::blockdata::locktime::absolute::LockTime;
Expand DownExpand Up@@ -120,6 +121,16 @@ pub enum Event {
/// This will be `None` if the payment was settled via an on-chain transaction. See the
/// caveat described for the `total_fee_earned_msat` field.
next_user_channel_id: Option<UserChannelId>,
/// The node id of the previous node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
prev_node_id: Option<PublicKey>,
/// The node id of the next node.
///
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
/// versions prior to v0.5.
next_node_id: Option<PublicKey>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
Expand DownExpand Up@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
},
(7, PaymentForwarded) => {
(0, prev_channel_id, required),
(1, prev_node_id, option),
(2, next_channel_id, required),
(3, next_node_id, option),
(4, prev_user_channel_id, option),
(6, next_user_channel_id, option),
(8, total_fee_earned_msat, option),
Expand DownExpand Up@@ -550,6 +563,7 @@ where
claim_deadline,
onion_fields,
counterparty_skimmed_fee_msat,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
if let Some(info) = self.payment_store.get(&payment_id) {
Expand DownExpand Up@@ -812,6 +826,7 @@ where
htlcs: _,
sender_intended_total_msat: _,
onion_fields,
payment_id: _,
} => {
let payment_id = PaymentId(payment_hash.0);
log_info!(
Expand DownExpand Up@@ -1025,7 +1040,7 @@ where
counterparty_node_id,
funding_satoshis,
channel_type,
push_msat: _,
channel_negotiation_type: _,
is_announced: _,
params: _,
} => {
Expand DownExpand Up@@ -1139,6 +1154,8 @@ where
next_channel_id,
prev_user_channel_id,
next_user_channel_id,
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand All@@ -1149,6 +1166,8 @@ where
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
next_user_channel_id: next_user_channel_id.map(UserChannelId),
prev_node_id,
next_node_id,
total_fee_earned_msat,
skimmed_fee_msat,
claim_from_onchain_tx,
Expand Down
3 changes: 1 addition & 2 deletions src/io/test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
};
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};

use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Expand DownExpand Up@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
check_added_monitors!(nodes[1], 1);

// Make sure everything is persisted as expected after close.
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
check_persisted_data!(11);
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,7 @@ pub use bip39;
pub use bitcoin;
pub use lightning;
pub use lightning_invoice;
pub use lightning_types;
pub use vss_client;

pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
Expand DownExpand Up@@ -823,7 +824,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand All@@ -841,7 +841,6 @@ impl Node {
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
Arc::clone(&self.keys_manager),
self.liquidity_source.clone(),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Expand Down
Loading