Partial revert
This commit is contained in:
@@ -116,6 +116,7 @@ struct CC_info
|
||||
|
||||
uint8_t didinit;
|
||||
};
|
||||
typedef struct CC_info CCcontract_info;
|
||||
struct CC_info *CCinit(struct CC_info *cp,uint8_t evalcode);
|
||||
|
||||
struct oracleprice_info
|
||||
|
||||
@@ -34,7 +34,7 @@ class TokenHelper;
|
||||
|
||||
// Plan validation runner, it may be called twice - for coins and tokens
|
||||
// (sadly we cannot have yet 'templatized' lambdas, if we could we could capture all these params inside HeirValidation()...)
|
||||
template <typename Helper> bool RunValidationPlans(uint8_t funcId, struct CC_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t hasHeirSpendingBegun)
|
||||
template <typename Helper> bool RunValidationPlans(uint8_t funcId, struct CCcontract_info* cp, Eval* eval, const CTransaction& tx, uint256 latestTxid, CScript fundingOpretScript, uint8_t hasHeirSpendingBegun)
|
||||
{
|
||||
int32_t numvins = tx.vin.size();
|
||||
int32_t numvouts = tx.vout.size();
|
||||
@@ -104,14 +104,14 @@ template <typename Helper> bool RunValidationPlans(uint8_t funcId, struct CC_inf
|
||||
/**
|
||||
* Tx validation entry function
|
||||
*/
|
||||
bool HeirValidate(struct CC_info* cpHeir, Eval* eval, const CTransaction& tx, uint32_t nIn)
|
||||
bool HeirValidate(struct CCcontract_info* cpHeir, Eval* eval, const CTransaction& tx, uint32_t nIn)
|
||||
{
|
||||
int32_t numvins = tx.vin.size();
|
||||
int32_t numvouts = tx.vout.size();
|
||||
//int32_t preventCCvins = -1;
|
||||
//int32_t preventCCvouts = -1;
|
||||
|
||||
struct CC_info *cpTokens, tokensC;
|
||||
struct CCcontract_info *cpTokens, tokensC;
|
||||
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
|
||||
|
||||
if (numvouts < 1)
|
||||
@@ -237,7 +237,7 @@ bool HeirValidate(struct CC_info* cpHeir, Eval* eval, const CTransaction& tx, ui
|
||||
* Checks if vout is to cryptocondition address
|
||||
* @return vout value in satoshis
|
||||
*/
|
||||
template <class Helper> int64_t IsHeirFundingVout(struct CC_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey)
|
||||
template <class Helper> int64_t IsHeirFundingVout(struct CCcontract_info* cp, const CTransaction& tx, int32_t voutIndex, CPubKey ownerPubkey, CPubKey heirPubkey)
|
||||
{
|
||||
char destaddr[65], heirFundingAddr[65];
|
||||
|
||||
@@ -437,7 +437,7 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke
|
||||
|
||||
// TODO: correct cc addr:
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>> unspentOutputs;
|
||||
struct CC_info *cp, C;
|
||||
struct CCcontract_info *cp, C;
|
||||
cp = CCinit(&C, EVAL_HEIR);
|
||||
char coinaddr[64];
|
||||
GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys'
|
||||
@@ -507,7 +507,7 @@ uint256 FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &token
|
||||
}
|
||||
|
||||
// add inputs of 1 of 2 cc address
|
||||
template <class Helper> int64_t Add1of2AddressInputs(struct CC_info* cp, uint256 fundingtxid, CMutableTransaction& mtx, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t total, int32_t maxinputs)
|
||||
template <class Helper> int64_t Add1of2AddressInputs(struct CCcontract_info* cp, uint256 fundingtxid, CMutableTransaction& mtx, CPubKey ownerPubkey, CPubKey heirPubkey, int64_t total, int32_t maxinputs)
|
||||
{
|
||||
// TODO: add threshold check
|
||||
int64_t nValue, voutValue, totalinputs = 0;
|
||||
@@ -566,7 +566,7 @@ template <class Helper> int64_t Add1of2AddressInputs(struct CC_info* cp, uint256
|
||||
/**
|
||||
* enumerate all tx's sending to CCHeir 1of2address and calc total lifetime funds
|
||||
*/
|
||||
template <class Helper> int64_t LifetimeHeirContractFunds(struct CC_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey)
|
||||
template <class Helper> int64_t LifetimeHeirContractFunds(struct CCcontract_info* cp, uint256 fundingtxid, CPubKey ownerPubkey, CPubKey heirPubkey)
|
||||
{
|
||||
char coinaddr[64];
|
||||
Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys'
|
||||
@@ -619,7 +619,7 @@ template <typename Helper> UniValue HeirFund(uint64_t txfee, int64_t amount, std
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
|
||||
struct CC_info *cp, C;
|
||||
struct CCcontract_info *cp, C;
|
||||
|
||||
cp = CCinit(&C, Helper::getMyEval());
|
||||
if (txfee == 0)
|
||||
@@ -707,7 +707,7 @@ template <class Helper> UniValue _HeirAdd(uint256 fundingtxid, uint64_t txfee, i
|
||||
UniValue result(UniValue::VOBJ);
|
||||
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
|
||||
int64_t inputs, CCchange = 0;
|
||||
struct CC_info *cp, C;
|
||||
struct CCcontract_info *cp, C;
|
||||
std::string rawhex;
|
||||
|
||||
cp = CCinit(&C, Helper::getMyEval()); // for tokens shoud be EVAL_TOKENS to sign it correctly!
|
||||
@@ -825,7 +825,7 @@ template <typename Helper>UniValue _HeirClaim(uint256 fundingtxid, uint64_t txfe
|
||||
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
|
||||
CPubKey myPubkey;
|
||||
int64_t inputs, change = 0;
|
||||
struct CC_info *cp, C;
|
||||
struct CCcontract_info *cp, C;
|
||||
|
||||
cp = CCinit(&C, EVAL_HEIR);
|
||||
if (txfee == 0)
|
||||
@@ -1006,7 +1006,7 @@ UniValue HeirInfo(uint256 fundingtxid)
|
||||
return result;
|
||||
}*/
|
||||
|
||||
struct CC_info *cp, C;
|
||||
struct CCcontract_info *cp, C;
|
||||
cp = CCinit(&C, EVAL_HEIR);
|
||||
|
||||
uint8_t hasHeirSpendingBegun = 0;
|
||||
@@ -1123,7 +1123,7 @@ UniValue HeirInfo(uint256 fundingtxid)
|
||||
* @return list of heir plan handles (fundingtxid)
|
||||
*/
|
||||
|
||||
template <typename Helper>void _HeirList(struct CC_info *cp, UniValue &result)
|
||||
template <typename Helper>void _HeirList(struct CCcontract_info *cp, UniValue &result)
|
||||
{
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>> unspentOutputs;
|
||||
char coinaddr[64];
|
||||
@@ -1174,7 +1174,7 @@ UniValue HeirList()
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.push_back(Pair("result", "success"));
|
||||
|
||||
struct CC_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit!
|
||||
struct CCcontract_info *cpHeir, *cpTokens, heirC, tokenC; // NOTE we must use a separate 'C' structure for each CCinit!
|
||||
|
||||
cpHeir = CCinit(&heirC, EVAL_HEIR);
|
||||
cpTokens = CCinit(&tokenC, EVAL_TOKENS);
|
||||
@@ -1185,4 +1185,3 @@ UniValue HeirList()
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ public:
|
||||
return CTxOut(amount, CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG);
|
||||
} */
|
||||
static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) {
|
||||
struct CC_info *cpHeir, heirC;
|
||||
struct CCcontract_info *cpHeir, heirC;
|
||||
cpHeir = CCinit(&heirC, EVAL_HEIR);
|
||||
return GetCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey);
|
||||
}
|
||||
static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) {
|
||||
static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) {
|
||||
CCaddr1of2set(cp, ownerPubkey, heirPubkey, coinaddr);
|
||||
}
|
||||
};
|
||||
@@ -61,7 +61,7 @@ class TokenHelper {
|
||||
public:
|
||||
static uint8_t getMyEval() { return EVAL_TOKENS; }
|
||||
static int64_t addOwnerInputs(uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) {
|
||||
struct CC_info *cpHeir, heirC;
|
||||
struct CCcontract_info *cpHeir, heirC;
|
||||
cpHeir = CCinit(&heirC, EVAL_TOKENS);
|
||||
return AddTokenCCInputs(cpHeir, mtx, ownerPubkey, tokenid, total, maxinputs);
|
||||
}
|
||||
@@ -89,12 +89,12 @@ public:
|
||||
return MakeCC1vout(EVAL_TOKENS, amount, myPubkey); // yes EVAL_TOKENS
|
||||
} */
|
||||
static bool GetCoinsOrTokensCCaddress1of2(char *coinaddr, CPubKey ownerPubkey, CPubKey heirPubkey) {
|
||||
struct CC_info *cpHeir, heirC;
|
||||
struct CCcontract_info *cpHeir, heirC;
|
||||
cpHeir = CCinit(&heirC, EVAL_HEIR);
|
||||
return GetTokensCCaddress1of2(cpHeir, coinaddr, ownerPubkey, heirPubkey);
|
||||
}
|
||||
|
||||
static void CCaddrCoinsOrTokens1of2set(struct CC_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) {
|
||||
static void CCaddrCoinsOrTokens1of2set(struct CCcontract_info *cp, CPubKey ownerPubkey, CPubKey heirPubkey, char *coinaddr) {
|
||||
|
||||
CCaddrTokens1of2set(cp, ownerPubkey, heirPubkey, coinaddr);
|
||||
}
|
||||
@@ -123,13 +123,13 @@ public:
|
||||
class CValidatorBase
|
||||
{
|
||||
public:
|
||||
CValidatorBase(CC_info* cp) : m_cp(cp) {}
|
||||
CValidatorBase(CCcontract_info* cp) : m_cp(cp) {}
|
||||
virtual bool isVinValidator() const = 0;
|
||||
virtual bool validateVin(CTxIn vin, CTxOut prevVout, std::string& message) const = 0;
|
||||
virtual bool validateVout(CTxOut vout, std::string& message) const = 0;
|
||||
|
||||
protected:
|
||||
CC_info * m_cp;
|
||||
CCcontract_info * m_cp;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -138,11 +138,11 @@ protected:
|
||||
class CInputIdentifierBase
|
||||
{
|
||||
public:
|
||||
CInputIdentifierBase(CC_info* cp) : m_cp(cp) {}
|
||||
CInputIdentifierBase(CCcontract_info* cp) : m_cp(cp) {}
|
||||
virtual std::string inputName() const = 0;
|
||||
virtual bool identifyInput(CTxIn vin) const = 0;
|
||||
protected:
|
||||
CC_info * m_cp;
|
||||
CCcontract_info * m_cp;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -375,7 +375,7 @@ private:
|
||||
|
||||
class CNormalInputIdentifier : CInputIdentifierBase {
|
||||
public:
|
||||
CNormalInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {}
|
||||
CNormalInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {}
|
||||
virtual std::string inputName() const { return std::string("normal input"); }
|
||||
virtual bool identifyInput(CTxIn vin) const {
|
||||
return !IsCCInput(vin.scriptSig);
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
|
||||
class CCCInputIdentifier : CInputIdentifierBase {
|
||||
public:
|
||||
CCCInputIdentifier(CC_info* cp) : CInputIdentifierBase(cp) {}
|
||||
CCCInputIdentifier(CCcontract_info* cp) : CInputIdentifierBase(cp) {}
|
||||
virtual std::string inputName() const { return std::string("CC input"); }
|
||||
virtual bool identifyInput(CTxIn vin) const {
|
||||
return IsCCInput(vin.scriptSig);
|
||||
@@ -398,7 +398,7 @@ public:
|
||||
template <class Helper> class CCC1of2AddressValidator : CValidatorBase
|
||||
{
|
||||
public:
|
||||
CCC1of2AddressValidator(CC_info* cp, CScript opRetScript, std::string customMessage = "") :
|
||||
CCC1of2AddressValidator(CCcontract_info* cp, CScript opRetScript, std::string customMessage = "") :
|
||||
m_fundingOpretScript(opRetScript), m_customMessage(customMessage), CValidatorBase(cp) {}
|
||||
|
||||
virtual bool isVinValidator() const { return false; }
|
||||
@@ -452,7 +452,7 @@ private:
|
||||
template <class Helper> class CMyPubkeyVoutValidator : CValidatorBase
|
||||
{
|
||||
public:
|
||||
CMyPubkeyVoutValidator(CC_info* cp, CScript opRetScript, bool checkNormals)
|
||||
CMyPubkeyVoutValidator(CCcontract_info* cp, CScript opRetScript, bool checkNormals)
|
||||
: m_fundingOpretScript(opRetScript), m_checkNormals(checkNormals), CValidatorBase(cp) { }
|
||||
|
||||
virtual bool isVinValidator() const { return false; }
|
||||
@@ -512,7 +512,7 @@ private:
|
||||
template <class Helper> class CHeirSpendValidator : CValidatorBase
|
||||
{
|
||||
public:
|
||||
CHeirSpendValidator(CC_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan)
|
||||
CHeirSpendValidator(CCcontract_info* cp, CScript opRetScript, uint256 latesttxid, uint8_t isHeirSpendingBegan)
|
||||
: m_fundingOpretScript(opRetScript), m_latesttxid(latesttxid), m_isHeirSpendingBegan(isHeirSpendingBegan), CValidatorBase(cp) {}
|
||||
|
||||
virtual bool isVinValidator() const { return false; }
|
||||
@@ -568,7 +568,7 @@ private:
|
||||
template <class Helper> class COpRetValidator : CValidatorBase
|
||||
{
|
||||
public:
|
||||
COpRetValidator(CC_info* cp, CScript opret)
|
||||
COpRetValidator(CCcontract_info* cp, CScript opret)
|
||||
: m_fundingOpretScript(opret), CValidatorBase(cp) {}
|
||||
|
||||
virtual bool isVinValidator() const { return false; }
|
||||
@@ -619,7 +619,7 @@ private:
|
||||
template <class Helper> class CNullValidator : CValidatorBase
|
||||
{
|
||||
public:
|
||||
CNullValidator(CC_info* cp)
|
||||
CNullValidator(CCcontract_info* cp)
|
||||
: CValidatorBase(cp) { }
|
||||
|
||||
virtual bool isVinValidator() const { return false; }
|
||||
|
||||
@@ -136,7 +136,7 @@ std::vector<CCcontract_info> &GetCryptoConditions()
|
||||
return vCC;
|
||||
}
|
||||
|
||||
bool GetCCByUnspendableAddress(struct CC_info *cp, char *addrstr)
|
||||
bool GetCCByUnspendableAddress(struct CCcontract_info *cp, char *addrstr)
|
||||
{
|
||||
std::vector<CCcontract_info> &vCC = GetCryptoConditions();
|
||||
bool found = false;
|
||||
@@ -153,7 +153,7 @@ bool GetCCByUnspendableAddress(struct CC_info *cp, char *addrstr)
|
||||
return found;
|
||||
}
|
||||
|
||||
bool CCinitLite(struct CC_info *cp, uint8_t evalcode)
|
||||
bool CCinitLite(struct CCcontract_info *cp, uint8_t evalcode)
|
||||
{
|
||||
std::vector<CCcontract_info> &vCC = GetCryptoConditions();
|
||||
bool found = false;
|
||||
|
||||
Reference in New Issue
Block a user