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

Commit 03fce61

Browse files
committed
Add on-chain balance and pending-channel balances in depositLabel
1 parent 5faec96 commit 03fce61

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/computed/wallet.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ const ComputedWallet = store => {
77
walletAddressUri: computed(
88
() => (store.walletAddress ? `bitcoin:${store.walletAddress}` : '')
99
),
10-
balanceLabel: computed(() =>
11-
toAmountLabel(store.balanceSatoshis, store.settings)
12-
),
10+
depositLabel: computed(() => {
11+
const { balanceSatoshis, pendingBalanceSatoshis, settings } = store;
12+
return toAmountLabel(balanceSatoshis + pendingBalanceSatoshis, settings);
13+
}),
1314
channelBalanceLabel: computed(() =>
1415
toAmountLabel(store.channelBalanceSatoshis, store.settings)
1516
),

test/unit/computed/wallet.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Computed Wallet Unit Tests', () => {
1212
it('should work with initial store', () => {
1313
ComputedWallet(store);
1414
expect(store.walletAddressUri, 'to equal', '');
15-
expect(store.balanceLabel, 'to equal', '0');
15+
expect(store.depositLabel, 'to equal', '0');
1616
expect(store.channelBalanceLabel, 'to equal', '0');
1717
expect(store.unitFiatLabel, 'to equal', 'BTC');
1818
expect(store.unitLabel, 'to equal', 'BTC');
@@ -32,23 +32,25 @@ describe('Computed Wallet Unit Tests', () => {
3232
it('should display channel balance in usd', () => {
3333
store.settings.displayFiat = true;
3434
store.settings.exchangeRate.usd = 0.00014503;
35-
store.balanceSatoshis = 100000000;
35+
store.balanceSatoshis = 50000000;
36+
store.pendingBalanceSatoshis = 50000000;
3637
store.channelBalanceSatoshis = 10000;
3738
ComputedWallet(store);
38-
expect(store.balanceLabel, 'to match', /6[,.]895[,.]13/);
39+
expect(store.depositLabel, 'to match', /6[,.]895[,.]13/);
3940
expect(store.channelBalanceLabel, 'to match', /0[,.]69/);
4041
expect(store.unitFiatLabel, 'to equal', '$');
4142
expect(store.unitLabel, 'to equal', null);
4243
});
4344

4445
it('should display channel balance in sat', () => {
4546
store.settings.exchangeRate.usd = 0.00014503;
46-
store.balanceSatoshis = 100000001;
47+
store.balanceSatoshis = 50000001;
48+
store.pendingBalanceSatoshis = 50000000;
4749
store.channelBalanceSatoshis = 10000;
4850
store.settings.unit = 'bit';
4951
ComputedWallet(store);
5052
expect(
51-
store.balanceLabel,
53+
store.depositLabel,
5254
'to match',
5355
/^1{1}[,.]0{3}[,.]0{3}[,.]0{1}1{1}$/
5456
);

0 commit comments

Comments
 (0)