aboutsummaryrefslogtreecommitdiff
path: root/src/policy/feerate.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2022-03-01 09:56:42 +0000
committerfanquake <fanquake@gmail.com>2022-03-01 13:40:11 +0000
commit9b5f674abb0e90280436fbacb8711250cde11773 (patch)
tree0f173c70b5ff3a3cf60cb3eb4a1bc30a01c07c75 /src/policy/feerate.cpp
parenteff97097239fa42764aaa14a7ae57ac9e73b9bd9 (diff)
parent269553fe73b17f8acda3071a48836c66092d31d0 (diff)
downloadbitcoin-9b5f674abb0e90280436fbacb8711250cde11773.tar.xz
Merge bitcoin/bitcoin#23276: [22.x] Backports for 22.x
269553fe73b17f8acda3071a48836c66092d31d0 test: Call ceildiv helper with integer (Martin Zumsande) 2f60fc6d8c6b1d8e74c340fed495b76deac4a048 ci: Replace soon EOL hirsute with jammy (MarcoFalke) 801b0f05aaf974ab9b0e3f7b59948564638d593f build: patch qt to explicitly define previously implicit header include (Kittywhiskers Van Gogh) c768bfa08af034c744402d4294cc323d653b97b8 tests: Calculate fees more similarly to CFeeRate::GetFee (Andrew Chow) f66bc42957ad2e86982c8c487f821683d3009b43 tests: Test for assertion when feerate is rounded down (Andrew Chow) bd7e08e36bf2e1238ddf8cc01433f8db82f848c9 fees: Always round up fee calculated from a feerate (Andrew Chow) 227ae652542451834faddbaffb54fc384e9156e6 wallet: fix segfault by avoiding invalid default-ctored `external_spk_managers` entry (Sebastian Falbesoner) 282863a7e9ddfb14ef02182945ca1978699dbe52 refactor: include a missing <limits> header in fs.cpp (Joan Karadimov) 7febe4f3c7f482390c4aa6fc528e2ee3fb34b142 consensus: don't call GetBlockPos in ReadBlockFromDisk without lock (Jon Atack) c671c6f4706d17cccfe5c35950235f8777a7975f the result of CWallet::IsHDEnabled() was initialized with true. (Saibato) a5a153882609c8d77118a88a9a440d4966c8d0ef build, qt: Fix typo in QtInputSupport check (Hennadii Stepanov) c95b188fc08387d0a89668e56bce3a4fad1ee611 system: skip trying to set the locale on NetBSD (fanquake) c1cdeddd905b5444eac330d565b297b3d4941c5d guix: Fix powerpc64(le) dynamic linker name (Carl Dong) 92d44ff36cc12e34f93bfcc4ec31ffae8787100c doc: Add 23061 release notes (MarcoFalke) db76db7329f6357c5226cd08611fe0f669c002af Fix (inverse) meaning of -persistmempool (MarcoFalke) 85c78e08ec857e51a9748d1a2492d1d3794b221a build: Restrict check for CRC32C intrinsic to aarch64 (W. J. van der Laan) Pull request description: Collecting backports for the 22.1 release. Currently: * https://github.com/bitcoin/bitcoin/pull/23045 * https://github.com/bitcoin/bitcoin/pull/23061 * https://github.com/bitcoin/bitcoin/pull/23148 * https://github.com/bitcoin/bitcoin/pull/22390 * https://github.com/bitcoin/bitcoin/pull/22820 * https://github.com/bitcoin/bitcoin/pull/22781 * https://github.com/bitcoin/bitcoin/pull/22895 * https://github.com/bitcoin/bitcoin/pull/23335 * https://github.com/bitcoin/bitcoin/pull/23333 * https://github.com/bitcoin/bitcoin/pull/22949 * https://github.com/bitcoin/bitcoin/pull/23580 * https://github.com/bitcoin/bitcoin/pull/23504 * https://github.com/bitcoin/bitcoin/pull/24239 ACKs for top commit: achow101: ACK 269553fe73b17f8acda3071a48836c66092d31d0 Tree-SHA512: b3a57ea241be7a83488eeb032276f4cf82a0987aada906a82f94a20c4acf9f2397708249dcecbe1c7575e70d09c60b835233d4718af4013c7bc58896c618274c
Diffstat (limited to 'src/policy/feerate.cpp')
-rw-r--r--src/policy/feerate.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/policy/feerate.cpp b/src/policy/feerate.cpp
index 25b9282b4e..ce149067b7 100644
--- a/src/policy/feerate.cpp
+++ b/src/policy/feerate.cpp
@@ -7,6 +7,8 @@
#include <tinyformat.h>
+#include <cmath>
+
CFeeRate::CFeeRate(const CAmount& nFeePaid, uint32_t num_bytes)
{
const int64_t nSize{num_bytes};
@@ -22,7 +24,9 @@ CAmount CFeeRate::GetFee(uint32_t num_bytes) const
{
const int64_t nSize{num_bytes};
- CAmount nFee = nSatoshisPerK * nSize / 1000;
+ // Be explicit that we're converting from a double to int64_t (CAmount) here.
+ // We've previously had issues with the silent double->int64_t conversion.
+ CAmount nFee{static_cast<CAmount>(std::ceil(nSatoshisPerK * nSize / 1000.0))};
if (nFee == 0 && nSize != 0) {
if (nSatoshisPerK > 0) nFee = CAmount(1);