Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #221 from JDonadio/fix/keep-seed
Browse files Browse the repository at this point in the history
keep the seed imported from mnemonics
  • Loading branch information
isocolsky committed Apr 1, 2016
2 parents e4d40c1 + 9ee0ee0 commit 4c707f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ Credentials.fromMnemonic = function(network, words, passphrase, account, derivat
var m = new Mnemonic(words);
var x = new Credentials();
x.xPrivKey = m.toHDPrivateKey(passphrase, network).toString();
x.mnemonic = words;
x.mnemonicHasPassphrase = !!passphrase;
x.account = account;
x.derivationStrategy = derivationStrategy;
x._expand();
return x;
};

/*
/*
* BWC uses
* xPrivKey -> m/44'/network'/account' -> Base Address Key
* so, xPubKey is PublicKeyHD(xPrivKey.derive("m/44'/network'/account'").
Expand Down
6 changes: 4 additions & 2 deletions test/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,8 @@ describe('client API', function() {
should.not.exist(err);
clients[0].openWallet(function(err) {
should.not.exist(err);
should.not.exist(clients[0].getMnemonic()); // mnemonics are *not* stored
should.exist(clients[0].getMnemonic());
words.should.be.equal(clients[0].getMnemonic());
clients[0].credentials.xPrivKey.should.equal('xprv9s21ZrQH143K4X2frJxRmGsmef9UfXhmfL4hdTGLm5ruSX46gekuSTspJX63d5nEi9q2wqUgg4KZ4yhSPy13CzVezAH6t6gCox1DN2hXV3L')
done();
});
Expand All @@ -1340,7 +1341,8 @@ describe('client API', function() {
should.exist(secret);
clients[0].openWallet(function(err) {
should.not.exist(err);
should.not.exist(clients[0].getMnemonic()); // mnemonics are *not* stored
should.exist(clients[0].getMnemonic());
words.should.be.equal(clients[0].getMnemonic());
clients[0].credentials.xPrivKey.should.equal('xprv9s21ZrQH143K4X2frJxRmGsmef9UfXhmfL4hdTGLm5ruSX46gekuSTspJX63d5nEi9q2wqUgg4KZ4yhSPy13CzVezAH6t6gCox1DN2hXV3L')
done();
});
Expand Down
3 changes: 2 additions & 1 deletion test/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ describe('Credentials', function() {
var path = c.getBaseAddressDerivationPath();

var c2 = Credentials.fromMnemonic('testnet', words, 'holamundo', 0, 'BIP44');
should.not.exist(c2.mnemonic);
should.exist(c2.mnemonic);
words.should.be.equal(c2.mnemonic);
c2.xPrivKey.should.equal(c.xPrivKey);
c2.network.should.equal(c.network);
c2.getBaseAddressDerivationPath().should.equal(path);
Expand Down

0 comments on commit 4c707f2

Please sign in to comment.