Skip to content

Commit

Permalink
fix floating point precision issue in outTx amount conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Oct 3, 2023
1 parent b41ca4d commit cb48f00
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,12 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64
amount = -res.Amount
}

amountInSat, _ := big.NewFloat(amount * 1e8).Int(nil)
sats, err := getSatoshis(amount)
if err != nil {
ob.logger.ObserveOutTx.Warn().Msgf("IsSendOutTxProcessed: getSatoshis error: %s", err)
return false, false, nil
}
amountInSat := big.NewInt(sats)
if res.Confirmations < ob.ConfirmationsThreshold(amountInSat) {
return true, false, nil
}
Expand Down

0 comments on commit cb48f00

Please sign in to comment.