bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
611 stars 1.03k forks source link

Fail To complete transaction #188

Open Bensigo opened 6 years ago

Bensigo commented 6 years ago

Am getting this error and i don't understand why.

TypeError: r.gt is not a function
ECDSA../node_modules/bitcore-lib/lib/crypto/ecdsa.js.ECDSA.sigError

here is my code for performing a transaction

export function sendBTC(paperWallet, toAddress, amount, network) {
  const insight = new explorer.Insight(network)
  insight.getUnspentUtxos(paperWallet.address, (err, utxos) => {
    if(err) {
      console.log(err)
    }
    console.log(utxos)
    console.log(paperWallet.privateKey)
    const tx = new bitcore.Transaction()
    tx.from(utxos)
    tx.to(toAddress, amount) // amount in satoki
    tx.fee((amount* 0.2))
    tx.sign(paperWallet.privateKey)
    tx.serialize()
    insight.broadcast(tx, (err, txid) => {
      if(err) {
        console.log(err)
      }
      console.log('transaction sent :' +  txid)
    })
  })
}
cyio commented 6 years ago

try not use yarn https://github.com/bitpay/bitcore-lib/issues/109