Skip to content

Commit

Permalink
fix - fixed address derivation for archived wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-blockchain committed Jul 3, 2018
1 parent 152235f commit 89e7075
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/blockchain-wallet-v4/src/redux/walletSync/middleware.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { futurizeP } from 'futurize'
import Task from 'data.task'
import { compose, assoc, join, curry, range, keysIn } from 'ramda'
import { compose, assoc, join, curry, range, keysIn, isNil } from 'ramda'
import { networks } from 'bitcoinjs-lib'

import * as A from '../actions'
Expand Down Expand Up @@ -37,9 +37,13 @@ export const getHDAccountAddressPromises = curry((state, account) => {
*/
const asyncDerive = index => toAsync(() =>
HDAccount.getReceiveAddress(account, index, networks.bitcoin.NETWORK_BITCOIN))
return selectors.data.bitcoin.getReceiveIndex(xpub, state)
.map((receiveIndex) => range(receiveIndex, receiveIndex + addressLookaheadCount))
.getOrElse([])

const receiveIndex = selectors.data.bitcoin
.getReceiveIndex(xpub, state)
.getOrElse(null)
if (isNil(receiveIndex)) return []

return range(receiveIndex, receiveIndex + addressLookaheadCount)
.map(asyncDerive)
})

Expand Down

0 comments on commit 89e7075

Please sign in to comment.