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

Commit 0666f01

Browse files
authored
Merge pull request #1009 from lightninglabs/limbo-balance
Include limbo balance in Home screen balance.
2 parents 473a408 + b833c45 commit 0666f01

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

src/action/channel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ChannelAction {
125125

126126
/**
127127
* List the pending channels by calling the respective grpc api and updating
128-
* the pendingChannels array in the global store.
128+
* the pendingChannels array and limbo balance in the global store.
129129
* @return {Promise<undefined>}
130130
*/
131131
async getPendingChannels() {
@@ -168,6 +168,7 @@ class ChannelAction {
168168
status: 'waiting-close',
169169
}));
170170
this._store.pendingChannels = [].concat(pocs, pccs, pfccs, wccs);
171+
this._store.limboBalanceSatoshis = response.totalLimboBalance;
171172
} catch (err) {
172173
log.error('Listing pending channels failed', err);
173174
}

src/computed/wallet.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ const ComputedWallet = store => {
2121
balanceSatoshis,
2222
pendingBalanceSatoshis,
2323
channelBalanceSatoshis,
24+
limboBalanceSatoshis,
2425
} = store;
25-
return balanceSatoshis + pendingBalanceSatoshis + channelBalanceSatoshis;
26+
return (
27+
balanceSatoshis +
28+
pendingBalanceSatoshis +
29+
channelBalanceSatoshis +
30+
limboBalanceSatoshis
31+
);
2632
},
2733
get totalBalanceLabel() {
2834
return toAmountLabel(store.totalBalanceSatoshis, store.settings);

src/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class Store {
3434
unconfirmedBalanceSatoshis: 0,
3535
pendingBalanceSatoshis: 0,
3636
channelBalanceSatoshis: 0,
37+
limboBalanceSatoshis: 0,
3738
pubKey: null,
3839
walletAddress: null,
3940
displayCopied: false,

test/unit/action/channel.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,15 @@ describe('Action Channels Unit Tests', () => {
148148
pendingClosingChannels: [{ channel: { ...pendingChannel } }],
149149
pendingForceClosingChannels: [{ channel: { ...pendingChannel } }],
150150
waitingCloseChannels: [{ channel: { ...pendingChannel } }],
151+
totalLimboBalance: 1,
151152
});
152153
await channel.getPendingChannels();
153154
expect(store.pendingChannels.length, 'to equal', 4);
154155
expect(store.pendingChannels[0], 'to satisfy', {
155156
remotePubkey: 'some-key',
156157
fundingTxId: 'FFFF',
157158
});
159+
expect(store.limboBalanceSatoshis, 'to equal', 1);
158160
});
159161

160162
it('should log error on failure', async () => {

test/unit/computed/wallet.spec.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ describe('Computed Wallet Unit Tests', () => {
3737
store.balanceSatoshis = 50000000;
3838
store.pendingBalanceSatoshis = 50000000;
3939
store.channelBalanceSatoshis = 10000;
40+
store.limboBalanceSatoshis = 100;
4041
ComputedWallet(store);
41-
expect(store.totalBalanceSatoshis, 'to equal', 100010000);
42-
expect(store.totalBalanceLabel, 'to match', /6[,.]895[,.]81/);
42+
expect(store.totalBalanceSatoshis, 'to equal', 100010100);
43+
expect(store.totalBalanceLabel, 'to match', /6[,.]895[,.]82/);
4344
expect(store.unitFiatLabel, 'to equal', '$');
4445
expect(store.unitLabel, 'to equal', null);
4546
expect(store.channelPercentageLabel, 'to equal', '50% on Lightning');
@@ -51,10 +52,11 @@ describe('Computed Wallet Unit Tests', () => {
5152
store.balanceSatoshis = 50000001;
5253
store.pendingBalanceSatoshis = 50000000;
5354
store.channelBalanceSatoshis = 10000;
55+
store.limboBalanceSatoshis = 100;
5456
store.settings.unit = 'bit';
5557
ComputedWallet(store);
56-
expect(store.totalBalanceSatoshis, 'to equal', 100010001);
57-
expect(store.totalBalanceLabel, 'to match', /1[,.]000[,.]100[,.]01/);
58+
expect(store.totalBalanceSatoshis, 'to equal', 100010101);
59+
expect(store.totalBalanceLabel, 'to match', /1[,.]000[,.]101[,.]01/);
5860
expect(store.unitFiatLabel, 'to equal', 'bits');
5961
expect(store.unitLabel, 'to equal', 'bits');
6062
});

0 commit comments

Comments
 (0)