From aacb2ada43ef1cb28a7c9567eb32bb56c1fa7c9d Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Sun, 10 Mar 2019 17:38:18 +0200 Subject: [PATCH] [NOD-36] Convert util.MaxSatoshi to integer (#199) --- blockdag/validate.go | 10 +++++----- util/const.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/blockdag/validate.go b/blockdag/validate.go index 51e94d822..5ea892a22 100644 --- a/blockdag/validate.go +++ b/blockdag/validate.go @@ -180,7 +180,7 @@ func CheckTransactionSanity(tx *util.Tx, subnetworkID *subnetworkid.SubnetworkID satoshi := txOut.Value if satoshi > util.MaxSatoshi { str := fmt.Sprintf("transaction output value of %d is "+ - "higher than max allowed value of %f", satoshi, + "higher than max allowed value of %d", satoshi, util.MaxSatoshi) return ruleError(ErrBadTxOutValue, str) } @@ -191,7 +191,7 @@ func CheckTransactionSanity(tx *util.Tx, subnetworkID *subnetworkid.SubnetworkID newTotalSatoshi := totalSatoshi + satoshi if newTotalSatoshi < totalSatoshi { str := fmt.Sprintf("total value of all transaction "+ - "outputs exceeds max allowed value of %f", + "outputs exceeds max allowed value of %d", util.MaxSatoshi) return ruleError(ErrBadTxOutValue, str) } @@ -199,7 +199,7 @@ func CheckTransactionSanity(tx *util.Tx, subnetworkID *subnetworkid.SubnetworkID if totalSatoshi > util.MaxSatoshi { str := fmt.Sprintf("total value of all transaction "+ "outputs is %d which is higher than max "+ - "allowed value of %f", totalSatoshi, + "allowed value of %d", totalSatoshi, util.MaxSatoshi) return ruleError(ErrBadTxOutValue, str) } @@ -925,7 +925,7 @@ func CheckTransactionInputs(tx *util.Tx, txHeight int32, utxoSet UTXOSet, dagPar originTxSatoshi := entry.Amount() if originTxSatoshi > util.MaxSatoshi { str := fmt.Sprintf("transaction output value of %s is "+ - "higher than max allowed value of %f", + "higher than max allowed value of %d", util.Amount(originTxSatoshi), util.MaxSatoshi) return 0, ruleError(ErrBadTxOutValue, str) @@ -940,7 +940,7 @@ func CheckTransactionInputs(tx *util.Tx, txHeight int32, utxoSet UTXOSet, dagPar totalSatoshiIn > util.MaxSatoshi { str := fmt.Sprintf("total value of all transaction "+ "inputs is %d which is higher than max "+ - "allowed value of %f", totalSatoshiIn, + "allowed value of %d", totalSatoshiIn, util.MaxSatoshi) return 0, ruleError(ErrBadTxOutValue, str) } diff --git a/util/const.go b/util/const.go index dc302b382..ae010d9bb 100644 --- a/util/const.go +++ b/util/const.go @@ -6,11 +6,11 @@ package util const ( // SatoshiPerBitcent is the number of satoshi in one bitcoin cent. - SatoshiPerBitcent = 1e6 + SatoshiPerBitcent = 1000000 // SatoshiPerBitcoin is the number of satoshi in one bitcoin (1 BTC). - SatoshiPerBitcoin = 1e8 + SatoshiPerBitcoin = 100000000 // MaxSatoshi is the maximum transaction amount allowed in satoshi. - MaxSatoshi = 21e6 * SatoshiPerBitcoin + MaxSatoshi = 21000000 * SatoshiPerBitcoin )