From 4020b78229745c1df28a42f40c0acd9e2339ca23 Mon Sep 17 00:00:00 2001 From: "Jacob H. Haven" Date: Wed, 16 Oct 2019 08:36:50 -0700 Subject: [PATCH 1/3] wallet: include network in master key JSON serialization calls --- lib/wallet/masterkey.js | 2 +- lib/wallet/wallet.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/wallet/masterkey.js b/lib/wallet/masterkey.js index fd38d99f7..487247f22 100644 --- a/lib/wallet/masterkey.js +++ b/lib/wallet/masterkey.js @@ -615,7 +615,7 @@ class MasterKey extends bio.Struct { return { encrypted: false, - key: unsafe ? this.key.toJSON(network) : undefined, + key: unsafe ? this.key.getJSON(network) : undefined, mnemonic: unsafe && this.mnemonic ? this.mnemonic.toJSON() : undefined }; } diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index 5dbe0bb22..f79b65012 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -4352,7 +4352,7 @@ class Wallet extends EventEmitter { accountDepth: this.accountDepth, token: this.token.toString('hex'), tokenDepth: this.tokenDepth, - master: this.master.toJSON(this.network, unsafe), + master: this.master.getJSON(this.network, unsafe), balance: balance ? balance.toJSON(true) : null }; } From 968a5ba1761793da55850fe07dd9e2b1e886b77e Mon Sep 17 00:00:00 2001 From: "Jacob H. Haven" Date: Tue, 15 Oct 2019 15:56:17 -0700 Subject: [PATCH 2/3] wallet plugin: add ability to restore wallet from backup --- lib/wallet/plugin.js | 3 ++- lib/wallet/walletdb.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/wallet/plugin.js b/lib/wallet/plugin.js index 26873707d..01d4d97aa 100644 --- a/lib/wallet/plugin.js +++ b/lib/wallet/plugin.js @@ -54,7 +54,8 @@ class Plugin extends EventEmitter { witness: this.config.bool('witness'), checkpoints: this.config.bool('checkpoints'), wipeNoReally: this.config.bool('wipe-no-really'), - spv: node.spv + spv: node.spv, + createWalletOptions: options.createWalletOptions }); this.rpc = new RPC(this); diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index 746ff8679..57a849912 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -194,6 +194,10 @@ class WalletDB extends EventEmitter { this.state.height, this.state.startHeight); + for (const options of this.options.createWalletOptions) { + await this.ensure(options); + } + const wallet = await this.ensure({ id: 'primary' }); @@ -2302,6 +2306,8 @@ class WalletOptions { this.checkpoints = false; this.wipeNoReally = false; + this.createWalletOptions = []; + if (options) this.fromOptions(options); } @@ -2383,6 +2389,12 @@ class WalletOptions { this.wipeNoReally = options.wipeNoReally; } + // https://handshake-org.github.io/api-docs/#wallet-options + if (options.createWalletOptions != null) { + assert(Array.isArray(options.createWalletOptions)); + this.createWalletOptions = options.createWalletOptions; + } + return this; } From 531e7f7a8da71d4faa7ca708bfd9cb9abc788e61 Mon Sep 17 00:00:00 2001 From: "Jacob H. Haven" Date: Wed, 16 Oct 2019 08:42:23 -0700 Subject: [PATCH 3/3] Bump the version number to 0.0.26 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b2a3e0232..70920d1d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "namebase-hsd", - "version": "0.0.25", + "version": "0.0.26", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 21d327f18..11248c054 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "namebase-hsd", - "version": "0.0.25", + "version": "0.0.26", "private": false, "description": "Cryptocurrency bike-shed", "license": "MIT",