From 382861de2bca28312c0db9ab6b5d54cf0e8cc35a Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 27 Nov 2023 18:45:49 -0500 Subject: [PATCH] Fixes #362 Array index 2 does not exist, which caused the foundersrewardaddress key of getblocktemplate to be incorrect. It would either show the next address in the list or be empty if it caused a read past the end of the 2D DEVTAX_DATA array. This is what happens in gcc 9.4.0 but since this is technically Undefined Behavior according to the C Standard it could cause a crash or even make demons fly out of your nose. See http://catb.org/jargon/html/N/nasal-demons.html for details. --- src/hush_globals.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hush_globals.h b/src/hush_globals.h index 2666c1e22..776de8a54 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -332,7 +332,7 @@ std::string devtax_scriptpub_for_height(uint32_t nHeight) { } // this is only used by getblocktemplate, so it cannot change consensus of -// blocks < DEVTAX_FORK_HEIGHT but it will affect consensus of later blocks +// blocks < DEVTAX_FORK_HEIGHT but it could affect consensus of later blocks std::string devtax_address_for_height(uint32_t nHeight) { const std::string legacy_devtax_address = "RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn"; bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; @@ -346,7 +346,7 @@ std::string devtax_address_for_height(uint32_t nHeight) { // Decentralized devtax is height-activated if (nHeight >= DEVTAX_FORK_HEIGHT) { if (ishush3 || istush3) { - return DEVTAX_DATA[ nHeight % DEVTAX_NUM ][2]; + return DEVTAX_DATA[ nHeight % DEVTAX_NUM ][0]; } else { // if this is not HUSH3 or TUSH3, return legacy return legacy_devtax_address;