Skip to content

Commit

Permalink
fix: Add truncate argument to history detail
Browse files Browse the repository at this point in the history
  • Loading branch information
holzeis committed Oct 26, 2023
1 parent 97f8db4 commit 4af7474
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions crates/ln-dlc-node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub fn app_config() -> UserConfig {
},
channel_config: ChannelConfig {
cltv_expiry_delta: MIN_CLTV_EXPIRY_DELTA,
accept_underpaying_htlcs: true,
..Default::default()
},
// we want to accept 0-conf channels from the coordinator
Expand Down
7 changes: 5 additions & 2 deletions crates/ln-dlc-node/src/ln/coordinator_event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ where

let channel = node.storage.get_channel(&user_channel_id)?;
let channel = Channel::open_channel(channel, channel_details)?;
node.storage.upsert_channel(channel)?;
node.storage.upsert_channel(channel.clone())?;

if let Some(interception) = pending_intercepted_htlcs.lock().get(&counterparty_node_id) {
tracing::info!(
Expand All @@ -328,12 +328,13 @@ where
"Pending intercepted HTLC found, forwarding payment"
);

let fee_msat = channel.fee_sats.map(|fee| fee * 1000).unwrap_or(0);
node.channel_manager
.forward_intercepted_htlc(
interception.id,
&channel_id,
counterparty_node_id,
interception.expected_outbound_amount_msat,
interception.expected_outbound_amount_msat - fee_msat,
)
.map_err(|e| anyhow!("{e:?}"))
.context("Failed to forward intercepted HTLC")?;
Expand Down Expand Up @@ -529,6 +530,7 @@ where

shadow_channel.outbound_sats = channel_value_sats;
shadow_channel.channel_state = ChannelState::Pending;
shadow_channel.fee_sats = Some(liquidity_request.fee_sats);

node.storage
.upsert_channel(shadow_channel.clone())
Expand Down Expand Up @@ -607,6 +609,7 @@ mod tests {
trade_up_to_sats: capacity * i,
max_deposit_sats: capacity * i,
coordinator_leverage: i as f32,
fee_sats: 5_000,
};

let channel_value_sat = calculate_channel_value(10_000_000, &request);
Expand Down
23 changes: 18 additions & 5 deletions mobile/lib/features/wallet/wallet_history_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,16 @@ class HistoryDetail extends StatelessWidget {
final String label;
final String value;
final Widget? displayWidget;
final bool truncate;

static const TextStyle defaultValueStyle = TextStyle(fontSize: 16);

const HistoryDetail({super.key, required this.label, required this.value, this.displayWidget});
const HistoryDetail(
{super.key,
required this.label,
required this.value,
this.displayWidget,
this.truncate = true});

@override
Widget build(BuildContext context) {
Expand All @@ -221,7 +227,8 @@ class HistoryDetail extends StatelessWidget {
child: Align(
alignment: Alignment.centerRight,
child: displayWidget ??
Text(truncateWithEllipsis(10, value), style: defaultValueStyle))),
Text(truncate ? truncateWithEllipsis(10, value) : value,
style: defaultValueStyle))),
IconButton(
padding: EdgeInsets.zero,
onPressed: () {
Expand Down Expand Up @@ -297,8 +304,13 @@ class LightningPaymentHistoryItem extends WalletHistoryItem {
List<Widget> getDetails() {
return [
Visibility(
visible: data.feeMsats != null && data.flow == PaymentFlow.outbound,
child: HistoryDetail(label: "Fee", value: "${(data.feeMsats ?? 0) / 1000} sats"),
visible: data.feeMsats != null,
child: HistoryDetail(
label: "Fee",
value: formatSats(Amount(((data.feeMsats ?? 0) / 1000).ceil())),
truncate: false,
),
),
),
Visibility(
visible: data.expiry != null,
Expand Down Expand Up @@ -351,7 +363,8 @@ class TradeHistoryItem extends WalletHistoryItem {
HistoryDetail(label: "Fee", value: formatSats(data.fee)),
Visibility(
visible: data.pnl != null,
child: HistoryDetail(label: "PnL", value: formatSats(data.pnl ?? Amount.zero()))),
child: HistoryDetail(
label: "PnL", value: formatSats(data.pnl ?? Amount.zero()), truncate: false)),
];
}

Expand Down

0 comments on commit 4af7474

Please sign in to comment.