From 1738456596c367d1c6b2bcbac5eaf5c549b33463 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Fri, 15 Nov 2024 20:43:25 -0500 Subject: [PATCH 1/3] Channels: reserve updates --- components/BalanceSlider.tsx | 10 ++++- components/Channels/ChannelItem.tsx | 61 ++++++++++++++++++----------- components/HopPicker.tsx | 18 ++++++--- components/LSPS1OrderResponse.tsx | 4 +- models/Channel.ts | 42 ++++++++++++++++---- stores/ChannelsStore.ts | 4 +- views/Channels/Channel.tsx | 61 ++++++++++++++++++++++------- views/Channels/ChannelsPane.tsx | 14 +++++-- 8 files changed, 153 insertions(+), 61 deletions(-) diff --git a/components/BalanceSlider.tsx b/components/BalanceSlider.tsx index e7ffba726..55db625c5 100644 --- a/components/BalanceSlider.tsx +++ b/components/BalanceSlider.tsx @@ -5,6 +5,8 @@ import { ChannelItem } from '../components/Channels/ChannelItem'; interface BalanceSliderProps { localBalance: string | number; remoteBalance: string | number; + sendingCapacity: string | number; + receivingCapacity: string | number; localReserveBalance?: string | number; remoteReserveBalance?: string | number; list?: boolean; @@ -18,14 +20,18 @@ export default class BalanceSlider extends React.Component< const { localBalance, remoteBalance, + sendingCapacity, + receivingCapacity, localReserveBalance, remoteReserveBalance } = this.props; return ( } - {inbound && outbound && !(inbound == 0 && outbound == 0) && ( - - - - )} + {localBalance && + remoteBalance && + !(localBalance == 0 && remoteBalance == 0) && ( + + + + )} {!hideLabels && ( this.toggleItem(item)}> @@ -159,10 +162,13 @@ export default class ChannelPicker extends React.Component< this.toggleItem(item)}> diff --git a/components/LSPS1OrderResponse.tsx b/components/LSPS1OrderResponse.tsx index 46a8b0830..4b9b7ccfc 100644 --- a/components/LSPS1OrderResponse.tsx +++ b/components/LSPS1OrderResponse.tsx @@ -48,8 +48,8 @@ export default class LSPS1OrderResponse extends React.Component< { const channelRemoteBalance = new BigNumber( - channel.remoteBalance + channel.receivingCapacity ); const channelLocalBalance = new BigNumber( - channel.localBalance + channel.sendingCapacity ); const channelTotal = channelRemoteBalance.plus(channelLocalBalance); diff --git a/views/Channels/Channel.tsx b/views/Channels/Channel.tsx index b067dae67..f1c81d27f 100644 --- a/views/Channels/Channel.tsx +++ b/views/Channels/Channel.tsx @@ -231,8 +231,11 @@ export default class ChannelView extends React.Component< commit_weight, localBalance, remoteBalance, + sendingCapacity, + receivingCapacity, localReserveBalance, remoteReserveBalance, + isBelowReserve, commit_fee, csv_delay, total_satoshis_received, @@ -358,6 +361,8 @@ export default class ChannelView extends React.Component< {remotePubkey && this.renderContactLink(remotePubkey)} )} + {!!alias_scids && alias_scids.length > 0 && ( + 1 + ? localeString('views.Channel.aliasScids') + : localeString('views.Channel.aliasScid') + } + value={PrivacyUtils.sensitiveValue( + alias_scids.join(', ') + )} + /> + )} @@ -575,17 +592,42 @@ export default class ChannelView extends React.Component< sensitive /> )} + + } + /> + + } + /> + } indicatorColor={themeColor('outbound')} /> + } indicatorColor={themeColor('inbound')} /> @@ -603,18 +645,6 @@ export default class ChannelView extends React.Component< } /> )} - {!!alias_scids && alias_scids.length > 0 && ( - 1 - ? localeString('views.Channel.aliasScids') - : localeString('views.Channel.aliasScid') - } - value={PrivacyUtils.sensitiveValue( - alias_scids.join(', ') - )} - /> - )} {!!local_chan_reserve_sat && ( } infoText={localeString( diff --git a/views/Channels/ChannelsPane.tsx b/views/Channels/ChannelsPane.tsx index 863e8611d..7734530fd 100644 --- a/views/Channels/ChannelsPane.tsx +++ b/views/Channels/ChannelsPane.tsx @@ -119,9 +119,12 @@ export default class ChannelsPane extends React.PureComponent { title={item.displayName} status={getStatus()} pendingHTLCs={item?.pending_htlcs?.length > 0} - inbound={item.remoteBalance} - outbound={item.localBalance} + localBalance={item.localBalance} + remoteBalance={item.remoteBalance} + receivingCapacity={item.receivingCapacity} + sendingCapacity={item.sendingCapacity} largestTotal={largestChannelSats} + isBelowReserve={item.isBelowReserve} /> ); @@ -137,8 +140,10 @@ export default class ChannelsPane extends React.PureComponent { > 0} pendingTimelock={ @@ -146,6 +151,7 @@ export default class ChannelsPane extends React.PureComponent { ? forceCloseTimeLabel(item.blocks_til_maturity) : undefined } + isBelowReserve={item.isBelowReserve} /> ); From 5a11f7cec4039fda7bfbe8f98462c3143503eb59 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Fri, 15 Nov 2024 21:01:13 -0500 Subject: [PATCH 2/3] Channel: change Unsettled balance position --- views/Channels/Channel.tsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/views/Channels/Channel.tsx b/views/Channels/Channel.tsx index f1c81d27f..eee84652a 100644 --- a/views/Channels/Channel.tsx +++ b/views/Channels/Channel.tsx @@ -609,6 +609,20 @@ export default class ChannelView extends React.Component< } /> + {unsettled_balance !== '0' && ( + + } + /> + )} - {unsettled_balance && ( - - } - /> - )} {!!local_chan_reserve_sat && ( Date: Fri, 15 Nov 2024 22:14:01 -0500 Subject: [PATCH 3/3] Themes: add warningReserve color --- components/Amount.tsx | 16 ++++++++++++++-- components/Channels/ChannelItem.tsx | 2 +- components/text/Body.tsx | 1 + utils/ThemeUtils.ts | 3 +++ views/Channels/Channel.tsx | 10 ++++++++-- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/components/Amount.tsx b/components/Amount.tsx index e184bd76d..fe528953c 100644 --- a/components/Amount.tsx +++ b/components/Amount.tsx @@ -32,7 +32,13 @@ interface AmountDisplayProps { space?: boolean; jumboText?: boolean; defaultTextSize?: boolean; - color?: 'text' | 'success' | 'warning' | 'highlight' | 'secondaryText'; + color?: + | 'text' + | 'success' + | 'warning' + | 'warningReserve' + | 'highlight' + | 'secondaryText'; colorOverride?: string; pending?: boolean; fee?: boolean; @@ -267,7 +273,13 @@ interface AmountProps { credit?: boolean; debit?: boolean; // If credit or debit doesn't cover the use case - color?: 'text' | 'success' | 'warning' | 'highlight' | 'secondaryText'; + color?: + | 'text' + | 'success' + | 'warning' + | 'warningReserve' + | 'highlight' + | 'secondaryText'; colorOverride?: string; toggleable?: boolean; pending?: boolean; diff --git a/components/Channels/ChannelItem.tsx b/components/Channels/ChannelItem.tsx index 6c8f3554e..adfd2176c 100644 --- a/components/Channels/ChannelItem.tsx +++ b/components/Channels/ChannelItem.tsx @@ -170,7 +170,7 @@ export function ChannelItem({ colorOverride={ highlightLabels ? themeColor('outbound') : undefined } - color={isBelowReserve ? 'warning' : undefined} + color={isBelowReserve ? 'warningReserve' : undefined} /> } /> @@ -656,7 +660,9 @@ export default class ChannelView extends React.Component< sensitive toggleable color={ - isBelowReserve ? 'warning' : undefined + isBelowReserve + ? 'warningReserve' + : undefined } /> }