How to use the @ledgerhq/live-common/lib/derivation.getDerivationScheme function in @ledgerhq/live-common

To help you get started, we’ve selected a few @ledgerhq/live-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledger-live-desktop / src / bridge / RippleJSBridge.js View on Github external
async function main() {
        const api = apiForEndpointConfig(RippleAPI)
        try {
          await api.connect()
          const serverInfo = await getServerInfo()
          const ledgers = serverInfo.completeLedgers.split('-')
          const minLedgerVersion = Number(ledgers[0])
          const maxLedgerVersion = Number(ledgers[1])

          const derivationModes = getDerivationModesForCurrency(currency)
          for (const derivationMode of derivationModes) {
            const derivationScheme = getDerivationScheme({
              derivationMode,
              currency,
            })
            const stopAt = isIterableDerivationMode(derivationMode) ? 255 : 1
            for (let index = 0; index < stopAt; index++) {
              if (!derivationModeSupportsIndex(derivationMode, index)) continue
              const freshAddressPath = runDerivationScheme(derivationScheme, currency, {
                account: index,
              })

              const { address } = await getAddress
                .send({
                  derivationMode,
                  currencyId: currency.id,
                  devicePath: deviceId,
                  path: freshAddressPath,
github LedgerHQ / ledger-live-mobile / src / components / DeviceJob / steps.js View on Github external
withDevicePolling(meta.deviceId)(transport =>
      from(
        meta.deviceId.startsWith("mock")
          ? [
              {
                ...meta,
                addressInfo: { address: "" },
              },
            ]
          : getAddress(transport, {
              currency,
              derivationMode: "",
              path: runDerivationScheme(
                getDerivationScheme({ currency, derivationMode: "" }),
                currency,
              ),
            }),
      ),
    ).pipe(
github LedgerHQ / ledger-live-desktop / src / components / modals / Debug.js View on Github external
onClickStressDevice = (device: *) => async () => {
    try {
      const currency = getCryptoCurrencyById('bitcoin')
      const derivationScheme = getDerivationScheme({
        currency,
        derivationMode: 'segwit',
      })
      for (let x = 0; x < 20; x++) {
        const { address, path } = await getAddress
          .send({
            derivationMode: 'segwit',
            path: runDerivationScheme(derivationScheme, currency, { account: x }),
            currencyId: currency.id,
            devicePath: device.path,
          })
          .toPromise()
        this.log(`derivated ${path} = ${address}`)
      }
    } catch (e) {
      this.error(e)
github LedgerHQ / ledger-live-common / tools / src / demos / derivations / index.js View on Github external
execInQueue(async () => {
      const { derivationMode, currency, index: account } = this.props;
      try {
        const p = transportGlobalP || TransportWebUSB.create();
        transportGlobalP = p;
        const transport = await p;
        const { address, path } = await getAddress(transport, {
          currency,
          path: runDerivationScheme(
            getDerivationScheme({ currency, derivationMode }),
            currency,
            { account }
          ),
          derivationMode,
          verify
        });
        this.setState({ address, path });
      } catch (error) {
        this.setState({ error });
      }
    });
github LedgerHQ / ledger-live-desktop / src / helpers / libcore.js View on Github external
walletName: string,
  {
    currency,
    derivationMode,
  }: {
    currency: CryptoCurrency,
    derivationMode: DerivationMode,
  },
): NJSWallet {
  const pool = core.getPoolInstance()
  try {
    const wallet = await timeoutTagged('getWallet', 5000, pool.getWallet(walletName))
    return wallet
  } catch (err) {
    const currencyCore = await timeoutTagged('getCurrency', 5000, pool.getCurrency(currency.id))
    const derivationScheme = getDerivationScheme({ currency, derivationMode })
    const walletConfig = isSegwitDerivationMode(derivationMode)
      ? {
          KEYCHAIN_ENGINE: 'BIP49_P2SH',
          KEYCHAIN_DERIVATION_SCHEME: derivationScheme,
        }
      : {
          KEYCHAIN_DERIVATION_SCHEME: derivationScheme,
        }
    const njsWalletConfig = createWalletConfig(core, walletConfig)
    const wallet = await timeoutTagged(
      'createWallet',
      10000,
      core.getPoolInstance().createWallet(walletName, currencyCore, njsWalletConfig),
    )
    return wallet
  }
github LedgerHQ / ledger-live-mobile / src / libcore / index.js View on Github external
walletName: string,
    currency: CryptoCurrency,
    derivationMode: DerivationMode,
  }) => {
    const poolInstance = core.getPoolInstance();
    let wallet;
    try {
      wallet = await core.coreWalletPool.getWallet(poolInstance, walletName);
    } catch (err) {
      const currencyCore = await core.coreWalletPool.getCurrency(
        poolInstance,
        currency.id,
      );
      const config = await core.coreDynamicObject.newInstance();

      const derivationScheme = getDerivationScheme({
        currency,
        derivationMode,
      });

      if (isSegwitDerivationMode(derivationMode)) {
        core.coreDynamicObject.putString(
          config,
          "KEYCHAIN_ENGINE",
          "BIP49_P2SH",
        );
      }
      core.coreDynamicObject.putString(
        config,
        "KEYCHAIN_DERIVATION_SCHEME",
        derivationScheme,
      );
github LedgerHQ / ledger-live-desktop / src / components / EnsureDeviceApp.js View on Github external
async function getAddressFromAccountOrCurrency(device, account, currency) {
  const { address } = await getAddress
    .send({
      derivationMode: account ? account.derivationMode : '',
      devicePath: device.path,
      currencyId: currency.id,
      path: account
        ? account.freshAddressPath
        : runDerivationScheme(getDerivationScheme({ currency, derivationMode: '' }), currency),
      segwit: account ? isSegwitDerivationMode(account.derivationMode) : false,
    })
    .toPromise()
  return address
}