Browse Source

Look back when importing postmix like-type change addresses

Pavel Ševčík 3 years ago
parent
commit
859f06c798
No known key found for this signature in database GPG Key ID: CFA54E4C0CD58DF0
  1. 10
      lib/bitcoin/hd-accounts-service.js

10
lib/bitcoin/hd-accounts-service.js

@ -4,7 +4,7 @@
*/
'use strict'
const _ = require('lodash')
const util = require('../util')
const errors = require('../errors')
const Logger = require('../logger')
const db = require('../db/mysql-db-wrapper')
@ -141,10 +141,10 @@ class HDAccountsService {
Logger.info(`HdAccountsService : Created HD Account: ${xpub}${segwit}`)
const externalPrm = hdaHelper.deriveAddresses(xpub, 0, _.range(gap.external), scheme)
const internalPrm = hdaHelper.deriveAddresses(xpub, 1, _.range(gap.internal), scheme)
const externalPrm = hdaHelper.deriveAddresses(xpub, 0, util.range(0, gap.external), scheme)
const internalPrm = hdaHelper.deriveAddresses(xpub, 1, util.range(0, gap.internal), scheme)
const addresses = _.flatten(await Promise.all([externalPrm, internalPrm]))
const addresses = (await Promise.all([externalPrm, internalPrm])).flat()
return db.addAddressesToHDAccount(xpub, addresses)
}
@ -269,7 +269,7 @@ class HDAccountsService {
const postmixNode = hdaHelper.getNode(postmixAcct)
const [externalUnused, internalUnused] = await db.getHDAccountNextUnusedIndices(postmixAcct)
const deriveRange = Array.from({ length: gap.internal }, (_, i) => i + internalUnused)
const deriveRange = util.range(Math.max(0, internalUnused - 50), internalUnused + gap.internal)
const likeTypeChangeAddresses = await Promise.all(deriveRange.map((index) => {
return [

Loading…
Cancel
Save