Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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());
} catch (err) {
console.log(err.message)
process.exit(1)
}
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}`)
}