Skip to content
Open
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
32 changes: 16 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ default = []
#lightning-macros = { version = "0.2.0" }
#lightning-dns-resolver = { version = "0.3.0" }

lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" }
lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }

bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls-ring"]}
bdk_electrum = { version = "0.24.0", default-features = false, features = ["use-rustls-ring"]}
bdk_wallet = { version = "2.3.0", default-features = false, features = ["std", "keys-bip39"]}

bitreq = { version = "0.3", default-features = false, features = ["async-https", "json-using-serde"] }
Expand All @@ -70,7 +70,7 @@ getrandom = { version = "0.3", default-features = false }
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros", "net" ] }
esplora-client = { version = "0.12", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.24.0", default-features = false, features = ["proxy", "use-rustls-ring"] }
electrum-client = { version = "0.25", default-features = false, features = ["proxy", "use-rustls-ring"] }
libc = "0.2"
uniffi = { version = "0.29.5", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All @@ -81,13 +81,13 @@ async-trait = { version = "0.1", default-features = false }
vss-client = { package = "vss-client-ng", version = "0.5" }
prost = { version = "0.11.6", default-features = false}
#bitcoin-payment-instructions = { version = "0.6" }
bitcoin-payment-instructions = { git = "https://github.com/jkczyz/bitcoin-payment-instructions", rev = "679dac50cc0d81ec4d31da94b93d467e5308f16a" }
bitcoin-payment-instructions = { git = "https://github.com/jkczyz/bitcoin-payment-instructions", rev = "c7d7ea849fcbe8cad385c93f8057cd68ecb994b7" }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "369a2cf9c8ef810deea0cd2b4cf6ed0691b78144", features = ["std", "_test_utils"] }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["std", "_test_utils"] }
rand = { version = "0.9.2", default-features = false, features = ["std", "thread_rng", "os_rng"] }
proptest = "1.0.0"
regex = "1.5.6"
Expand Down
2 changes: 1 addition & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use bitcoin::secp256k1::PublicKey;
use bitcoin::Network;
use bitcoin_payment_instructions::dns_resolver::DNSHrnResolver;
use bitcoin_payment_instructions::onion_message_resolver::LDKOnionMessageDNSSECHrnResolver;
use lightning::chain::{chainmonitor, BestBlock as BlockLocator};
use lightning::chain::{chainmonitor, BlockLocator};
use lightning::ln::channelmanager::{self, ChainParameters, ChannelManagerReadArgs};
use lightning::ln::msgs::{RoutingMessageHandler, SocketAddress};
use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler};
Expand Down
6 changes: 3 additions & 3 deletions src/chain/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use base64::prelude::BASE64_STANDARD;
use base64::Engine;
use bitcoin::{BlockHash, FeeRate, Network, OutPoint, Transaction, Txid};
use lightning::chain::chaininterface::ConfirmationTarget as LdkConfirmationTarget;
use lightning::chain::{BestBlock as BlockLocator, Listen};
use lightning::chain::{BlockLocator, Listen};
use lightning::util::ser::Writeable;
use lightning_block_sync::gossip::UtxoSource;
use lightning_block_sync::http::{HttpClientError, JsonResponse};
Expand Down Expand Up @@ -326,7 +326,7 @@ impl BitcoindChainSource {
}

pub(super) async fn poll_best_block(&self) -> Result<BlockLocator, Error> {
self.poll_chain_tip().await.map(|tip| tip.to_best_block())
self.poll_chain_tip().await.map(|tip| tip.to_block_locator())
}

async fn poll_chain_tip(&self) -> Result<ValidatedBlockHeader, Error> {
Expand Down Expand Up @@ -1365,7 +1365,7 @@ impl Listen for ChainListener {
self.output_sweeper.block_connected(block, height);
}

fn blocks_disconnected(&self, fork_point_block: lightning::chain::BestBlock) {
fn blocks_disconnected(&self, fork_point_block: lightning::chain::BlockLocator) {
self.onchain_wallet.blocks_disconnected(fork_point_block);
self.channel_manager.blocks_disconnected(fork_point_block);
self.chain_monitor.blocks_disconnected(fork_point_block);
Expand Down
6 changes: 4 additions & 2 deletions src/chain/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ impl ElectrumRuntimeClient {
) -> Result<Self, Error> {
let electrum_config = ElectrumConfigBuilder::new()
.retry(ELECTRUM_CLIENT_NUM_RETRIES)
.timeout(Some(sync_config.timeouts_config.per_request_timeout_secs))
.timeout(Some(Duration::from_secs(
sync_config.timeouts_config.per_request_timeout_secs as u64,
)))
.build();

let electrum_client = Arc::new(
Expand Down Expand Up @@ -578,7 +580,7 @@ impl ElectrumRuntimeClient {
let confirmation_targets = get_all_conf_targets();
for target in confirmation_targets {
let num_blocks = get_num_block_defaults_for_target(target);
batch.estimate_fee(num_blocks);
batch.estimate_fee(num_blocks, None);
}

let spawn_fut = self.runtime.spawn_blocking(move || electrum_client.batch_call(&batch));
Expand Down
2 changes: 1 addition & 1 deletion src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::sync::{Arc, Mutex, RwLock};
use std::time::Duration;

use bitcoin::{Script, Txid};
use lightning::chain::{BestBlock as BlockLocator, Filter};
use lightning::chain::{BlockLocator, Filter};

use crate::chain::bitcoind::{BitcoindChainSource, UtxoSourceClient};
use crate::chain::electrum::ElectrumChainSource;
Expand Down
58 changes: 25 additions & 33 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,9 @@ pub enum Event {
/// This will be `None` for events serialized by LDK Node v0.2.1 and prior.
reason: Option<ClosureReason>,
},
/// A channel splice is pending confirmation on-chain.
SplicePending {
/// A channel splice has been negotiated and the funding transaction is pending
/// confirmation on-chain.
SpliceNegotiated {
/// The `channel_id` of the channel.
channel_id: ChannelId,
/// The `user_channel_id` of the channel.
Expand All @@ -281,16 +282,14 @@ pub enum Event {
/// The outpoint of the channel's splice funding transaction.
new_funding_txo: OutPoint,
},
/// A channel splice has failed.
SpliceFailed {
/// A channel splice negotiation round has failed.
SpliceNegotiationFailed {
/// The `channel_id` of the channel.
channel_id: ChannelId,
/// The `user_channel_id` of the channel.
user_channel_id: UserChannelId,
/// The `node_id` of the channel counterparty.
counterparty_node_id: PublicKey,
/// The outpoint of the channel's splice funding transaction, if one was created.
abandoned_funding_txo: Option<OutPoint>,
},
}

Expand Down Expand Up @@ -362,17 +361,16 @@ impl_writeable_tlv_based_enum!(Event,
node_id: legacy_next_node_id,
}])),
},
(8, SplicePending) => {
(8, SpliceNegotiated) => {
(1, channel_id, required),
(3, counterparty_node_id, required),
(5, user_channel_id, required),
(7, new_funding_txo, required),
},
(9, SpliceFailed) => {
(9, SpliceNegotiationFailed) => {
(1, channel_id, required),
(3, counterparty_node_id, required),
(5, user_channel_id, required),
(7, abandoned_funding_txo, option),
},
);

Expand Down Expand Up @@ -1612,7 +1610,13 @@ where
version: bitcoin::transaction::Version::TWO,
lock_time: bitcoin::absolute::LockTime::ZERO,
input: vec![],
output: outputs,
output: outputs
.into_iter()
.map(|script_pubkey| bitcoin::TxOut {
value: bitcoin::Amount::ZERO,
script_pubkey,
})
.collect(),
};
if let Err(e) = self.wallet.cancel_tx(&tx) {
log_error!(self.logger, "Failed reclaiming unused addresses: {}", e);
Expand Down Expand Up @@ -1814,7 +1818,7 @@ where
},
Err(()) => log_error!(self.logger, "Failed signing funding transaction"),
},
LdkEvent::SplicePending {
LdkEvent::SpliceNegotiated {
channel_id,
user_channel_id,
counterparty_node_id,
Expand All @@ -1823,13 +1827,13 @@ where
} => {
log_info!(
self.logger,
"Channel {} with counterparty {} pending splice with funding_txo {}",
"Channel {} with counterparty {} negotiated splice with funding_txo {}",
channel_id,
counterparty_node_id,
new_funding_txo,
);

let event = Event::SplicePending {
let event = Event::SpliceNegotiated {
channel_id,
user_channel_id: UserChannelId(user_channel_id),
counterparty_node_id,
Expand All @@ -1844,35 +1848,23 @@ where
},
};
},
LdkEvent::SpliceFailed {
LdkEvent::SpliceNegotiationFailed {
channel_id,
user_channel_id,
counterparty_node_id,
abandoned_funding_txo,
..
} => {
if let Some(funding_txo) = abandoned_funding_txo {
log_info!(
self.logger,
"Channel {} with counterparty {} failed splice with funding_txo {}",
channel_id,
counterparty_node_id,
funding_txo,
);
} else {
log_info!(
self.logger,
"Channel {} with counterparty {} failed splice",
channel_id,
counterparty_node_id,
);
}
log_info!(
self.logger,
"Channel {} with counterparty {} splice negotiation failed",
channel_id,
counterparty_node_id,
);

let event = Event::SpliceFailed {
let event = Event::SpliceNegotiationFailed {
channel_id,
user_channel_id: UserChannelId(user_channel_id),
counterparty_node_id,
abandoned_funding_txo,
};

match self.event_queue.add_event(event).await {
Expand Down
29 changes: 19 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ use gossip::GossipSource;
use graph::NetworkGraph;
use io::utils::update_and_persist_node_metrics;
pub use lightning;
use lightning::chain::BestBlock as BlockLocator;
use lightning::chain::BlockLocator;
use lightning::impl_writeable_tlv_based;
use lightning::ln::chan_utils::FUNDING_TRANSACTION_WITNESS_WEIGHT;
use lightning::ln::channel_state::ChannelDetails as LdkChannelDetails;
Expand Down Expand Up @@ -1582,6 +1582,14 @@ impl Node {
Error::ChannelSplicingFailed
})?;

if funding_template.prior_contribution().is_some() {
log_error!(
self.logger,
"Failed to splice channel: a prior splice contribution is pending"
);
return Err(Error::ChannelSplicingFailed);
}

let contribution = self
.runtime
.block_on(funding_template.splice_in(
Expand Down Expand Up @@ -1695,19 +1703,20 @@ impl Node {
Error::ChannelSplicingFailed
})?;

if funding_template.prior_contribution().is_some() {
log_error!(
self.logger,
"Failed to splice channel: a prior splice contribution is pending"
);
return Err(Error::ChannelSplicingFailed);
}

let outputs = vec![bitcoin::TxOut {
value: Amount::from_sat(splice_amount_sats),
script_pubkey: address.script_pubkey(),
}];
let contribution = self
.runtime
.block_on(funding_template.splice_out(
outputs,
min_feerate,
max_feerate,
Arc::clone(&self.wallet),
))
.map_err(|e| {
let contribution =
funding_template.splice_out(outputs, min_feerate, max_feerate).map_err(|e| {
log_error!(self.logger, "Failed to splice channel: {}", e);
Error::ChannelSplicingFailed
})?;
Expand Down
3 changes: 2 additions & 1 deletion src/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@ where
None,
expiry_secs,
Some(min_final_cltv_expiry_delta),
None,
)
.map_err(|e| {
log_error!(self.logger, "Failed to register inbound payment: {:?}", e);
Expand All @@ -1322,7 +1323,7 @@ where
},
None => self
.channel_manager
.create_inbound_payment(None, expiry_secs, Some(min_final_cltv_expiry_delta))
.create_inbound_payment(None, expiry_secs, Some(min_final_cltv_expiry_delta), None)
.map_err(|e| {
log_error!(self.logger, "Failed to register inbound payment: {:?}", e);
Error::InvoiceCreationFailed
Expand Down
8 changes: 5 additions & 3 deletions src/payment/bolt11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Bolt11Payment {
// will know the preimage at this point.
let res = self
.channel_manager
.get_payment_preimage(payment_hash, payment_secret.clone())
.get_payment_preimage(payment_hash, payment_secret.clone(), None)
.ok();
debug_assert!(res.is_some(), "We just let ChannelManager create an inbound payment, it can't have forgotten the preimage by now.");
res
Expand Down Expand Up @@ -206,8 +206,10 @@ impl Bolt11Payment {
max_proportional_opening_fee_ppm_msat: lsp_prop_opening_fee,
};
let id = PaymentId(payment_hash.0);
let preimage =
self.channel_manager.get_payment_preimage(payment_hash, payment_secret.clone()).ok();
let preimage = self
.channel_manager
.get_payment_preimage(payment_hash, payment_secret.clone(), None)
.ok();
let kind = PaymentKind::Bolt11Jit {
hash: payment_hash,
preimage,
Expand Down
Loading
Loading