Skip to content

Commit

Permalink
use actual txSize for fee calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Oct 8, 2023
1 parent a2c2e81 commit d9dffa2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions zetaclient/btc_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ func (signer *BTCSigner) SignWithdrawTx(to *btcutil.AddressWitnessPubKeyHash, am
if txSize > sizeLimit { // ZRC20 'withdraw' charged less fee from end user
signer.logger.Info().Msgf("sizeLimit %d is less than txSize %d for nonce %d", sizeLimit, txSize, nonce)
}
if sizeLimit < outTxBytesMin { // outbound shouldn't be blocked a low sizeLimit
if txSize < outTxBytesMin { // outbound shouldn't be blocked a low sizeLimit
signer.logger.Warn().Msgf("sizeLimit %d is less than outTxBytesMin %d; use outTxBytesMin", sizeLimit, outTxBytesMin)
sizeLimit = outTxBytesMin
txSize = outTxBytesMin
}
if sizeLimit > outTxBytesCap { // in case of accident
if txSize > outTxBytesCap { // in case of accident
signer.logger.Warn().Msgf("sizeLimit %d is greater than outTxBytesCap %d; use outTxBytesCap", sizeLimit, outTxBytesCap)
sizeLimit = outTxBytesCap
txSize = outTxBytesCap
}

// fee calculation
fees := new(big.Int).Mul(big.NewInt(int64(sizeLimit)), gasPrice)
fees := new(big.Int).Mul(big.NewInt(int64(txSize)), gasPrice)
fees.Div(fees, big.NewInt(bytesPerKB))
signer.logger.Info().Msgf("bitcoin outTx nonce %d gasPrice %s size %d fees %s", nonce, gasPrice.String(), txSize, fees.String())

Expand Down

0 comments on commit d9dffa2

Please sign in to comment.