How to use the @ledgerhq/ledger-core.getCurrency function in @ledgerhq/ledger-core

To help you get started, we’ve selected a few @ledgerhq/ledger-core 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 / alix.js View on Github external
// const accounts = await scanAccountsOnDevice({
  //   devicePath: device.path,
  //   currencyId: 'bitcoin_testnet',
  // })
  // console.log(accounts)
  try {
    console.log(`> Creating transport`)
    const transport = await CommNodeHid.open(device.path)

    // transport.setDebugMode(true)

    console.log(`> Instanciate BTC app`)
    const hwApp = new Btc(transport)

    console.log(`> Get currency`)
    const currency = await getCurrency('bitcoin_testnet')

    console.log(`> Create wallet`)
    const wallet = CREATE ? await createWallet('khalil', currency) : await getWallet('khalil')

    console.log(`> Create account`)
    const account = CREATE ? await createAccount(wallet, hwApp) : await wallet.getAccount(0)

    console.log(`> Sync account`)
    if (CREATE) {
      await syncAccount(account)
    }

    console.log(`> Create transaction`)
    const transaction = await createTransaction(wallet, account)
    const signedTransaction = await signTransaction(hwApp, transaction)
github LedgerHQ / ledger-live-desktop / alix.js View on Github external
async function getOrCreateWallet(currencyId) {
  try {
    const wallet = await getWallet(currencyId)
    return wallet
  } catch (err) {
    const currency = await getCurrency(currencyId)
    const wallet = await createWallet(currencyId, currency)
    return wallet
  }
}