@ -144,6 +144,23 @@ class DashboardPage extends PureComponent<Props, State> {
<Box flow={7}>
{currentDevice && (
<Box p={8}>
<button
onClick={async () => {
const freshAddress = await runJob({
channel: 'usb',
job: 'wallet.getFreshReceiveAddress',
successResponse: 'wallet.getFreshReceiveAddress.success',
errorResponse: 'wallet.getFreshReceiveAddress.fail',
data: {
accountIndex: accounts[0].index,
currencyId: 'bitcoin_testnet',
},
})
console.log(freshAddress)
}}
>
{'get fresh address'}
</button>
{currentDevice.path}
@ -55,7 +55,8 @@ class CheckAddress extends PureComponent<Props, State> {
verifyAddress = ({ device, account }: { device: Device, account: Account }) =>
sendEvent('usb', 'wallet.verifyAddress', {
pathDevice: device.path,
path: `${account.rootPath}${account.path}`,
path: account.path,
segwit: account.path.startsWith("49'"), // TODO: store segwit info in account
render() {
@ -84,6 +84,7 @@ class DeviceMonit extends PureComponent<Props, State> {
devicePath: currentDevice.path,
accountPath: account.path,
accountAddress: account.address,
}
@ -101,6 +101,7 @@ class DeviceMonit extends PureComponent<Props, State> {
options = {
@ -24,6 +24,23 @@ export function getPath({
}`
export async function getFreshReceiveAddress({
currencyId,
accountIndex,
}: {
currencyId: string,
accountIndex: number,
}) {
const core = require('ledger-core')
const wallet = await core.getWallet(currencyId)
const account = await wallet.getAccount(accountIndex)
const addresses = await account.getFreshPublicAddresses()
if (!addresses.length) {
throw new Error('No fresh addresses')
return addresses[0]
export function verifyAddress({
transport,
path,
@ -3,7 +3,7 @@
import CommNodeHid from '@ledgerhq/hw-transport-node-hid'
import Btc from '@ledgerhq/hw-app-btc'
import { getPath, verifyAddress } from './accounts'
import { getPath, verifyAddress, getFreshReceiveAddress } from './accounts'
import scanAccountsOnDevice from './scanAccountsOnDevice'
export default (sendEvent: Function) => ({
@ -37,6 +37,21 @@ export default (sendEvent: Function) => ({
`NOT IMPLEMENTED: getting account for ${pathDevice} ${currencyId} ${currentAccounts.length}`,
)
getFreshReceiveAddress: async ({
}) => {
try {
console.log(accountIndex)
const freshAddress = await getFreshReceiveAddress({ currencyId, accountIndex })
sendEvent('wallet.getFreshReceiveAddress.success', freshAddress)
} catch (err) {
sendEvent('wallet.getFreshReceiveAddress.fail', err)
verifyAddress: async ({ pathDevice, path }: { pathDevice: string, path: string }) => {
const transport = await CommNodeHid.open(pathDevice)
@ -59,7 +59,7 @@ async function scanNextAccount({ wallet, hwApp, accountIndex = 0, accountsCount,
accounts.push(account)
// returns if the current index points on an account with no ops
if (!ops.length) {
if (utxosCount === 0) {
return accounts