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.
This commit is contained in:
Andrew Chow
2022-12-05 14:33:35 -05:00
parent e5daf976d5
commit c1a84f108e
2 changed files with 25 additions and 9 deletions

View File

@@ -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.