Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CryptoConditions to use more OO features #444

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ libbitcoin_server_a_SOURCES = \
cc/import.cpp \
cc/importgateway.cpp \
cc/CCassetsCore.cpp \
cc/CCcontract.cpp \
cc/CCcustom.cpp \
cc/CCtx.cpp \
cc/CCutils.cpp \
Expand Down
22 changes: 16 additions & 6 deletions src/cc/CCGateways.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/


#ifndef CC_GATEWAYS_H
#define CC_GATEWAYS_H
#pragma once

#include "CCinclude.h"

bool GatewaysValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);
UniValue GatewaysBind(const CPubKey& pk, uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector<CPubKey> pubkeys,uint8_t p1,uint8_t p2,uint8_t p3,uint8_t p4);
UniValue GatewaysDeposit(const CPubKey& pk, uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vector<uint8_t>proof,CPubKey destpub,int64_t amount);
UniValue GatewaysClaim(const CPubKey& pk, uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount);
Expand All @@ -37,4 +33,18 @@ UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey);
UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey privkey);
UniValue GatewaysList();

#endif
struct CCGatewaysContract_info : public CCcontract_info
{
CCGatewaysContract_info() : CCcontract_info()
{
evalcode = EVAL_GATEWAYS;
strcpy(unspendableCCaddr, "RKWpoK6vTRtq5b9qrRBodLkCzeURHeEk33");
strcpy(normaladdr, "RGJKV97ZN1wBfunuMt1tebiiHENNEq73Yh");
strcpy(CChexstr, "03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40");
uint8_t GatewaysCCpriv[32] = { 0xf7, 0x4b, 0x5b, 0xa2, 0x7a, 0x5e, 0x9c, 0xda, 0x89,
0xb1, 0xcb, 0xb9, 0xe6, 0x9c, 0x2c, 0x70, 0x85, 0x37, 0xdd, 0x00, 0x7a, 0x67,
0xff, 0x7c, 0x62, 0x1b, 0xe2, 0xfb, 0x04, 0x8f, 0x85, 0xbf };
memcpy(CCpriv, GatewaysCCpriv, 32);
}
virtual bool validate(Eval* eval, const CTransaction &tx, uint32_t nIn) override;
};
25 changes: 16 additions & 9 deletions src/cc/CCHeir.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/


#ifndef CC_HEIR_H
#define CC_HEIR_H
#pragma once

#include "CCinclude.h"
#include "CCtokens.h"

//#define EVAL_HEIR 0xea

bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);

class CoinHelper;
class TokenHelper;

Expand All @@ -34,4 +27,18 @@ UniValue HeirAddCaller(uint256 fundingtxid, int64_t txfee, std::string amount);
UniValue HeirInfo(uint256 fundingtxid);
UniValue HeirList();

#endif
struct CCHeirContract_info : public CCcontract_info
{
CCHeirContract_info() : CCcontract_info()
{
evalcode = EVAL_HEIR;
strcpy(unspendableCCaddr, "RDVHcSekmXgeYBqRupNTmqo3Rn8QRXNduy");
strcpy(normaladdr, "RTPwUjKYECcGn6Y4KYChLhgaht1RSU4jwf");
strcpy(CChexstr, "03c91bef3d7cc59c3a89286833a3446b29e52a5e773f738a1ad2b09785e5f4179e");
uint8_t HeirCCpriv[32] = { 0x9d, 0xa1, 0xf8, 0xf7, 0xba, 0x0a, 0x91, 0x36, 0x89, 0x9a,
0x86, 0x30, 0x63, 0x20, 0xd7, 0xdf, 0xaa, 0x35, 0xe3, 0x99, 0x32, 0x2b, 0x63,
0xc0, 0x66, 0x9c, 0x93, 0xc4, 0x5e, 0x9d, 0xb9, 0xce };
memcpy(CCpriv, HeirCCpriv, 32);
}
virtual bool validate(Eval* eval, const CTransaction &tx, uint32_t nIn) override;
};
21 changes: 15 additions & 6 deletions src/cc/CCImportGateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/


#ifndef CC_IMPORTGATEWAY_H
#define CC_IMPORTGATEWAY_H
#pragma once

#include "CCinclude.h"

// CCcustom
bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx, uint32_t nIn);
bool ImportGatewayExactAmounts(bool goDeeper, struct CCcontract_info *cpTokens, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid);
std::string ImportGatewayBind(uint64_t txfee,std::string coin,uint256 oracletxid,uint8_t M,uint8_t N,std::vector<CPubKey> pubkeys,uint8_t p1,uint8_t p2,uint8_t p3,uint8_t p4);
std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 burntxid,int32_t burnvout,std::string rawburntx,std::vector<uint8_t>proof,CPubKey destpub,int64_t amount);
Expand All @@ -34,4 +30,17 @@ UniValue ImportGatewayExternalAddress(uint256 bindtxid,CPubKey pubkey);
UniValue ImportGatewayDumpPrivKey(uint256 bindtxid,CKey key);
UniValue ImportGatewayList();
UniValue ImportGatewayInfo(uint256 bindtxid);
#endif

struct CCImportGatewayContract_info : public CCcontract_info
{
CCImportGatewayContract_info() : CCcontract_info()
{
evalcode = EVAL_IMPORTGATEWAY;
strcpy(unspendableCCaddr, "RXJT6CRAXHFuQ2UjqdxMj7EfrayF6UJpzZ");
strcpy(normaladdr, "RNFRho63Ddz1Rh2eGPETykrU4fA8r67S4Y");
strcpy(CChexstr, "0397231cfe04ea32d5fafb2206773ec9fba6e15c5a4e86064468bca195f7542714");
uint8_t ImportGatewayCCpriv[32] = { 0x65, 0xef, 0x27, 0xeb, 0x3d, 0xb0, 0xb4, 0xae, 0x0f, 0xbc, 0x77, 0xdb, 0xf8, 0x40, 0x48, 0x90, 0x52, 0x20, 0x9e, 0x45, 0x3b, 0x49, 0xd8, 0x97, 0x60, 0x8c, 0x27, 0x4c, 0x59, 0x46, 0xe1, 0xdf };
memcpy(CCpriv, ImportGatewayCCpriv, 32);
}
virtual bool validate(Eval* eval, const CTransaction &tx, uint32_t nIn) override;
};
22 changes: 16 additions & 6 deletions src/cc/CCOracles.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/


#ifndef CC_ORACLES_H
#define CC_ORACLES_H
#pragma once

#include "CCinclude.h"

bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);
UniValue OracleCreate(const CPubKey& pk, int64_t txfee,std::string name,std::string description,std::string format);
UniValue OracleFund(const CPubKey& pk, int64_t txfee,uint256 oracletxid);
UniValue OracleRegister(const CPubKey& pk, int64_t txfee,uint256 oracletxid,int64_t datafee);
Expand All @@ -31,4 +27,18 @@ UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num);
UniValue OracleInfo(uint256 origtxid);
UniValue OraclesList();

#endif
struct CCOraclesContract_info : public CCcontract_info
{
CCOraclesContract_info() : CCcontract_info()
{
evalcode = EVAL_ORACLES;
strcpy(unspendableCCaddr, "REt2C4ZMnX8YYX1DRpffNA4hECZTFm39e3");
strcpy(normaladdr, "RHkFKzn1csxA3fWzAsxsLWohoCgBbirXb5");
strcpy(CChexstr, "038c1d42db6a45a57eccb8981b078fb7857b9b496293fe299d2b8d120ac5b5691a");
uint8_t OraclesCCpriv[32] = { 0xf7, 0x4b, 0x5b, 0xa2, 0x7a, 0x5e, 0x9c, 0xda, 0x89,
0xb1, 0xcb, 0xb9, 0xe6, 0x9c, 0x2c, 0x70, 0x85, 0x37, 0xdd, 0x00, 0x7a,
0x67, 0xff, 0x7c, 0x62, 0x1b, 0xe2, 0xfb, 0x04, 0x8f, 0x85, 0xbf };
memcpy(CCpriv, OraclesCCpriv, 32);
}
virtual bool validate(Eval* eval, const CTransaction &tx, uint32_t nIn) override;
};
24 changes: 16 additions & 8 deletions src/cc/CCPayments.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/


#ifndef CC_PAYMENTS_H
#define CC_PAYMENTS_H
#pragma once

#include "CCinclude.h"
#include <gmp.h>
Expand All @@ -26,8 +23,6 @@
extern std::vector <std::pair<CAmount, CTxDestination>> vAddressSnapshot;
extern int32_t lastSnapShotHeight;

bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);

// CCcustom
UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr);
UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr);
Expand All @@ -39,5 +34,18 @@ UniValue PaymentsAirdropTokens(struct CCcontract_info *cp,char *jsonstr);
UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr);
UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr);

#endif

struct CCPaymentsContract_info : public CCcontract_info
{
CCPaymentsContract_info() : CCcontract_info()
{
evalcode = EVAL_PAYMENTS;
strcpy(unspendableCCaddr, "REpyKi7avsVduqZ3eimncK4uKqSArLTGGK");
strcpy(normaladdr, "RHRX8RTMAh2STWe9DHqsvJbzS7ty6aZy3d");
strcpy(CChexstr, "0358f1764f82c63abc7c7455555fd1d3184905e30e819e97667e247e5792b46856");
uint8_t PaymentsCCpriv[32] = { 0x03, 0xc9, 0x73, 0xc2, 0xb8, 0x30, 0x3d, 0xbd, 0xc8,
0xd9, 0xbf, 0x02, 0x49, 0xd9, 0x65, 0x61, 0x45, 0xed, 0x9e, 0x93, 0x51, 0xab,
0x8b, 0x2e, 0xe7, 0xc7, 0x40, 0xf1, 0xc4, 0xd2, 0xc0, 0x5b };
memcpy(CCpriv, PaymentsCCpriv, 32);
}
virtual bool validate(Eval* eval, const CTransaction &tx, uint32_t nIn) override;
};
21 changes: 16 additions & 5 deletions src/cc/CCPegs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/


#ifndef CC_PEGS_H
#define CC_PEGS_H
#pragma once

#include "CCinclude.h"

Expand All @@ -33,4 +30,18 @@ UniValue PegsAccountInfo(const CPubKey& pk,uint256 pegstxid);
UniValue PegsWorstAccounts(uint256 pegstxid);
UniValue PegsInfo(uint256 pegstxid);

#endif
struct CCPegsContract_info : public CCcontract_info
{
CCPegsContract_info() : CCcontract_info()
{
evalcode = EVAL_PEGS;
strcpy(unspendableCCaddr, "RHnkVb7vHuHnjEjhkCF1bS6xxLLNZPv5fd");
strcpy(normaladdr, "RMcCZtX6dHf1fz3gpLQhUEMQ8cVZ6Rzaro");
strcpy(CChexstr, "03c75c1de29a35e41606363b430c08be1c2dd93cf7a468229a082cc79c7b77eece");
uint8_t PegsCCpriv[32] = { 0x52, 0x56, 0x4c, 0x78, 0x87, 0xf7, 0xa2, 0x39, 0xb0, 0x90,
0xb7, 0xb8, 0x62, 0x80, 0x0f, 0x83, 0x18, 0x9d, 0xf4, 0xf4, 0xbd, 0x28, 0x09,
0xa9, 0x9b, 0x85, 0x54, 0x16, 0x0f, 0x3f, 0xfb, 0x65 };
memcpy(CCpriv, PegsCCpriv, 32);
}
virtual bool validate(Eval* eval, const CTransaction &tx, uint32_t nIn) override;
};
24 changes: 16 additions & 8 deletions src/cc/CCPrices.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/


#ifndef CC_PRICES_H
#define CC_PRICES_H
#pragma once

#include "komodo_defs.h"
#include "CCinclude.h"
Expand Down Expand Up @@ -46,8 +43,6 @@ extern CScript KOMODO_EARLYTXID_SCRIPTPUB;
#define PRICES_SUBREVSHAREFEE(amount) ((amount) * 199 / 200) // revshare fee percentage == 0.005
#define PRICES_MINAVAILFUNDFRACTION 0.1 // leveraged bet limit < fund fraction

bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);

// CCcustom
UniValue PricesBet(int64_t txfee,int64_t amount,int16_t leverage,std::vector<std::string> synthetic);
UniValue PricesAddFunding(int64_t txfee,uint256 bettxid,int64_t amount);
Expand All @@ -59,5 +54,18 @@ UniValue PricesList(uint32_t filter, CPubKey mypk);
UniValue PricesGetOrderbook();
UniValue PricesRefillFund(int64_t amount);


#endif
struct CCPricesContract_info : public CCcontract_info
{
CCPricesContract_info() : CCcontract_info()
{
evalcode = EVAL_PRICES;
strcpy(unspendableCCaddr, "RAL5Vh8NXmFqEKJRKrk1KjKaUckK7mM1iS");
strcpy(normaladdr, "RBunXCsMHk5NPd6q8SQfmpgre3x133rSwZ");
strcpy(CChexstr, "039894cb054c0032e99e65e715b03799607aa91212a16648d391b6fa2cc52ed0cf");
uint8_t PricesCCpriv[32] = { 0x0a, 0x3b, 0xe7, 0x5d, 0xce, 0x06, 0xed, 0xb7, 0xc0,
0xb1, 0xbe, 0xe8, 0x7b, 0x5a, 0xd4, 0x99, 0xb8, 0x8d, 0xde, 0xac, 0xb2, 0x7e,
0x7a, 0x52, 0x96, 0x15, 0xd2, 0xa0, 0xc6, 0xb9, 0x89, 0x61 };
memcpy(CCpriv, PricesCCpriv, 32);
}
virtual bool validate(Eval* eval, const CTransaction &tx, uint32_t nIn) override;
};
29 changes: 19 additions & 10 deletions src/cc/CCassets.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#pragma once


/*
Expand All @@ -20,11 +21,10 @@
CCassetsCore has functions that are used in two contexts, both during rpc transaction create time and also during the blockchain validation. Using the identical functions is a good way to prevent them from being mismatched. The must match or the transaction will get rejected.
*/

#ifndef CC_ASSETS_H
#define CC_ASSETS_H

#include "CCinclude.h"

#include "CCtokens.h"

// CCcustom
bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);

Expand All @@ -44,15 +44,9 @@ int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpp
bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid);

// CCassetstx
//int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); // --> GetTokenBalance()
int64_t AddAssetInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs);

UniValue AssetOrders(uint256 tokenid, CPubKey pubkey, uint8_t additionalEvalCode);
//UniValue AssetInfo(uint256 tokenid);
//UniValue AssetList();
//std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description);
//std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector<uint8_t> destpubkey,int64_t total);
//std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector<uint8_t> destpubkey,int64_t total,int32_t evalcode);

std::string CreateBuyOffer(int64_t txfee,int64_t bidamount,uint256 assetid,int64_t pricetotal);
std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid);
Expand All @@ -62,4 +56,19 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a
std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid);
std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 asktxid,int64_t fillamount);

#endif
struct CCAssetContract_info : public CCcontract_info
{
CCAssetContract_info() : CCcontract_info()
{
evalcode = EVAL_ASSETS;
strcpy(unspendableCCaddr, "RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6");
strcpy(normaladdr, "RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u");
strcpy(CChexstr, "02adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702");
uint8_t AssetsCCpriv[32] = { 0x9b, 0x17, 0x66, 0xe5, 0x82, 0x66, 0xac, 0xb6, 0xba, 0x43,
0x83, 0x74, 0xf7, 0x63, 0x11, 0x3b, 0xf0, 0xf3, 0x50, 0x6f, 0xd9, 0x6b, 0x67,
0x85, 0xf9, 0x7a, 0xf0, 0x54, 0x4d, 0xb1, 0x30, 0x77 };
memcpy(CCpriv, AssetsCCpriv,32);
}
virtual bool validate(Eval* eval, const CTransaction &tx, uint32_t nIn) override;
};

26 changes: 11 additions & 15 deletions src/cc/CCassetsCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,15 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp, char *origCCaddr, char *origN
return(false);

bool bGetCCaddr = false;
struct CCcontract_info *cpTokens, tokensC;
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
CCTokensContract_info tokensC;

if (vintxFuncId == 's' || vintxFuncId == 'S') {
// bGetCCaddr = GetCCaddress(cpTokens, origCCaddr, pubkey2pk(origpubkey));
cpTokens->additionalTokensEvalcode2 = cp->additionalTokensEvalcode2; // add non-fungible if present
bGetCCaddr = GetTokensCCaddress(cpTokens, origCCaddr, pubkey2pk(origpubkey)); // tokens to single-eval token or token+nonfungible
tokensC.additionalTokensEvalcode2 = tokensC.additionalTokensEvalcode2; // add non-fungible if present
bGetCCaddr = GetTokensCCaddress(&tokensC, origCCaddr, pubkey2pk(origpubkey)); // tokens to single-eval token or token+nonfungible
}
else if (vintxFuncId == 'b' || vintxFuncId == 'B') {
cpTokens->additionalTokensEvalcode2 = cp->additionalTokensEvalcode2; // add non-fungible if present
bGetCCaddr = GetTokensCCaddress(cpTokens, origCCaddr, pubkey2pk(origpubkey)); // tokens to single-eval token or token+nonfungible
tokensC.additionalTokensEvalcode2 = tokensC.additionalTokensEvalcode2; // add non-fungible if present
bGetCCaddr = GetTokensCCaddress(&tokensC, origCCaddr, pubkey2pk(origpubkey)); // tokens to single-eval token or token+nonfungible
}
else {
std::cerr << "GetAssetorigaddrs incorrect vintx funcid=" << (char)(vintxFuncId?vintxFuncId:' ') << std::endl;
Expand Down Expand Up @@ -439,7 +437,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *origCCadd
// if fillSell or cancelSell --> should spend tokens from dual-eval token-assets unspendable addr
else if( (funcid == 'S' || funcid == 'x') &&
(Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 ||
!GetTokensCCaddress(cp, unspendableAddr, GetUnspendable(cp, NULL)) ||
!GetTokensCCaddress(cp, unspendableAddr, cp->GetUnspendable()) ||
strcmp(destaddr, unspendableAddr) != 0))
{
fprintf(stderr,"AssetValidateCCvin() cc addr %s is not dual token-evalcode=0x%02x asset unspendable addr %s\n", destaddr, (int)cp->evalcode, unspendableAddr);
Expand All @@ -448,7 +446,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *origCCadd
// if fillBuy or cancelBuy --> should spend coins from asset unspendable addr
else if ((funcid == 'B' || funcid == 'o') &&
(Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 ||
!GetCCaddress(cp, unspendableAddr, GetUnspendable(cp, NULL)) ||
!GetCCaddress(cp, unspendableAddr, cp->GetUnspendable()) ||
strcmp(destaddr, unspendableAddr) != 0))
{
fprintf(stderr, "AssetValidateCCvin() cc addr %s is not evalcode=0x%02x asset unspendable addr %s\n", destaddr, (int)cp->evalcode, unspendableAddr);
Expand Down Expand Up @@ -599,13 +597,11 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t
int32_t numvouts = tx.vout.size();
inputs = outputs = 0;

struct CCcontract_info *cpTokens, C;

cpTokens = CCinit(&C, EVAL_TOKENS);
CCTokensContract_info C;

for (int32_t i = 0; i<numvins; i++)
{ // only tokens are relevant!!
if (/*(*cpAssets->ismyvin)(tx.vin[i].scriptSig)*/ (*cpTokens->ismyvin)(tx.vin[i].scriptSig) ) // || IsVinAllowed(tx.vin[i].scriptSig) != 0)
{
if (C.ismyvin(tx.vin[i].scriptSig) )
{
//std::cerr << indentStr << "AssetExactAmounts() eval is true=" << (eval != NULL) << " ismyvin=ok for_i=" << i << std::endl;
// we are not inside the validation code -- dimxy
Expand All @@ -622,7 +618,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t
std::vector<CPubKey> vinPubkeysEmpty;

// TODO: maybe we do not need call to IsTokensVout here, cause we've already selected token vins
assetoshis = IsTokensvout(false, false, cpTokens, NULL, vinTx, tx.vin[i].prevout.n, assetid);
assetoshis = IsTokensvout(false, false, &C, NULL, vinTx, tx.vin[i].prevout.n, assetid);
if (assetoshis != 0)
{
//std::cerr << "AssetCalcAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl;
Expand Down
Loading