From 866fdaa084b47beac348bb4e5f928e131495d6aa Mon Sep 17 00:00:00 2001 From: David Stoneham Date: Wed, 3 Apr 2019 16:24:23 +1000 Subject: [PATCH] hangle v3.4 change of listunspent command --- lib/client.ts | 4 +++- src/app/providers/rpc.service.ts | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/client.ts b/lib/client.ts index d90e2902..856fe545 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -35,6 +35,8 @@ export default class Client { updateResponse; // client status status: ClientStatus = ClientStatus.INITIALISING; + // when using hash of unknown daemon assume version + readonly assumeClientVersion = '3.4.0.0'; constructor(win) { this.win = win; @@ -456,7 +458,7 @@ export default class Client { }) } if (!this.clientVersion) { - this.clientVersion = '3.2.0.0'; + this.clientVersion = this.assumeClientVersion; log.info('Client', 'Unknown version. Assuming', this.clientVersion); } else { log.info('Client', 'Client Version', this.clientVersion); diff --git a/src/app/providers/rpc.service.ts b/src/app/providers/rpc.service.ts index 96ad25c7..36ff4c64 100644 --- a/src/app/providers/rpc.service.ts +++ b/src/app/providers/rpc.service.ts @@ -216,7 +216,7 @@ export class RpcService { // get address groupings let groups: any = await this.callServer("listaddressgroupings"); // get all unspent - let unspents: any = await this.callServer("listunspent", [1, 9999999, [], true]); + let unspents: any = await this.listUnspent(); // assemble accounts let accounts = []; for (let i = 0; i < groups.result.length; i++) { @@ -303,11 +303,19 @@ export class RpcService { return data; } + private listUnspent() { + // as of v3.4 listunspent now has a watchonlyconfig flag + if (compareVersions(this.electron.clientVersion, '3.4.0.0') >= 0) + return this.callServer("listunspent", [1, 9999999, [], 1, true]); + else + return this.callServer("listunspent", [1, 9999999, [], true]); + } + private async createTransaction(params) { let [inputs, outputs, fee, passphrase, changeAddress] = params; try { // get unspents - let unspents: any = await this.callServer("listunspent", [1, 9999999, [], true]); + let unspents: any = await this.listUnspent(); unspents = unspents.result; // safety check inputs let sendingBalance = Big(0);