Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/neuron-wallet/src/keys/hd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import * as bip32 from 'bip32'
import { AddressType } from '../services/addresses'
import { KeysData } from './keystore'

// 360 is just a tentative value, and we also need a coin type of mainnet.
const COIN_TYPE_TESTNET = "360'"

class HD {
public static pathFromIndex = (type: AddressType, index: number) => {
return `m/44'/${COIN_TYPE_TESTNET}/0'/${type}/${index}`
return `m/44'/309'/0'/${type}/${index}`
}

public static indexFromPath = (path: string) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/services/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const MAX_ADDRESS_COUNT = 30
export const SEARCH_RANGE = 20

export enum AddressType {
Receiving = 0,
Change = 1,
Receiving = 0, // External chain
Change = 1, // Internal chain
}

export interface HDAddress {
Expand Down
8 changes: 4 additions & 4 deletions packages/neuron-wallet/tests/services/address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ describe('Key tests', () => {
}
const addresses = Addresses.generateAddresses(keysData, 2, 2)
expect(2).toBe(addresses.receiving.length)
expect('ckt1q9gry5zgy4tp7rnhacvl49rqgcufpn6hsacc2edvdzg26n').toBe(addresses.receiving[0].address)
expect("m/44'/360'/0'/0/0").toBe(addresses.receiving[0].path)
expect('ckt1q9gry5zgmgxa776jt6k40ysfkhwv8egepeqwzuv6jqjt02').toBe(addresses.receiving[0].address)
expect("m/44'/309'/0'/0/0").toBe(addresses.receiving[0].path)

expect(2).toBe(addresses.change.length)
expect('ckt1q9gry5zgl0arwx02534dv6k6mfarffgulzqmxwvgpfvk23').toBe(addresses.change[0].address)
expect("m/44'/360'/0'/1/0").toBe(addresses.change[0].path)
expect('ckt1q9gry5zgclst8my3sdp75u0htlh56u8md3c4fttkum6mt3').toBe(addresses.change[0].address)
expect("m/44'/309'/0'/1/0").toBe(addresses.change[0].path)
})
})