Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to LDK 0.2 #462

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
35 changes: 24 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
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 = { 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" }
Expand All @@ -50,6 +50,18 @@ lightning-liquidity = { version = "0.1.0", features = ["std"] }
#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 = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c" }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c", features = ["futures"] }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c", features = ["esplora-async-https", "time"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c" }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
Expand Down Expand Up @@ -89,8 +101,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.1.0", 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 = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "c5fd164f1db6773c6561c1d54bfbafdca8c6278c", 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 }
Expand Down
4 changes: 2 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,8 @@ fn build_with_store_internal(

// Give ChannelMonitors to ChainMonitor
for (_blockhash, channel_monitor) in channel_monitors.into_iter() {
let funding_outpoint = channel_monitor.get_funding_txo().0;
chain_monitor.watch_channel(funding_outpoint, channel_monitor).map_err(|e| {
let channel_id = channel_monitor.channel_id();
chain_monitor.watch_channel(channel_id, channel_monitor).map_err(|e| {
log_error!(logger, "Failed to watch channel monitor: {:?}", e);
BuildError::InvalidChannelMonitor
})?;
Expand Down
2 changes: 1 addition & 1 deletion src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl ChainSource {
if let Some(worst_channel_monitor_block_hash) = chain_monitor
.list_monitors()
.iter()
.flat_map(|(txo, _)| chain_monitor.get_monitor(*txo))
.flat_map(|channel_id| chain_monitor.get_monitor(*channel_id))
.map(|m| m.current_best_block())
.min_by_key(|b| b.height)
.map(|b| b.block_hash)
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,8 +1376,8 @@ impl Node {

let mut total_lightning_balance_sats = 0;
let mut lightning_balances = Vec::new();
for (funding_txo, channel_id) in self.chain_monitor.list_monitors() {
match self.chain_monitor.get_monitor(funding_txo) {
for channel_id in self.chain_monitor.list_monitors() {
match self.chain_monitor.get_monitor(channel_id) {
Ok(monitor) => {
// unwrap safety: `get_counterparty_node_id` will always be `Some` after 0.0.110 and
// LDK Node 0.1 depended on 0.0.115 already.
Expand Down
18 changes: 9 additions & 9 deletions src/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA;
use lightning::ln::msgs::SocketAddress;
use lightning::routing::router::{RouteHint, RouteHintHop};
use lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription, InvoiceBuilder, RoutingFees};
use lightning_liquidity::events::Event;
use lightning_liquidity::lsps0::ser::RequestId;
use lightning_liquidity::events::LiquidityEvent;
use lightning_liquidity::lsps0::ser::LSPSRequestId;
use lightning_liquidity::lsps2::event::LSPS2ClientEvent;
use lightning_liquidity::lsps2::msgs::OpeningFeeParams;
use lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams;
use lightning_liquidity::lsps2::utils::compute_opening_fee;

use bitcoin::hashes::{sha256, Hash};
Expand All @@ -35,8 +35,8 @@ struct LSPS2Service {
address: SocketAddress,
node_id: PublicKey,
token: Option<String>,
pending_fee_requests: Mutex<HashMap<RequestId, oneshot::Sender<LSPS2FeeResponse>>>,
pending_buy_requests: Mutex<HashMap<RequestId, oneshot::Sender<LSPS2BuyResponse>>>,
pending_fee_requests: Mutex<HashMap<LSPSRequestId, oneshot::Sender<LSPS2FeeResponse>>>,
pending_buy_requests: Mutex<HashMap<LSPSRequestId, oneshot::Sender<LSPS2BuyResponse>>>,
}

pub(crate) struct LiquiditySource<L: Deref>
Expand Down Expand Up @@ -87,7 +87,7 @@ where

pub(crate) async fn handle_next_event(&self) {
match self.liquidity_manager.next_event_async().await {
Event::LSPS2Client(LSPS2ClientEvent::OpeningParametersReady {
LiquidityEvent::LSPS2Client(LSPS2ClientEvent::OpeningParametersReady {
request_id,
counterparty_node_id,
opening_fee_params_menu,
Expand Down Expand Up @@ -137,7 +137,7 @@ where
);
}
},
Event::LSPS2Client(LSPS2ClientEvent::InvoiceParametersReady {
LiquidityEvent::LSPS2Client(LSPS2ClientEvent::InvoiceParametersReady {
request_id,
counterparty_node_id,
intercept_scid,
Expand Down Expand Up @@ -330,7 +330,7 @@ where
}

async fn lsps2_send_buy_request(
&self, amount_msat: Option<u64>, opening_fee_params: OpeningFeeParams,
&self, amount_msat: Option<u64>, opening_fee_params: LSPS2OpeningFeeParams,
) -> Result<LSPS2BuyResponse, Error> {
let lsps2_service = self.lsps2_service.as_ref().ok_or(Error::LiquiditySourceUnavailable)?;

Expand Down Expand Up @@ -430,7 +430,7 @@ where

#[derive(Debug, Clone)]
pub(crate) struct LSPS2FeeResponse {
opening_fee_params_menu: Vec<OpeningFeeParams>,
opening_fee_params_menu: Vec<LSPS2OpeningFeeParams>,
}

#[derive(Debug, Clone)]
Expand Down
Loading