Remove libcryptoconditions dependency #381
This commit is contained in:
@@ -14,28 +14,13 @@
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "cryptoconditions/include/cryptoconditions.h"
|
||||
#include "script/cc.h"
|
||||
|
||||
|
||||
bool IsCryptoConditionsEnabled()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool IsSupportedCryptoCondition(const CC *cond)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool IsSignedCryptoCondition(const CC *cond)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static unsigned char* CopyPubKey(CPubKey pkIn)
|
||||
{
|
||||
unsigned char* pk = (unsigned char*) malloc(33);
|
||||
@@ -43,12 +28,6 @@ static unsigned char* CopyPubKey(CPubKey pkIn)
|
||||
return pk;
|
||||
}
|
||||
|
||||
|
||||
CScript CCPubKey(const CC *cond)
|
||||
{
|
||||
return CScript();
|
||||
}
|
||||
|
||||
bool GetPushData(const CScript &sig, std::vector<unsigned char> &data)
|
||||
{
|
||||
opcodetype opcode;
|
||||
|
||||
@@ -21,78 +21,11 @@
|
||||
|
||||
#include "pubkey.h"
|
||||
#include "script/script.h"
|
||||
#include "cryptoconditions/include/cryptoconditions.h"
|
||||
|
||||
|
||||
extern uint32_t ASSETCHAINS_CC;
|
||||
bool IsCryptoConditionsEnabled();
|
||||
|
||||
// Limit acceptable condition types
|
||||
// Prefix not enabled because no current use case, ambiguity on how to combine with secp256k1
|
||||
// RSA not enabled because no current use case, not implemented
|
||||
const int CCEnabledTypes = 1 << CC_Secp256k1 | \
|
||||
1 << CC_Threshold | \
|
||||
1 << CC_Eval | \
|
||||
1 << CC_Preimage | \
|
||||
1 << CC_Ed25519;
|
||||
|
||||
const int CCSigningNodes = 1 << CC_Ed25519 | 1 << CC_Secp256k1;
|
||||
|
||||
|
||||
/*
|
||||
* Check if the server can accept the condition based on it's structure / types
|
||||
*/
|
||||
bool IsSupportedCryptoCondition(const CC *cond);
|
||||
|
||||
|
||||
/*
|
||||
* Check if crypto condition is signed. Can only accept signed conditions.
|
||||
*/
|
||||
bool IsSignedCryptoCondition(const CC *cond);
|
||||
|
||||
|
||||
/*
|
||||
* Construct crypto conditions
|
||||
*/
|
||||
CC* CCNewPreimage(std::vector<unsigned char> preimage);
|
||||
CC* CCNewEval(std::vector<unsigned char> code);
|
||||
CC* CCNewSecp256k1(CPubKey k);
|
||||
CC* CCNewThreshold(int t, std::vector<CC*> v);
|
||||
|
||||
|
||||
/*
|
||||
* Turn a condition into a scriptPubKey
|
||||
*/
|
||||
CScript CCPubKey(const CC *cond);
|
||||
|
||||
|
||||
/*
|
||||
* Turn a condition into a scriptSig
|
||||
*
|
||||
* Note: This will fail in undefined ways if the condition is missing signatures
|
||||
*/
|
||||
CScript CCSig(const CC *cond);
|
||||
|
||||
/*
|
||||
* Turn a condition into a scriptSig
|
||||
*
|
||||
* Note: This will fail in undefined ways if the condition is missing signatures
|
||||
*/
|
||||
std::vector<unsigned char> CCSigVec(const CC *cond);
|
||||
|
||||
/*
|
||||
* Produces a string showing the structure of a CC condition
|
||||
*/
|
||||
std::string CCShowStructure(CC *cond);
|
||||
|
||||
|
||||
/*
|
||||
* Take a signed CC, encode it, and decode it again. This has the effect
|
||||
* of removing branches unneccesary for fulfillment.
|
||||
*/
|
||||
CC* CCPrune(CC *cond);
|
||||
|
||||
|
||||
/*
|
||||
* Get PUSHDATA from a script
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include <cryptoconditions.h>
|
||||
#include "interpreter.h"
|
||||
#include "consensus/upgrades.h"
|
||||
#include "primitives/transaction.h"
|
||||
@@ -1366,14 +1365,6 @@ int TransactionSignatureChecker::CheckCryptoCondition(
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int TransactionSignatureChecker::CheckEvalCondition(const CC *cond) const
|
||||
{
|
||||
//fprintf(stderr, "Cannot check crypto-condition Eval outside of server, returning true in pre-checks\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TransactionSignatureChecker::CheckLockTime(const CScriptNum& nLockTime) const
|
||||
{
|
||||
// There are two times of nLockTime: lock-by-blockheight
|
||||
|
||||
@@ -179,7 +179,6 @@ public:
|
||||
const std::vector<unsigned char>& ffillBin,
|
||||
const CScript& scriptCode,
|
||||
uint32_t consensusBranchId) const;
|
||||
virtual int CheckEvalCondition(const CC *cond) const;
|
||||
};
|
||||
|
||||
class MutableTransactionSignatureChecker : public TransactionSignatureChecker
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "util/strencodings.h"
|
||||
#include "script/cc.h"
|
||||
#include "cc/eval.h"
|
||||
#include "cryptoconditions/include/cryptoconditions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -363,50 +362,22 @@ bool CScript::GetOpretData(std::vector<std::vector<unsigned char>>& vData) const
|
||||
|
||||
bool CScript::IsPayToCryptoCondition(CScript *pCCSubScript, std::vector<std::vector<unsigned char>>& vParams) const
|
||||
{
|
||||
const_iterator pc = begin();
|
||||
vector<unsigned char> data;
|
||||
opcodetype opcode;
|
||||
if (this->GetOp(pc, opcode, data))
|
||||
// Sha256 conditions are <76 bytes
|
||||
if (opcode > OP_0 && opcode < OP_PUSHDATA1)
|
||||
if (this->GetOp(pc, opcode, data))
|
||||
if (opcode == OP_CHECKCRYPTOCONDITION)
|
||||
{
|
||||
const_iterator pcCCEnd = pc;
|
||||
if (GetBalancedData(pc, vParams))
|
||||
{
|
||||
if (pCCSubScript)
|
||||
*pCCSubScript = CScript(begin(),pcCCEnd);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CScript::IsPayToCryptoCondition(CScript *pCCSubScript) const
|
||||
{
|
||||
std::vector<std::vector<unsigned char>> vParams;
|
||||
return IsPayToCryptoCondition(pCCSubScript, vParams);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CScript::IsPayToCryptoCondition() const
|
||||
{
|
||||
return IsPayToCryptoCondition(NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CScript::MayAcceptCryptoCondition() const
|
||||
{
|
||||
// Get the type mask of the condition
|
||||
const_iterator pc = this->begin();
|
||||
vector<unsigned char> data;
|
||||
opcodetype opcode;
|
||||
if (!this->GetOp(pc, opcode, data)) return false;
|
||||
if (!(opcode > OP_0 && opcode < OP_PUSHDATA1)) return false;
|
||||
CC *cond = cc_readConditionBinary(data.data(), data.size());
|
||||
if (!cond) return false;
|
||||
bool out = IsSupportedCryptoCondition(cond);
|
||||
cc_free(cond);
|
||||
return out;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CScript::IsCoinImport() const
|
||||
|
||||
@@ -107,18 +107,3 @@ bool ServerTransactionSignatureChecker::VerifySignature(const std::vector<unsign
|
||||
signatureCache.Set(sighash, vchSig, pubkey);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* The reason that these functions are here is that the what used to be the
|
||||
* CachingTransactionSignatureChecker, now the ServerTransactionSignatureChecker,
|
||||
* is an entry point that the server uses to validate signatures and which is not
|
||||
* included as part of bitcoin common libs. Since Crypto-Condtions eval methods
|
||||
* may call server code (GetTransaction etc), the best way to get it to run this
|
||||
* code without pulling the whole bitcoin server code into bitcoin common was
|
||||
* using this class. Thus it has been renamed to ServerTransactionSignatureChecker.
|
||||
*/
|
||||
int ServerTransactionSignatureChecker::CheckEvalCondition(const CC *cond) const
|
||||
{
|
||||
//fprintf(stderr,"call RunCCeval from ServerTransactionSignatureChecker::CheckEvalCondition\n");
|
||||
return RunCCEval(cond, *txTo, nIn);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ public:
|
||||
ServerTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nIn, const CAmount& amount, bool storeIn) : TransactionSignatureChecker(txToIn, nIn, amount), store(storeIn) {}
|
||||
|
||||
bool VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const;
|
||||
int CheckEvalCondition(const CC *cond) const;
|
||||
};
|
||||
|
||||
#endif // HUSH_SCRIPT_SERVERCHECKER_H
|
||||
|
||||
@@ -166,11 +166,6 @@ bool _Getscriptaddress(char *destaddr, const CScript &scriptPubKey)
|
||||
return(false);
|
||||
}
|
||||
|
||||
CScript _CCPubKey(const CC *cond)
|
||||
{
|
||||
return CScript();
|
||||
}
|
||||
|
||||
static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scriptPubKey, vector<valtype> &vSolutions,
|
||||
vector<valtype>& ret, uint32_t consensusBranchId)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user