Skip to content

Commit

Permalink
Merge PR#1025 from 'RajWorking/wallet-seedphrase'
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Aug 13, 2021
2 parents cae1bb9 + 99c7cfb commit b7280a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/wallet/masterkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ class MasterKey {
*/

toJSON(network, unsafe) {
if (this.encrypted) {
if (!this.key) {
return {
encrypted: true,
until: this.until,
Expand Down
25 changes: 25 additions & 0 deletions test/wallet-http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,31 @@ for (const witnessOpt of witnessOptions) {
addr = Address.fromString(str, node.network);
});

it('should enable seed phrase recovery', async () => {
const options = {
passphrase: 'PASSPHRASE',
mnemonic: 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong'
};
const walletName = `test_seed-${witnessOpt}`;

const testwallet = await wclient.createWallet(walletName, options);
assert.strictEqual(testwallet.master.encrypted, false);

const master1 = await wclient.getMaster(walletName);
assert.strictEqual(master1.encrypted, false);
assert.strictEqual(master1.mnemonic.phrase, options.mnemonic);

await wclient.lock(walletName);
const master2 = await wclient.getMaster(walletName);
assert.strictEqual(master2.encrypted, true);
assert.strictEqual(master2.mnemonic, undefined);

await wclient.unlock(walletName, 'PASSPHRASE', 100);
const master3 = await wclient.getMaster(walletName);
assert.strictEqual(master3.encrypted, false);
assert.strictEqual(master3.mnemonic.phrase, options.mnemonic);
});

it('should fill with funds', async () => {
const mtx = new MTX();
mtx.addOutpoint(new Outpoint(consensus.ZERO_HASH, 0));
Expand Down

0 comments on commit b7280a1

Please sign in to comment.