This commit is contained in:
jl777
2018-07-22 03:06:53 -11:00
parent 2e482a0e68
commit ea06d536b1
5 changed files with 20 additions and 20 deletions

View File

@@ -296,7 +296,7 @@ bool AssetExactAmounts(Eval* eval,CTransaction &tx,uint256 assetid)
numvouts = tx.vout.size();
for (i=1; i<numvins; i++)
{
if ( IsEvalInput(EVAL_ASSETS,tx.vin[i].scriptSig) != 0 )
if ( IsAssetsInput(tx.vin[i].scriptSig) != 0 )
{
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 )
return eval->Invalid("always should find vin, but didnt");

View File

@@ -35,6 +35,24 @@ char AssetsCChexstr[67] = { "02adf84e0e075cf90868bd4e3d34a03420e034719649c41f371
uint8_t AssetsCCpriv[32] = { 0x9b, 0x17, 0x66, 0xe5, 0x82, 0x66, 0xac, 0xb6, 0xba, 0x43, 0x83, 0x74, 0xf7, 0x63, 0x11, 0x3b, 0xf0, 0xf3, 0x50, 0x6f, 0xd9, 0x6b, 0x67, 0x85, 0xf9, 0x7a, 0xf0, 0x54, 0x4d, 0xb1, 0x30, 0x77 };
CC *MakeAssetCond(CPubKey pk);
bool IsAssetsInput(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] == EVAL_ASSETS;
// 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;
}
CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv)
{
static CPubKey nullpk;

View File

@@ -43,7 +43,6 @@ bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk);
// CCutils
CC* GetCryptoCondition(CScript const& scriptSig);
bool IsCCInput(CScript const& scriptSig);
bool IsEvalInput(uint8_t evalcode,CScript const& scriptSig);
uint256 revuint256(uint256 txid);
char *uint256_str(char *dest,uint256 txid);
uint256 Parseuint256(char *hexstr);

View File

@@ -37,23 +37,6 @@ bool IsCCInput(CScript const& scriptSig)
return true;
}
bool IsEvalInput(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;
}
uint256 revuint256(uint256 txid)
{
uint256 revtxid; int32_t i;

View File

@@ -997,7 +997,7 @@ bool AssetExactAmounts(Eval* eval,CTransaction &tx,uint256 assetid)
numvouts = tx.vout.size();
for (i=1; i<numvins; i++)
{
if ( IsEvalInput(EVAL_ASSETS,tx.vin[i].scriptSig) != 0 )
if ( IsAssetsInput(tx.vin[i].scriptSig) != 0 )
{
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 )
return eval->Invalid("always should find vin, but didnt");