Skip to content

Commit

Permalink
Merge pull request #2047 from get10101/chore/unreserve-utxos-if-chann…
Browse files Browse the repository at this point in the history
…el-get-rejected

feat(wallet): Unreserve locked outpoints if channel gets rejected
  • Loading branch information
holzeis authored Feb 16, 2024
2 parents d4e6f05 + f06ba5f commit 92ff2da
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix(validation): Show correct max counterparty collateral in validation message.
- Fix(mobile): Calculate counterparty balance correctly when checking the validity of trade parameters.
- Fix(trade): Spawn dedicated tokio task when executing trade
- Fix(trade): Spawn dedicated tokio task when executing trade.
- Chore(wallet): Unreserve locked utxos if offer get rejected.

## [1.8.8] - 2024-02-14

Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ resolver = "2"
# We are using our own fork of `rust-dlc` at least until we can drop all the LN-DLC features. Also,
# `p2pderivatives/rust-dlc#master` is missing certain patches that can only be found in the LN-DLC
# branch.
dlc-manager = { git = "https://github.com/get10101/rust-dlc", rev = "1534c18" }
dlc-messages = { git = "https://github.com/get10101/rust-dlc", rev = "1534c18" }
dlc = { git = "https://github.com/get10101/rust-dlc", rev = "1534c18" }
p2pd-oracle-client = { git = "https://github.com/get10101/rust-dlc", rev = "1534c18" }
dlc-trie = { git = "https://github.com/get10101/rust-dlc", rev = "1534c18" }
dlc-manager = { git = "https://github.com/get10101/rust-dlc", rev = "0ce71cb21f2c0e636af96385c3ed660a1c3e9a6b" }
dlc-messages = { git = "https://github.com/get10101/rust-dlc", rev = "0ce71cb21f2c0e636af96385c3ed660a1c3e9a6b" }
dlc = { git = "https://github.com/get10101/rust-dlc", rev = "0ce71cb21f2c0e636af96385c3ed660a1c3e9a6b" }
p2pd-oracle-client = { git = "https://github.com/get10101/rust-dlc", rev = "0ce71cb21f2c0e636af96385c3ed660a1c3e9a6b" }
dlc-trie = { git = "https://github.com/get10101/rust-dlc", rev = "0ce71cb21f2c0e636af96385c3ed660a1c3e9a6b" }

# We should usually track the `p2pderivatives/split-tx-experiment[-10101]` branch. For now we depend
# on a special fork which removes a panic in `rust-lightning`.
Expand Down
7 changes: 7 additions & 0 deletions crates/ln-dlc-node/src/ldk_node_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ where
Ok(utxos)
}

pub fn unreserve_utxos(&self, outpoints: &[OutPoint]) -> Result<()> {
self.locked_outpoints
.lock()
.retain(|lo| !outpoints.contains(lo));
Ok(())
}

pub fn get_utxos_for_dlc_funding_transaction(
&self,
amount: u64,
Expand Down
11 changes: 11 additions & 0 deletions crates/ln-dlc-node/src/ln_dlc_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use bitcoin::Block;
use bitcoin::BlockHash;
use bitcoin::KeyPair;
use bitcoin::Network;
use bitcoin::OutPoint;
use bitcoin::Script;
use bitcoin::Transaction;
use bitcoin::Txid;
Expand Down Expand Up @@ -298,6 +299,16 @@ impl<S: TenTenOneStorage, N: Storage> dlc_manager::Wallet for LnDlcWallet<S, N>
fn import_address(&self, _address: &Address) -> Result<(), Error> {
Ok(())
}

fn unreserve_utxos(&self, outpoints: &[OutPoint]) -> Result<(), Error> {
self.ln_wallet.unreserve_utxos(outpoints).map_err(|error| {
Error::InvalidState(format!(
"Could not unreserve utxos {outpoints:?}: {error:?}"
))
})?;

Ok(())
}
}

impl<S: TenTenOneStorage, N: Storage> BroadcasterInterface for LnDlcWallet<S, N> {
Expand Down

0 comments on commit 92ff2da

Please sign in to comment.