|
@ -35,13 +35,13 @@ export default function scanAccountsOnDevice(props: Props): Promise<AccountRaw[] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// scan segwit AND non-segwit accounts
|
|
|
// scan segwit AND non-segwit accounts
|
|
|
const segwitAccounts = await scanAccountsOnDeviceBySegwit({ ...commonParams, isSegwit: true }) |
|
|
|
|
|
const nonSegwitAccounts = await scanAccountsOnDeviceBySegwit({ |
|
|
const nonSegwitAccounts = await scanAccountsOnDeviceBySegwit({ |
|
|
...commonParams, |
|
|
...commonParams, |
|
|
isSegwit: false, |
|
|
isSegwit: false, |
|
|
}) |
|
|
}) |
|
|
|
|
|
const segwitAccounts = await scanAccountsOnDeviceBySegwit({ ...commonParams, isSegwit: true }) |
|
|
|
|
|
|
|
|
const accounts = [...segwitAccounts, ...nonSegwitAccounts] |
|
|
const accounts = [...nonSegwitAccounts, ...segwitAccounts] |
|
|
|
|
|
|
|
|
return accounts |
|
|
return accounts |
|
|
}) |
|
|
}) |
|
@ -154,16 +154,18 @@ async function scanNextAccount(props: { |
|
|
ops, |
|
|
ops, |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
// returns if the current index points on an account with no ops
|
|
|
const isEmpty = ops.length === 0 |
|
|
if (ops.length === 0) { |
|
|
|
|
|
return accounts |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// trigger event
|
|
|
// trigger event
|
|
|
onAccountScanned(account) |
|
|
onAccountScanned(account) |
|
|
|
|
|
|
|
|
accounts.push(account) |
|
|
accounts.push(account) |
|
|
|
|
|
|
|
|
|
|
|
// returns if the current index points on an account with no ops
|
|
|
|
|
|
if (isEmpty) { |
|
|
|
|
|
return accounts |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return scanNextAccount({ ...props, accountIndex: accountIndex + 1 }) |
|
|
return scanNextAccount({ ...props, accountIndex: accountIndex + 1 }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -259,7 +261,9 @@ async function buildAccountRaw({ |
|
|
id: xpub, // FIXME for account id you might want to prepend the crypto currency id to this because it's not gonna be unique.
|
|
|
id: xpub, // FIXME for account id you might want to prepend the crypto currency id to this because it's not gonna be unique.
|
|
|
xpub, |
|
|
xpub, |
|
|
path: walletPath, |
|
|
path: walletPath, |
|
|
name: `Account ${accountIndex}${isSegwit ? ' (segwit)' : ''}`, // TODO: placeholder name?
|
|
|
name: `${operations.length === 0 ? 'New ' : ''}Account ${accountIndex}${ |
|
|
|
|
|
isSegwit ? ' (segwit)' : '' |
|
|
|
|
|
}`, // TODO: placeholder name?
|
|
|
isSegwit, |
|
|
isSegwit, |
|
|
freshAddress, |
|
|
freshAddress, |
|
|
freshAddressPath, |
|
|
freshAddressPath, |
|
|