@@ -51,7 +51,7 @@ Komodo is based on Zcash and has been extended by our innovative consensus algor
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
#The following packages are needed:
|
#The following packages are needed:
|
||||||
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl
|
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl libboost-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Build Komodo
|
### Build Komodo
|
||||||
|
|||||||
@@ -3276,7 +3276,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
|
|||||||
} else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey"));
|
} else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 pubtxid,int64_t total,int32_t maxinputs,char *cmpaddr)
|
int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 destpubtxid,int64_t total,int32_t maxinputs,char *cmpaddr)
|
||||||
{
|
{
|
||||||
char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 checktxid,txid,hashBlock; std::vector<uint8_t> origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector<uint256> voutpubtxids;
|
char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 checktxid,txid,hashBlock; std::vector<uint8_t> origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector<uint256> voutpubtxids;
|
||||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||||
@@ -3294,7 +3294,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu
|
|||||||
{
|
{
|
||||||
if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
|
if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
|
||||||
{
|
{
|
||||||
if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && desttxid == checktxid )
|
if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && destpubtxid == checktxid )
|
||||||
{
|
{
|
||||||
if ( total != 0 && maxinputs != 0 )
|
if ( total != 0 && maxinputs != 0 )
|
||||||
mtx.vin.push_back(CTxIn(txid,vout,CScript()));
|
mtx.vin.push_back(CTxIn(txid,vout,CScript()));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd rogue;
|
cd rogue;
|
||||||
|
make clean;
|
||||||
|
|
||||||
if [ "$HOST" = "x86_64-w64-mingw32" ]; then
|
if [ "$HOST" = "x86_64-w64-mingw32" ]; then
|
||||||
echo building rogue.exe...
|
echo building rogue.exe...
|
||||||
|
|||||||
@@ -118,22 +118,22 @@ int32_t roguefname(char *fname,uint64_t seed,int32_t counter)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef test
|
int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag)
|
||||||
int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag)
|
|
||||||
{
|
{
|
||||||
|
#ifndef BUILD_ROGUE
|
||||||
char fname[1024]; FILE *fp; int32_t i,retflag = -1;
|
char fname[1024]; FILE *fp; int32_t i,retflag = -1;
|
||||||
|
rs->counter++;
|
||||||
roguefname(fname,rs->seed,rs->counter);
|
roguefname(fname,rs->seed,rs->counter);
|
||||||
if ( (fp= fopen(fname,"wb")) != 0 )
|
if ( (fp= fopen(fname,"wb")) != 0 )
|
||||||
{
|
{
|
||||||
if ( fwrite(rs->buffered,1,rs->num,fp) == rs->num )
|
if ( fwrite(rs->buffered,1,rs->num,fp) == rs->num )
|
||||||
{
|
{
|
||||||
rs->counter++;
|
|
||||||
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++)
|
||||||
@@ -149,8 +149,10 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag)
|
|||||||
} 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);
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
|
return(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef BUILD_ROGUE
|
#ifdef BUILD_ROGUE
|
||||||
// stubs for inside daemon
|
// stubs for inside daemon
|
||||||
@@ -174,9 +176,10 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag)
|
|||||||
//rs->keytxid = rogue_progress(rs,waitflag,rs->seed,&rs->buffered[rs->lastnum],rs->num - rs->lastnum);
|
//rs->keytxid = rogue_progress(rs,waitflag,rs->seed,&rs->buffered[rs->lastnum],rs->num - rs->lastnum);
|
||||||
//rs->lastnum = rs->num;
|
//rs->lastnum = rs->num;
|
||||||
rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num);
|
rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num);
|
||||||
|
flushkeystrokes_local(rs,waitflag);
|
||||||
memset(rs->buffered,0,sizeof(rs->buffered));
|
memset(rs->buffered,0,sizeof(rs->buffered));
|
||||||
rs->num = 0;
|
//rs->num = 0;
|
||||||
rs->counter++;
|
//rs->counter++;
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -241,7 +244,6 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu
|
|||||||
free(rs);
|
free(rs);
|
||||||
return(n);
|
return(n);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
long get_filesize(FILE *fp)
|
long get_filesize(FILE *fp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1084,8 +1084,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 )
|
||||||
{
|
{
|
||||||
@@ -1447,9 +1447,14 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
|||||||
|
|
||||||
bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx)
|
bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx)
|
||||||
{
|
{
|
||||||
CScript scriptPubKey; std::vector<uint8_t> vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector<uint8_t> playerdata,keystrokes; std::string symbol,pname;
|
CScript scriptPubKey; std::vector<uint8_t> vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,enabled = 0,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector<uint8_t> playerdata,keystrokes; std::string symbol,pname;
|
||||||
if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 )
|
if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 )
|
||||||
return(true);
|
{
|
||||||
|
if (height < 21274 )
|
||||||
|
return(true);
|
||||||
|
else if ( height > 50000 )
|
||||||
|
enabled = 1;
|
||||||
|
} else enabled = 1;
|
||||||
if ( (numvouts= tx.vout.size()) > 1 )
|
if ( (numvouts= tx.vout.size()) > 1 )
|
||||||
{
|
{
|
||||||
txid = tx.GetHash();
|
txid = tx.GetHash();
|
||||||
@@ -1549,6 +1554,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
strcpy(laststr,cashstr);
|
strcpy(laststr,cashstr);
|
||||||
fprintf(stderr,"%s\n",cashstr);
|
fprintf(stderr,"%s\n",cashstr);
|
||||||
}
|
}
|
||||||
|
if ( enabled != 0 && tx.vout[2].nValue != cashout )
|
||||||
|
return eval->Invalid("mismatched cashout amount");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( funcid == 'Q' )
|
if ( funcid == 'Q' )
|
||||||
|
|||||||
@@ -2012,10 +2012,13 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
|
|||||||
{
|
{
|
||||||
script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0];
|
script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0];
|
||||||
scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size();
|
scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size();
|
||||||
//int32_t i;
|
if ( 0 )
|
||||||
//for (i=0; i<scriptlen; i++)
|
{
|
||||||
// fprintf(stderr,"%02x",script[i]);
|
int32_t i;
|
||||||
//fprintf(stderr," vout[1] %.8f vs %.8f\n",(double)checktoshis/COIN,(double)pblock->vtx[0].vout[1].nValue/COIN);
|
for (i=0; i<scriptlen; i++)
|
||||||
|
fprintf(stderr,"%02x",script[i]);
|
||||||
|
fprintf(stderr," vout[1] %.8f vs %.8f\n",(double)checktoshis/COIN,(double)pblock->vtx[0].vout[1].nValue/COIN);
|
||||||
|
}
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) )
|
if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) )
|
||||||
@@ -2031,7 +2034,13 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
|
|||||||
matched = 25;
|
matched = 25;
|
||||||
if ( matched == 0 )
|
if ( matched == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d] checktoshis.%llu\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2,(long long)checktoshis);
|
if ( 0 && ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||||
|
{
|
||||||
|
int32_t i;
|
||||||
|
for (i=0; i<ASSETCHAINS_SCRIPTPUB.size(); i++)
|
||||||
|
fprintf(stderr,"%02x",ASSETCHAINS_SCRIPTPUB[i]);
|
||||||
|
}
|
||||||
|
fprintf(stderr," -ac[%d] payment to wrong pubkey scriptlen.%d, scriptpub[%d] checktoshis.%llu\n",(int32_t)ASSETCHAINS_SCRIPTPUB.size(),scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2,(long long)checktoshis);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/main.cpp
14
src/main.cpp
@@ -1808,6 +1808,8 @@ 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 )
|
||||||
|
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
|
||||||
// during reorgs to ensure COINBASE_MATURITY is still met.
|
// during reorgs to ensure COINBASE_MATURITY is still met.
|
||||||
@@ -3371,6 +3373,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
int64_t nTimeStart = GetTimeMicros();
|
int64_t nTimeStart = GetTimeMicros();
|
||||||
CAmount nFees = 0;
|
CAmount nFees = 0;
|
||||||
int nInputs = 0;
|
int nInputs = 0;
|
||||||
|
uint64_t voutsum = 0,prevsum=0,valueout;
|
||||||
int64_t interest,sum = 0;
|
int64_t interest,sum = 0;
|
||||||
unsigned int nSigOps = 0;
|
unsigned int nSigOps = 0;
|
||||||
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
|
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
|
||||||
@@ -3490,9 +3493,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
|
|
||||||
txdata.emplace_back(tx);
|
txdata.emplace_back(tx);
|
||||||
|
|
||||||
|
valueout = tx.GetValueOut();
|
||||||
|
if ( KOMODO_BIT63SET(valueout) != 0 )
|
||||||
|
return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
|
prevsum = voutsum;
|
||||||
|
voutsum += valueout;
|
||||||
|
if ( KOMODO_BIT63SET(voutsum) != 0 )
|
||||||
|
return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
|
else if ( voutsum < prevsum )
|
||||||
|
return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");
|
||||||
if (!tx.IsCoinBase())
|
if (!tx.IsCoinBase())
|
||||||
{
|
{
|
||||||
nFees += view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime) - tx.GetValueOut();
|
nFees += view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime) - valueout;
|
||||||
sum += interest;
|
sum += interest;
|
||||||
|
|
||||||
std::vector<CScriptCheck> vChecks;
|
std::vector<CScriptCheck> vChecks;
|
||||||
|
|||||||
Reference in New Issue
Block a user