Fixed path for x-ethers metadata and wallet (#).
This commit is contained in:
parent
442553620a
commit
e5bee7e5a3
@ -109,7 +109,7 @@ export class HDNode {
|
||||
// Base path
|
||||
var mnemonic = this.mnemonic;
|
||||
var path = this.path;
|
||||
if (path) { path += '/' + index; }
|
||||
if (path) { path += '/' + (index & ~HardenedBit); }
|
||||
|
||||
if (index & HardenedBit) {
|
||||
// Data = 0x00 || ser_256(k_par)
|
||||
|
@ -438,6 +438,7 @@ export function encrypt(privateKey: Arrayish | SigningKey, password: Arrayish |
|
||||
gethFilename: ('UTC--' + timestamp + '--' + data.address),
|
||||
mnemonicCounter: hexlify(mnemonicIv).substring(2),
|
||||
mnemonicCiphertext: hexlify(mnemonicCiphertext).substring(2),
|
||||
path: path,
|
||||
version: "0.1"
|
||||
};
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export class Wallet extends AbstractSigner {
|
||||
get address(): string { return this.signingKey.address; }
|
||||
|
||||
get mnemonic(): string { return this.signingKey.mnemonic; }
|
||||
get path(): string { return this.signingKey.mnemonic; }
|
||||
get path(): string { return this.signingKey.path; }
|
||||
|
||||
get privateKey(): string { return this.signingKey.privateKey; }
|
||||
|
||||
|
@ -31,7 +31,7 @@ describe('Test JSON Wallets', function() {
|
||||
// A few extra test cases to test encrypting/decrypting
|
||||
['one', 'two', 'three'].forEach(function(i) {
|
||||
var password = 'foobar' + i;
|
||||
var wallet = new Wallet(utils.randomHexString('test-' + i, 32));
|
||||
var wallet = Wallet.createRandom({ path: "m/56'/82", extraEntropy: utils.randomHexString('test-' + i, 32) });
|
||||
it('encrypts and decrypts a random wallet - ' + i, function() {
|
||||
this.timeout(1200000);
|
||||
|
||||
@ -39,6 +39,10 @@ describe('Test JSON Wallets', function() {
|
||||
return Wallet.fromEncryptedJson(json, password).then(function(decryptedWallet) {
|
||||
assert.equal(decryptedWallet.address, wallet.address,
|
||||
'decrypted wallet - ' + wallet.privateKey);
|
||||
assert.equal(decryptedWallet.mnemonic, wallet.mnemonic,
|
||||
"decrypted wallet menonic - " + wallet.privateKey);
|
||||
assert.equal(decryptedWallet.path, wallet.path,
|
||||
"decrypted wallet path - " + wallet.privateKey);
|
||||
return decryptedWallet.encrypt(password).then(function(encryptedWallet) {
|
||||
var parsedWallet = JSON.parse(encryptedWallet);
|
||||
assert.equal(decryptedWallet.address.toLowerCase().substring(2), parsedWallet.address,
|
||||
|
Loading…
x
Reference in New Issue
Block a user