diff --git a/lib/wallet/account.js b/lib/wallet/account.js index 52f35d26..7b7a71f0 100644 --- a/lib/wallet/account.js +++ b/lib/wallet/account.js @@ -691,7 +691,7 @@ Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) { key = this.deriveChange(change - 1); yield this.saveKey(key); - this.change = this.deriveChange(change - 1); + this.change = key; this.changeDepth = change; derived = true; diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index d52f1f08..78b58bd4 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -1164,8 +1164,8 @@ WalletDB.prototype.getPathMap = co(function* getPathMap(hash) { /** * Save an address to the path map. - * @param {WalletID} wid - * @param {KeyRing[]} ring + * @param {Wallet} wallet + * @param {WalletKey} ring * @returns {Promise} */ @@ -1177,11 +1177,12 @@ WalletDB.prototype.saveKey = function saveKey(wallet, ring) { * Save a path to the path map. * * The path map exists in the form of: - * - `p[address-hash] -> wids` - * - `P[wid][address-hash] -> path` + * - `p[address-hash] -> wid map` + * - `P[wid][address-hash] -> path data` + * - `r[wid][account-index][address-hash] -> dummy` * - * @param {WalletID} wid - * @param {Path[]} path + * @param {Wallet} wallet + * @param {Path} path * @returns {Promise} */ @@ -1204,8 +1205,13 @@ WalletDB.prototype.savePath = co(function* savePath(wallet, path) { this.pathMapCache.set(hash, map); wallet.pathCache.push(hash, path); + // Address Hash -> Wallet Map batch.put(layout.p(hash), map.toRaw()); + + // Wallet ID + Address Hash -> Path Data batch.put(layout.P(wid, hash), path.toRaw()); + + // Wallet ID + Account Index + Address Hash -> Dummy batch.put(layout.r(wid, path.account, hash), DUMMY); });