How to use the @ledgerhq/ledger-core.createAccount 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
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)

    await account.asBitcoinLikeAccount().broadcastRawTransaction(signedTransaction)
    // console.log(signedTransaction);

    process.exit(0)
    // console.log(account.getIndex());
    // console.log(account.isSynchronizing());
github LedgerHQ / ledger-live-desktop / alix.js View on Github external
async function scanNextAccount(wallet, hwApp, accountIndex = 0) {
  console.log(`creating an account with index ${accountIndex}`)
  const account = await createAccount(wallet, hwApp)
  console.log(`synchronizing account ${accountIndex}`)
  await syncAccount(account)
  console.log(`finished sync`)
  const utxoCount = await account.asBitcoinLikeAccount().getUTXOCount()
  console.log(`utxoCount = ${utxoCount}`)
}