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

Commit a7c644b

Browse files
committed
Parse pending_open_balance for ChannelBalance grape call
1 parent 04a4e7f commit a7c644b

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/action/wallet.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ class WalletAction {
158158

159159
async getChannelBalance() {
160160
try {
161-
const response = await this._grpc.sendCommand('ChannelBalance');
162-
this._store.channelBalanceSatoshis = parseSat(response.balance);
161+
const r = await this._grpc.sendCommand('ChannelBalance');
162+
this._store.channelBalanceSatoshis = parseSat(r.balance);
163+
this._store.pendingBalanceSatoshis = parseSat(r.pending_open_balance);
163164
} catch (err) {
164165
log.error('Getting channel balance failed', err);
165166
}

src/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class Store {
2424
balanceSatoshis: 0,
2525
confirmedBalanceSatoshis: 0,
2626
unconfirmedBalanceSatoshis: 0,
27+
pendingBalanceSatoshis: 0,
2728
channelBalanceSatoshis: 0,
2829
pubKey: null,
2930
walletAddress: null,

test/unit/action/wallet.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,13 @@ describe('Action Wallet Unit Tests', () => {
292292

293293
describe('getChannelBalance()', () => {
294294
it('should get channel balance', async () => {
295-
grpc.sendCommand.withArgs('ChannelBalance').resolves({ balance: '1' });
295+
grpc.sendCommand.withArgs('ChannelBalance').resolves({
296+
balance: '1',
297+
pending_open_balance: '2',
298+
});
296299
await wallet.getChannelBalance();
297300
expect(store.channelBalanceSatoshis, 'to equal', 1);
301+
expect(store.pendingBalanceSatoshis, 'to equal', 2);
298302
});
299303

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

0 commit comments

Comments
 (0)