Skip to content

Commit

Permalink
hangle v3.4 change of listunspent command
Browse files Browse the repository at this point in the history
  • Loading branch information
davidstoneham committed Apr 3, 2019
1 parent c132b0a commit 866fdaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions src/app/providers/rpc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 866fdaa

Please sign in to comment.