if (cond->type->typeId != CC_Secp256k1) return 1;
struct SecP256k1ApplyData *apply = (struct SecP256k1ApplyData *)visitor.context;
+ /*
char *jsonCondStr = cc_conditionToJSONString(cond);
if (jsonCondStr)
{
printf("Ready to apply sig: %s\n", jsonCondStr);
cJSON_free(jsonCondStr);
}
+ */
// if we match, add or replace the signature, if the signature is null, remove the signature
int isPKHash = 0;
- if (!memcmp(cond->publicKey, apply->publicKey, SECP256K1_PK_SIZE) || ((isPKHash = cc_secp256k1IsPKHash(cond->publicKey)) && !memcmp(cond->publicKey, apply->publicKey, SECP256K1_PK_SIZE)))
+ if (!memcmp(cond->publicKey, apply->publicKey, SECP256K1_PK_SIZE) || ((isPKHash = cc_secp256k1IsPKHash(cond->publicKey)) && !memcmp(cond->publicKey, apply->pubkeyHash20, 20)))
{
if (cond->signature)
{
return 1;
}
+ /*
+ jsonCondStr = cc_conditionToJSONString(cond);
+ if (jsonCondStr)
+ {
+ printf("After signature: %s\n", jsonCondStr);
+ cJSON_free(jsonCondStr);
+ }
+ */
+
apply->applyCount++;
return 1;
}
int expectedEvals = 1;
CC *outputCC = nullptr;
+ int nHashType;
if (p.IsValid() && p.version >= p.VERSION_V3 && p.vData.size())
{
}
else
{
-
- /*
- char *jsonCondStr = cc_conditionToJSONString(outputCC);
- if (jsonCondStr)
- {
- printf("Reconstructed condition: %s\n", jsonCondStr);
- cJSON_free(jsonCondStr);
- }
- */
condBinary = CCPubKeyVec(outputCC);
CSmartTransactionSignatures signatures(std::vector<unsigned char>((unsigned char*)ffillBin.data(), (unsigned char*)ffillBin.data() + ffillBin.size()));
else
{
// apply signatures to the condition to create the fulfillment
+ nHashType = signatures.sigHashType;
for (auto &sig : signatures.signatures)
{
+
if (sig.second.sigType != sig.second.SIGTYPE_SECP256K1 || !sig.second.signature.size() || !cc_ApplySecp256k1Signature(outputCC, sig.second.pubKeyData.data(), sig.first.begin(), sig.second.signature.data()))
{
success = false;
}
if (!success || !condBinary.size())
{
+ /*
+ char *jsonCondStr = cc_conditionToJSONString(outputCC);
+ if (jsonCondStr)
+ {
+ printf("Signed condition: %s\n", jsonCondStr);
+ cJSON_free(jsonCondStr);
+ }
+ */
+
cc_free(outputCC);
condBinary.clear();
}
{
cond = outputCC;
signScript = scriptCode;
+ error = false;
}
else
{
signScript = CScript() << condBinary << OP_CHECKCRYPTOCONDITION;
error = cc_readFulfillmentBinaryExt((unsigned char*)ffillBin.data(), ffillBin.size()-1, &cond);
+ nHashType = ffillBin.back();
}
if (error || !cond)
}
uint256 sighash;
- int nHashType = ffillBin.back();
try {
sighash = SignatureHash(signScript, *txTo, nIn, nHashType, amount, consensusBranchId, this->txdata);
} catch (logic_error ex) {
obj.push_back(Pair("signaturetype", (int)sigType));
obj.push_back(Pair("publickeydata", HexBytes(&pubKeyData[0], pubKeyData.size())));
obj.push_back(Pair("signature", HexBytes(&signature[0], signature.size())));
+ return obj;
}
bool IsValid()
free(onesig);
signatures.AddSignature(signature);
vchSig = signatures.AsVector();
+
+
+ /*
+ printf("signatures: %s\n", signatures.ToUniValue().write().c_str());
+ CC *cc = (CC *)extraData;
+ if (!cc || cc_signTreeSecp256k1Msg32(cc, key.begin(), hash.begin()) == 0)
+ return false;
+ char *jsonCondStr = cc_conditionToJSONString(cc);
+ if (jsonCondStr)
+ {
+ printf("Signed condition: %s\n", jsonCondStr);
+ cJSON_free(jsonCondStr);
+ }
+ */
}
else
{