Skip to content

Commit fbc28d0

Browse files
MarcoFalkevijaydasmp
authored andcommitted
Merge bitcoin#26611: wallet: Change coin selection fee assert to error
3eb041f wallet: Change coin selection fee assert to error (Andrew Chow) c6e7f22 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: ACK 3eb041f aureleoules: ACK 3eb041f furszy: ACK 3eb041f Tree-SHA512: 118c13d7cdfce492080edd4cb12e6d960695377b978c7573f9c58b6d918664afd0e8e591eed0605d08ac756fa8eceed456349de5f3a025174069abf369bb5a5f
1 parent efde4e0 commit fbc28d0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/util/check.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
#include <cstdio>
1515
#include <cstdlib>
1616

17-
18-
NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func)
19-
: std::runtime_error{
20-
strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\n"
17+
std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func)
18+
{
19+
return strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\n"
2120
"%s %s\n"
2221
"Please report this issue here: %s\n",
23-
msg, file, line, func, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT)}
22+
msg, file, line, func, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT);
23+
}
24+
25+
NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func)
26+
: std::runtime_error{StrFormatInternalBug(msg, file, line, func)}
2427
{
2528
}
2629

src/util/check.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
#include <stdexcept>
1111
#include <utility>
1212

13+
std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func);
14+
1315
class NonFatalCheckError : public std::runtime_error
1416
{
1517
public:
1618
NonFatalCheckError(const char* msg, const char* file, int line, const char* func);
1719
};
1820

21+
#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
22+
1923
/** Helper for CHECK_NONFATAL() */
2024
template <typename T>
2125
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion)

0 commit comments

Comments
 (0)