How to use the @ledgerhq/ledger-core.createAmount 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
async function createTransaction(wallet, account) {
  const ADDRESS_TO_SEND = 'n2jdejywRogCunR2ozZAfXp1jMnfGpGXGR'

  const bitcoinLikeAccount = account.asBitcoinLikeAccount()
  const walletCurrency = wallet.getCurrency()
  const amount = createAmount(walletCurrency, 10000)

  console.log(`--------------------------------`)
  console.log(amount.toLong())
  console.log(`-----------------after `)
  const fees = createAmount(walletCurrency, 1000)

  const transactionBuilder = bitcoinLikeAccount.buildTransaction()
  transactionBuilder.sendToAddress(amount, ADDRESS_TO_SEND)
  // TODO: don't use hardcoded value for sequence (and first also maybe)
  transactionBuilder.pickInputs(0, 0xffffff)
  transactionBuilder.setFeesPerByte(fees)

  return transactionBuilder.build()
}
github LedgerHQ / ledger-live-desktop / alix.js View on Github external
async function createTransaction(wallet, account) {
  const ADDRESS_TO_SEND = 'n2jdejywRogCunR2ozZAfXp1jMnfGpGXGR'

  const bitcoinLikeAccount = account.asBitcoinLikeAccount()
  const walletCurrency = wallet.getCurrency()
  const amount = createAmount(walletCurrency, 10000)

  console.log(`--------------------------------`)
  console.log(amount.toLong())
  console.log(`-----------------after `)
  const fees = createAmount(walletCurrency, 1000)

  const transactionBuilder = bitcoinLikeAccount.buildTransaction()
  transactionBuilder.sendToAddress(amount, ADDRESS_TO_SEND)
  // TODO: don't use hardcoded value for sequence (and first also maybe)
  transactionBuilder.pickInputs(0, 0xffffff)
  transactionBuilder.setFeesPerByte(fees)

  return transactionBuilder.build()
}