1216 | @@ -1217,9 +1217,10 @@ static RPCHelpMan gettxoutsetinfo()
1217 | ret.pushKV("hash_serialized_2", stats.hashSerialized.GetHex());
1218 | }
1219 | if (hash_type == CoinStatsHashType::MUHASH) {
1220 | - ret.pushKV("muhash", stats.hashSerialized.GetHex());
1221 | + ret.pushKV("muhash", stats.hashSerialized.GetHex());
1222 | }
1223 | - ret.pushKV("total_amount", ValueFromAmount(stats.nTotalAmount));
1224 | + CHECK_NONFATAL(stats.total_amount);
nit: this looks like we are checking that the amount is not 0. Maybe better to be more explicit:
CHECK_NONFATAL(stats.total_amount.has_value());
This would throw and not display any results. Is that the desirable outcome? What about just skipping the ret.pushKV("total_amount", ...) if there is no value? Or push something like "N/A", "NaN" or "overflow"? I mean the rest of the stats are still useful, right?
I think we should throw on internal bugs, which are impossible to hit. Otherwise it will be harder to find and fix them. Also, they'll crash the client regardless either with KeyError or with a parse error, since a string isn't int.