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

chore: Show settle transaction txid on dlc channels api #2271

Merged
merged 4 commits into from
Mar 18, 2024
Merged
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
17 changes: 17 additions & 0 deletions crates/ln-dlc-node/src/ln/dlc_channel_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ impl From<Channel> for DlcChannelDetails {
Some(fund_tx.txid().to_string()),
Some(fund_output_index),
Some(close_tx.txid().to_string())),
Channel::Signed(SignedChannel {
update_idx,
fee_rate_per_vb,
fund_tx,
fund_output_index,
state: dlc_manager::channel::signed_channel::SignedChannelState::SettledClosing {
settle_transaction,
..
},
..
}) => (
Some(update_idx),
Some(SignedChannelState::SettledClosing),
Some(fee_rate_per_vb),
Some(fund_tx.txid().to_string()),
Some(fund_output_index),
Some(settle_transaction.txid().to_string())),
Channel::Signed(signed_channel) => (
Some(signed_channel.update_idx),
Some(SignedChannelState::from(signed_channel.state)),
Expand Down
7 changes: 7 additions & 0 deletions mobile/lib/common/dlc_channel_change_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class DlcChannelChangeNotifier extends ChangeNotifier {
.toList();
}

List<SettledClosingDlcChannel> getAllSettledClosingDlcChannels() {
return channels
.where((channel) => channel.state == ChannelState.settledClosing)
.map((channel) => channel as SettledClosingDlcChannel)
.toList();
}

List<ClosedDlcChannel> getAllClosedDlcChannels() {
return channels
.where((channel) => [
Expand Down
5 changes: 4 additions & 1 deletion mobile/lib/common/domain/dlc_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DlcChannel {
{
return SettledClosingDlcChannel(
id: dlcChannel.dlcChannelId,
state: ChannelState.closing,
state: ChannelState.settledClosing,
settleTxid: closing.settleTxid,
);
}
Expand Down Expand Up @@ -182,6 +182,7 @@ enum ChannelState {
accepted,
signed,
closing,
settledClosing,
closed,
counterClosed,
closedPunished,
Expand All @@ -201,6 +202,8 @@ enum ChannelState {
return "Signed";
case ChannelState.closing:
return "Closing";
case ChannelState.settledClosing:
return "Settled Closing";
case ChannelState.closed:
return "Closed";
case ChannelState.counterClosed:
Expand Down
6 changes: 6 additions & 0 deletions mobile/lib/common/settings/channel_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class _ChannelScreenState extends State<ChannelScreen> {
...dlcChannelChangeNotifier.getAllAcceptedDlcChannels(),
...dlcChannelChangeNotifier.getAllCancelledDlcChannels(),
...dlcChannelChangeNotifier.getAllClosingDlcChannels(),
...dlcChannelChangeNotifier.getAllSettledClosingDlcChannels(),
...dlcChannelChangeNotifier.getAllClosedDlcChannels(),
...dlcChannelChangeNotifier.getAllOtherDlcChannels()
];
Expand Down Expand Up @@ -223,6 +224,11 @@ class ChannelsTile extends StatelessWidget {
leading: const Text('Buffer TXID', style: TextStyle(fontSize: 17)),
title: TransactionIdText(channel.bufferTxid))
: Container(),
channel is SettledClosingDlcChannel
? ListTile(
leading: const Text('Settle TXID', style: TextStyle(fontSize: 17)),
title: TransactionIdText(channel.settleTxid))
: Container(),
channel is ClosedDlcChannel
? ListTile(
leading: const Text('Closing TXID', style: TextStyle(fontSize: 17)),
Expand Down
15 changes: 15 additions & 0 deletions mobile/native/src/dlc_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ impl From<&Channel> for DlcChannel {
closing_txid: Some(close_tx.txid().to_string()),
state: SignedChannelState::CollaborativeCloseOffered,
},
s @ Channel::Signed(SignedChannel {
state: dlc_manager::channel::signed_channel::SignedChannelState::SettledClosing {
settle_transaction,
..
},
fund_tx,
fund_output_index,
..
}) => ChannelState::Signed {
contract_id: s.get_contract_id().map(hex::encode),
funding_txid: fund_tx.txid().to_string(),
funding_tx_vout: *fund_output_index,
closing_txid: Some(settle_transaction.txid().to_string()),
state: SignedChannelState::SettledClosing,
holzeis marked this conversation as resolved.
Show resolved Hide resolved
},
Channel::Signed(s) => ChannelState::Signed {
contract_id: s.get_contract_id().map(hex::encode),
funding_txid: s.fund_tx.txid().to_string(),
Expand Down
1 change: 1 addition & 0 deletions webapp/frontend/lib/settings/channel_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class _ChannelDetailWidgetState extends State<ChannelDetailWidget> {
buildCopyableTxId(context, "Funding TxId", widget.channel.fundTxid),
buildCopyableTxId(context, "Buffer TxId", widget.channel.bufferTxid),
buildCopyableTxId(context, "Close TxId", widget.channel.closeTxid),
buildCopyableTxId(context, "Settle TxId", widget.channel.settleTxid),
Visibility(
visible: widget.channel.channelState == ChannelState.signed &&
widget.channel.signedChannelState != null &&
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,9 @@ impl From<&dlc_manager::channel::Channel> for DlcChannel {
settle_transaction, ..
} => (
SignedChannelState::Closing,
None,
Some(settle_transaction),
None,
None,
),
dlc_manager::channel::signed_channel::SignedChannelState::CollaborativeCloseOffered { close_tx, .. } => (
SignedChannelState::CollaborativeCloseOffered,
Expand Down
Loading