diff --git a/lib/bcoin/address.js b/lib/bcoin/address.js index 40283cad..78fa6577 100644 --- a/lib/bcoin/address.js +++ b/lib/bcoin/address.js @@ -37,6 +37,7 @@ function Address(options) { this.derived = !!options.derived; this.key = bcoin.keypair(options); + this.index = options.index; this.path = options.path; this.type = options.type || 'pubkeyhash'; @@ -519,6 +520,7 @@ Address.prototype.toJSON = function toJSON(encrypt) { label: this.label, change: this.change, derived: this.derived, + index: this.index, path: this.path, address: this.getKeyAddress(), scriptAddress: this.getScriptAddress(), @@ -545,6 +547,7 @@ Address.fromJSON = function fromJSON(json, decrypt) { label: json.label, change: json.change, derived: json.derived, + index: json.index, path: json.path, key: bcoin.keypair.fromJSON(json.key, decrypt), type: json.type, diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index ccfcc3d6..df2034a5 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -168,6 +168,7 @@ function Wallet(options) { privateKey: key.privateKey, publicKey: key.publicKey, compressed: key.compressed, + index: key.index, path: key.path, type: this.type, subtype: this.subtype, @@ -192,6 +193,7 @@ function Wallet(options) { privateKey: key.privateKey, publicKey: key.publicKey, compressed: key.compressed, + index: key.index, path: key.path, type: this.type, subtype: this.subtype, @@ -561,6 +563,7 @@ Wallet.prototype.createAddress = function createAddress(change, index) { privateKey: key.privateKey, publicKey: key.publicKey, compressed: key.compressed, + index: key.index, path: key.path, type: this.type, subtype: this.subtype, @@ -751,7 +754,11 @@ Wallet.prototype.createKey = function createKey(change, index) { privateKey: key.privateKey, publicKey: key.publicKey, compressed: true, - path: 'm/' + (change ? 1 : 0) + '/' + index + index: index, + path: 'm' + // + (this.derivation === 'bip45' ? '/' + this.cosignerIndex : '') + + '/' + (change ? 1 : 0) + + '/' + index }; };