3 - Address derivation | Developers

3 - Address derivation

Estimated reading time: 2 minutes

From step 3 to step 6, you work will be implemented in the Ledger Live repository.

Derive Address from device

Tip
If your app JS bindings are not yet published in LedgerJS, use yalc to link your local packages.

First and easiest step is to get an address from the device for MyCoin, by creating the hw-getAddress.ts Resolver:

src/families/mycoin/hw-getAddress.js:

import type { Resolver } from "../../hw/getAddress/types";
import MyCoin from "@ledgerhq/hw-app-mycoin";

const resolver: Resolver = async (transport, { path, verify }) => {
  const myCoin = new MyCoin(transport);

  const r = await myCoin.getAddress(path, verify);

  return {
    address: r.address,
    publicKey: r.publicKey,
    path,
  };
};

export default resolver;

Test that you can derive an address:

ledger-live getAddress --currency mycoin --path "44'/8008'/0'/0/0" --derivationMode ""

Derivation

Ledger Live uses the BIP44 derivation mode by default (as derivationMode=""), which is standard and most common way for HD wallet. If MyCoin has a conventional derivation path (BIP44), Ledger Live should already be able to derive an address correctly.

If you need to use another derivation mode:

Make changes to src/derivation.ts:

  1. Add a new derivation mode with overridesDerivation:
      // const modes = Object.freeze({
      // ...
     mycoinbip44h: { // Hardened BIP44 for MyCoin
       overridesDerivation: "44'/8008'/<account>'/0'/<address>'",
     },
      // });
    
  2. add the mode to family in legacyDerivations:
      // const legacyDerivations: $Shape<CryptoCurrencyConfig<DerivationMode[]>> = {
      // ...
     mycoin: ["mycoinbip44h"],
      // };
    
  3. disable the default use of BIP44 in disableBIP44:
      // const disableBIP44 = {
      // ...
     mycoin: true,
      // };
    

See Derivation documentation for further details.

You can check that the derivationMode is correct by executing:

ledger-live derivation --currency mycoin

#>  default: MyCoin 1: 44'/8008'/<account>'/<change>/<address>

Did you find this page helpful?


How would you improve this page for developers?



2 - Nano App JS Bindings
4 - Add accounts: light sync
Getting Started
Theme Features
Customization