Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plumbing to the wallet plugin to accept configuration for primary wallet #9

Merged
merged 3 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/wallet/masterkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
Expand Down
3 changes: 2 additions & 1 deletion lib/wallet/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/wallet/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
Expand Down
12 changes: 12 additions & 0 deletions lib/wallet/walletdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
Expand Down Expand Up @@ -2302,6 +2306,8 @@ class WalletOptions {
this.checkpoints = false;
this.wipeNoReally = false;

this.createWalletOptions = [];

if (options)
this.fromOptions(options);
}
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "namebase-hsd",
"version": "0.0.25",
"version": "0.0.26",
"private": false,
"description": "Cryptocurrency bike-shed",
"license": "MIT",
Expand Down