From bfce0c18b87635acdf856f4274ce90910156b56c Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 12 Jan 2019 16:11:04 +0500 Subject: [PATCH] getMyEval() resurrection --- src/cc/CCtokens.cpp | 10 +++++----- src/cc/heir.cpp | 2 +- src/cc/heir_validate.h | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 167a0a241..939f1e7d7 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -108,7 +108,7 @@ uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCode, uint256 funcId = script[1]; //fprintf(stderr,"decode.[%c]\n",funcId); - switch ( funcId ) + switch( funcId ) { case 'c': return DecodeTokenCreateOpRet(scriptPubKey, dummyPubkey, dummyName, dummyDescription); @@ -366,7 +366,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c // moved opret checking to this new reusable func (dimxy): std::vector voutPubkeys; const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra); - std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << funcId << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; + std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; if (funcId != 0) { std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned not-null" << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl; @@ -490,7 +490,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t // add inputs from token cc addr int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs) { - char coinaddr[64], destaddr[64]; + char tokenaddr[64], destaddr[64]; int64_t threshold, nValue, price, totalinputs = 0; uint256 txid, hashBlock; std::vector vopretExtra; @@ -498,8 +498,8 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C int32_t j, vout, n = 0; std::vector > unspentOutputs; - GetCCaddress(cp, coinaddr, pk); - SetCCunspents(unspentOutputs, coinaddr); + GetTokensCCaddress(cp, tokenaddr, pk); + SetCCunspents(unspentOutputs, tokenaddr); threshold = total / (maxinputs != 0 ? maxinputs : 64); // TODO: is maxinputs really could not be over 64? what if i want to calc total balance? diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 784e0a88c..5e9eb4362 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -725,7 +725,7 @@ template std::string HeirFund(uint64_t txfee, int64_t amount, CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); struct CCcontract_info *cp, C; - cp = CCinit(&C, EVAL_HEIR); + cp = CCinit(&C, Helper::getMyEval()); if (txfee == 0) txfee = 10000; diff --git a/src/cc/heir_validate.h b/src/cc/heir_validate.h index 0094f5f4c..88d1d2745 100644 --- a/src/cc/heir_validate.h +++ b/src/cc/heir_validate.h @@ -29,6 +29,7 @@ inline static bool isSpendingTx(uint8_t funcid) { return (funcid == 'C'); } class CoinHelper { public: + static uint8_t getMyEval() { return EVAL_HEIR; } static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 dummyid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { return AddNormalinputs(mtx, ownerPubkey, total, maxinputs); } @@ -62,6 +63,7 @@ public: // helper class to allow polymorphic behaviour for HeirXXX() functions in case of tokens class TokenHelper { public: + static uint8_t getMyEval() { return EVAL_TOKENS; } static int64_t addOwnerInputs(struct CCcontract_info* cp, uint256 tokenid, CMutableTransaction& mtx, CPubKey ownerPubkey, int64_t total, int32_t maxinputs) { return AddTokenCCInputs(cp, mtx, ownerPubkey, tokenid, total, maxinputs); }