Bitcoincashjs generates dust output with 0 amount

1

I am using bitcoincashjs (Bitcore fork) library to make BCH transaction (actually it is an exchange with ChangeNow API). Source wallet has only one UTXO:

[
  {
    "address":"bitcoincash:qpde96gh8j9hd9jewzdu6rfme725vpm0mqc2wzyque",
    "txid":"422defba3dce33a55bf84650848a2fa971907ec6b6ce156fa414254d2e5b45a4",
    "vout":1,
    "scriptPubKey":"76a9145b92e9173c8b769659709bcd0d3bcf9546076fd888ac",
    "amount":0.02880688,
    "satoshis":2880688,
    "height":531325,
    "confirmations":3
  }
]

So, then I build the transaction

const bitcoreTransaction = new Bitcore.Transaction()
  .from(unspentOutputs)
  .to(toAddress, fromFunction(data.amount)[toFunction]())
  .fee(fromFunction(fee)[toFunction]())
  .feePerKb(this.getFeePerKb()) // 4000
  .change(fromAddress)
  .sign(privateKeyForSign);

and check for serialization error, which says: Dust amount detected in one output. When I debug resulting tx object, I see two outputs and one of them has 0 amount. Skipping of dust check on client does not help as it is checked on API side while publishing the transaction and error is returned.

Any ideas how to avoid this?

oxfn

Posted 2018-05-22T14:01:59.983

Reputation: 111

Question was closed 2019-07-17T17:40:50.800

Try if it also happens with bitcore-lib. If not, report it.MCCCS 2018-05-22T14:07:19.010

No answers