Decentralized Devtax
This commit is contained in:
@@ -30,6 +30,7 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
|
|||||||
bool EnsureWalletIsAvailable(bool avoidException);
|
bool EnsureWalletIsAvailable(bool avoidException);
|
||||||
extern bool fRequestShutdown;
|
extern bool fRequestShutdown;
|
||||||
extern CScript HUSH_EARLYTXID_SCRIPTPUB;
|
extern CScript HUSH_EARLYTXID_SCRIPTPUB;
|
||||||
|
extern std::string scriptpub_for_height(uint32_t nHeight);
|
||||||
|
|
||||||
uint32_t hush_heightstamp(int32_t height);
|
uint32_t hush_heightstamp(int32_t height);
|
||||||
|
|
||||||
@@ -1548,6 +1549,8 @@ bool hush_appendACscriptpub()
|
|||||||
static bool didinit = false;
|
static bool didinit = false;
|
||||||
if ( didinit )
|
if ( didinit )
|
||||||
return didinit;
|
return didinit;
|
||||||
|
// HUSH doesn't use earlytxid so we do not need this in this function
|
||||||
|
//ASSETCHAINS_SCRIPTPUB = scriptpub_for_height(height);
|
||||||
if ( ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] == 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] == 51 )
|
if ( ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] == 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] == 51 )
|
||||||
{
|
{
|
||||||
CTransaction tx; uint256 blockhash;
|
CTransaction tx; uint256 blockhash;
|
||||||
@@ -1616,6 +1619,7 @@ int64_t hush_checkcommission(CBlock *pblock,int32_t height)
|
|||||||
if(fDebug)
|
if(fDebug)
|
||||||
fprintf(stderr,"%s at height=%d\n",__func__,height);
|
fprintf(stderr,"%s at height=%d\n",__func__,height);
|
||||||
int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false;
|
int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false;
|
||||||
|
ASSETCHAINS_SCRIPTPUB = scriptpub_for_height(height);
|
||||||
if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
||||||
{
|
{
|
||||||
checktoshis = the_commission(pblock,height);
|
checktoshis = the_commission(pblock,height);
|
||||||
@@ -1728,6 +1732,7 @@ int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
}
|
}
|
||||||
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) {
|
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) {
|
||||||
if ( height == 1 ) {
|
if ( height == 1 ) {
|
||||||
|
ASSETCHAINS_SCRIPTPUB = scriptpub_for_height(height);
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] != 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] != 51 ) {
|
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] != 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] != 51 ) {
|
||||||
int32_t scriptlen; uint8_t scripthex[10000];
|
int32_t scriptlen; uint8_t scripthex[10000];
|
||||||
script = (uint8_t *)&pblock->vtx[0].vout[0].scriptPubKey[0];
|
script = (uint8_t *)&pblock->vtx[0].vout[0].scriptPubKey[0];
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ const uint32_t nHushHardforkHeight2 = 245055;
|
|||||||
|
|
||||||
// This height begins Hush DPoW from Hush notaries
|
// This height begins Hush DPoW from Hush notaries
|
||||||
const uint32_t nHushHardforkHeight3 = 340420;
|
const uint32_t nHushHardforkHeight3 = 340420;
|
||||||
|
// This height begins Hush Decentralized Devtax
|
||||||
|
const uint32_t nHushHardforkHeight4 = 99999999; // TODO
|
||||||
|
|
||||||
const uint32_t nHushHardforkTimestamp = 1580303652; // Jan 29nd 1pm GMT
|
const uint32_t nHushHardforkTimestamp = 1580303652; // Jan 29nd 1pm GMT
|
||||||
const uint32_t nHushHardforkTimestamp2 = 1594425600; // Jul 11th 12a GMT
|
const uint32_t nHushHardforkTimestamp2 = 1594425600; // Jul 11th 12a GMT
|
||||||
|
|
||||||
|
|||||||
@@ -280,3 +280,53 @@ uint64_t hush_current_supply(uint32_t nHeight)
|
|||||||
//fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN);
|
//fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN);
|
||||||
return(cur_money);
|
return(cur_money);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: production scriptpubs
|
||||||
|
std::string DEVTAX_SCRIPTPUBS[20] = {
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac",
|
||||||
|
"76a914f70a2e3df98d2befba431dfe01d4eaa3e418f68488ac",
|
||||||
|
"76a914941907aa5f85952bc8deff20f1e50aa676a2d8dd88ac"
|
||||||
|
};
|
||||||
|
|
||||||
|
// this is a deterministic consensus-changing function. All miners must be able
|
||||||
|
// to predict the scriptpub for the next block
|
||||||
|
std::string scriptpub_for_height(uint32_t nHeight) {
|
||||||
|
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||||
|
bool istush3 = strncmp(SMART_CHAIN_SYMBOL, "TUSH3",5) == 0 ? true : false;
|
||||||
|
// Fork height for HUSH3 mainnet needs to be decided just before code is merged
|
||||||
|
// Since it requires all full nodes on the network to have enough time to update.
|
||||||
|
// For testing, we choose an early blockheight so we can observe the value changing
|
||||||
|
// from the old fixed value to the new values which cycle
|
||||||
|
const int DEVTAX_FORK_HEIGHT = ishush3 ? nHushHardforkHeight4 : 5;
|
||||||
|
|
||||||
|
// Decentralized devtax is height-activated
|
||||||
|
if (nHeight >= DEVTAX_FORK_HEIGHT) {
|
||||||
|
if (ishush3 || istush3) {
|
||||||
|
// devtax_scriptpubs is an array of length 20 with 20 different scriptpubs
|
||||||
|
int NUM_SCRIPTPUBS = 20;
|
||||||
|
return DEVTAX_SCRIPTPUBS[ nHeight % NUM_SCRIPTPUBS ];
|
||||||
|
} else {
|
||||||
|
// if this is not HUSH3 or a testchain for HUSH3, return it unchanged
|
||||||
|
return ASSETCHAINS_SCRIPTPUB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// return default unchanged if we are less than fork height
|
||||||
|
return ASSETCHAINS_SCRIPTPUB;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1952,6 +1952,8 @@ void hush_args(char *argv0)
|
|||||||
ASSETCHAINS_SAPLING = 1;
|
ASSETCHAINS_SAPLING = 1;
|
||||||
// this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn
|
// this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn
|
||||||
ASSETCHAINS_SCRIPTPUB = "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac";
|
ASSETCHAINS_SCRIPTPUB = "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac";
|
||||||
|
// we do not want to change the magic of HUSH3 mainnet so we do not call scriptpub_for_height() here,
|
||||||
|
// instead we call it whenever ASSETCHAINS_SCRIPTPUB is used later on
|
||||||
|
|
||||||
// Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things
|
// Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things
|
||||||
ASSETCHAINS_REWARD[0] = 0;
|
ASSETCHAINS_REWARD[0] = 0;
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ public:
|
|||||||
extern int8_t ASSETCHAINS_ADAPTIVEPOW;
|
extern int8_t ASSETCHAINS_ADAPTIVEPOW;
|
||||||
extern uint32_t ASSETCHAINS_RANDOMX;
|
extern uint32_t ASSETCHAINS_RANDOMX;
|
||||||
extern bool fRandomXDebug;
|
extern bool fRandomXDebug;
|
||||||
|
extern std::string scriptpub_for_height(uint32_t nHeight);
|
||||||
|
|
||||||
void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
|
void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
|
||||||
{
|
{
|
||||||
@@ -630,6 +631,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
pblock->vtx[0] = txNew;
|
pblock->vtx[0] = txNew;
|
||||||
|
|
||||||
|
ASSETCHAINS_SCRIPTPUB = scriptpub_for_height(nHeight);
|
||||||
if ( nHeight > 1 && SMART_CHAIN_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= the_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 )
|
if ( nHeight > 1 && SMART_CHAIN_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= the_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 )
|
||||||
{
|
{
|
||||||
int32_t i; uint8_t *ptr;
|
int32_t i; uint8_t *ptr;
|
||||||
@@ -819,6 +821,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
{
|
{
|
||||||
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
||||||
// fprintf(stderr,"%s: with nHeight=%d\n", __func__, nHeight);
|
// fprintf(stderr,"%s: with nHeight=%d\n", __func__, nHeight);
|
||||||
|
ASSETCHAINS_SCRIPTPUB = scriptpub_for_height(nHeight);
|
||||||
if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] != 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] != 51 )
|
if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] != 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] != 51 )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||||
|
|||||||
@@ -1036,6 +1036,8 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp, const CPubKey& mypk
|
|||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.push_back(Pair("miner", ValueFromAmount(nReward)));
|
result.push_back(Pair("miner", ValueFromAmount(nReward)));
|
||||||
|
|
||||||
|
// the value of ASSETCHAINS_SCRIPTPUB is not used here, this is just a check if it exists
|
||||||
|
// so we don't need to call scriptpub_for_height()
|
||||||
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_FOUNDERS == 0 && ASSETCHAINS_COMMISSION != 0 )
|
if ( ASSETCHAINS_FOUNDERS == 0 && ASSETCHAINS_COMMISSION != 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user