@@ -247,4 +247,5 @@
|
|||||||
"ac_cc": "2",
|
"ac_cc": "2",
|
||||||
"addnode": ["51.75.122.83"]
|
"addnode": ["51.75.122.83"]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -147,6 +147,13 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
outputsDummy = inputs = 0;
|
outputsDummy = inputs = 0;
|
||||||
preventCCvins = preventCCvouts = -1;
|
preventCCvins = preventCCvouts = -1;
|
||||||
|
|
||||||
|
// add specific chains exceptions for old token support:
|
||||||
|
if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190)
|
||||||
|
return true;
|
||||||
|
|
||||||
// add specific chains exceptions for old token support:
|
// add specific chains exceptions for old token support:
|
||||||
if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073)
|
if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1213,6 +1213,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit
|
|||||||
} else {
|
} else {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
//fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN);
|
||||||
|
entropytxs = n;
|
||||||
|
return(totalinputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks)
|
bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks)
|
||||||
|
|||||||
@@ -2929,26 +2929,28 @@ int32_t main(void)
|
|||||||
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen);
|
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen);
|
||||||
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
||||||
|
|
||||||
int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector<uint256> voutpubtxids)
|
int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector<uint256> voutpubtxids)
|
||||||
{
|
{
|
||||||
CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector<uint256> vintxids; std::vector<int32_t> vinprevns; std::vector<CTxOut> vouts;
|
CScript data; uint256 hash; int32_t i,numvins,len = 0; std::vector<uint256> vintxids; std::vector<int32_t> vinprevns; std::vector<CTxOut> vouts;
|
||||||
numvins = tx.vin.size();
|
numvins = tx.vin.size();
|
||||||
numvouts = tx.vout.size();
|
|
||||||
if ( tx.vout[numvouts-1].scriptPubKey[0] == 0x6a )
|
|
||||||
{
|
|
||||||
for (i=0; i<numvins; i++)
|
for (i=0; i<numvins; i++)
|
||||||
{
|
{
|
||||||
vintxids.push_back(tx.vin[i].prevout.hash);
|
vintxids.push_back(tx.vin[i].prevout.hash);
|
||||||
vinprevns.push_back(tx.vin[i].prevout.n);
|
vinprevns.push_back(tx.vin[i].prevout.n);
|
||||||
|
//fprintf(stderr,"%s/v%d ",tx.vin[i].prevout.hash.GetHex().c_str(),tx.vin[i].prevout.n);
|
||||||
}
|
}
|
||||||
for (i=0; i<numvouts-1; i++)
|
for (i=0; i<numvouts; i++)
|
||||||
|
{
|
||||||
|
//char destaddr[64];
|
||||||
|
//Getscriptaddress(destaddr,tx.vout[i].scriptPubKey);
|
||||||
|
//fprintf(stderr,"%s %.8f ",destaddr,(double)tx.vout[i].nValue/COIN);
|
||||||
vouts.push_back(tx.vout[i]);
|
vouts.push_back(tx.vout[i]);
|
||||||
|
}
|
||||||
data << E_MARSHAL(ss << vintxids << vinprevns << vouts << voutpubtxids);
|
data << E_MARSHAL(ss << vintxids << vinprevns << vouts << voutpubtxids);
|
||||||
fprintf(stderr,"size of data.%d\n",(int32_t)data.size());
|
//fprintf(stderr,"numvins.%d numvouts.%d size of data.%d\n",numvins,numvouts,(int32_t)data.size());
|
||||||
hash = Hash(data.begin(),data.end());
|
hash = Hash(data.begin(),data.end());
|
||||||
memcpy(msg,&hash,sizeof(hash));
|
memcpy(msg,&hash,sizeof(hash));
|
||||||
return(0);
|
return(0);
|
||||||
} else return(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CScript dilithium_registeropret(std::string handle,CPubKey pk,std::vector<uint8_t> bigpub)
|
CScript dilithium_registeropret(std::string handle,CPubKey pk,std::vector<uint8_t> bigpub)
|
||||||
@@ -3367,7 +3369,10 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
|
|||||||
voutpubtxids.push_back(mypubtxid);
|
voutpubtxids.push_back(mypubtxid);
|
||||||
}
|
}
|
||||||
tx = mtx;
|
tx = mtx;
|
||||||
dilithium_Qmsghash(msg,tx,voutpubtxids);
|
dilithium_Qmsghash(msg,tx,(int32_t)voutpubtxids.size(),voutpubtxids);
|
||||||
|
//for (i=0; i<32; i++)
|
||||||
|
// fprintf(stderr,"%02x",msg[i]);
|
||||||
|
//fprintf(stderr," msg\n");
|
||||||
sig.resize(32+CRYPTO_BYTES);
|
sig.resize(32+CRYPTO_BYTES);
|
||||||
if ( dilithium_bigpubget(handle,destpub33,pk2,mypubtxid) < 0 )
|
if ( dilithium_bigpubget(handle,destpub33,pk2,mypubtxid) < 0 )
|
||||||
return(cclib_error(result,"couldnt get bigpub"));
|
return(cclib_error(result,"couldnt get bigpub"));
|
||||||
@@ -3423,7 +3428,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co
|
|||||||
numvouts = tx.vout.size();
|
numvouts = tx.vout.size();
|
||||||
if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen )
|
if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen )
|
||||||
{
|
{
|
||||||
if ( dilithium_Qmsghash(msg,tx,voutpubtxids) < 0 )
|
if ( dilithium_Qmsghash(msg,tx,numvouts-1,voutpubtxids) < 0 )
|
||||||
return eval->Invalid("couldnt get Qmsghash");
|
return eval->Invalid("couldnt get Qmsghash");
|
||||||
else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 )
|
else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 )
|
||||||
return eval->Invalid("couldnt get bigpub");
|
return eval->Invalid("couldnt get bigpub");
|
||||||
@@ -3432,7 +3437,15 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co
|
|||||||
if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 )
|
if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 )
|
||||||
return eval->Invalid("failed dilithium verify");
|
return eval->Invalid("failed dilithium verify");
|
||||||
else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 )
|
else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 )
|
||||||
|
{
|
||||||
|
for (i=0; i<32; i++)
|
||||||
|
fprintf(stderr,"%02x",msg[i]);
|
||||||
|
fprintf(stderr," vs ");
|
||||||
|
for (i=0; i<mlen; i++)
|
||||||
|
fprintf(stderr,"%02x",msg2[i]);
|
||||||
|
fprintf(stderr,"mlen.%d\n",mlen);
|
||||||
return eval->Invalid("failed dilithium msg verify");
|
return eval->Invalid("failed dilithium msg verify");
|
||||||
|
}
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
} else return eval->Invalid("failed decode Qsend");
|
} else return eval->Invalid("failed decode Qsend");
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ int32_t safecopy(char *dest,char *src,long len)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t rogue_replay(uint64_t seed,int32_t sleeptime);
|
int32_t rogue_replay(uint64_t seed,int32_t sleeptime);
|
||||||
|
char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter);
|
||||||
int rogue(int argc, char **argv, char **envp);
|
int rogue(int argc, char **argv, char **envp);
|
||||||
|
|
||||||
void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep)
|
void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep)
|
||||||
@@ -741,7 +742,7 @@ int32_t rogue_sendrawtransaction(char *rawtx)
|
|||||||
|
|
||||||
void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
||||||
{
|
{
|
||||||
char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx; int32_t i; cJSON *retjson;
|
char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys; int32_t i,numpastkeys; cJSON *retjson;
|
||||||
//fprintf(stderr,"rogue_progress num.%d\n",num);
|
//fprintf(stderr,"rogue_progress num.%d\n",num);
|
||||||
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
||||||
{
|
{
|
||||||
@@ -762,6 +763,11 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *
|
|||||||
}
|
}
|
||||||
free(rs->keystrokeshex), rs->keystrokeshex = 0;
|
free(rs->keystrokeshex), rs->keystrokeshex = 0;
|
||||||
}
|
}
|
||||||
|
if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 )
|
||||||
|
{
|
||||||
|
free(pastkeys);
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0; i<num; i++)
|
for (i=0; i<num; i++)
|
||||||
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]&0xff);
|
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]&0xff);
|
||||||
hexstr[i<<1] = 0;
|
hexstr[i<<1] = 0;
|
||||||
|
|||||||
@@ -131,21 +131,21 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag)
|
|||||||
rs->num = 0;
|
rs->num = 0;
|
||||||
retflag = 0;
|
retflag = 0;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if ( (fp= fopen("savefile","wb")) != 0 )
|
/*if ( (fp= fopen("savefile","wb")) != 0 )
|
||||||
{
|
{
|
||||||
//save_file(rs,fp,0);
|
save_file(rs,fp,0);
|
||||||
if ( 0 && (fp= fopen("savefile","rb")) != 0 )
|
if ( 0 && (fp= fopen("savefile","rb")) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<0x150; i++)
|
for (i=0; i<0x150; i++)
|
||||||
fprintf(stderr,"%02x",fgetc(fp));
|
fprintf(stderr,"%02x",fgetc(fp));
|
||||||
fprintf(stderr," first part rnd.%d\n",rnd(1000));
|
fprintf(stderr," first part rnd.%d\n",rnd(1000));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}*/
|
||||||
roguefname(fname,rs->seed,rs->counter);
|
roguefname(fname,rs->seed,rs->counter+1);
|
||||||
if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file
|
if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
//fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag);
|
//fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag);
|
||||||
}
|
//}
|
||||||
} else fprintf(stderr,"error writing (%s)\n",fname);
|
} else fprintf(stderr,"error writing (%s)\n",fname);
|
||||||
} else fprintf(stderr,"error creating (%s)\n",fname);
|
} else fprintf(stderr,"error creating (%s)\n",fname);
|
||||||
return(retflag);
|
return(retflag);
|
||||||
@@ -254,11 +254,10 @@ long get_filesize(FILE *fp)
|
|||||||
return(fsize);
|
return(fsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter)
|
||||||
{
|
{
|
||||||
FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0;
|
char fname[1024],*keystrokes = 0; FILE *fp; long fsize; int32_t num = 0;
|
||||||
if ( seed == 0 )
|
*numkeysp = 0;
|
||||||
seed = 777;
|
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
{
|
{
|
||||||
roguefname(fname,seed,counter);
|
roguefname(fname,seed,counter);
|
||||||
@@ -275,19 +274,30 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
|||||||
{
|
{
|
||||||
fprintf(stderr,"error reallocating keystrokes\n");
|
fprintf(stderr,"error reallocating keystrokes\n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return(-1);
|
return(0);
|
||||||
}
|
}
|
||||||
if ( fread(&keystrokes[num],1,fsize,fp) != fsize )
|
if ( fread(&keystrokes[num],1,fsize,fp) != fsize )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error reading keystrokes from (%s)\n",fname);
|
fprintf(stderr,"error reading keystrokes from (%s)\n",fname);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return(-1);
|
free(keystrokes);
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
num += fsize;
|
num += fsize;
|
||||||
counter++;
|
counter++;
|
||||||
fprintf(stderr,"loaded %ld from (%s) total %ld\n",fsize,fname,num);
|
fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num);
|
||||||
}
|
}
|
||||||
|
*numkeysp = num;
|
||||||
|
return(keystrokes);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
||||||
|
{
|
||||||
|
FILE *fp; char fname[1024]; char *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0;
|
||||||
|
if ( seed == 0 )
|
||||||
|
seed = 777;
|
||||||
|
keystrokes = rogue_keystrokesload(&num,seed,counter);
|
||||||
if ( num > 0 )
|
if ( num > 0 )
|
||||||
{
|
{
|
||||||
sprintf(fname,"rogue.%llu.player",(long long)seed);
|
sprintf(fname,"rogue.%llu.player",(long long)seed);
|
||||||
@@ -301,7 +311,6 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
rogue_replay2(0,seed,keystrokes,num,player,sleeptime);
|
rogue_replay2(0,seed,keystrokes,num,player,sleeptime);
|
||||||
|
|
||||||
mvaddstr(LINES - 2, 0, (char *)"replay completed");
|
mvaddstr(LINES - 2, 0, (char *)"replay completed");
|
||||||
endwin();
|
endwin();
|
||||||
my_exit(0);
|
my_exit(0);
|
||||||
|
|||||||
@@ -978,16 +978,18 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto
|
|||||||
}
|
}
|
||||||
if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 )
|
if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"zero value character was killed -> no playerdata\n");
|
sprintf(str,"zero value character was killed -> no playerdata\n");
|
||||||
newdata.resize(0);
|
newdata.resize(0);
|
||||||
//P.gold = (P.gold * 8) / 10;
|
*numkeysp = numkeys;
|
||||||
|
return(keystrokes);
|
||||||
|
/* P.gold = (P.gold * 8) / 10;
|
||||||
if ( keystrokes != 0 )
|
if ( keystrokes != 0 )
|
||||||
{
|
{
|
||||||
free(keystrokes);
|
free(keystrokes);
|
||||||
keystrokes = 0;
|
keystrokes = 0;
|
||||||
*numkeysp = 0;
|
*numkeysp = 0;
|
||||||
return(keystrokes);
|
return(keystrokes);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1084,8 +1086,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C
|
|||||||
if ( P.amulet != 0 )
|
if ( P.amulet != 0 )
|
||||||
mult *= 5;
|
mult *= 5;
|
||||||
dungeonlevel = P.dungeonlevel;
|
dungeonlevel = P.dungeonlevel;
|
||||||
if ( P.amulet != 0 && dungeonlevel < 21 )
|
if ( P.amulet != 0 && dungeonlevel < 26 )
|
||||||
dungeonlevel = 21;
|
dungeonlevel = 26;
|
||||||
*cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel;
|
*cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel;
|
||||||
if ( newdata == playerdata )
|
if ( newdata == playerdata )
|
||||||
{
|
{
|
||||||
@@ -1315,7 +1317,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
|||||||
rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr);
|
rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr);
|
||||||
a.push_back(obj);
|
a.push_back(obj);
|
||||||
}
|
}
|
||||||
else
|
else if ( 0 )
|
||||||
{
|
{
|
||||||
sprintf(str,"vout %d+1 is unspent",i);
|
sprintf(str,"vout %d+1 is unspent",i);
|
||||||
result.push_back(Pair("unspent",str));
|
result.push_back(Pair("unspent",str));
|
||||||
@@ -1466,7 +1468,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
funcid = script[1];
|
funcid = script[1];
|
||||||
if ( (e= script[0]) == EVAL_TOKENS )
|
if ( (e= script[0]) == EVAL_TOKENS )
|
||||||
{
|
{
|
||||||
tokentx = 1;
|
tokentx = funcid;
|
||||||
if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 )
|
if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 )
|
||||||
{
|
{
|
||||||
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
||||||
@@ -1539,22 +1541,29 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
// verify pk belongs to this tx
|
// verify pk belongs to this tx
|
||||||
if ( playerdata.size() > 0 )
|
if ( playerdata.size() > 0 )
|
||||||
{
|
{
|
||||||
|
static char laststr[512]; char cashstr[512];
|
||||||
if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 )
|
if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size());
|
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size());
|
||||||
}
|
|
||||||
if ( funcid == 'H' )
|
|
||||||
cashout *= 2;
|
|
||||||
if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout
|
|
||||||
{
|
|
||||||
static char laststr[512]; char cashstr[512];
|
|
||||||
sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
|
|
||||||
if ( strcmp(laststr,cashstr) != 0 )
|
if ( strcmp(laststr,cashstr) != 0 )
|
||||||
{
|
{
|
||||||
strcpy(laststr,cashstr);
|
strcpy(laststr,cashstr);
|
||||||
fprintf(stderr,"%s\n",cashstr);
|
fprintf(stderr,"%s\n",cashstr);
|
||||||
}
|
}
|
||||||
if ( enabled != 0 && tx.vout[2].nValue != cashout )
|
if ( enabled != 0 )
|
||||||
|
return eval->Invalid("mismatched playerdata");
|
||||||
|
}
|
||||||
|
if ( funcid == 'H' )
|
||||||
|
cashout *= 2;
|
||||||
|
//if ( tokentx == 0 )
|
||||||
|
{
|
||||||
|
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
|
||||||
|
if ( strcmp(laststr,cashstr) != 0 )
|
||||||
|
{
|
||||||
|
strcpy(laststr,cashstr);
|
||||||
|
fprintf(stderr,"%s\n",cashstr);
|
||||||
|
}
|
||||||
|
if ( tokentx == 0 && enabled != 0 && tx.vout[2].nValue != cashout )
|
||||||
return eval->Invalid("mismatched cashout amount");
|
return eval->Invalid("mismatched cashout amount");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2126,7 +2126,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED);
|
bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED);
|
||||||
if ( bhash > bnTarget )
|
if ( bhash > bnTarget && height > 100 )
|
||||||
{
|
{
|
||||||
for (i=31; i>=16; i--)
|
for (i=31; i>=16; i--)
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&bhash)[i]);
|
fprintf(stderr,"%02x",((uint8_t *)&bhash)[i]);
|
||||||
@@ -2135,7 +2135,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]);
|
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]);
|
||||||
fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED);
|
fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED);
|
||||||
return(-1);
|
return(-1);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
failed = 0;
|
failed = 0;
|
||||||
CBlockIndex *pindex;
|
CBlockIndex *pindex;
|
||||||
|
|||||||
@@ -34,6 +34,10 @@
|
|||||||
#define GETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] & (1 << ((bitoffset) & 7)))
|
#define GETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] & (1 << ((bitoffset) & 7)))
|
||||||
#define CLEARBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] &= ~(1 << ((bitoffset) & 7)))
|
#define CLEARBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] &= ~(1 << ((bitoffset) & 7)))
|
||||||
|
|
||||||
|
#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1)
|
||||||
|
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
|
||||||
|
#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN)
|
||||||
|
|
||||||
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
||||||
int32_t MAX_BLOCK_SIZE(int32_t height);
|
int32_t MAX_BLOCK_SIZE(int32_t height);
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
|
|||||||
@@ -134,15 +134,15 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
uint64_t cur_money;
|
uint64_t cur_money;
|
||||||
int32_t baseid;
|
int32_t baseid;
|
||||||
|
|
||||||
if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 )
|
//if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 )
|
||||||
cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN;
|
// cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN;
|
||||||
else
|
//else
|
||||||
{
|
{
|
||||||
// figure out max_money by adding up supply to a maximum of 10,000,000 blocks
|
// figure out max_money by adding up supply to a maximum of 10,000,000 blocks
|
||||||
cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL;
|
cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL;
|
||||||
if ( ASSETCHAINS_LASTERA == 0 && ASSETCHAINS_REWARD[0] == 0 )
|
if ( ASSETCHAINS_LASTERA == 0 && ASSETCHAINS_REWARD[0] == 0 )
|
||||||
{
|
{
|
||||||
cur_money += (nHeight * 10000) / SATOSHIDEN;
|
cur_money += (nHeight * 10000);// / SATOSHIDEN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -155,6 +155,8 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
|
|
||||||
// add rewards from this era, up to nHeight
|
// add rewards from this era, up to nHeight
|
||||||
int64_t reward = ASSETCHAINS_REWARD[j];
|
int64_t reward = ASSETCHAINS_REWARD[j];
|
||||||
|
|
||||||
|
//fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]);
|
||||||
if ( reward > 0 )
|
if ( reward > 0 )
|
||||||
{
|
{
|
||||||
uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1];
|
uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1];
|
||||||
@@ -166,10 +168,12 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
uint32_t modulo = (curEnd - lastEnd) % period;
|
uint32_t modulo = (curEnd - lastEnd) % period;
|
||||||
uint64_t decay = ASSETCHAINS_DECAY[j];
|
uint64_t decay = ASSETCHAINS_DECAY[j];
|
||||||
|
|
||||||
if (!period)
|
//fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight);
|
||||||
|
if ( ASSETCHAINS_HALVING[j] == 0 )
|
||||||
{
|
{
|
||||||
// no halving, straight multiply
|
// no halving, straight multiply
|
||||||
cur_money += reward * (nHeight - 1);
|
cur_money += reward * (nHeight - 1);
|
||||||
|
//fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN);
|
||||||
}
|
}
|
||||||
// if exactly SATOSHIDEN, linear decay to zero or to next era, same as:
|
// if exactly SATOSHIDEN, linear decay to zero or to next era, same as:
|
||||||
// (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks
|
// (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks
|
||||||
@@ -264,19 +268,17 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1)
|
|
||||||
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
|
|
||||||
|
|
||||||
if ( KOMODO_BIT63SET(cur_money) != 0 )
|
if ( KOMODO_BIT63SET(cur_money) != 0 )
|
||||||
return(KOMODO_MAXNVALUE);
|
return(KOMODO_MAXNVALUE);
|
||||||
if ( ASSETCHAINS_COMMISSION != 0 )
|
if ( ASSETCHAINS_COMMISSION != 0 )
|
||||||
{
|
{
|
||||||
uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION));
|
uint64_t newval = (cur_money + (cur_money/COIN * ASSETCHAINS_COMMISSION));
|
||||||
if ( KOMODO_BIT63SET(newval) != 0 )
|
if ( KOMODO_BIT63SET(newval) != 0 )
|
||||||
return(KOMODO_MAXNVALUE);
|
return(KOMODO_MAXNVALUE);
|
||||||
else if ( newval < cur_money ) // check for underflow
|
else if ( newval < cur_money ) // check for underflow
|
||||||
return(KOMODO_MAXNVALUE);
|
return(KOMODO_MAXNVALUE);
|
||||||
return(newval);
|
return(newval);
|
||||||
}
|
}
|
||||||
|
//fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN);
|
||||||
return(cur_money);
|
return(cur_money);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1639,9 +1639,18 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( nHeight == 1 )
|
|
||||||
{
|
|
||||||
uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff);
|
uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff);
|
||||||
|
if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion?
|
||||||
|
{
|
||||||
|
if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 )
|
||||||
|
{
|
||||||
|
subsidy += (uint64_t)1000000000 * COIN;
|
||||||
|
if ( nHeight == 1 )
|
||||||
|
subsidy += (ASSETCHAINS_SUPPLY % 1000000000)*COIN + magicExtra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( nHeight == 1 )
|
||||||
|
{
|
||||||
if ( ASSETCHAINS_LASTERA == 0 )
|
if ( ASSETCHAINS_LASTERA == 0 )
|
||||||
subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra;
|
subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra;
|
||||||
else
|
else
|
||||||
@@ -1792,6 +1801,8 @@ void komodo_args(char *argv0)
|
|||||||
fprintf(stderr,"-ac_supply must be less than 90 billion\n");
|
fprintf(stderr,"-ac_supply must be less than 90 billion\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"ASSETCHAINS_SUPPLY %llu\n",(long long)ASSETCHAINS_SUPPLY);
|
||||||
|
|
||||||
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
|
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
|
||||||
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
|
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
|
||||||
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
|
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
|
||||||
@@ -1885,6 +1896,11 @@ void komodo_args(char *argv0)
|
|||||||
}
|
}
|
||||||
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_SUPPLY > 10000000000 )
|
||||||
|
{
|
||||||
|
printf("ac_pubkey or ac_script wont work with ac_supply over 10 billion\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
|
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
|
||||||
{
|
{
|
||||||
printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n");
|
printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n");
|
||||||
@@ -2049,9 +2065,9 @@ void komodo_args(char *argv0)
|
|||||||
|
|
||||||
if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN )
|
if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN )
|
||||||
MAX_MONEY = 1000000LL*SATOSHIDEN;
|
MAX_MONEY = 1000000LL*SATOSHIDEN;
|
||||||
if ( MAX_MONEY <= 0 || MAX_MONEY > 10000100000LL*SATOSHIDEN )
|
if ( KOMODO_BIT63SET(MAX_MONEY) != 0 )
|
||||||
MAX_MONEY = 10000100000LL*SATOSHIDEN;
|
MAX_MONEY = KOMODO_MAXNVALUE;
|
||||||
//fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN);
|
fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN);
|
||||||
//printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
|
//printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
|
||||||
uint16_t tmpport = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
|
uint16_t tmpport = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
|
||||||
if ( GetArg("-port",0) != 0 )
|
if ( GetArg("-port",0) != 0 )
|
||||||
|
|||||||
22
src/main.cpp
22
src/main.cpp
@@ -1808,7 +1808,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
CAmount nValueOut = tx.GetValueOut();
|
CAmount nValueOut = tx.GetValueOut();
|
||||||
CAmount nFees = nValueIn-nValueOut;
|
CAmount nFees = nValueIn-nValueOut;
|
||||||
double dPriority = view.GetPriority(tx, chainActive.Height());
|
double dPriority = view.GetPriority(tx, chainActive.Height());
|
||||||
if ( KOMODO_BIT63SET(nValueOut) != 0 )
|
if ( nValueOut > 777777*COIN && KOMODO_VALUETOOBIG(nValueOut - 777777*COIN) != 0 ) // some room for blockreward and txfees
|
||||||
return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
|
|
||||||
// Keep track of transactions that spend a coinbase, which we re-scan
|
// Keep track of transactions that spend a coinbase, which we re-scan
|
||||||
@@ -2845,7 +2845,7 @@ namespace {
|
|||||||
hasher << hashBlock;
|
hasher << hashBlock;
|
||||||
hasher << blockundo;
|
hasher << blockundo;
|
||||||
fileout << hasher.GetHash();
|
fileout << hasher.GetHash();
|
||||||
|
//fprintf(stderr,"hashBlock.%s hasher.%s\n",hashBlock.GetHex().c_str(),hasher.GetHash().GetHex().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2870,7 +2870,7 @@ namespace {
|
|||||||
hasher << hashBlock;
|
hasher << hashBlock;
|
||||||
hasher << blockundo;
|
hasher << blockundo;
|
||||||
if (hashChecksum != hasher.GetHash())
|
if (hashChecksum != hasher.GetHash())
|
||||||
return error("%s: Checksum mismatch", __func__);
|
return error("%s: %s Checksum mismatch %s vs %s", __func__,hashBlock.GetHex().c_str(),hashChecksum.GetHex().c_str(),hasher.GetHash().GetHex().c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3494,12 +3494,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
txdata.emplace_back(tx);
|
txdata.emplace_back(tx);
|
||||||
|
|
||||||
valueout = tx.GetValueOut();
|
valueout = tx.GetValueOut();
|
||||||
if ( KOMODO_BIT63SET(valueout) != 0 )
|
if ( KOMODO_VALUETOOBIG(valueout) != 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"valueout %.8f too big\n",(double)valueout/COIN);
|
||||||
return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
|
}
|
||||||
prevsum = voutsum;
|
prevsum = voutsum;
|
||||||
voutsum += valueout;
|
voutsum += valueout;
|
||||||
if ( KOMODO_BIT63SET(voutsum) != 0 )
|
if ( KOMODO_VALUETOOBIG(voutsum) != 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN);
|
||||||
return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
|
}
|
||||||
else if ( voutsum < prevsum )
|
else if ( voutsum < prevsum )
|
||||||
return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");
|
||||||
if (!tx.IsCoinBase())
|
if (!tx.IsCoinBase())
|
||||||
@@ -3634,9 +3640,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Write undo information to disk
|
// Write undo information to disk
|
||||||
|
//fprintf(stderr,"nFile.%d isNull %d vs isvalid %d nStatus %x\n",(int32_t)pindex->nFile,pindex->GetUndoPos().IsNull(),pindex->IsValid(BLOCK_VALID_SCRIPTS),(uint32_t)pindex->nStatus);
|
||||||
if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
||||||
{
|
{
|
||||||
if (pindex->GetUndoPos().IsNull()) {
|
if (pindex->GetUndoPos().IsNull())
|
||||||
|
{
|
||||||
CDiskBlockPos pos;
|
CDiskBlockPos pos;
|
||||||
if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
|
if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
|
||||||
return error("ConnectBlock(): FindUndoPos failed");
|
return error("ConnectBlock(): FindUndoPos failed");
|
||||||
@@ -3644,7 +3652,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
fprintf(stderr,"ConnectBlock: unexpected null pprev\n");
|
fprintf(stderr,"ConnectBlock: unexpected null pprev\n");
|
||||||
if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
||||||
return AbortNode(state, "Failed to write undo data");
|
return AbortNode(state, "Failed to write undo data");
|
||||||
|
|
||||||
// update nUndoPos in block index
|
// update nUndoPos in block index
|
||||||
pindex->nUndoPos = pos.nPos;
|
pindex->nUndoPos = pos.nPos;
|
||||||
pindex->nStatus |= BLOCK_HAVE_UNDO;
|
pindex->nStatus |= BLOCK_HAVE_UNDO;
|
||||||
@@ -4269,6 +4276,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" +
|
ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" +
|
||||||
_("Please help, human!");
|
_("Please help, human!");
|
||||||
LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10);
|
LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10);
|
||||||
|
fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg.c_str(),reorgLength+10);
|
||||||
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
|
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
}
|
}
|
||||||
} else pk = _pk;
|
} else pk = _pk;
|
||||||
|
|
||||||
uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||||
bool fNotarisationBlock = false; std::vector<int8_t> NotarisationNotaries;
|
bool fNotarisationBlock = false; std::vector<int8_t> NotarisationNotaries;
|
||||||
|
|
||||||
//fprintf(stderr,"create new block\n");
|
//fprintf(stderr,"create new block\n");
|
||||||
@@ -233,6 +233,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
|
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
|
||||||
uint32_t proposedTime = GetAdjustedTime();
|
uint32_t proposedTime = GetAdjustedTime();
|
||||||
|
voutsum = GetBlockSubsidy(nHeight,consensusParams) + 10000*COIN; // approx fees
|
||||||
|
|
||||||
if (proposedTime == nMedianTimePast)
|
if (proposedTime == nMedianTimePast)
|
||||||
{
|
{
|
||||||
@@ -270,7 +271,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
vecPriority.reserve(mempool.mapTx.size() + 1);
|
vecPriority.reserve(mempool.mapTx.size() + 1);
|
||||||
|
|
||||||
// now add transactions from the mem pool
|
// now add transactions from the mem pool
|
||||||
int32_t Notarisations = 0;
|
int32_t Notarisations = 0; uint64_t txvalue;
|
||||||
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
|
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
|
||||||
mi != mempool.mapTx.end(); ++mi)
|
mi != mempool.mapTx.end(); ++mi)
|
||||||
{
|
{
|
||||||
@@ -285,7 +286,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
//fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight));
|
//fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
txvalue = tx.GetValueOut();
|
||||||
|
if ( KOMODO_VALUETOOBIG(txvalue) != 0 )
|
||||||
|
continue;
|
||||||
|
if ( KOMODO_VALUETOOBIG(txvalue + voutsum) != 0 )
|
||||||
|
continue;
|
||||||
|
voutsum += txvalue;
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime);
|
//fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime);
|
||||||
@@ -621,7 +627,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
txNew.vout.resize(1);
|
txNew.vout.resize(1);
|
||||||
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
||||||
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
|
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
|
||||||
|
//fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN);
|
||||||
txNew.nExpiryHeight = 0;
|
txNew.nExpiryHeight = 0;
|
||||||
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||||
|
|
||||||
|
|||||||
@@ -419,10 +419,26 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out)
|
|||||||
int mantissa_tzeros = 0;
|
int mantissa_tzeros = 0;
|
||||||
bool mantissa_sign = false;
|
bool mantissa_sign = false;
|
||||||
bool exponent_sign = false;
|
bool exponent_sign = false;
|
||||||
int ptr = 0;
|
int i,n,ptr = 0; char *str = (char *)val.c_str();
|
||||||
int end = val.size();
|
int end = val.size();
|
||||||
int point_ofs = 0;
|
int point_ofs = 0;
|
||||||
|
n = val.size();
|
||||||
|
if ( n == 11 && (val[0] < '9' || val[1] < '3') )
|
||||||
|
{
|
||||||
|
uint64_t val64 = 0;
|
||||||
|
for (i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
if ( val[i] < '0' || val[i] > '9' )
|
||||||
|
break;
|
||||||
|
val64 = (val64 * 10) + (val[i] - '0');
|
||||||
|
}
|
||||||
|
if ( i == n ) // 90000000000
|
||||||
|
{
|
||||||
|
*amount_out = val64 * 100000000;
|
||||||
|
//fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)*amount_out/100000000);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ptr < end && val[ptr] == '-') {
|
if (ptr < end && val[ptr] == '-') {
|
||||||
mantissa_sign = true;
|
mantissa_sign = true;
|
||||||
++ptr;
|
++ptr;
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
|
|||||||
// Check amount
|
// Check amount
|
||||||
if (nValue <= 0)
|
if (nValue <= 0)
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount");
|
||||||
|
//fprintf(stderr,"nValue %.8f vs curBalance %.8f\n",(double)nValue/COIN,(double)curBalance/COIN);
|
||||||
if (nValue > curBalance)
|
if (nValue > curBalance)
|
||||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
|
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
|
||||||
|
|
||||||
@@ -1030,7 +1030,6 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef
|
|||||||
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
|
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UniValue cleanwallettransactions(const UniValue& params, bool fHelp)
|
UniValue cleanwallettransactions(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
|||||||
Reference in New Issue
Block a user