Fix dustvout
This commit is contained in:
@@ -21,7 +21,6 @@ uint64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||
GetCCaddress(cp,coinaddr,pk);
|
||||
SetCCunspents(unspentOutputs,coinaddr);
|
||||
//std::sort(unspentOutputs.begin(), unspentOutputs.end(), heightSort);
|
||||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++)
|
||||
{
|
||||
txid = it->first.txhash;
|
||||
|
||||
@@ -235,9 +235,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx
|
||||
return eval->Invalid("mismatched remainder for fillbuy");
|
||||
else if ( remaining_price != 0 )
|
||||
{
|
||||
if ( remaining_price < 10000 )
|
||||
return eval->Invalid("dust vout0 to AssetsCCaddr for fillbuy");
|
||||
else if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,0) == 0 )
|
||||
if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,0) == 0 )
|
||||
return eval->Invalid("mismatched vout0 AssetsCCaddr for fillbuy");
|
||||
}
|
||||
}
|
||||
@@ -309,9 +307,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx
|
||||
return eval->Invalid("CC vout2 for fillask");
|
||||
else if ( remaining_price != 0 )
|
||||
{
|
||||
if ( remaining_price < 10000 )
|
||||
return eval->Invalid("dust vout0 to AssetsCCaddr for fill");
|
||||
else if ( ConstrainVout(tx.vout[0],1,(char *)cp->unspendableCCaddr,0) == 0 )
|
||||
if ( ConstrainVout(tx.vout[0],1,(char *)cp->unspendableCCaddr,0) == 0 )
|
||||
return eval->Invalid("mismatched vout0 AssetsCCaddr for fill");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,43 @@ uint64_t RewardsCalc(uint64_t claim,uint256 txid) // min/max time, mindeposit an
|
||||
return(reward);
|
||||
}
|
||||
|
||||
CScript EncodeRewardsOpRet(uint8_t funcid,uint64_t sbits)
|
||||
{
|
||||
CScript opret; uint8_t evalcode = EVAL_REWARDS;
|
||||
switch ( funcid )
|
||||
{
|
||||
case 't': case 'x': case 'o':
|
||||
opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << sbits);
|
||||
break;
|
||||
}
|
||||
return(opret);
|
||||
}
|
||||
|
||||
uint8_t DecodeAssetOpRet(const CScript &scriptPubKey,uint64_t &sbits)
|
||||
{
|
||||
std::vector<uint8_t> vopret; uint8_t funcid=0,*script,e,f;
|
||||
GetOpReturnData(scriptPubKey, vopret);
|
||||
script = (uint8_t *)vopret.data();
|
||||
price = 0;
|
||||
if ( script[0] == EVAL_REWARDS )
|
||||
{
|
||||
funcid = script[1];
|
||||
//fprintf(stderr,"decode.[%c]\n",funcid);
|
||||
switch ( funcid )
|
||||
{
|
||||
case 't': case 'x': case 'o':
|
||||
if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> sbits) != 0 )
|
||||
return(funcid);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"DecodeRewardsOpRet: illegal funcid.%02x\n",funcid);
|
||||
funcid = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(funcid);
|
||||
}
|
||||
|
||||
uint64_t IsRewardsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v)
|
||||
{
|
||||
char destaddr[64];
|
||||
@@ -167,6 +204,7 @@ uint64_t RewardsPlanFunds(uint64_t &refsbits,struct CCcontract_info *cp,CPubKey
|
||||
{
|
||||
if ( (nValue= IsRewardsvout(cp,vintx,(int32_t)it->first.index)) > 0 )
|
||||
{
|
||||
|
||||
totalinputs += nValue;
|
||||
}
|
||||
}
|
||||
@@ -191,8 +229,7 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 txid)
|
||||
if ( CCchange != 0 )
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange,rewardspk));
|
||||
mtx.vout.push_back(CTxOut(amount+reward,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
|
||||
opret << OP_RETURN << E_MARSHAL(ss << cp->evalcode << 'U');
|
||||
return(FinalizeCCTx(cp,mtx,mypk,txfee,opret));
|
||||
return(FinalizeCCTx(cp,mtx,mypk,txfee,EncodeRewardsCreateOpRet('U',sbits));
|
||||
}
|
||||
} else fprintf(stderr,"cant find rewards inputs\n");
|
||||
return(0);
|
||||
@@ -213,8 +250,7 @@ std::string RewardsFund(uint64_t txfee,char *planstr,uint64_t funds,uint64_t APR
|
||||
mtx.vout.push_back(CTxOut(minseconds,CScript() << ParseHex(HexStr(rewardspk)) << OP_CHECKSIG));
|
||||
mtx.vout.push_back(CTxOut(maxseconds,CScript() << ParseHex(HexStr(rewardspk)) << OP_CHECKSIG));
|
||||
mtx.vout.push_back(CTxOut(mindeposit,CScript() << ParseHex(HexStr(rewardspk)) << OP_CHECKSIG));
|
||||
opret << OP_RETURN << E_MARSHAL(ss << cp->evalcode << 'F' << sbits);
|
||||
return(FinalizeCCTx(cp,mtx,mypk,txfee,opret));
|
||||
return(FinalizeCCTx(cp,mtx,mypk,txfee,EncodeRewardsCreateOpRet('F',sbits)));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -232,8 +268,7 @@ std::string RewardsLock(uint64_t txfee,char *planstr,uint64_t amount)
|
||||
if ( AddNormalinputs(mtx,mypk,amount+txfee,64) > 0 )
|
||||
{
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,rewardspk));
|
||||
opret << OP_RETURN << E_MARSHAL(ss << cp->evalcode << 'L' << sbits);
|
||||
return(FinalizeCCTx(cp,mtx,mypk,txfee,opret));
|
||||
return(FinalizeCCTx(cp,mtx,mypk,txfee,EncodeRewardsCreateOpRet('L',sbits)));
|
||||
} else fprintf(stderr,"cant find rewards inputs\n");
|
||||
}
|
||||
return(0);
|
||||
|
||||
@@ -3474,7 +3474,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
||||
if ( KOMODO_LONGESTCHAIN != 0 && pindexNew->nHeight >= KOMODO_LONGESTCHAIN )
|
||||
KOMODO_INSYNC = 1;
|
||||
else KOMODO_INSYNC = 0;
|
||||
fprintf(stderr,"connect.%d insync.%d\n",(int32_t)pindexNew->nHeight,KOMODO_INSYNC);
|
||||
//fprintf(stderr,"connect.%d insync.%d\n",(int32_t)pindexNew->nHeight,KOMODO_INSYNC);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && KOMODO_INSYNC != 0 )
|
||||
komodo_broadcast(pblock,8);
|
||||
return true;
|
||||
|
||||
@@ -197,7 +197,7 @@ int32_t komodo_longestchain()
|
||||
if ( num > (n >> 1) )
|
||||
{
|
||||
extern char ASSETCHAINS_SYMBOL[];
|
||||
if ( height != KOMODO_LONGESTCHAIN )
|
||||
if ( 0 && height != KOMODO_LONGESTCHAIN )
|
||||
fprintf(stderr,"set %s KOMODO_LONGESTCHAIN <- %d\n",ASSETCHAINS_SYMBOL,height);
|
||||
KOMODO_LONGESTCHAIN = height;
|
||||
return(height);
|
||||
|
||||
Reference in New Issue
Block a user