From 553ef336392fa7130707947a7af9e25cdd6fedd0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 13 Dec 2018 08:11:48 -1100 Subject: [PATCH 01/11] Remove unused n --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c99a5f1a6..e8d2d2036 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -889,9 +889,9 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blo int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width) { - int32_t i,j,n,nonz,numnotaries; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33],pubkey33[33]; + int32_t i,j,nonz,numnotaries; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33],pubkey33[33]; numnotaries = komodo_notaries(notarypubs33,height,0); - for (i=nonz=0; i Date: Thu, 13 Dec 2018 08:20:20 -1100 Subject: [PATCH 02/11] Initialize scriptlen --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e8d2d2036..363d3dac6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1806,7 +1806,9 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { int32_t scriptlen; uint8_t scripthex[10000]; - if ( ASSETCHAINS_SCRIPTPUB.size()/2 == pblock->vtx[0].vout[0].scriptPubKey.size() && scriptlen < sizeof(scripthex) ) + script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; + scriptlen = (int32_t)pblock->vtx[0].vout[0].scriptPubKey.size(); + if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) { decode_hex(scripthex,scriptlen,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); if ( memcmp(scripthex,script,scriptlen) != 0 ) From d3cb22caea86064b78f7ded00b38ec7f91195b8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 00:36:02 -1100 Subject: [PATCH 03/11] Make -ac_founders= --- src/komodo_bitcoind.h | 10 ++++------ src/komodo_globals.h | 4 ++-- src/komodo_utils.h | 25 +++++++++++++------------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d7def36f5..881db459f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ commission must be in coinbase.vout[1] and must be >= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ -extern int32_t ASSETCHAINS_FOUNDERS_PERIOD; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); @@ -1125,12 +1124,11 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + if ( ASSETCHAINS_FOUNDERS > 1 ) { - if ( height % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) - commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; - else - commission = 0; + if ( (height % ASSETCHAINS_FOUNDERS) == 0 ) + commission = commission * ASSETCHAINS_FOUNDERS; + else commission = 0; } } else diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0c69322e3..3e9b84db1 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,10 +45,10 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS_PERIOD; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; bool VERUS_MINTBLOCKS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index dd133cd02..becc8fcbf 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1765,12 +1765,12 @@ void komodo_args(char *argv0) MAX_BLOCK_SIGOPS = 60000; ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; - ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0) & 1; + ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); + //ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1872,13 +1872,14 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) - { - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); - if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); - } + { + uint8_t tmp = 1; + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(tmp),(void *)&tmp); + if ( ASSETCHAINS_FOUNDERS > 1 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) - extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } addn = GetArg("-seednode",""); @@ -1905,11 +1906,11 @@ void komodo_args(char *argv0) while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) { fprintf(stderr,"waiting for datadir\n"); - #ifndef _WIN32 +#ifndef _WIN32 sleep(3); - #else - boost::this_thread::sleep(boost::posix_time::milliseconds(3000)); - #endif +#else + boost::this_thread::sleep(boost::posix_time::milliseconds(3000)); +#endif } //fprintf(stderr,"Got datadir.(%s)\n",dirname); if ( ASSETCHAINS_SYMBOL[0] != 0 ) From 6afa73204769eb46ea399fb833c0900daf17d0b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 01:39:32 -1100 Subject: [PATCH 04/11] Require scriptPubKeyIn size > 0 in miner.cpp --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9b0a04aaa..e94ed0b03 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -148,7 +148,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, CPubKey pk = CPubKey(); std::vector> vAddrs; txnouttype txT; - if (Solver(scriptPubKeyIn, txT, vAddrs)) + if ( scriptPubKeyIn.size() > 0 && Solver(scriptPubKeyIn, txT, vAddrs)) { if (txT == TX_PUBKEY) pk = CPubKey(vAddrs[0]); From 41431aff2b4534b92defacaa25007a359934dd9a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 01:51:45 -1100 Subject: [PATCH 05/11] Vout1 -> vout0 in height.1 check --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 881db459f..096590563 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1807,7 +1807,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { int32_t scriptlen; uint8_t scripthex[10000]; - script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; + script = (uint8_t *)&pblock->vtx[0].vout[0].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[0].scriptPubKey.size(); if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) { From ff289aed155d305996a64d7de0f390c3019ed18f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:01:14 -1100 Subject: [PATCH 06/11] +prints --- src/komodo_utils.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index becc8fcbf..0d387b41f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1500,6 +1500,7 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_ { vcalc_sha256(0,hash.bytes,extraptr,extralen); crc0 = hash.uints[0]; + fprintf(stderr,"crc0.%x\n",crc0); } return(calc_crc32(crc0,buf,len)); } @@ -1825,7 +1826,7 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...]\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2]); + fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33; @@ -1879,7 +1880,10 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) + { extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + fprintf(stderr,"append ac_script\n"); + } } addn = GetArg("-seednode",""); From 9a2bac4db45dbdca33691d14814aa5eb267136fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:05:25 -1100 Subject: [PATCH 07/11] Test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0d387b41f..556152f76 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1882,7 +1882,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); - fprintf(stderr,"append ac_script\n"); + fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } } From ca9c262c38054811ce7ec650076b3fcc80c5322d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:06:46 -1100 Subject: [PATCH 08/11] Test --- src/komodo_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 556152f76..908e0fcb3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1881,7 +1881,9 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); + extralen += ASSETCHAINS_SCRIPTPUB.size()/2; + //extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } } From 143c778222db7945cb2a0c0259f12f9fb4ada240 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:11:40 -1100 Subject: [PATCH 09/11] Test --- src/komodo_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 908e0fcb3..e6600fa65 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1500,7 +1500,9 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_ { vcalc_sha256(0,hash.bytes,extraptr,extralen); crc0 = hash.uints[0]; - fprintf(stderr,"crc0.%x\n",crc0); + int32_t i; for (i=0; i Date: Fri, 14 Dec 2018 04:14:48 -1100 Subject: [PATCH 10/11] Test --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e6600fa65..99bcebb5c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1883,9 +1883,9 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); - extralen += ASSETCHAINS_SCRIPTPUB.size()/2; - //extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + //decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); + //extralen += ASSETCHAINS_SCRIPTPUB.size()/2; + extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } } From c338c2922af7ca0f9b01080aa85c012bec51c092 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:18:10 -1100 Subject: [PATCH 11/11] Fix -ac_script not changing magic --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 99bcebb5c..e6600fa65 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1883,9 +1883,9 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - //decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); - //extralen += ASSETCHAINS_SCRIPTPUB.size()/2; - extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); + extralen += ASSETCHAINS_SCRIPTPUB.size()/2; + //extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } }