Delete more CCs #381

This commit is contained in:
Duke
2024-02-10 23:06:56 -05:00
parent b41785a684
commit 7791d50230
5 changed files with 7 additions and 1060 deletions

View File

@@ -44,70 +44,11 @@ static unsigned char* CopyPubKey(CPubKey pkIn)
}
CC* CCNewThreshold(int t, std::vector<CC*> v)
{
CC *cond = cc_new(CC_Threshold);
cond->threshold = t;
cond->size = v.size();
cond->subconditions = (CC**) calloc(v.size(), sizeof(CC*));
memcpy(cond->subconditions, v.data(), v.size() * sizeof(CC*));
return cond;
}
CC* CCNewSecp256k1(CPubKey k)
{
CC *cond = cc_new(CC_Secp256k1);
cond->publicKey = CopyPubKey(k);
return cond;
}
CC* CCNewEval(std::vector<unsigned char> code)
{
CC *cond = cc_new(CC_Eval);
cond->code = (unsigned char*) malloc(code.size());
memcpy(cond->code, code.data(), code.size());
cond->codeLength = code.size();
return cond;
}
CScript CCPubKey(const CC *cond)
{
return CScript();
}
CScript CCSig(const CC *cond)
{
return CScript();
}
std::vector<unsigned char> CCSigVec(const CC *cond)
{
unsigned char buf[10000];
size_t len = cc_fulfillmentBinary(cond, buf, 10000);
auto ffill = std::vector<unsigned char>(buf, buf+len);
ffill.push_back(1); // SIGHASH_ALL
return ffill;
}
std::string CCShowStructure(CC *cond)
{
std::string out;
return out;
}
CC* CCPrune(CC *cond)
{
std::vector<unsigned char> ffillBin;
GetPushData(CCSig(cond), ffillBin);
return cc_readFulfillmentBinary(ffillBin.data(), ffillBin.size()-1);
}
bool GetPushData(const CScript &sig, std::vector<unsigned char> &data)
{
opcodetype opcode;