mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
Merge bitcoin/bitcoin#26611: wallet: Change coin selection fee assert to error
3eb041f014
wallet: Change coin selection fee assert to error (Andrew Chow)c6e7f224c1
util: Add StrFormatInternalBug and STR_INTERNAL_BUG (MarcoFalke) Pull request description: Returning an error instead of asserting for the low fee check will be better as it does not crash the node and instructs users to report the bug. ACKs for top commit: S3RK: ACK3eb041f014
aureleoules: ACK3eb041f014
furszy: ACK3eb041f0
Tree-SHA512: 118c13d7cdfce492080edd4cb12e6d960695377b978c7573f9c58b6d918664afd0e8e591eed0605d08ac756fa8eceed456349de5f3a025174069abf369bb5a5f
This commit is contained in:
commit
edbe4f808a
3 changed files with 12 additions and 3 deletions
|
@ -14,10 +14,13 @@
|
|||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func)
|
||||
{
|
||||
return strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this issue here: %s\n", msg, file, line, func, PACKAGE_BUGREPORT);
|
||||
}
|
||||
|
||||
NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func)
|
||||
: std::runtime_error{
|
||||
strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this issue here: %s\n", msg, file, line, func, PACKAGE_BUGREPORT)}
|
||||
: std::runtime_error{StrFormatInternalBug(msg, file, line, func)}
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,16 @@
|
|||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func);
|
||||
|
||||
class NonFatalCheckError : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
NonFatalCheckError(const char* msg, const char* file, int line, const char* func);
|
||||
};
|
||||
|
||||
#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
|
||||
|
||||
/** Helper for CHECK_NONFATAL() */
|
||||
template <typename T>
|
||||
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion)
|
||||
|
|
|
@ -955,7 +955,9 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
|
|||
|
||||
// The only time that fee_needed should be less than the amount available for fees is when
|
||||
// we are subtracting the fee from the outputs. If this occurs at any other time, it is a bug.
|
||||
assert(coin_selection_params.m_subtract_fee_outputs || fee_needed <= nFeeRet);
|
||||
if (!coin_selection_params.m_subtract_fee_outputs && fee_needed > nFeeRet) {
|
||||
return util::Error{Untranslated(STR_INTERNAL_BUG("Fee needed > fee paid"))};
|
||||
}
|
||||
|
||||
// If there is a change output and we overpay the fees then increase the change to match the fee needed
|
||||
if (nChangePosInOut != -1 && fee_needed < nFeeRet) {
|
||||
|
|
Loading…
Reference in a new issue