@@ -14,7 +14,6 @@ import SwipeToConfirm from '../../components/SwipeToConfirm';
1414import PieChart from '../Lightning/PieChart' ;
1515import { addTodo , removeTodo } from '../../store/actions/todos' ;
1616import { confirmChannelPurchase } from '../../store/actions/blocktank' ;
17- import { useLightningBalance } from '../../hooks/lightning' ;
1817import { useBalance } from '../../hooks/wallet' ;
1918import useDisplayValues from '../../hooks/displayValues' ;
2019import type { TransferScreenProps } from '../../navigation/types' ;
@@ -34,20 +33,21 @@ const Confirm = ({
3433 const { spendingAmount, orderId } = route . params ;
3534 const { t } = useTranslation ( 'lightning' ) ;
3635 const { satoshis : onchainBalance } = useBalance ( { onchain : true } ) ;
36+ const { satoshis : lightningBalance } = useBalance ( {
37+ lightning : true ,
38+ subtractReserveBalance : false ,
39+ } ) ;
3740 const [ loading , setLoading ] = useState ( false ) ;
38- const lightningBalance = useLightningBalance ( ) ;
3941
40- const savingsAmount = onchainBalance - spendingAmount ;
41- const savingsPercentage = Math . round ( ( savingsAmount / onchainBalance ) * 100 ) ;
42- const spendingPercentage = Math . round (
43- ( spendingAmount / onchainBalance ) * 100 ,
44- ) ;
45- const currentSpendingAmount = lightningBalance . localBalance ;
42+ const totalBalance = onchainBalance + lightningBalance ;
43+ const savingsAmount = totalBalance - spendingAmount ;
44+ const savingsPercentage = Math . round ( ( savingsAmount / totalBalance ) * 100 ) ;
45+ const spendingPercentage = Math . round ( ( spendingAmount / totalBalance ) * 100 ) ;
4646 const spendingCurrentPercentage = Math . round (
47- ( currentSpendingAmount / onchainBalance ) * 100 ,
47+ ( lightningBalance / totalBalance ) * 100 ,
4848 ) ;
4949
50- const isTransferringToSavings = spendingAmount < currentSpendingAmount ;
50+ const isTransferringToSavings = spendingAmount < lightningBalance ;
5151
5252 const selectedNetwork = useSelector ( selectedNetworkSelector ) ;
5353 const orders = useSelector ( blocktankOrdersSelector ) ;
0 commit comments