diff --git a/lib/wallet/account.js b/lib/wallet/account.js index f0173628..a076d19f 100644 --- a/lib/wallet/account.js +++ b/lib/wallet/account.js @@ -279,10 +279,10 @@ Account.prototype.open = function open() { Account.prototype.pushKey = function pushKey(key) { var index; - if (HD.isBase58(key)) - key = HD.fromBase58(key, this.network); + if (typeof key === 'string') + key = HD.PublicKey.fromBase58(key, this.network); - assert(key.verifyNetwork(this.network), + assert(key.network === this.network, 'Network mismatch for account key.'); if (!HD.isPublic(key)) @@ -319,13 +319,13 @@ Account.prototype.pushKey = function pushKey(key) { */ Account.prototype.spliceKey = function spliceKey(key) { - if (HD.isBase58(key)) - key = HD.fromBase58(key, this.network); + if (typeof key === 'string') + key = HD.PublicKey.fromBase58(key, this.network); - assert(key.verifyNetwork(this.network), + assert(key.network === this.network, 'Network mismatch for account key.'); - if (!HD.isHDPublicKey(key)) + if (!HD.isPublic(key)) throw new Error('Must add HD keys to wallet.'); if (!key.isAccount44()) @@ -973,14 +973,14 @@ Account.prototype.fromRaw = function fromRaw(data) { this.changeDepth = br.readU32(); this.nestedDepth = br.readU32(); this.lookahead = br.readU8(); - this.accountKey = HD.fromRaw(br.readBytes(82)); + this.accountKey = HD.PublicKey.fromRaw(br.readBytes(82)); assert(Account.typesByVal[this.type]); count = br.readU8(); for (i = 0; i < count; i++) { - key = HD.fromRaw(br.readBytes(82)); + key = HD.PublicKey.fromRaw(br.readBytes(82)); this.pushKey(key); } diff --git a/lib/wallet/masterkey.js b/lib/wallet/masterkey.js index 33860948..6e601660 100644 --- a/lib/wallet/masterkey.js +++ b/lib/wallet/masterkey.js @@ -600,7 +600,7 @@ MasterKey.prototype.fromRaw = function fromRaw(raw) { // NOTE: useless varint br.skipVarint(); - this.key = HD.fromRaw(br.readBytes(82)); + this.key = HD.PrivateKey.fromRaw(br.readBytes(82)); if (br.readU8() === 1) this.mnemonic = Mnemonic.fromReader(br); diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index 04ab4e8c..010982a8 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -107,7 +107,7 @@ Wallet.prototype.fromOptions = function fromOptions(options) { if (key) { if (typeof key === 'string') - key = HD.fromBase58(key, this.network); + key = HD.PrivateKey.fromBase58(key, this.network); assert(HD.isPrivate(key), 'Must create wallet with hd private key.'); @@ -116,7 +116,7 @@ Wallet.prototype.fromOptions = function fromOptions(options) { key = HD.fromMnemonic(mnemonic, this.network); } - assert(key.verifyNetwork(this.network), + assert(key.network === this.network, 'Network mismatch for master key.'); this.master.fromKey(key, mnemonic); @@ -695,13 +695,13 @@ Wallet.prototype._createAccount = co(function* createAccount(options, passphrase if (this.watchOnly && options.accountKey) { key = options.accountKey; - if (HD.isBase58(key)) - key = HD.fromBase58(key, this.network); + if (typeof key === 'string') + key = HD.PublicKey.fromBase58(key, this.network); if (!HD.isPublic(key)) throw new Error('Must add HD public keys to watch only wallet.'); - assert(key.verifyNetwork(this.network), + assert(key.network === this.network, 'Network mismatch for watch only key.'); } else { assert(this.master.key); @@ -1239,7 +1239,7 @@ Wallet.prototype._importKey = co(function* importKey(acct, ring, passphrase) { if (acct == null) acct = 0; - assert(ring.verifyNetwork(this.network), + assert(ring.network === this.network, 'Network mismatch for key.'); if (!this.watchOnly) { @@ -1324,7 +1324,7 @@ Wallet.prototype._importAddress = co(function* importAddress(acct, address) { if (acct == null) acct = 0; - assert(address.verifyNetwork(this.network), + assert(address.network === this.network, 'Network mismatch for address.'); if (!this.watchOnly)