How to use the @ledgerhq/live-common/lib/account.getWalletName 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 / helpers / libcore.js View on Github external
isUnsubscribed: () => boolean,
  derivationMode: DerivationMode,
  showNewAccount: boolean,
}): Promise {
  const isSegwit = isSegwitDerivationMode(derivationMode)
  const unsplitFork = isUnsplitDerivationMode(derivationMode) ? currency.forkedFrom : null
  const { coinType } = unsplitFork ? getCryptoCurrencyById(unsplitFork) : currency
  const path = `${isSegwit ? '49' : '44'}'/${coinType}'`

  const { publicKey: seedIdentifier } = await withDevice(devicePath)(transport =>
    from(getAddress(transport, currency, path)),
  ).toPromise()

  if (isUnsubscribed()) return []

  const walletName = getWalletName({
    seedIdentifier,
    currency,
    derivationMode,
  })

  // retrieve or create the wallet
  const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode })

  // recursively scan all accounts on device on the given app
  // new accounts will be created in sqlite, existing ones will be updated
  const accounts = await scanNextAccount({
    core,
    wallet,
    walletName,
    devicePath,
    currency,
github LedgerHQ / ledger-live-mobile / src / libcore / scanAccountsOnDevice.js View on Github external
: null;
          const { coinType } = unsplitFork
            ? getCryptoCurrencyById(unsplitFork)
            : currency;
          const path = `${isSegwit ? "49" : "44"}'/${coinType}'`;

          const hwApp = new Btc(transport);
          const { publicKey: seedIdentifier } = await hwApp.getWalletPublicKey(
            path,
            false,
            isSegwit,
          );

          if (isUnsubscribed()) return;

          const walletName = getWalletName({
            seedIdentifier,
            currency,
            derivationMode,
          });

          const wallet = await getOrCreateWallet({
            core,
            walletName,
            currency,
            derivationMode,
          });

          const onAccountScanned = account => o.next(account);

          // recursively scan all accounts on device on the given app
          // new accounts will be created in sqlite, existing ones will be updated
github LedgerHQ / ledger-live-mobile / src / libcore / index.js View on Github external
export async function getFeesForTransaction({
  account,
  transaction,
}: {
  account: Account,
  transaction: *,
}): Promise {
  try {
    const { derivationMode, currency, xpub, index } = account;
    const core = await load();
    const walletName = getWalletName(account);

    const coreWallet = await getOrCreateWallet({
      core,
      walletName,
      currency,
      derivationMode,
    });

    const coreAccount = await getOrCreateAccount({
      core,
      coreWallet,
      index,
      xpub,
    });

    const bitcoinLikeAccount = await core.coreAccount.asBitcoinLikeAccount(
github LedgerHQ / ledger-live-mobile / src / libcore / syncAccount.js View on Github external
async function getCoreObjects(core, account: Account) {
  const walletName = getWalletName(account);
  const { currency, derivationMode, index, xpub } = account;

  const coreWallet = await getOrCreateWallet({
    core,
    walletName,
    currency,
    derivationMode,
  });

  const coreAccount = await getOrCreateAccount({
    core,
    coreWallet,
    index,
    xpub,
  });
github LedgerHQ / ledger-live-mobile / src / libcore / getFeesForTransaction.js View on Github external
core => async ({
    account,
    transaction,
  }: {
    account: Account,
    transaction: *,
  }): Promise => {
    try {
      const { derivationMode, currency, xpub, index } = account;
      const walletName = getWalletName(account);

      const coreWallet = await getOrCreateWallet({
        core,
        walletName,
        currency,
        derivationMode,
      });

      const coreAccount = await getOrCreateAccount({
        core,
        coreWallet,
        index,
        xpub,
      });

      const bitcoinLikeAccount = await coreAccount.asBitcoinLikeAccount();
github LedgerHQ / ledger-live-mobile / src / libcore / signAndBroadcast.js View on Github external
blockHeight: number,
    currency: CryptoCurrency,
    xpub: string,
    index: number,
    transaction: Transaction,
    deviceId: string,
    isCancelled: () => boolean,
    onSigning: () => void,
    onSigned: () => void,
    onOperationBroadcasted: (optimisticOp: Operation) => void,
  }): Promise => {
    const { feePerByte } = transaction;
    if (!feePerByte) throw FeeNotLoaded();
    if (isCancelled()) return;

    const walletName = getWalletName({
      currency,
      seedIdentifier,
      derivationMode,
    });

    const coreWallet = await getOrCreateWallet({
      core,
      walletName,
      currency,
      derivationMode,
    });
    if (isCancelled()) return;
    const coreAccount = await coreWallet.getAccount(index);
    if (isCancelled()) return;
    const bitcoinLikeAccount = await coreAccount.asBitcoinLikeAccount();
    if (isCancelled()) return;
github LedgerHQ / ledger-live-desktop / src / helpers / libcore.js View on Github external
export async function scanAccountsFromXPUB({
  core,
  currencyId,
  xpub,
  derivationMode,
  seedIdentifier,
}: {
  core: *,
  currencyId: string,
  xpub: string,
  derivationMode: DerivationMode,
  seedIdentifier: string,
}) {
  const currency = getCryptoCurrencyById(currencyId)
  const walletName = getWalletName({
    currency,
    seedIdentifier,
    derivationMode,
  })

  const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode })

  const index = 0

  const isSegwit = isSegwitDerivationMode(derivationMode)

  const extendedInfos = {
    index,
    owners: ['main'],
    derivations: [
      `${isSegwit ? '49' : '44'}'/${currency.coinType}'`,
github LedgerHQ / ledger-live-mobile / src / libcore / index.js View on Github external
export async function syncAccount({ account }: { account: Account }) {
  const { derivationMode, currency, xpub, index, seedIdentifier } = account;
  const core = await load();
  const walletName = getWalletName(account);

  const coreWallet = await getOrCreateWallet({
    core,
    walletName,
    currency,
    derivationMode,
  });

  const coreAccount = await getOrCreateAccount({
    core,
    coreWallet,
    index,
    xpub,
  });

  const updatedAccount = await syncCoreAccount({