Increase robustness when loading malformed mempool.dat
files.
Avoids the following three signed integer overflows when loading malformed mempool.dat
files:
0$ xxd -p -r > mempool.dat-crash-1 <<EOF
10100000000000000000000000004000000000000000000000000ffffffff
2ffffff7f00000000000000000000000000
3EOF
4$ cp mempool.dat-crash-1 ~/.bitcoin/regtest/mempool.dat
5$ UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1:report_error_type=1" src/bitcoind -regtest
6validation.cpp:5079:23: runtime error: signed integer overflow: 9223372036854775807 + 1209600 cannot be represented in type 'long'
7 [#0](/bitcoin-bitcoin/0/) 0x5618d335197f in LoadMempool(CTxMemPool&) src/validation.cpp:5079:23
8 [#1](/bitcoin-bitcoin/1/) 0x5618d3350df3 in CChainState::LoadMempool(ArgsManager const&) src/validation.cpp:4217:9
9 [#2](/bitcoin-bitcoin/2/) 0x5618d2b9345f in ThreadImport(ChainstateManager&, std::vector<boost::filesystem::path, std::allocator<boost::filesystem::path> >, ArgsManager const&) src/init.cpp:762:33
10 [#3](/bitcoin-bitcoin/3/) 0x5618d2b92162 in AppInitMain(util::Ref const&, NodeContext&, interfaces::BlockAndHeaderTipInfo*)::$_14::operator()() const src/init.cpp:1881:9
0$ xxd -p -r > mempool.dat-crash-2 <<EOF
1010000000000000000050900000000000509000000000000800000000000
20000000000000000000000800000000000
3EOF
4$ cp mempool.dat-crash-2 ~/.bitcoin/regtest/mempool.dat
5$ UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1:report_error_type=1" src/bitcoind -regtest
6util/moneystr.cpp:16:34: runtime error: negation of -9223372036854775808 cannot be represented in type 'CAmount' (aka 'long'); cast to an unsigned type to negate this value to itself
7 [#0](/bitcoin-bitcoin/0/) 0x5618a4a6366c in FormatMoney[abi:cxx11](long const&) src/util/moneystr.cpp:16:34
8 [#1](/bitcoin-bitcoin/1/) 0x5618a406c2f1 in CTxMemPool::PrioritiseTransaction(uint256 const&, long const&) src/txmempool.cpp:861:77
9 [#2](/bitcoin-bitcoin/2/) 0x5618a411064f in LoadMempool(CTxMemPool&) src/validation.cpp:5076:22
10 [#3](/bitcoin-bitcoin/3/) 0x5618a410fdf3 in CChainState::LoadMempool(ArgsManager const&) src/validation.cpp:4217:9
11 [#4](/bitcoin-bitcoin/4/) 0x5618a395245f in ThreadImport(ChainstateManager&, std::vector<boost::filesystem::path, std::allocator<boost::filesystem::path> >, ArgsManager const&) src/init.cpp:762:33
12 [#5](/bitcoin-bitcoin/5/) 0x5618a3951162 in AppInitMain(util::Ref const&, NodeContext&, interfaces::BlockAndHeaderTipInfo*)::$_14::operator()() const src/init.cpp:1881:9
0$ xxd -p -r > mempool.dat-crash-3 <<EOF
10100000000000000000000000000000001253d8c0000000000000000006b
200000000f7000000ff00f7000000ff0000000000000000000000800000ff
30000
4EOF
5$ cp mempool.dat-crash-3 ~/.bitcoin/regtest/mempool.dat
6$ UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1:report_error_type=1" src/bitcoind -regtest
7util/moneystr.cpp:16:34: runtime error: negation of -9223372036854775808 cannot be represented in type 'CAmount' (aka 'long'); cast to an unsigned type to negate this value to itself
8 [#0](/bitcoin-bitcoin/0/) 0x5575f515e66c in FormatMoney[abi:cxx11](long const&) src/util/moneystr.cpp:16:34
9 [#1](/bitcoin-bitcoin/1/) 0x5575f47672f1 in CTxMemPool::PrioritiseTransaction(uint256 const&, long const&) src/txmempool.cpp:861:77
10 [#2](/bitcoin-bitcoin/2/) 0x5575f480bc82 in LoadMempool(CTxMemPool&) src/validation.cpp:5107:18
11 [#3](/bitcoin-bitcoin/3/) 0x5575f480adf3 in CChainState::LoadMempool(ArgsManager const&) src/validation.cpp:4217:9
12 [#4](/bitcoin-bitcoin/4/) 0x5575f404d45f in ThreadImport(ChainstateManager&, std::vector<boost::filesystem::path, std::allocator<boost::filesystem::path> >, ArgsManager const&) src/init.cpp:762:33
13 [#5](/bitcoin-bitcoin/5/) 0x5575f404c162 in AppInitMain(util::Ref const&, NodeContext&, interfaces::BlockAndHeaderTipInfo*)::$_14::operator()() const src/init.cpp:1881:9
Fixes #19278.