From 0d8c36c74876d3c1e2033bf3fb5ee0c84628185b Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Tue, 20 Feb 2024 03:02:07 +1100 Subject: [PATCH] fix(app): Rename reservedFeeSats to fundingTxFee The value that we were displaying corresponded to half of the funding transaction fee. The fee reserve cannot be derived just by looking at the funding transaction, as it is included in the funding transaction shared output. Eventually, we should display the fee reserve in the corresponding wallet history entry (and perhaps in a channel details section too). --- mobile/lib/features/wallet/domain/wallet_history.dart | 6 +++--- mobile/lib/features/wallet/wallet_history_item.dart | 2 +- mobile/native/src/api.rs | 2 +- mobile/native/src/ln_dlc/mod.rs | 11 ++++++++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mobile/lib/features/wallet/domain/wallet_history.dart b/mobile/lib/features/wallet/domain/wallet_history.dart index 20737e72a..00c64a8fa 100644 --- a/mobile/lib/features/wallet/domain/wallet_history.dart +++ b/mobile/lib/features/wallet/domain/wallet_history.dart @@ -81,7 +81,7 @@ abstract class WalletHistoryItemData { amount: amount, status: status, timestamp: timestamp, - reservedFeeSats: Amount(type.reservedFeeSats ?? 0), + fundingTxFee: Amount(type.fundingTxFeeSats ?? 0), fundingTxid: type.fundingTxid, confirmations: type.confirmations, ourChannelInputAmountSats: Amount(type.ourChannelInputAmountSats), @@ -183,7 +183,7 @@ class TradeData extends WalletHistoryItemData { } class DlcChannelFundingData extends WalletHistoryItemData { - final Amount reservedFeeSats; + final Amount fundingTxFee; final String fundingTxid; final int confirmations; final Amount ourChannelInputAmountSats; @@ -193,7 +193,7 @@ class DlcChannelFundingData extends WalletHistoryItemData { required super.amount, required super.status, required super.timestamp, - required this.reservedFeeSats, + required this.fundingTxFee, required this.confirmations, required this.ourChannelInputAmountSats, required this.fundingTxid}); diff --git a/mobile/lib/features/wallet/wallet_history_item.dart b/mobile/lib/features/wallet/wallet_history_item.dart index e410246c3..aeff7c137 100644 --- a/mobile/lib/features/wallet/wallet_history_item.dart +++ b/mobile/lib/features/wallet/wallet_history_item.dart @@ -443,7 +443,7 @@ class DlcChannelFundingHistoryItem extends WalletHistoryItem { displayWidget: TransactionIdText(data.fundingTxid)), HistoryDetail(label: "Confirmations", value: data.confirmations.toString()), HistoryDetail(label: "Channel input", value: formatSats(data.ourChannelInputAmountSats)), - HistoryDetail(label: "Reserved fee", value: formatSats(data.reservedFeeSats)), + HistoryDetail(label: "Funding TX fee estimate", value: formatSats(data.fundingTxFee)), ]; return details; diff --git a/mobile/native/src/api.rs b/mobile/native/src/api.rs index b8dd08e13..903b2b660 100644 --- a/mobile/native/src/api.rs +++ b/mobile/native/src/api.rs @@ -232,7 +232,7 @@ pub enum WalletHistoryItemType { funding_txid: String, // This fee represents the total fee reserved for all off-chain transactions, i.e. for the // fund/buffer/cet/refund. Only the part for the fund tx has been paid for now - reserved_fee_sats: Option, + funding_tx_fee_sats: Option, confirmations: u64, // The amount we hold in the channel our_channel_input_amount_sats: u64, diff --git a/mobile/native/src/ln_dlc/mod.rs b/mobile/native/src/ln_dlc/mod.rs index 0a8fbd342..9a59e352a 100644 --- a/mobile/native/src/ln_dlc/mod.rs +++ b/mobile/native/src/ln_dlc/mod.rs @@ -479,9 +479,14 @@ fn keep_wallet_balance_and_history_up_to_date(node: &Node) -> Result<()> { status, wallet_type: WalletHistoryItemType::DlcChannelFunding { funding_txid: details.transaction.txid().to_string(), - // this is not 100% correct as fees are not exactly divided by 2. The fee a - // user has to pay depends on his final address. - reserved_fee_sats: details.fee.as_ref().map(|fee| (*fee / 2).to_sat()).ok(), + // this is not 100% correct as fees are not exactly divided by 2. The share + // of the funding transaction fee that the user has paid depends on their + // inputs and change outputs. + funding_tx_fee_sats: details + .fee + .as_ref() + .map(|fee| (*fee / 2).to_sat()) + .ok(), confirmations: details.confirmation_status.n_confirmations() as u64, our_channel_input_amount_sats: channel.own_params.collateral, },