Skip to content

Commit

Permalink
fix(app): Rename reservedFeeSats to fundingTxFee
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
luckysori committed Mar 1, 2024
1 parent 35a5333 commit 0d8c36c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions mobile/lib/features/wallet/domain/wallet_history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand All @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/features/wallet/wallet_history_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mobile/native/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
funding_tx_fee_sats: Option<u64>,
confirmations: u64,
// The amount we hold in the channel
our_channel_input_amount_sats: u64,
Expand Down
11 changes: 8 additions & 3 deletions mobile/native/src/ln_dlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 0d8c36c

Please sign in to comment.