Browse Source

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.
dev-old-randomx
Duke 5 months ago
parent
commit
382861de2b
  1. 4
      src/hush_globals.h

4
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;

Loading…
Cancel
Save