Skip to content

Commit

Permalink
Merge pull request #2099 from get10101/feat/add-closing-tx
Browse files Browse the repository at this point in the history
Feat: Add closing tx
  • Loading branch information
holzeis authored Feb 28, 2024
2 parents df0f23d + 0f03bd1 commit 2b2ef4d
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 60 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Fix(wallet): Gracefully handle an error during the wallet sync. Fixes an issue where the app was not able to start because of an inconsistent state.
- Fix(wallet): Gracefully handle an error during the wallet sync. Fixes an issue where the app was not able to start because of an inconsistent state.´
- Feat: Show closing txid on closing and closed channels.

## [1.9.0] - 2024-02-26

Expand Down
55 changes: 30 additions & 25 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ 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 = "aa487662a8af75174bf0e60f24e07e171820d0c3" }
dlc-messages = { git = "https://github.com/get10101/rust-dlc", rev = "aa487662a8af75174bf0e60f24e07e171820d0c3" }
dlc = { git = "https://github.com/get10101/rust-dlc", rev = "aa487662a8af75174bf0e60f24e07e171820d0c3" }
p2pd-oracle-client = { git = "https://github.com/get10101/rust-dlc", rev = "aa487662a8af75174bf0e60f24e07e171820d0c3" }
dlc-trie = { git = "https://github.com/get10101/rust-dlc", rev = "aa487662a8af75174bf0e60f24e07e171820d0c3" }
dlc-manager = { git = "https://github.com/get10101/rust-dlc", rev = "bc31c6167e304d7886c328da91e8c17dad1afce5" }
dlc-messages = { git = "https://github.com/get10101/rust-dlc", rev = "bc31c6167e304d7886c328da91e8c17dad1afce5" }
dlc = { git = "https://github.com/get10101/rust-dlc", rev = "bc31c6167e304d7886c328da91e8c17dad1afce5" }
p2pd-oracle-client = { git = "https://github.com/get10101/rust-dlc", rev = "bc31c6167e304d7886c328da91e8c17dad1afce5" }
dlc-trie = { git = "https://github.com/get10101/rust-dlc", rev = "bc31c6167e304d7886c328da91e8c17dad1afce5" }

# 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`.
lightning = { git = "https://github.com/bonomat/rust-lightning-p2p-derivatives", rev = "e49030e" }
lightning-background-processor = { git = "https://github.com/bonomat/rust-lightning-p2p-derivatives", rev = "e49030e" }
lightning-transaction-sync = { git = "https://github.com/bonomat/rust-lightning-p2p-derivatives", rev = "e49030e" }
lightning-net-tokio = { git = "https://github.com/bonomat/rust-lightning-p2p-derivatives", rev = "e49030e" }
lightning-persister = { git = "https://github.com/bonomat/rust-lightning-p2p-derivatives", rev = "e49030e" }
lightning-rapid-gossip-sync = { git = "https://github.com/bonomat/rust-lightning-p2p-derivatives", rev = "e49030e" }

Expand Down
1 change: 1 addition & 0 deletions coordinator/src/collaborative_revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ pub fn confirm_collaborative_revert(
temporary_channel_id: signed_channel.temporary_channel_id,
channel_id: signed_channel.channel_id,
reference_id: None,
closing_txid: revert_transaction.txid(),
}),
// The contract doesn't matter anymore.
None,
Expand Down
45 changes: 42 additions & 3 deletions crates/ln-dlc-node/src/ln/dlc_channel_details.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bitcoin::hashes::hex::ToHex;
use bitcoin::secp256k1::PublicKey;
use dlc_manager::channel::signed_channel::SignedChannel;
use dlc_manager::channel::Channel;
use dlc_manager::DlcChannelId;
use serde::Serialize;
Expand All @@ -17,6 +18,7 @@ pub struct DlcChannelDetails {
pub fee_rate_per_vb: Option<u64>,
pub funding_txid: Option<String>,
pub funding_tx_vout: Option<usize>,
pub closing_txid: Option<String>,
}

#[derive(Serialize, Debug, Ord, PartialOrd, Eq, PartialEq)]
Expand Down Expand Up @@ -52,16 +54,52 @@ pub enum ChannelState {

impl From<Channel> for DlcChannelDetails {
fn from(channel: Channel) -> Self {
let (update_idx, state, fee_rate_per_vb, funding_txid, funding_tx_vout) =
let (update_idx, state, fee_rate_per_vb, funding_txid, funding_tx_vout, closing_txid) =
match channel.clone() {
Channel::Signed(SignedChannel {
update_idx,
fee_rate_per_vb,
fund_tx,
fund_output_index,
state: dlc_manager::channel::signed_channel::SignedChannelState::CollaborativeCloseOffered {
close_tx,
..
},
..
}) => (
Some(update_idx),
Some(SignedChannelState::CollaborativeCloseOffered),
Some(fee_rate_per_vb),
Some(fund_tx.txid().to_string()),
Some(fund_output_index),
Some(close_tx.txid().to_string())),
Channel::Signed(signed_channel) => (
Some(signed_channel.update_idx),
Some(SignedChannelState::from(signed_channel.state)),
Some(signed_channel.fee_rate_per_vb),
Some(signed_channel.fund_tx.txid().to_hex()),
Some(signed_channel.fund_tx.txid().to_string()),
Some(signed_channel.fund_output_index),
None,
),
_ => (None, None, None, None, None),
Channel::CollaborativelyClosed(closed_channel)
| Channel::Closed(closed_channel)
| Channel::CounterClosed(closed_channel) => (
None,
None,
None,
None,
None,
Some(closed_channel.closing_txid.to_string()),
),
Channel::Closing(closing_channel) => (
None,
None,
None,
None,
None,
Some(closing_channel.buffer_transaction.txid().to_string()),
),
_ => (None, None, None, None, None, None),
};

DlcChannelDetails {
Expand All @@ -73,6 +111,7 @@ impl From<Channel> for DlcChannelDetails {
fee_rate_per_vb,
funding_txid,
funding_tx_vout,
closing_txid,
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions mobile/lib/common/dlc_channel_change_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,21 @@ class DlcChannelChangeNotifier extends ChangeNotifier {
.toList();
}

List<DlcChannel> getAllOtherDlcChannels() {
List<ClosedDlcChannel> getAllClosedDlcChannels() {
return channels
.where((channel) => [
ChannelState.closed,
ChannelState.counterClosed,
ChannelState.closedPunished,
ChannelState.collaborativelyClosed,
].contains(channel.state))
.map((channel) => channel as ClosedDlcChannel)
.toList();
}

List<DlcChannel> getAllOtherDlcChannels() {
return channels
.where((channel) => [
ChannelState.closedPunished,
ChannelState.failedAccept,
ChannelState.failedSign,
].contains(channel.state))
Expand Down
Loading

0 comments on commit 2b2ef4d

Please sign in to comment.