diff options
author | Andrew Chow <github@achow101.com> | 2022-12-05 14:33:35 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2022-12-09 14:52:26 -0500 |
commit | c1a84f108e320bd44c172a4dd3bb486ab777ff69 (patch) | |
tree | a257f489d858ec571cd502f953af70f83edd2939 /src/primitives/transaction.h | |
parent | e5daf976d5b064b585029d4bb38d68a8153ea13b (diff) | |
download | bitcoin-c1a84f108e320bd44c172a4dd3bb486ab777ff69.tar.xz |
wallet: Move fee underpayment check to after fee setting
It doesn't make sense to be checking whether the fee paid is underpaying
before we've finished setting the fees. So do that after we have done
the reduction for SFFO and change adjustment for fee overpayment.
Diffstat (limited to 'src/primitives/transaction.h')
-rw-r--r-- | src/primitives/transaction.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index f496ea022e..6b4a6335a1 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -17,6 +17,7 @@ #include <ios> #include <limits> #include <memory> +#include <numeric> #include <string> #include <tuple> #include <utility> @@ -280,6 +281,12 @@ inline void SerializeTransaction(const TxType& tx, Stream& s) { s << tx.nLockTime; } +template<typename TxType> +inline CAmount CalculateOutputValue(const TxType& tx) +{ + return std::accumulate(tx.vout.cbegin(), tx.vout.cend(), CAmount{0}, [](CAmount sum, const auto& txout) { return sum + txout.nValue; }); +} + /** The basic transaction that is broadcasted on the network and contained in * blocks. A transaction can contain multiple inputs and outputs. |