Test
This commit is contained in:
@@ -80,12 +80,30 @@ bool IsFaucetInput(CScript const& scriptSig)
|
||||
return out;
|
||||
}
|
||||
|
||||
bool IsRewardsInput(CScript const& scriptSig)
|
||||
bool IsCCinput(uint8_t evalcode,CScript const& scriptSig)
|
||||
{
|
||||
CC *cond;
|
||||
if (!(cond = GetCryptoCondition(scriptSig)))
|
||||
return false;
|
||||
// Recurse the CC tree to find asset condition
|
||||
auto findEval = [&] (CC *cond, struct CCVisitor _) {
|
||||
bool r = cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == evalcode;
|
||||
// false for a match, true for continue
|
||||
return r ? 0 : 1;
|
||||
};
|
||||
CCVisitor visitor = {findEval, (uint8_t*)"", 0, NULL};
|
||||
bool out =! cc_visit(cond, visitor);
|
||||
cc_free(cond);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool IsRewardsInput(CScript const& scriptSig)
|
||||
{
|
||||
return(IsCCinput(EVAL_REWARDS,scriptSig));
|
||||
/*CC *cond;
|
||||
if (!(cond = GetCryptoCondition(scriptSig)))
|
||||
return false;
|
||||
// Recurse the CC tree to find asset condition
|
||||
auto findEval = [&] (CC *cond, struct CCVisitor _) {
|
||||
bool r = cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == EVAL_REWARDS;
|
||||
// false for a match, true for continue
|
||||
@@ -94,7 +112,7 @@ bool IsRewardsInput(CScript const& scriptSig)
|
||||
CCVisitor visitor = {findEval, (uint8_t*)"", 0, NULL};
|
||||
bool out =! cc_visit(cond, visitor);
|
||||
cc_free(cond);
|
||||
return out;
|
||||
return out;*/
|
||||
}
|
||||
|
||||
CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv)
|
||||
@@ -133,7 +151,7 @@ CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv)
|
||||
CC *Sig = CCNewThreshold(1, pks);
|
||||
return CCNewThreshold(2, {assetCC, Sig});
|
||||
} else return(0);
|
||||
}*/
|
||||
}
|
||||
|
||||
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk)
|
||||
{
|
||||
@@ -171,6 +189,6 @@ bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk)
|
||||
}
|
||||
fprintf(stderr,"GetCCaddress %02x is invalid evalcode\n",evalcode);
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ static uint256 zeroid;
|
||||
// CCcustom
|
||||
CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv);
|
||||
//CC *MakeCC(uint8_t evalcode,CPubKey pk);
|
||||
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk);
|
||||
//bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk);
|
||||
|
||||
// CCutils
|
||||
CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk);
|
||||
@@ -49,6 +49,7 @@ uint256 revuint256(uint256 txid);
|
||||
char *uint256_str(char *dest,uint256 txid);
|
||||
uint256 Parseuint256(char *hexstr);
|
||||
CPubKey pubkey2pk(std::vector<uint8_t> pubkey);
|
||||
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk);
|
||||
bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,uint64_t nValue);
|
||||
bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t numvins,int32_t preventCCvouts,int32_t numvouts);
|
||||
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
||||
|
||||
@@ -106,6 +106,20 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey)
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk)
|
||||
{
|
||||
CC *payoutCond;
|
||||
destaddr[0] = 0;
|
||||
if ( pk.size() == 0 )
|
||||
pk = GetUnspendable(evalcode,0);
|
||||
if ( (payoutCond= MakeCCcond1(evalcode,pk)) != 0 )
|
||||
{
|
||||
Getscriptaddress(destaddr,CCPubKey(payoutCond));
|
||||
cc_free(payoutCond);
|
||||
}
|
||||
return(destaddr[0] != 0);
|
||||
}
|
||||
|
||||
bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,uint64_t nValue)
|
||||
{
|
||||
char destaddr[64];
|
||||
|
||||
Reference in New Issue
Block a user