|
|
@ -197,9 +197,6 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t |
|
|
|
uint256 txid,fundingtxid,hashBlock,vinfundingtxid; uint64_t vinsbits,sbits,APR,minseconds,maxseconds,mindeposit,amount,reward,txfee=10000; int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; uint8_t funcid; CScript scriptPubKey; CTransaction fundingTx,vinTx; |
|
|
|
numvins = tx.vin.size(); |
|
|
|
numvouts = tx.vout.size(); |
|
|
|
int64_t interest; uint64_t valuein; |
|
|
|
CCoinsViewCache &view = *pcoinsTip; |
|
|
|
valuein = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime); |
|
|
|
preventCCvins = preventCCvouts = -1; |
|
|
|
if ( numvouts < 1 ) |
|
|
|
return eval->Invalid("no vouts"); |
|
|
@ -258,20 +255,17 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t |
|
|
|
if ( (*cp->ismyvin)(tx.vin[i].scriptSig) == 0 ) |
|
|
|
return eval->Invalid("unexpected normal vin for unlock"); |
|
|
|
} |
|
|
|
if ( valuein-tx.GetValueOut() > txfee ) |
|
|
|
if ( !CheckTxFee(tx, txfee, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) ) |
|
|
|
return eval->Invalid("txfee is too high"); |
|
|
|
if ( numvins == 1 && tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 && tx.vout[1].nValue == 10000 ) |
|
|
|
{ |
|
|
|
fprintf(stderr, "valueout.%li vs valuein.%li txfee.%li\n", tx.GetValueOut(), valuein, txfee); |
|
|
|
return eval->Invalid("alright is stealing your money"); |
|
|
|
} |
|
|
|
if ( numvouts == 2 && numvins == 1 ) |
|
|
|
{ |
|
|
|
if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 ) |
|
|
|
return eval->Invalid("unlock recover tx vout.0 is not normal output"); |
|
|
|
if ( tx.vout[1].scriptPubKey != tx.vout[0].scriptPubKey ) |
|
|
|
return eval->Invalid("unlock recover tx vout.1 mismatched scriptPubKey"); |
|
|
|
else if ( tx.vout[0].scriptPubKey != vinTx.vout[1].scriptPubKey ) |
|
|
|
return eval->Invalid("unlock recover tx vout.0 mismatched scriptPubKey"); |
|
|
|
else if ( tx.vout[0].nValue > vinTx.vout[0].nValue ) |
|
|
|
return eval->Invalid("unlock recover tx vout.0 mismatched amounts"); |
|
|
|
else if ( tx.vout[1].nValue > 0 ) |
|
|
|
else if ( tx.vout[2].nValue > 0 ) |
|
|
|
return eval->Invalid("unlock recover tx vout.1 nonz amount"); |
|
|
|
else return(true); |
|
|
|
} |
|
|
@ -689,8 +683,7 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint2 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
firstmtx.vout.push_back(CTxOut(amount-txfee,scriptPubKey)); |
|
|
|
//CCerror = "cant find enough rewards inputs";
|
|
|
|
firstmtx.vout.push_back(CTxOut(amount-txfee*2,scriptPubKey)); |
|
|
|
fprintf(stderr,"not enough rewards funds to payout %.8f, recover mode tx\n",(double)(reward+txfee)/COIN); |
|
|
|
return(FinalizeCCTx(-1LL,cp,firstmtx,mypk,txfee,EncodeRewardsOpRet('U',sbits,fundingtxid))); |
|
|
|
} |
|
|
|