Merge branch 'FSM' of https://github.com/jl777/komodo into jl777-FSM
fix
This commit is contained in:
@@ -40,7 +40,10 @@ bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScrip
|
|||||||
std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret)
|
std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret)
|
||||||
{
|
{
|
||||||
auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus());
|
auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus());
|
||||||
CTransaction vintx; std::string hex; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[64],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0; int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64]; uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; CC *mycond=0,*othercond=0,*othercond2=0,*othercond3=0,*cond; CPubKey unspendablepk;
|
CTransaction vintx; std::string hex; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0;
|
||||||
|
int64_t utxovalues[64],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0;
|
||||||
|
int32_t i,utxovout,n,err = 0; char myaddr[64],destaddr[64],unspendable[64];
|
||||||
|
uint8_t *privkey,myprivkey[32],unspendablepriv[32],*msg32 = 0; CC *mycond=0,*othercond=0,*othercond2=0,*othercond3=0,*cond; CPubKey unspendablepk;
|
||||||
n = mtx.vout.size();
|
n = mtx.vout.size();
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
@@ -71,11 +74,13 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
|||||||
if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"vin.%d is normal %.8f\n",i,(double)utxovalues[i]/COIN);
|
//fprintf(stderr,"vin.%d is normal %.8f\n",i,(double)utxovalues[i]/COIN);
|
||||||
|
if (ccvins==0) normalvins++;
|
||||||
normalinputs += utxovalues[i];
|
normalinputs += utxovalues[i];
|
||||||
vinimask |= (1LL << i);
|
vinimask |= (1LL << i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ccvins++;
|
||||||
mask |= (1LL << i);
|
mask |= (1LL << i);
|
||||||
}
|
}
|
||||||
} else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str());
|
} else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str());
|
||||||
@@ -92,6 +97,16 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
|||||||
mtx.vout.push_back(CTxOut(0,opret));
|
mtx.vout.push_back(CTxOut(0,opret));
|
||||||
PrecomputedTransactionData txdata(mtx);
|
PrecomputedTransactionData txdata(mtx);
|
||||||
n = mtx.vin.size();
|
n = mtx.vin.size();
|
||||||
|
//Reorder vins so that for multiple normal vins all other except vin0 goes to the end
|
||||||
|
//This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation.
|
||||||
|
if (normalvins>1)
|
||||||
|
{
|
||||||
|
for(i=1;i<normalvins;i++)
|
||||||
|
{
|
||||||
|
mtx.vin.push_back(mtx.vin[1]);
|
||||||
|
mtx.vin.erase(mtx.vin.begin() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
if ( GetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock,false) != 0 )
|
if ( GetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock,false) != 0 )
|
||||||
@@ -122,9 +137,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
|||||||
{
|
{
|
||||||
//fprintf(stderr,"matched %s unspendable2!\n",cp->unspendableaddr2);
|
//fprintf(stderr,"matched %s unspendable2!\n",cp->unspendableaddr2);
|
||||||
privkey = cp->unspendablepriv2;
|
privkey = cp->unspendablepriv2;
|
||||||
if ( othercond2 == 0 && cp->evalcode != EVAL_CHANNELS)
|
if ( othercond2 == 0 && cp->evalcode != EVAL_CHANNELS && cp->evalcode != EVAL_HEIR )
|
||||||
othercond2 = MakeCCcond1(cp->evalcode2,cp->unspendablepk2);
|
othercond2 = MakeCCcond1(cp->evalcode2,cp->unspendablepk2);
|
||||||
else if ( othercond2 == 0 && cp->evalcode == EVAL_CHANNELS)
|
else if ( othercond2 == 0 && (cp->evalcode == EVAL_CHANNELS || cp->evalcode == EVAL_HEIR) )
|
||||||
othercond2 = MakeCCcond1of2(cp->evalcode2,cp->unspendablepk2,cp->unspendablepk3);
|
othercond2 = MakeCCcond1of2(cp->evalcode2,cp->unspendablepk2,cp->unspendablepk3);
|
||||||
cond = othercond2;
|
cond = othercond2;
|
||||||
}
|
}
|
||||||
@@ -276,8 +291,8 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *
|
|||||||
for (above=below=i=0; i<numunspents; i++)
|
for (above=below=i=0; i<numunspents; i++)
|
||||||
{
|
{
|
||||||
// Filter to randomly pick utxo to avoid conflicts, and having multiple CC choose the same ones.
|
// Filter to randomly pick utxo to avoid conflicts, and having multiple CC choose the same ones.
|
||||||
//if ( numunspents > 500 ) {
|
//if ( numunspents > 200 ) {
|
||||||
// if ( (rand() % 100) < 80 )
|
// if ( (rand() % 100) < 90 )
|
||||||
// continue;
|
// continue;
|
||||||
//}
|
//}
|
||||||
if ( (atx_value= utxos[i].nValue) <= 0 )
|
if ( (atx_value= utxos[i].nValue) <= 0 )
|
||||||
|
|||||||
@@ -1442,7 +1442,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet
|
|||||||
entropyval = entropyval2;
|
entropyval = entropyval2;
|
||||||
entropytxid = entropytxid2;
|
entropytxid = entropytxid2;
|
||||||
}
|
}
|
||||||
if ( ( funding >= 2*bet*odds+txfee && entropyval != 0 ) )
|
if ( funding >= 2*bet*odds+txfee && entropyval != 0 )
|
||||||
{
|
{
|
||||||
if ( entropytxs < 100 ) {
|
if ( entropytxs < 100 ) {
|
||||||
CCerror = "Your dealer is broke, find a new casino.";
|
CCerror = "Your dealer is broke, find a new casino.";
|
||||||
@@ -1476,7 +1476,6 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv
|
|||||||
entropyused = zeroid;
|
entropyused = zeroid;
|
||||||
*resultp = 0;
|
*resultp = 0;
|
||||||
funcid = 0;
|
funcid = 0;
|
||||||
//char str[65]; fprintf(stderr,"DiceBetFinish.%s %s\n",planstr,uint256_str(str,bettxid));
|
|
||||||
if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 )
|
if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 )
|
||||||
{
|
{
|
||||||
CCerror = "Diceinit error in finish, is your transaction confirmed?";
|
CCerror = "Diceinit error in finish, is your transaction confirmed?";
|
||||||
|
|||||||
@@ -133,10 +133,11 @@ uint8_t DecodeOraclesOpRet(const CScript &scriptPubKey,uint256 &oracletxid,CPubK
|
|||||||
std::vector<uint8_t> vopret; uint8_t *script,e,f;
|
std::vector<uint8_t> vopret; uint8_t *script,e,f;
|
||||||
GetOpReturnData(scriptPubKey,vopret);
|
GetOpReturnData(scriptPubKey,vopret);
|
||||||
script = (uint8_t *)vopret.data();
|
script = (uint8_t *)vopret.data();
|
||||||
if ( vopret.size() > 1 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> oracletxid; ss >> pk; ss >> num) != 0 )
|
if ( vopret.size() > 1 && script[0] == EVAL_ORACLES )
|
||||||
{
|
{
|
||||||
if ( e == EVAL_ORACLES && (f == 'R' || f == 'S') )
|
if (script[0] == EVAL_ORACLES && (script[1]== 'R' || script[1] == 'S') && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> oracletxid; ss >> pk; ss >> num)!=0)
|
||||||
return(f);
|
return(f);
|
||||||
|
else return(script[1]);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -567,9 +568,6 @@ bool OraclesDataValidate(struct CCcontract_info *cp,Eval* eval,const CTransactio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( i != 0 )
|
|
||||||
return eval->Invalid("vin0 not normal");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
for (i=0; i<numvouts; i++)
|
for (i=0; i<numvouts; i++)
|
||||||
{
|
{
|
||||||
@@ -665,10 +663,10 @@ bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t
|
|||||||
|
|
||||||
// helper functions for rpc calls in rpcwallet.cpp
|
// helper functions for rpc calls in rpcwallet.cpp
|
||||||
|
|
||||||
int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs)
|
int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint256 oracletxid,CPubKey pk,int64_t total,int32_t maxinputs)
|
||||||
{
|
{
|
||||||
char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector<uint8_t> origpubkey; CTransaction vintx; int32_t vout,n = 0;
|
char coinaddr[64],funcid; int64_t nValue,price,totalinputs = 0; uint256 tmporacletxid,tmpbatontxid,txid,hashBlock; std::vector<uint8_t> origpubkey,data; CTransaction vintx; int32_t numvouts,vout,n = 0;
|
||||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; CPubKey tmppk; int64_t tmpnum;
|
||||||
GetCCaddress(cp,coinaddr,pk);
|
GetCCaddress(cp,coinaddr,pk);
|
||||||
SetCCunspents(unspentOutputs,coinaddr);
|
SetCCunspents(unspentOutputs,coinaddr);
|
||||||
//fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr);
|
//fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr);
|
||||||
@@ -677,19 +675,27 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub
|
|||||||
txid = it->first.txhash;
|
txid = it->first.txhash;
|
||||||
vout = (int32_t)it->first.index;
|
vout = (int32_t)it->first.index;
|
||||||
//char str[65]; fprintf(stderr,"oracle check %s/v%d\n",uint256_str(str,txid),vout);
|
//char str[65]; fprintf(stderr,"oracle check %s/v%d\n",uint256_str(str,txid),vout);
|
||||||
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 )
|
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && (numvouts=vintx.vout.size()-1)>0)
|
||||||
{
|
{
|
||||||
// get valid CC payments
|
if ((funcid=DecodeOraclesOpRet(vintx.vout[numvouts].scriptPubKey,tmporacletxid,tmppk,tmpnum))!=0 && (funcid=='S' || funcid=='D'))
|
||||||
if ( (nValue= IsOraclesvout(cp,vintx,vout)) >= 10000 && myIsutxo_spentinmempool(txid,vout) == 0 )
|
|
||||||
{
|
{
|
||||||
if ( total != 0 && maxinputs != 0 )
|
if (funcid=='D' && DecodeOraclesData(vintx.vout[numvouts].scriptPubKey,tmporacletxid,tmpbatontxid,tmppk,data)==0)
|
||||||
mtx.vin.push_back(CTxIn(txid,vout,CScript()));
|
fprintf(stderr,"invalid oraclesdata transaction \n");
|
||||||
nValue = it->second.satoshis;
|
else if (tmporacletxid==oracletxid)
|
||||||
totalinputs += nValue;
|
{
|
||||||
n++;
|
// get valid CC payments
|
||||||
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) )
|
if ( (nValue= IsOraclesvout(cp,vintx,vout)) >= 10000 && myIsutxo_spentinmempool(txid,vout) == 0 )
|
||||||
break;
|
{
|
||||||
} //else fprintf(stderr,"nValue %.8f or utxo memspent\n",(double)nValue/COIN);
|
if ( total != 0 && maxinputs != 0 )
|
||||||
|
mtx.vin.push_back(CTxIn(txid,vout,CScript()));
|
||||||
|
nValue = it->second.satoshis;
|
||||||
|
totalinputs += nValue;
|
||||||
|
n++;
|
||||||
|
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) )
|
||||||
|
break;
|
||||||
|
} //else fprintf(stderr,"nValue %.8f or utxo memspent\n",(double)nValue/COIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else fprintf(stderr,"couldnt find transaction\n");
|
} else fprintf(stderr,"couldnt find transaction\n");
|
||||||
}
|
}
|
||||||
return(totalinputs);
|
return(totalinputs);
|
||||||
@@ -802,7 +808,7 @@ std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector <uint8_t> da
|
|||||||
if ( batontxid != zeroid ) // not impossible to fail, but hopefully a very rare event
|
if ( batontxid != zeroid ) // not impossible to fail, but hopefully a very rare event
|
||||||
mtx.vin.push_back(CTxIn(batontxid,1,CScript()));
|
mtx.vin.push_back(CTxIn(batontxid,1,CScript()));
|
||||||
else fprintf(stderr,"warning: couldnt find baton utxo %s\n",batonaddr);
|
else fprintf(stderr,"warning: couldnt find baton utxo %s\n",batonaddr);
|
||||||
if ( (inputs= AddOracleInputs(cp,mtx,mypk,datafee,60)) > 0 )
|
if ( (inputs= AddOracleInputs(cp,mtx,oracletxid,mypk,datafee,60)) > 0 )
|
||||||
{
|
{
|
||||||
if ( inputs > datafee )
|
if ( inputs > datafee )
|
||||||
CCchange = (inputs - datafee);
|
CCchange = (inputs - datafee);
|
||||||
@@ -898,7 +904,7 @@ UniValue OracleInfo(uint256 origtxid)
|
|||||||
funding = LifetimeOraclesFunds(cp,oracletxid,pk);
|
funding = LifetimeOraclesFunds(cp,oracletxid,pk);
|
||||||
sprintf(numstr,"%.8f",(double)funding/COIN);
|
sprintf(numstr,"%.8f",(double)funding/COIN);
|
||||||
obj.push_back(Pair("lifetime",numstr));
|
obj.push_back(Pair("lifetime",numstr));
|
||||||
funding = AddOracleInputs(cp,mtx,pk,0,0);
|
funding = AddOracleInputs(cp,mtx,oracletxid,pk,0,0);
|
||||||
sprintf(numstr,"%.8f",(double)funding/COIN);
|
sprintf(numstr,"%.8f",(double)funding/COIN);
|
||||||
obj.push_back(Pair("funds",numstr));
|
obj.push_back(Pair("funds",numstr));
|
||||||
sprintf(numstr,"%.8f",(double)datafee/COIN);
|
sprintf(numstr,"%.8f",(double)datafee/COIN);
|
||||||
|
|||||||
@@ -1508,10 +1508,10 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
|
|||||||
matched = 25;
|
matched = 25;
|
||||||
if ( matched == 0 )
|
if ( matched == 0 )
|
||||||
{
|
{
|
||||||
int32_t i;
|
//int32_t i;
|
||||||
for (i=0; i<25; i++)
|
//for (i=0; i<25; i++)
|
||||||
fprintf(stderr,"%02x",script[i]);
|
// fprintf(stderr,"%02x",script[i]);
|
||||||
fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d]\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2);
|
//fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d]\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1606,13 +1606,25 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||||
{
|
{
|
||||||
if ( height == 1 )
|
if ( height == 1 )
|
||||||
{
|
{
|
||||||
script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data();
|
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||||
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) {
|
{
|
||||||
return(-1);
|
int32_t scriptlen; uint8_t scripthex[10000];
|
||||||
|
if ( ASSETCHAINS_SCRIPTPUB.size()/2 == pblock->vtx[0].vout[0].scriptPubKey.size() && scriptlen < sizeof(scripthex) )
|
||||||
|
{
|
||||||
|
decode_hex(scripthex,scriptlen,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
||||||
|
if ( memcmp(scripthex,script,scriptlen) != 0 )
|
||||||
|
return(-1);
|
||||||
|
} else return(-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data();
|
||||||
|
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 )
|
||||||
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1623,19 +1635,15 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
if ( ASSETCHAINS_STREAM != 0 && height > 128 )
|
if ( ASSETCHAINS_STREAM != 0 && height > 128 )
|
||||||
{
|
{
|
||||||
int lasttx = ( pblock->vtx.size() -1 );
|
int lasttx = ( pblock->vtx.size() -1 );
|
||||||
printf("ABOUT TO CHECK LAST TX: %d\n",lasttx);
|
|
||||||
if ( lasttx == 0 )
|
if ( lasttx == 0 )
|
||||||
return(-1);
|
return(-1);
|
||||||
uint256 hash; CTransaction tx;
|
uint256 hash; CTransaction tx;
|
||||||
if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false))
|
if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false))
|
||||||
{
|
{
|
||||||
printf("CHECKING THE script pubkey\n");
|
|
||||||
script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data();
|
script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data();
|
||||||
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) {
|
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) {
|
||||||
printf("THE PUBKEY IS WRONG!\n");
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
printf("THE PUBKEY IS RIGHT! \n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1613,10 +1613,18 @@ void komodo_args(char *argv0)
|
|||||||
decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str());
|
decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str());
|
||||||
calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33);
|
calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33);
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 )
|
if ( ASSETCHAINS_COMMISSION == 0 )
|
||||||
{
|
{
|
||||||
ASSETCHAINS_COMMISSION = 53846154; // maps to 35%
|
if (ASSETCHAINS_FOUNDERS != 0 )
|
||||||
printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n");
|
{
|
||||||
|
ASSETCHAINS_COMMISSION = 53846154; // maps to 35%
|
||||||
|
printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ASSETCHAINS_OVERRIDE_PUBKEY.clear();
|
||||||
|
printf("-ac_perc must be set with -ac_pubkey\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1634,7 +1642,7 @@ void komodo_args(char *argv0)
|
|||||||
}
|
}
|
||||||
if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]);
|
fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x%02x%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2]);
|
||||||
extraptr = extrabuf;
|
extraptr = extrabuf;
|
||||||
memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33;
|
memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33;
|
||||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY),(void *)&ASSETCHAINS_ENDSUBSIDY);
|
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY),(void *)&ASSETCHAINS_ENDSUBSIDY);
|
||||||
@@ -1765,7 +1773,7 @@ void komodo_args(char *argv0)
|
|||||||
dpowconfs = 0;
|
dpowconfs = 0;
|
||||||
} else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort());
|
} else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort());
|
||||||
KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs);
|
KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs);
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"SUPERNET") == 0 || strcmp(ASSETCHAINS_SYMBOL,"DEX") == 0 || strcmp(ASSETCHAINS_SYMBOL,"COQUI") == 0 || strcmp(ASSETCHAINS_SYMBOL,"PIRATE") == 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"SUPERNET") == 0 || strcmp(ASSETCHAINS_SYMBOL,"DEX") == 0 || strcmp(ASSETCHAINS_SYMBOL,"COQUI") == 0 || strcmp(ASSETCHAINS_SYMBOL,"PIRATE") == 0 || strcmp(ASSETCHAINS_SYMBOL,"KMDICE") == 0 )
|
||||||
KOMODO_EXTRASATOSHI = 1;
|
KOMODO_EXTRASATOSHI = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3181,12 +3181,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001);
|
LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001);
|
||||||
|
|
||||||
CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum;
|
CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum;
|
||||||
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) )
|
if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 &&
|
||||||
{
|
{
|
||||||
uint64_t checktoshis;
|
uint64_t checktoshis;
|
||||||
if ( (checktoshis= komodo_commission((CBlock *)&block,(int32_t)pindex->nHeight)) != 0 )
|
if ( (checktoshis= komodo_commission((CBlock *)&block,(int32_t)pindex->nHeight)) != 0 )
|
||||||
{
|
{
|
||||||
if ( block.vtx[0].vout.size() == 2 && block.vtx[0].vout[1].nValue == checktoshis )
|
if ( block.vtx[0].vout.size() >= 2 && block.vtx[0].vout[1].nValue == checktoshis )
|
||||||
blockReward += checktoshis;
|
blockReward += checktoshis;
|
||||||
else fprintf(stderr,"checktoshis %.8f numvouts %d\n",dstr(checktoshis),(int32_t)block.vtx[0].vout.size());
|
else fprintf(stderr,"checktoshis %.8f numvouts %d\n",dstr(checktoshis),(int32_t)block.vtx[0].vout.size());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
|
|||||||
uint64_t komodo_commission(const CBlock *block,int32_t height);
|
uint64_t komodo_commission(const CBlock *block,int32_t height);
|
||||||
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig);
|
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig);
|
||||||
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33);
|
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33);
|
||||||
|
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
||||||
|
|
||||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
||||||
{
|
{
|
||||||
@@ -464,7 +465,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
|||||||
txNew.vout.resize(2);
|
txNew.vout.resize(2);
|
||||||
txNew.vout[1].nValue = commission;
|
txNew.vout[1].nValue = commission;
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||||
txNew.vout[1].scriptPubKey = CScript() << ParseHex(ASSETCHAINS_SCRIPTPUB);
|
{
|
||||||
|
//txNew.vout[1].scriptPubKey = CScript() << ParseHex();
|
||||||
|
int32_t len = strlen(ASSETCHAINS_SCRIPTPUB.c_str());
|
||||||
|
len >>= 1;
|
||||||
|
txNew.vout[1].scriptPubKey.resize(len);
|
||||||
|
ptr = (uint8_t *)txNew.vout[1].scriptPubKey.data();
|
||||||
|
decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
txNew.vout[1].scriptPubKey.resize(35);
|
txNew.vout[1].scriptPubKey.resize(35);
|
||||||
@@ -660,10 +668,19 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
|||||||
|
|
||||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount)
|
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount)
|
||||||
{
|
{
|
||||||
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i;
|
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
||||||
if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 )
|
||||||
{
|
{
|
||||||
scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG;
|
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||||
|
scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len = strlen(ASSETCHAINS_SCRIPTPUB.c_str());
|
||||||
|
len >>= 1;
|
||||||
|
scriptPubKey.resize(len);
|
||||||
|
ptr = (uint8_t *)scriptPubKey.data();
|
||||||
|
decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_STREAM != 0 )
|
else if ( ASSETCHAINS_STREAM != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -756,6 +756,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class submitblock_StateCatcher : public CValidationInterface
|
class submitblock_StateCatcher : public CValidationInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ extern std::string ASSETCHAINS_OVERRIDE_PUBKEY;
|
|||||||
extern int32_t ASSETCHAINS_STREAM;
|
extern int32_t ASSETCHAINS_STREAM;
|
||||||
extern UniValue TxJoinSplitToJSON(const CTransaction& tx);
|
extern UniValue TxJoinSplitToJSON(const CTransaction& tx);
|
||||||
extern uint8_t ASSETCHAINS_PRIVATE;
|
extern uint8_t ASSETCHAINS_PRIVATE;
|
||||||
|
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||||
uint32_t komodo_segid32(char *coinaddr);
|
uint32_t komodo_segid32(char *coinaddr);
|
||||||
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
|
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
|
||||||
int32_t komodo_isnotaryvout(char *coinaddr); // from ac_private chains only
|
int32_t komodo_isnotaryvout(char *coinaddr); // from ac_private chains only
|
||||||
@@ -5088,7 +5089,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
|
|||||||
if ( fHelp || params.size() > 1 )
|
if ( fHelp || params.size() > 1 )
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"setpubkey\n"
|
"setpubkey\n"
|
||||||
"\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n"
|
"\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey, and its Raddress.\n"
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"pubkey\" (string) pubkey to set.\n"
|
"1. \"pubkey\" (string) pubkey to set.\n"
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
@@ -5511,7 +5512,7 @@ UniValue rewardscreatefunding(const UniValue& params, bool fHelp)
|
|||||||
minseconds = maxseconds = 60 * 3600 * 24;
|
minseconds = maxseconds = 60 * 3600 * 24;
|
||||||
mindeposit = 100 * COIN;
|
mindeposit = 100 * COIN;
|
||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
funds = atof(params[1].get_str().c_str()) * COIN;
|
funds = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
|
|
||||||
if (!VALID_PLAN_NAME(name)) {
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||||
@@ -5549,7 +5550,7 @@ UniValue rewardscreatefunding(const UniValue& params, bool fHelp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if ( params.size() > 5 )
|
if ( params.size() > 5 )
|
||||||
mindeposit = atof(params[5].get_str().c_str()) * COIN;
|
mindeposit = atof(params[5].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
if ( mindeposit <= 0 ) {
|
if ( mindeposit <= 0 ) {
|
||||||
ERR_RESULT("mindeposit must be positive");
|
ERR_RESULT("mindeposit must be positive");
|
||||||
return result;
|
return result;
|
||||||
@@ -5577,7 +5578,7 @@ UniValue rewardslock(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
amount = atof(params[2].get_str().c_str()) * COIN;
|
amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
hex = RewardsLock(0,name,fundingtxid,amount);
|
hex = RewardsLock(0,name,fundingtxid,amount);
|
||||||
|
|
||||||
if (!VALID_PLAN_NAME(name)) {
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
@@ -5607,7 +5608,7 @@ UniValue rewardsaddfunding(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
amount = atof(params[2].get_str().c_str()) * COIN;
|
amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
hex = RewardsAddfunding(0,name,fundingtxid,amount);
|
hex = RewardsAddfunding(0,name,fundingtxid,amount);
|
||||||
|
|
||||||
if (!VALID_PLAN_NAME(name)) {
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
@@ -5750,7 +5751,7 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp)
|
|||||||
deposithex = params[5].get_str();
|
deposithex = params[5].get_str();
|
||||||
proof = ParseHex(params[6].get_str());
|
proof = ParseHex(params[6].get_str());
|
||||||
destpub = ParseHex(params[7].get_str());
|
destpub = ParseHex(params[7].get_str());
|
||||||
amount = atof((char *)params[8].get_str().c_str()) * COIN;
|
amount = atof((char *)params[8].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
if ( amount <= 0 || claimvout < 0 )
|
if ( amount <= 0 || claimvout < 0 )
|
||||||
throw runtime_error("invalid param: amount, numpks or claimvout\n");
|
throw runtime_error("invalid param: amount, numpks or claimvout\n");
|
||||||
hex = GatewaysDeposit(0,bindtxid,height,coin,cointxid,claimvout,deposithex,proof,pubkey2pk(destpub),amount);
|
hex = GatewaysDeposit(0,bindtxid,height,coin,cointxid,claimvout,deposithex,proof,pubkey2pk(destpub),amount);
|
||||||
@@ -5775,7 +5776,7 @@ UniValue gatewaysclaim(const UniValue& params, bool fHelp)
|
|||||||
coin = params[1].get_str();
|
coin = params[1].get_str();
|
||||||
deposittxid = Parseuint256((char *)params[2].get_str().c_str());
|
deposittxid = Parseuint256((char *)params[2].get_str().c_str());
|
||||||
destpub = ParseHex(params[3].get_str());
|
destpub = ParseHex(params[3].get_str());
|
||||||
amount = atof((char *)params[4].get_str().c_str()) * COIN;
|
amount = atof((char *)params[4].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
hex = GatewaysClaim(0,bindtxid,coin,deposittxid,pubkey2pk(destpub),amount);
|
hex = GatewaysClaim(0,bindtxid,coin,deposittxid,pubkey2pk(destpub),amount);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
{
|
{
|
||||||
@@ -5797,7 +5798,7 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp)
|
|||||||
bindtxid = Parseuint256((char *)params[0].get_str().c_str());
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
coin = params[1].get_str();
|
coin = params[1].get_str();
|
||||||
withdrawpub = ParseHex(params[2].get_str());
|
withdrawpub = ParseHex(params[2].get_str());
|
||||||
amount = atof((char *)params[3].get_str().c_str()) * COIN;
|
amount = atof((char *)params[3].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
hex = GatewaysWithdraw(0,bindtxid,coin,pubkey2pk(withdrawpub),amount);
|
hex = GatewaysWithdraw(0,bindtxid,coin,pubkey2pk(withdrawpub),amount);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
{
|
{
|
||||||
@@ -5905,7 +5906,7 @@ UniValue oraclesregister(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
txid = Parseuint256((char *)params[0].get_str().c_str());
|
txid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
if ( (datafee= atol((char *)params[1].get_str().c_str())) == 0 )
|
if ( (datafee= atol((char *)params[1].get_str().c_str())) == 0 )
|
||||||
datafee = atof((char *)params[1].get_str().c_str()) * COIN;
|
datafee = atof((char *)params[1].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
hex = OracleRegister(0,txid,datafee);
|
hex = OracleRegister(0,txid,datafee);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
{
|
{
|
||||||
@@ -5926,7 +5927,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
txid = Parseuint256((char *)params[0].get_str().c_str());
|
txid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
pubkey = ParseHex(params[1].get_str().c_str());
|
pubkey = ParseHex(params[1].get_str().c_str());
|
||||||
amount = atof((char *)params[2].get_str().c_str()) * COIN;
|
amount = atof((char *)params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
hex = OracleSubscribe(0,txid,pubkey2pk(pubkey),amount);
|
hex = OracleSubscribe(0,txid,pubkey2pk(pubkey),amount);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
{
|
{
|
||||||
@@ -6083,7 +6084,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp)
|
|||||||
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
|
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
|
||||||
const CKeyStore& keystore = *pwalletMain;
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
funds = atof(params[0].get_str().c_str()) * COIN;
|
funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
if (funds > 0) {
|
if (funds > 0) {
|
||||||
hex = FaucetFund(0,(uint64_t) funds);
|
hex = FaucetFund(0,(uint64_t) funds);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
@@ -6148,7 +6149,7 @@ UniValue pricescreate(const UniValue& params, bool fHelp)
|
|||||||
longtoken = Parseuint256((char *)params[4].get_str().c_str());
|
longtoken = Parseuint256((char *)params[4].get_str().c_str());
|
||||||
shorttoken = Parseuint256((char *)params[5].get_str().c_str());
|
shorttoken = Parseuint256((char *)params[5].get_str().c_str());
|
||||||
maxleverage = atol(params[6].get_str().c_str());
|
maxleverage = atol(params[6].get_str().c_str());
|
||||||
funding = atof(params[7].get_str().c_str()) * COIN;
|
funding = atof(params[7].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
n = atoi(params[8].get_str().c_str());
|
n = atoi(params[8].get_str().c_str());
|
||||||
if ( n > 0 )
|
if ( n > 0 )
|
||||||
{
|
{
|
||||||
@@ -6184,7 +6185,7 @@ UniValue pricesaddfunding(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
bettoken = Parseuint256((char *)params[1].get_str().c_str());
|
bettoken = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
amount = atof(params[2].get_str().c_str()) * COIN;
|
amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
hex = PricesAddFunding(0,bettoken,fundingtxid,amount);
|
hex = PricesAddFunding(0,bettoken,fundingtxid,amount);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
{
|
{
|
||||||
@@ -6209,7 +6210,7 @@ UniValue pricesbet(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
bettoken = Parseuint256((char *)params[1].get_str().c_str());
|
bettoken = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
amount = atof(params[2].get_str().c_str()) * COIN;
|
amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
leverage = atoi(params[3].get_str().c_str());
|
leverage = atoi(params[3].get_str().c_str());
|
||||||
hex = PricesBet(0,bettoken,fundingtxid,amount,leverage);
|
hex = PricesBet(0,bettoken,fundingtxid,amount,leverage);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
@@ -6272,9 +6273,9 @@ UniValue dicefund(const UniValue& params, bool fHelp)
|
|||||||
const CKeyStore& keystore = *pwalletMain;
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
funds = atof(params[1].get_str().c_str()) * COIN;
|
funds = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
minbet = atof(params[2].get_str().c_str()) * COIN;
|
minbet = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
maxbet = atof(params[3].get_str().c_str()) * COIN;
|
maxbet = atof(params[3].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
maxodds = atol(params[4].get_str().c_str());
|
maxodds = atol(params[4].get_str().c_str());
|
||||||
timeoutblocks = atol(params[5].get_str().c_str());
|
timeoutblocks = atol(params[5].get_str().c_str());
|
||||||
|
|
||||||
@@ -6306,7 +6307,7 @@ UniValue diceaddfunds(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
amount = atof(params[2].get_str().c_str()) * COIN;
|
amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
if (!VALID_PLAN_NAME(name)) {
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||||
return(result);
|
return(result);
|
||||||
@@ -6334,7 +6335,7 @@ UniValue dicebet(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
amount = atof(params[2].get_str().c_str()) * COIN;
|
amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
odds = atol(params[3].get_str().c_str());
|
odds = atol(params[3].get_str().c_str());
|
||||||
|
|
||||||
if (!VALID_PLAN_NAME(name)) {
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
@@ -6523,7 +6524,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp)
|
|||||||
const CKeyStore& keystore = *pwalletMain;
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = params[0].get_str();
|
name = params[0].get_str();
|
||||||
supply = atof(params[1].get_str().c_str()) * COIN;
|
supply = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
if ( name.size() == 0 || name.size() > 32)
|
if ( name.size() == 0 || name.size() > 32)
|
||||||
{
|
{
|
||||||
ERR_RESULT("Token name must not be empty and up to 32 characters");
|
ERR_RESULT("Token name must not be empty and up to 32 characters");
|
||||||
|
|||||||
Reference in New Issue
Block a user