2
0
mirror of synced 2025-02-24 12:08:10 +00:00

Fixed path for x-ethers metadata and wallet (#).

This commit is contained in:
Richard Moore 2019-01-17 16:32:51 -05:00
parent 442553620a
commit e5bee7e5a3
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
4 changed files with 8 additions and 3 deletions

View File

@ -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)

View File

@ -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"
};
}

View File

@ -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; }

View File

@ -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,