MakeTokensCCcond1of2 corrrected and simplified
This commit is contained in:
@@ -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)
|
if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0)
|
||||||
return eval->Invalid("TokenValidate: invalid opreturn payload");
|
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)
|
if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0)
|
||||||
return eval->Invalid("cant find token create txid");
|
return eval->Invalid("cant find token create txid");
|
||||||
|
|||||||
@@ -83,21 +83,11 @@ CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2)
|
|||||||
pks.push_back(CCNewSecp256k1(pk1));
|
pks.push_back(CCNewSecp256k1(pk1));
|
||||||
pks.push_back(CCNewSecp256k1(pk2));
|
pks.push_back(CCNewSecp256k1(pk2));
|
||||||
CC *condEvalCC = CCNewEval(E_MARSHAL(ss << evalcode)); // this is eval cc
|
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 *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
|
return cond1of2Threshold;
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2)
|
CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2)
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction
|
|||||||
fundingTxOpRetScript = tx.vout[numvouts - 1].scriptPubKey;
|
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 ////////////////////////
|
//////////////// temp ////////////////////////
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user