Backwards compatibility breaking changes

Assets:
change tokeninfo to return "supply" in satoshis
Max description length to 4096

Rewards:
Fix  rewardsunlock without giving it a locked txid always gives error
Fix (nonconsensus) allow anybody to unlock only AFTER maxtime
Fix rewards unlock to use mempool
fix could you add a locked_funds value to rewardsinfo?
Fix i deposited 100000 at 20% apr for one day i only got back
100000.01140669 seems like too little for 20% APR

Faucet:
Fix txid with 0x00 at beginning and end required for faucetget txid
(65536 average iterations needed)
Change reduce faucet get to 0.1 coins
Can’t reproduce: it seems that if you re-run faucetget twice in the
same block is when it pegs the cpu to max

Dice:
fix Dice status always returning loss
Wont fix Profit margin for dice plan sounds good. -> use -ac_commission
This commit is contained in:
jl777
2018-08-15 00:18:13 -11:00
parent 1da742e71e
commit 6ca2e99883
8 changed files with 119 additions and 34 deletions

View File

@@ -69,17 +69,17 @@ bool FaucetExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction
if ( (assetoshis= IsFaucetvout(cp,tx,i)) != 0 )
outputs += assetoshis;
}
if ( inputs != outputs+COIN+txfee )
if ( inputs != outputs+FAUCETSIZE+txfee )
{
fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs);
return eval->Invalid("mismatched inputs != outputs + COIN + txfee");
return eval->Invalid("mismatched inputs != outputs + FAUCETSIZE + txfee");
}
else return(true);
}
bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx)
{
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval;
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval; uint256 txid; uint8_t hash[32];
numvins = tx.vin.size();
numvouts = tx.vout.size();
preventCCvins = preventCCvouts = -1;
@@ -87,7 +87,6 @@ bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx
return eval->Invalid("no vouts");
else
{
//fprintf(stderr,"check vins\n");
for (i=0; i<numvins; i++)
{
if ( IsCCInput(tx.vin[0].scriptSig) == 0 )
@@ -110,8 +109,13 @@ bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx
preventCCvouts++;
i = 1;
} else i = 0;
if ( tx.vout[i].nValue != COIN )
txid = tx.GetHash();
memcpy(hash,&txid,sizeof(hash));
fprintf(stderr,"check faucetget txid %s %02x/%02x\n",uint256_str(str,txid),hash[0],hash[31]);
if ( tx.vout[i].nValue != FAUCETSIZE )
return eval->Invalid("invalid faucet output");
else if ( hash[0] != 0 || hash[31] != 0 )
return eval->Invalid("invalid faucetget txid");
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts);
if ( retval != 0 )
fprintf(stderr,"faucetget validated\n");
@@ -154,7 +158,7 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub
std::string FaucetGet(uint64_t txfee)
{
CMutableTransaction mtx; CPubKey mypk,faucetpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C;
CMutableTransaction mtx,tmpmtx; CPubKey mypk,faucetpk; CScript opret; int64_t inputs,CCchange=0,nValue=FAUCETSIZE; struct CCcontract_info *cp,C; std::string rawhex; int32_t i,len; uint8_t hash[32],buf[32768];
cp = CCinit(&C,EVAL_FAUCET);
if ( txfee == 0 )
txfee = 10000;
@@ -167,7 +171,27 @@ std::string FaucetGet(uint64_t txfee)
if ( CCchange != 0 )
mtx.vout.push_back(MakeCC1vout(EVAL_FAUCET,CCchange,faucetpk));
mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
return(FinalizeCCTx(-1LL,cp,mtx,mypk,txfee,opret));
for (i=0; i<1000000; i++)
{
tmpmtx = mtx;
rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,opret); // signature changes each time
if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 )
{
len >>= 1;
decode_hex(buf,len,(char *)rawhex.c_str());
vcalc_sha256(0,hash,buf,len);
fprintf(stderr,"%02x%02x ",hash[0],hash[31]);
if ( hash[0] == 0 && hash[31] == 0 )
{
fprintf(stderr,"found valid txid after %d iterations\n",i);
return(rawhex);
}
}
rawhex.delete();
tmpmtx.delete();
}
fprintf(stderr,"couldnt generate valid txid\n");
return("");
} else fprintf(stderr,"cant find faucet inputs\n");
return("");
}