MakeTokensCCcond1of2 corrrected and simplified

This commit is contained in:
dimxy
2019-01-10 21:28:13 +05:00
parent 0177628e7d
commit d67ca1779a
3 changed files with 5 additions and 15 deletions

View File

@@ -173,7 +173,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &
if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0)
return eval->Invalid("TokenValidate: invalid opreturn payload");
fprintf(stderr, "TokensValidate (%c)\n", funcid);
fprintf(stderr, "TokensValidate (%c) evalcode=0x%0x\n", funcid, cp->evalcode);
if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0)
return eval->Invalid("cant find token create txid");

View File

@@ -83,21 +83,11 @@ CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2)
pks.push_back(CCNewSecp256k1(pk1));
pks.push_back(CCNewSecp256k1(pk2));
CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); // this is eval cc
CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // this is eval token cc
CC *cond1of2Sig = CCNewThreshold(1, pks); // this is 1 of 2 sigs cc
CC *cond1of2Threshold = CCNewThreshold(2, { condEvalCC, cond1of2Sig });
CC *cond1of2Threshold = CCNewThreshold(3, { condEvalCC, condEvalTokensCC, cond1of2Sig });
// make token cond
struct CCcontract_info *cpTokens, tokensC;
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL);
std::vector<CC*> pksTokens;
pks.push_back(CCNewSecp256k1(unspendableTokensPk));
CC *condEvalTokensCC = CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS)); // this is eval cc
CC *condUnspendableSig = CCNewThreshold(1, pksTokens); // this is 1 of 2 sigs cc
CC *condTopThreshold = CCNewThreshold(2, { condEvalTokensCC, condUnspendableSig });
return CCNewThreshold(2, { cond1of2Threshold, condTopThreshold });
return cond1of2Threshold;
}
CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2)

View File

@@ -158,7 +158,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction
fundingTxOpRetScript = tx.vout[numvouts - 1].scriptPubKey;
}
std::cerr << "HeirValidate funcid=" << (char)funcId << std::endl;
std::cerr << "HeirValidate funcid=" << (char)funcId << " evalcode=" << cpHeir->evalcode << std::endl;
//////////////// temp ////////////////////////
return true;