mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
[amount] Add support for negative fee rates
Currently negative fee rates are not supported on archs of 64-bit or more
This commit is contained in:
@@ -9,20 +9,30 @@
|
||||
|
||||
const std::string CURRENCY_UNIT = "BTC";
|
||||
|
||||
CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize)
|
||||
CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nBytes_)
|
||||
{
|
||||
assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max()));
|
||||
int64_t nSize = int64_t(nBytes_);
|
||||
|
||||
if (nSize > 0)
|
||||
nSatoshisPerK = nFeePaid*1000/nSize;
|
||||
nSatoshisPerK = nFeePaid * 1000 / nSize;
|
||||
else
|
||||
nSatoshisPerK = 0;
|
||||
}
|
||||
|
||||
CAmount CFeeRate::GetFee(size_t nSize) const
|
||||
CAmount CFeeRate::GetFee(size_t nBytes_) const
|
||||
{
|
||||
assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max()));
|
||||
int64_t nSize = int64_t(nBytes_);
|
||||
|
||||
CAmount nFee = nSatoshisPerK * nSize / 1000;
|
||||
|
||||
if (nFee == 0 && nSize != 0 && nSatoshisPerK > 0)
|
||||
nFee = CAmount(1);
|
||||
if (nFee == 0 && nSize != 0) {
|
||||
if (nSatoshisPerK > 0)
|
||||
nFee = CAmount(1);
|
||||
if (nSatoshisPerK < 0)
|
||||
nFee = CAmount(-1);
|
||||
}
|
||||
|
||||
return nFee;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user