Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit b86c822

Browse files
authored
Merge pull request #1048 from lightninglabs/on-chain-balance
On chain balance
2 parents 9869e53 + ff80fc8 commit b86c822

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/computed/wallet.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const ComputedWallet = store => {
1616
get walletAddressUri() {
1717
return store.walletAddress ? `bitcoin:${store.walletAddress}` : '';
1818
},
19+
get balanceLabel() {
20+
return toAmountLabel(store.balanceSatoshis, store.settings);
21+
},
1922
get totalBalanceSatoshis() {
2023
const {
2124
balanceSatoshis,

src/view/channel.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ResizeableSpinner } from '../component/spinner';
1212
import { H1Text, CopyText } from '../component/text';
1313
import Text from '../component/text';
1414
import PlusIcon from '../../src/asset/icon/plus';
15+
import BitcoinIcon from '../../src/asset/icon/bitcoin';
1516
import LightningBoltGradientIcon from '../../src/asset/icon/lightning-bolt-gradient';
1617
import { color, font } from '../component/style';
1718

@@ -96,6 +97,7 @@ const ChannelList = ({ store, channel }) => {
9697
channelBalanceInactiveLabel,
9798
channelBalancePendingLabel,
9899
channelBalanceClosingLabel,
100+
balanceLabel,
99101
unitLabel,
100102
} = store;
101103
return (
@@ -105,6 +107,7 @@ const ChannelList = ({ store, channel }) => {
105107
channelBalanceInactiveLabel={channelBalanceInactiveLabel}
106108
channelBalancePendingLabel={channelBalancePendingLabel}
107109
channelBalanceClosingLabel={channelBalanceClosingLabel}
110+
balanceLabel={balanceLabel}
108111
unitLabel={unitLabel}
109112
/>
110113
<ListContent>
@@ -164,6 +167,7 @@ const ChannelSummary = ({
164167
channelBalanceInactiveLabel,
165168
channelBalancePendingLabel,
166169
channelBalanceClosingLabel,
170+
balanceLabel,
167171
unitLabel,
168172
}) => (
169173
<View style={summaryStyles.wrapper}>
@@ -195,6 +199,15 @@ const ChannelSummary = ({
195199
{channelBalanceClosingLabel} {unitLabel}
196200
</Text>
197201
</View>
202+
<View style={summaryStyles.box}>
203+
<View style={summaryStyles.alert}>
204+
<BitcoinIcon height={170 * 0.06} width={135 * 0.06} />
205+
</View>
206+
<Text style={summaryStyles.txt}>On-chain</Text>
207+
<Text style={[summaryStyles.txt, summaryStyles.total]}>
208+
{balanceLabel} {unitLabel}
209+
</Text>
210+
</View>
198211
</View>
199212
);
200213

@@ -203,6 +216,7 @@ ChannelSummary.propTypes = {
203216
channelBalanceInactiveLabel: PropTypes.string.isRequired,
204217
channelBalancePendingLabel: PropTypes.string.isRequired,
205218
channelBalanceClosingLabel: PropTypes.string.isRequired,
219+
balanceLabel: PropTypes.string.isRequired,
206220
unitLabel: PropTypes.string,
207221
};
208222

test/unit/computed/wallet.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe('Computed Wallet Unit Tests', () => {
1313
store.channelBalanceForceClosingSatoshis = 0;
1414
ComputedWallet(store);
1515
expect(store.walletAddressUri, 'to equal', '');
16+
expect(store.balanceLabel, 'to match', /0[,.]00/);
1617
expect(store.totalBalanceSatoshis, 'to equal', 0);
1718
expect(store.totalBalanceLabel, 'to match', /0[,.]00/);
1819
expect(store.unitFiatLabel, 'to equal', '$');
@@ -40,6 +41,7 @@ describe('Computed Wallet Unit Tests', () => {
4041
store.channelBalanceSatoshis = 10000;
4142
store.channelBalanceForceClosingSatoshis = 100;
4243
ComputedWallet(store);
44+
expect(store.balanceLabel, 'to match', /3[,.]447[,.]56/);
4345
expect(store.totalBalanceSatoshis, 'to equal', 100010100);
4446
expect(store.totalBalanceLabel, 'to match', /6[,.]895[,.]82/);
4547
expect(store.unitFiatLabel, 'to equal', '$');
@@ -56,6 +58,7 @@ describe('Computed Wallet Unit Tests', () => {
5658
store.channelBalanceForceClosingSatoshis = 100;
5759
store.settings.unit = 'bit';
5860
ComputedWallet(store);
61+
expect(store.balanceLabel, 'to match', /500[,.]000[,.]01/);
5962
expect(store.totalBalanceSatoshis, 'to equal', 100010101);
6063
expect(store.totalBalanceLabel, 'to match', /1[,.]000[,.]101[,.]01/);
6164
expect(store.unitFiatLabel, 'to equal', 'bits');

0 commit comments

Comments
 (0)