From 106f5cd620716d8be2a4597875d0f627438212ae Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Thu, 23 Mar 2023 14:11:40 +1100 Subject: [PATCH] fix: Update to latest rust-dlc with bug fix Now we should not run into payout amounts being greater than the total collateral. --- Cargo.lock | 14 +++++++------- Cargo.toml | 14 +++++++------- crates/ln-dlc-node/src/ln/dlc_channel_details.rs | 2 ++ crates/ln-dlc-node/src/node/dlc_channel.rs | 2 +- crates/ln-dlc-node/src/node/mod.rs | 6 ++---- crates/ln-dlc-node/src/node/sub_channel_manager.rs | 2 -- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b9b8d589..8d73f8659 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -825,7 +825,7 @@ dependencies = [ [[package]] name = "dlc" version = "0.4.0" -source = "git+https://github.com/get10101/rust-dlc?rev=ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f#ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" +source = "git+https://github.com/p2pderivatives/rust-dlc?rev=182442b318f5430b74fde407ed79ccad0d596597#182442b318f5430b74fde407ed79ccad0d596597" dependencies = [ "bitcoin", "miniscript", @@ -837,7 +837,7 @@ dependencies = [ [[package]] name = "dlc-manager" version = "0.4.0" -source = "git+https://github.com/get10101/rust-dlc?rev=ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f#ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" +source = "git+https://github.com/p2pderivatives/rust-dlc?rev=182442b318f5430b74fde407ed79ccad0d596597#182442b318f5430b74fde407ed79ccad0d596597" dependencies = [ "async-trait", "bitcoin", @@ -853,7 +853,7 @@ dependencies = [ [[package]] name = "dlc-messages" version = "0.4.0" -source = "git+https://github.com/get10101/rust-dlc?rev=ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f#ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" +source = "git+https://github.com/p2pderivatives/rust-dlc?rev=182442b318f5430b74fde407ed79ccad0d596597#182442b318f5430b74fde407ed79ccad0d596597" dependencies = [ "bitcoin", "dlc", @@ -865,7 +865,7 @@ dependencies = [ [[package]] name = "dlc-sled-storage-provider" version = "0.1.0" -source = "git+https://github.com/get10101/rust-dlc?rev=ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f#ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" +source = "git+https://github.com/p2pderivatives/rust-dlc?rev=182442b318f5430b74fde407ed79ccad0d596597#182442b318f5430b74fde407ed79ccad0d596597" dependencies = [ "bitcoin", "dlc-manager", @@ -878,7 +878,7 @@ dependencies = [ [[package]] name = "dlc-trie" version = "0.4.0" -source = "git+https://github.com/get10101/rust-dlc?rev=ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f#ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" +source = "git+https://github.com/p2pderivatives/rust-dlc?rev=182442b318f5430b74fde407ed79ccad0d596597#182442b318f5430b74fde407ed79ccad0d596597" dependencies = [ "bitcoin", "dlc", @@ -1984,7 +1984,7 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "p2pd-oracle-client" version = "0.1.0" -source = "git+https://github.com/get10101/rust-dlc?rev=ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f#ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" +source = "git+https://github.com/p2pderivatives/rust-dlc?rev=182442b318f5430b74fde407ed79ccad0d596597#182442b318f5430b74fde407ed79ccad0d596597" dependencies = [ "chrono", "dlc-manager", @@ -2647,7 +2647,7 @@ dependencies = [ [[package]] name = "simple-wallet" version = "0.1.0" -source = "git+https://github.com/get10101/rust-dlc?rev=ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f#ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" +source = "git+https://github.com/p2pderivatives/rust-dlc?rev=182442b318f5430b74fde407ed79ccad0d596597#182442b318f5430b74fde407ed79ccad0d596597" dependencies = [ "bitcoin", "dlc", diff --git a/Cargo.toml b/Cargo.toml index 3dbafb3e1..aadec7867 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,13 +3,13 @@ members = ["coordinator", "maker", "mobile/native/", "crates/*"] resolver = "2" [patch.crates-io] -dlc-manager = { git = "https://github.com/get10101/rust-dlc", rev = "ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" } -dlc-messages = { git = "https://github.com/get10101/rust-dlc", rev = "ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" } -dlc = { git = "https://github.com/get10101/rust-dlc", rev = "ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" } -dlc-sled-storage-provider = { git = "https://github.com/get10101/rust-dlc", rev = "ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" } -p2pd-oracle-client = { git = "https://github.com/get10101/rust-dlc", rev = "ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" } -dlc-trie = { git = "https://github.com/get10101/rust-dlc", rev = "ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" } -simple-wallet = { git = "https://github.com/get10101/rust-dlc", rev = "ef3fe72c5e0f8930010fb13b6ea5dc3d91457c0f" } +dlc-manager = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "182442b318f5430b74fde407ed79ccad0d596597" } +dlc-messages = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "182442b318f5430b74fde407ed79ccad0d596597" } +dlc = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "182442b318f5430b74fde407ed79ccad0d596597" } +dlc-sled-storage-provider = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "182442b318f5430b74fde407ed79ccad0d596597" } +p2pd-oracle-client = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "182442b318f5430b74fde407ed79ccad0d596597" } +dlc-trie = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "182442b318f5430b74fde407ed79ccad0d596597" } +simple-wallet = { git = "https://github.com/p2pderivatives/rust-dlc", rev = "182442b318f5430b74fde407ed79ccad0d596597" } lightning = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "dff302382d04700f23d79fb3275c1798d775fef6" } lightning-background-processor = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "dff302382d04700f23d79fb3275c1798d775fef6" } lightning-block-sync = { git = "https://github.com/p2pderivatives/rust-lightning/", rev = "dff302382d04700f23d79fb3275c1798d775fef6" } diff --git a/crates/ln-dlc-node/src/ln/dlc_channel_details.rs b/crates/ln-dlc-node/src/ln/dlc_channel_details.rs index ddfc1c4e1..045bb0962 100644 --- a/crates/ln-dlc-node/src/ln/dlc_channel_details.rs +++ b/crates/ln-dlc-node/src/ln/dlc_channel_details.rs @@ -32,6 +32,7 @@ pub enum SubChannelState { CloseConfirmed, OffChainClosed, ClosedPunished, + Rejected, } impl From for DlcChannelDetails { @@ -63,6 +64,7 @@ impl From for SubChannelState { CloseConfirmed(_) => SubChannelState::CloseConfirmed, OffChainClosed => SubChannelState::OffChainClosed, ClosedPunished(_) => SubChannelState::ClosedPunished, + Rejected => SubChannelState::Rejected, } } } diff --git a/crates/ln-dlc-node/src/node/dlc_channel.rs b/crates/ln-dlc-node/src/node/dlc_channel.rs index 73f00df7d..d9ce03b3b 100644 --- a/crates/ln-dlc-node/src/node/dlc_channel.rs +++ b/crates/ln-dlc-node/src/node/dlc_channel.rs @@ -230,6 +230,6 @@ pub fn sub_channel_message_as_str(msg: &SubChannelMessage) -> &str { CloseAccept(_) => "CloseAccept", CloseConfirm(_) => "CloseConfirm", CloseFinalize(_) => "CloseFinalize", - CloseReject(_) => "CloseReject", + Reject(_) => "Reject", } } diff --git a/crates/ln-dlc-node/src/node/mod.rs b/crates/ln-dlc-node/src/node/mod.rs index a3daf43d3..d8e710136 100644 --- a/crates/ln-dlc-node/src/node/mod.rs +++ b/crates/ln-dlc-node/src/node/mod.rs @@ -329,10 +329,8 @@ impl Node { )?; let dlc_manager = Arc::new(dlc_manager); - let sub_channel_manager = { - let (height, _) = ln_dlc_wallet.tip()?; - sub_channel_manager::build(channel_manager.clone(), dlc_manager.clone(), height as u64)? - }; + let sub_channel_manager = + sub_channel_manager::build(channel_manager.clone(), dlc_manager.clone())?; // Connection manager tokio::spawn({ diff --git a/crates/ln-dlc-node/src/node/sub_channel_manager.rs b/crates/ln-dlc-node/src/node/sub_channel_manager.rs index 01931d540..91054c715 100644 --- a/crates/ln-dlc-node/src/node/sub_channel_manager.rs +++ b/crates/ln-dlc-node/src/node/sub_channel_manager.rs @@ -22,11 +22,9 @@ pub type SubChannelManager = sub_channel_manager::SubChannelManager< pub(crate) fn build( channel_manager: Arc, dlc_manager: Arc, - height: u64, ) -> Result> { Ok(Arc::new(SubChannelManager::new( channel_manager.clone(), dlc_manager, - height, ))) }