diff --git a/createtx.go b/createtx.go index 0013f6f..3bb615b 100644 --- a/createtx.go +++ b/createtx.go @@ -370,20 +370,20 @@ func minimumFee(tx *btcwire.MsgTx, allowFree bool) btcutil.Amount { } } - max := btcutil.Amount(btcutil.MaxSatoshi) - if fee < 0 || fee > max { - fee = max + if fee < 0 || fee > btcutil.MaxSatoshi { + fee = btcutil.MaxSatoshi } return fee } // allowFree calculates the transaction priority and checks that the -// priority reaches a certain threshhold. If the threshhold is +// priority reaches a certain threshold. If the threshhold is // reached, a free transaction fee is allowed. func allowFree(curHeight int32, txouts []txstore.Credit, txSize int) bool { - const blocksPerDayEstimate = 144 - const txSizeEstimate = 250 + const blocksPerDayEstimate = 144.0 + const txSizeEstimate = 250.0 + const threshold = btcutil.SatoshiPerBitcoin * blocksPerDayEstimate / txSizeEstimate var weightedSum int64 for _, txout := range txouts { @@ -391,7 +391,7 @@ func allowFree(curHeight int32, txouts []txstore.Credit, txSize int) bool { weightedSum += int64(txout.Amount()) * int64(depth) } priority := float64(weightedSum) / float64(txSize) - return priority > float64(btcutil.SatoshiPerBitcoin)*blocksPerDayEstimate/txSizeEstimate + return priority > threshold } // chainDepth returns the chaindepth of a target given the current diff --git a/createtx_test.go b/createtx_test.go index 70929e4..1e47940 100644 --- a/createtx_test.go +++ b/createtx_test.go @@ -38,7 +38,7 @@ var allowFreeTests = []allowFreeTest{ name: "priority < 57,600,000", inputs: []*tx.Utxo{ { - Amt: uint64(btcutil.SatoshiPerBitcoin), + Amt: btcutil.SatoshiPerBitcoin, Height: 0, }, }, @@ -50,7 +50,7 @@ var allowFreeTests = []allowFreeTest{ name: "priority == 57,600,000", inputs: []*tx.Utxo{ { - Amt: uint64(btcutil.SatoshiPerBitcoin), + Amt: btcutil.SatoshiPerBitcoin, Height: 0, }, }, @@ -62,7 +62,7 @@ var allowFreeTests = []allowFreeTest{ name: "priority > 57,600,000", inputs: []*tx.Utxo{ { - Amt: uint64(btcutil.SatoshiPerBitcoin), + Amt: btcutil.SatoshiPerBitcoin, Height: 0, }, }, diff --git a/rpcserver.go b/rpcserver.go index 01c50c3..39de197 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1348,7 +1348,7 @@ func GetInfo(icmd btcjson.Cmd) (interface{}, error) { info.KeypoolOldest = time.Now().Unix() info.KeypoolSize = int32(cfg.KeypoolSize) TxFeeIncrement.Lock() - info.PaytxFee = float64(TxFeeIncrement.i) / float64(btcutil.SatoshiPerBitcoin) + info.PaytxFee = float64(TxFeeIncrement.i) / btcutil.SatoshiPerBitcoin TxFeeIncrement.Unlock() // We don't set the following since they don't make much sense in the // wallet architecture: