Updates for untyped btcutil consts.
This commit is contained in:
parent
9036d36e68
commit
0abe6e32bf
3 changed files with 11 additions and 11 deletions
14
createtx.go
14
createtx.go
|
@ -370,20 +370,20 @@ func minimumFee(tx *btcwire.MsgTx, allowFree bool) btcutil.Amount {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
max := btcutil.Amount(btcutil.MaxSatoshi)
|
if fee < 0 || fee > btcutil.MaxSatoshi {
|
||||||
if fee < 0 || fee > max {
|
fee = btcutil.MaxSatoshi
|
||||||
fee = max
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fee
|
return fee
|
||||||
}
|
}
|
||||||
|
|
||||||
// allowFree calculates the transaction priority and checks that the
|
// 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.
|
// reached, a free transaction fee is allowed.
|
||||||
func allowFree(curHeight int32, txouts []txstore.Credit, txSize int) bool {
|
func allowFree(curHeight int32, txouts []txstore.Credit, txSize int) bool {
|
||||||
const blocksPerDayEstimate = 144
|
const blocksPerDayEstimate = 144.0
|
||||||
const txSizeEstimate = 250
|
const txSizeEstimate = 250.0
|
||||||
|
const threshold = btcutil.SatoshiPerBitcoin * blocksPerDayEstimate / txSizeEstimate
|
||||||
|
|
||||||
var weightedSum int64
|
var weightedSum int64
|
||||||
for _, txout := range txouts {
|
for _, txout := range txouts {
|
||||||
|
@ -391,7 +391,7 @@ func allowFree(curHeight int32, txouts []txstore.Credit, txSize int) bool {
|
||||||
weightedSum += int64(txout.Amount()) * int64(depth)
|
weightedSum += int64(txout.Amount()) * int64(depth)
|
||||||
}
|
}
|
||||||
priority := float64(weightedSum) / float64(txSize)
|
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
|
// chainDepth returns the chaindepth of a target given the current
|
||||||
|
|
|
@ -38,7 +38,7 @@ var allowFreeTests = []allowFreeTest{
|
||||||
name: "priority < 57,600,000",
|
name: "priority < 57,600,000",
|
||||||
inputs: []*tx.Utxo{
|
inputs: []*tx.Utxo{
|
||||||
{
|
{
|
||||||
Amt: uint64(btcutil.SatoshiPerBitcoin),
|
Amt: btcutil.SatoshiPerBitcoin,
|
||||||
Height: 0,
|
Height: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -50,7 +50,7 @@ var allowFreeTests = []allowFreeTest{
|
||||||
name: "priority == 57,600,000",
|
name: "priority == 57,600,000",
|
||||||
inputs: []*tx.Utxo{
|
inputs: []*tx.Utxo{
|
||||||
{
|
{
|
||||||
Amt: uint64(btcutil.SatoshiPerBitcoin),
|
Amt: btcutil.SatoshiPerBitcoin,
|
||||||
Height: 0,
|
Height: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -62,7 +62,7 @@ var allowFreeTests = []allowFreeTest{
|
||||||
name: "priority > 57,600,000",
|
name: "priority > 57,600,000",
|
||||||
inputs: []*tx.Utxo{
|
inputs: []*tx.Utxo{
|
||||||
{
|
{
|
||||||
Amt: uint64(btcutil.SatoshiPerBitcoin),
|
Amt: btcutil.SatoshiPerBitcoin,
|
||||||
Height: 0,
|
Height: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1348,7 +1348,7 @@ func GetInfo(icmd btcjson.Cmd) (interface{}, error) {
|
||||||
info.KeypoolOldest = time.Now().Unix()
|
info.KeypoolOldest = time.Now().Unix()
|
||||||
info.KeypoolSize = int32(cfg.KeypoolSize)
|
info.KeypoolSize = int32(cfg.KeypoolSize)
|
||||||
TxFeeIncrement.Lock()
|
TxFeeIncrement.Lock()
|
||||||
info.PaytxFee = float64(TxFeeIncrement.i) / float64(btcutil.SatoshiPerBitcoin)
|
info.PaytxFee = float64(TxFeeIncrement.i) / btcutil.SatoshiPerBitcoin
|
||||||
TxFeeIncrement.Unlock()
|
TxFeeIncrement.Unlock()
|
||||||
// We don't set the following since they don't make much sense in the
|
// We don't set the following since they don't make much sense in the
|
||||||
// wallet architecture:
|
// wallet architecture:
|
||||||
|
|
Loading…
Reference in a new issue