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

Commit b833c45

Browse files
Set limbo balance during existing pendingchannels grpc call, rather than in a new one.
1 parent 4c58679 commit b833c45

File tree

4 files changed

+6
-37
lines changed

4 files changed

+6
-37
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/action/wallet.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ class WalletAction {
144144
* @return {Promise<undefined>}
145145
*/
146146
async update() {
147-
await Promise.all([
148-
this.getBalance(),
149-
this.getChannelBalance(),
150-
this.getLimboBalance(),
151-
]);
147+
await Promise.all([this.getBalance(), this.getChannelBalance()]);
152148
}
153149

154150
/**
@@ -453,20 +449,6 @@ class WalletAction {
453449
}
454450
}
455451

456-
/**
457-
* Fetch the limbo balance using the lnd grpc api and set the
458-
* corresponding value on the global store.
459-
* @return {Promise<undefined>}
460-
*/
461-
async getLimboBalance() {
462-
try {
463-
const r = await this._grpc.sendCommand('PendingChannels');
464-
this._store.limboBalanceSatoshis = r.totalLimboBalance;
465-
} catch (err) {
466-
log.error('Getting limbo balance failed', err);
467-
}
468-
}
469-
470452
/**
471453
* Ensure that the wallet address is non-null before navigating to the
472454
* NewAddress view during onboarding.

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/action/wallet.spec.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe('Action Wallet Unit Tests', () => {
138138
it('should refresh wallet balances', async () => {
139139
sandbox.stub(wallet, 'pollExchangeRate');
140140
await wallet.update();
141-
expect(grpc.sendCommand, 'was called thrice');
141+
expect(grpc.sendCommand, 'was called twice');
142142
expect(wallet.pollExchangeRate, 'was not called');
143143
});
144144
});
@@ -571,22 +571,6 @@ describe('Action Wallet Unit Tests', () => {
571571
});
572572
});
573573

574-
describe('getLimboBalance()', () => {
575-
it('should get limbo balance', async () => {
576-
grpc.sendCommand.withArgs('PendingChannels').resolves({
577-
totalLimboBalance: 1,
578-
});
579-
await wallet.getLimboBalance();
580-
expect(store.limboBalanceSatoshis, 'to equal', 1);
581-
});
582-
583-
it('should log error on failure', async () => {
584-
grpc.sendCommand.rejects();
585-
await wallet.getLimboBalance();
586-
expect(logger.error, 'was called once');
587-
});
588-
});
589-
590574
describe('getNewAddress()', () => {
591575
it('should get new address', async () => {
592576
grpc.sendCommand.withArgs('NewAddress').resolves({

0 commit comments

Comments
 (0)