more debug logging removed
This commit is contained in:
@@ -617,7 +617,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t
|
|||||||
std::vector<CPubKey> vinPubkeysEmpty;
|
std::vector<CPubKey> vinPubkeysEmpty;
|
||||||
|
|
||||||
// TODO: maybe we do not need call to IsTokensVout here, cause we've already selected token vins
|
// TODO: maybe we do not need call to IsTokensVout here, cause we've already selected token vins
|
||||||
assetoshis = IsTokensvout(false, false, cpTokens, NULL, /* vopretExtra,*/ vinTx, tx.vin[i].prevout.n, assetid, vinPubkeysEmpty);
|
assetoshis = IsTokensvout(false, false, cpTokens, NULL, vinTx, tx.vin[i].prevout.n, assetid);
|
||||||
if (assetoshis != 0)
|
if (assetoshis != 0)
|
||||||
{
|
{
|
||||||
std::cerr << "AssetCalcAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl;
|
std::cerr << "AssetCalcAmounts() vin i=" << i << " assetoshis=" << assetoshis << std::endl;
|
||||||
|
|||||||
@@ -630,9 +630,8 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f
|
|||||||
if (inputs > fillamount)
|
if (inputs > fillamount)
|
||||||
CCchange = (inputs - fillamount);
|
CCchange = (inputs - fillamount);
|
||||||
|
|
||||||
//CPubKey unspendableTokensPk = GetUnspendable(cpTokens, NULL);
|
|
||||||
uint8_t unspendableAssetsPrivkey[32];
|
uint8_t unspendableAssetsPrivkey[32];
|
||||||
cpAssets = CCinit(&assetsC, EVAL_ASSETS); //???
|
cpAssets = CCinit(&assetsC, EVAL_ASSETS);
|
||||||
CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey);
|
CPubKey unspendableAssetsPk = GetUnspendable(cpAssets, unspendableAssetsPrivkey);
|
||||||
|
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // vout0 coins remainder
|
mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // vout0 coins remainder
|
||||||
@@ -745,7 +744,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a
|
|||||||
//mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); //vout.2 tokens... (swap is not implemented yet)
|
//mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, paid_nValue, origpubkey)); //vout.2 tokens... (swap is not implemented yet)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl;
|
//std::cerr << "FillSell() paid_value=" << paid_nValue << " origpubkey=" << HexStr(pubkey2pk(origpubkey)) << std::endl;
|
||||||
mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //vout.2 coins to tokens seller's normal addr
|
mtx.vout.push_back(CTxOut(paid_nValue, CScript() << origpubkey << OP_CHECKSIG)); //vout.2 coins to tokens seller's normal addr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ uint256 OraclesBatontxid(uint256 oracletxid,CPubKey pk);
|
|||||||
|
|
||||||
//int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs);
|
//int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs);
|
||||||
int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs);
|
int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 tokenid, int64_t total, int32_t maxinputs);
|
||||||
int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, /*std::vector<uint8_t> &origpubkey,*/ const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector<CPubKey> vinPubkeys);
|
int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid);
|
||||||
|
|
||||||
bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx);
|
bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx);
|
||||||
CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector<uint8_t> origpubkey);
|
CScript EncodeAssetOpRet(uint8_t assetFuncId, uint256 assetid2, int64_t price, std::vector<uint8_t> origpubkey);
|
||||||
|
|||||||
@@ -353,12 +353,12 @@ uint8_t ValidateTokenOpret(CTransaction tx, int32_t v, uint256 tokenid, std::vec
|
|||||||
// goDeeper is true: the func also validates amounts of the passed transaction:
|
// goDeeper is true: the func also validates amounts of the passed transaction:
|
||||||
// it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx
|
// it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx
|
||||||
// checkPubkeys is true: validates if the vout is token vout1 or token vout1of2. Should always be true!
|
// checkPubkeys is true: validates if the vout is token vout1 or token vout1of2. Should always be true!
|
||||||
int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, /*std::vector<uint8_t> &vopretExtra,*/ const CTransaction& tx, int32_t v, uint256 reftokenid, std::vector<CPubKey> vinPubkeys000)
|
int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *cp, Eval* eval, const CTransaction& tx, int32_t v, uint256 reftokenid)
|
||||||
{
|
{
|
||||||
|
|
||||||
// this is just for log messages indentation fur debugging recursive calls:
|
// this is just for log messages indentation fur debugging recursive calls:
|
||||||
std::string indentStr = std::string().append(tokenValIndentSize, '.');
|
std::string indentStr = std::string().append(tokenValIndentSize, '.');
|
||||||
std::cerr << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl;
|
//std::cerr << indentStr << "IsTokensvout() entered for txid=" << tx.GetHash().GetHex() << " v=" << v << " for tokenid=" << reftokenid.GetHex() << std::endl;
|
||||||
|
|
||||||
//TODO: validate cc vouts are EVAL_TOKENS!
|
//TODO: validate cc vouts are EVAL_TOKENS!
|
||||||
if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition()) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here
|
if (tx.vout[v].scriptPubKey.IsPayToCryptoCondition()) // maybe check address too? dimxy: possibly no, because there are too many cases with different addresses here
|
||||||
@@ -393,7 +393,6 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c
|
|||||||
// moved opret checking to this new reusable func (dimxy):
|
// moved opret checking to this new reusable func (dimxy):
|
||||||
std::vector<CPubKey> voutPubkeys;
|
std::vector<CPubKey> voutPubkeys;
|
||||||
std::vector<uint8_t> vopretExtra;
|
std::vector<uint8_t> vopretExtra;
|
||||||
//std::vector<uint8_t> vcontractOpret;
|
|
||||||
const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra);
|
const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra);
|
||||||
//std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl;
|
//std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl;
|
||||||
if (funcId != 0) {
|
if (funcId != 0) {
|
||||||
@@ -401,11 +400,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c
|
|||||||
|
|
||||||
if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!):
|
if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!):
|
||||||
|
|
||||||
//CScript contractScript = CScript(vopretExtra);
|
//std::cerr << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl;
|
||||||
//GetOpReturnData(contractScript, vcontractOpret);
|
|
||||||
|
|
||||||
std::cerr << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl;
|
|
||||||
//std::cerr << "IsTokensvout() vcontractOpret=" << HexStr(vcontractOpret) << std::endl;;
|
|
||||||
|
|
||||||
uint8_t evalCodeInOpret;
|
uint8_t evalCodeInOpret;
|
||||||
if (vopretExtra.size() >= 2 /*|| vopretExtra.size() != vopretExtra.begin()[0] <-- shold we check this?*/) {
|
if (vopretExtra.size() >= 2 /*|| vopretExtra.size() != vopretExtra.begin()[0] <-- shold we check this?*/) {
|
||||||
@@ -448,7 +443,7 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c
|
|||||||
CTxOut testTokenVout1;
|
CTxOut testTokenVout1;
|
||||||
testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]);
|
testTokenVout1 = MakeCC1vout(EVAL_TOKENS, tx.vout[v].nValue, voutPubkeys[0]);
|
||||||
if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) {
|
if (tx.vout[v].scriptPubKey == testTokenVout1.scriptPubKey) {
|
||||||
std::cerr << indentStr << "IsTokensvout() this is single-eval token vout (i=0), returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl;
|
//std::cerr << indentStr << "IsTokensvout() this is single-eval token vout (i=0), returning nValue=" << tx.vout[v].nValue << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl;
|
||||||
return tx.vout[v].nValue;
|
return tx.vout[v].nValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,11 +491,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c
|
|||||||
bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid)
|
bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inputs, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 tokenid)
|
||||||
{
|
{
|
||||||
CTransaction vinTx;
|
CTransaction vinTx;
|
||||||
uint256 hashBlock; //, id, id2;
|
uint256 hashBlock;
|
||||||
//int32_t flag;
|
|
||||||
int64_t tokenoshis;
|
int64_t tokenoshis;
|
||||||
// std::vector<uint8_t> tmporigpubkey; int64_t tmpprice;
|
|
||||||
std::vector<CPubKey> vinPubkeys000;
|
|
||||||
|
|
||||||
struct CCcontract_info *cpTokens, tokensC;
|
struct CCcontract_info *cpTokens, tokensC;
|
||||||
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
|
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
|
||||||
@@ -512,8 +504,6 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu
|
|||||||
// this is just for log messages indentation for debugging recursive calls:
|
// this is just for log messages indentation for debugging recursive calls:
|
||||||
std::string indentStr = std::string().append(tokenValIndentSize, '.');
|
std::string indentStr = std::string().append(tokenValIndentSize, '.');
|
||||||
|
|
||||||
//ExtractTokensVinPubkeys(tx, vinPubkeys);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i<numvins; i++)
|
for (int32_t i = 0; i<numvins; i++)
|
||||||
{ // check for additional contracts which may send tokens to the Tokens contract
|
{ // check for additional contracts which may send tokens to the Tokens contract
|
||||||
if ((*cpTokens->ismyvin)(tx.vin[i].scriptSig) /*|| IsVinAllowed(tx.vin[i].scriptSig) != 0*/)
|
if ((*cpTokens->ismyvin)(tx.vin[i].scriptSig) /*|| IsVinAllowed(tx.vin[i].scriptSig) != 0*/)
|
||||||
@@ -528,8 +518,8 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu
|
|||||||
else {
|
else {
|
||||||
tokenValIndentSize++;
|
tokenValIndentSize++;
|
||||||
// validate vouts of vintx
|
// validate vouts of vintx
|
||||||
std::cerr << indentStr << "TokenExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl;
|
//std::cerr << indentStr << "TokenExactAmounts() check vin i=" << i << " nValue=" << vinTx.vout[tx.vin[i].prevout.n].nValue << std::endl;
|
||||||
tokenoshis = IsTokensvout(goDeeper, true, cpTokens, eval, /*tmporigpubkey,*/ vinTx, tx.vin[i].prevout.n, tokenid, vinPubkeys000);
|
tokenoshis = IsTokensvout(goDeeper, true, cpTokens, eval, vinTx, tx.vin[i].prevout.n, tokenid);
|
||||||
tokenValIndentSize--;
|
tokenValIndentSize--;
|
||||||
if (tokenoshis != 0)
|
if (tokenoshis != 0)
|
||||||
{
|
{
|
||||||
@@ -547,7 +537,7 @@ bool TokensExactAmounts(bool goDeeper, struct CCcontract_info *cp, int64_t &inpu
|
|||||||
// Note: we pass in here 'false' because we don't need to call TokenExactAmounts() recursively from IsTokensvout
|
// Note: we pass in here 'false' because we don't need to call TokenExactAmounts() recursively from IsTokensvout
|
||||||
// indeed, in this case we'll be checking this tx again
|
// indeed, in this case we'll be checking this tx again
|
||||||
//std::cerr << indentStr << "TokenExactAmounts() check vout i=" << i << " nValue=" << tx.vout[i].nValue << std::endl;
|
//std::cerr << indentStr << "TokenExactAmounts() check vout i=" << i << " nValue=" << tx.vout[i].nValue << std::endl;
|
||||||
tokenoshis = IsTokensvout(false, true /*<--exclude non-tokens vouts*/, cpTokens, eval,/* tmporigpubkey,*/ tx, i, tokenid, vinPubkeys000);
|
tokenoshis = IsTokensvout(false, true /*<--exclude non-tokens vouts*/, cpTokens, eval, tx, i, tokenid);
|
||||||
tokenValIndentSize--;
|
tokenValIndentSize--;
|
||||||
|
|
||||||
if (tokenoshis != 0)
|
if (tokenoshis != 0)
|
||||||
@@ -601,11 +591,11 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C
|
|||||||
Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey);
|
Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey);
|
||||||
if (strcmp(destaddr, tokenaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0)
|
if (strcmp(destaddr, tokenaddr) != 0 && strcmp(destaddr, cp->unspendableCCaddr) != 0 && strcmp(destaddr, cp->unspendableaddr2) != 0)
|
||||||
continue;
|
continue;
|
||||||
fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN);
|
//fprintf(stderr, "AddTokenCCInputs() check destaddress=%s vout amount=%.8f\n", destaddr, (double)vintx.vout[vout].nValue / COIN);
|
||||||
|
|
||||||
std::vector<CPubKey> vinPubkeys;
|
std::vector<CPubKey> vinPubkeys;
|
||||||
|
|
||||||
if ((nValue = IsTokensvout(true, true/*<--add only checked uxtos */, cp, NULL, /*vopretExtra,*/ vintx, vout, tokenid, vinPubkeys)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0)
|
if ((nValue = IsTokensvout(true, true/*<--add only checked token uxtos */, cp, NULL, vintx, vout, tokenid)) > 0 && myIsutxo_spentinmempool(txid, vout) == 0)
|
||||||
{
|
{
|
||||||
if (total != 0 && maxinputs != 0)
|
if (total != 0 && maxinputs != 0)
|
||||||
mtx.vin.push_back(CTxIn(txid, vout, CScript()));
|
mtx.vin.push_back(CTxIn(txid, vout, CScript()));
|
||||||
|
|||||||
@@ -540,7 +540,6 @@ template <class Helper> int64_t Add1of2AddressInputs(struct CCcontract_info* cp,
|
|||||||
uint256 tokenid;
|
uint256 tokenid;
|
||||||
uint256 fundingTxidInOpret;
|
uint256 fundingTxidInOpret;
|
||||||
uint8_t hasHeirSpendingBegunDummy;
|
uint8_t hasHeirSpendingBegunDummy;
|
||||||
std::vector<CPubKey> vinPubkeysEmpty;
|
|
||||||
|
|
||||||
CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary
|
CScript heirScript = (heirtx.vout.size() > 0) ? heirtx.vout[heirtx.vout.size() - 1].scriptPubKey : CScript(); // check boundary
|
||||||
uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false);
|
uint8_t funcId = DecodeHeirEitherOpRet(heirScript, tokenid, fundingTxidInOpret, hasHeirSpendingBegunDummy, false);
|
||||||
@@ -548,7 +547,7 @@ template <class Helper> int64_t Add1of2AddressInputs(struct CCcontract_info* cp,
|
|||||||
if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) &&
|
if ((txid == fundingtxid || fundingTxidInOpret == fundingtxid) &&
|
||||||
funcId != 0 &&
|
funcId != 0 &&
|
||||||
isMyFuncId(funcId) &&
|
isMyFuncId(funcId) &&
|
||||||
(typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid, vinPubkeysEmpty) > 0) && // token validation logic
|
(typeid(Helper) != typeid(TokenHelper) || IsTokensvout(true, true, cp, nullptr, heirtx, voutIndex, tokenid) > 0) && // token validation logic
|
||||||
//(voutValue = IsHeirFundingVout<Helper>(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && // heir contract vout validation logic - not used since we moved to 2-eval vouts
|
//(voutValue = IsHeirFundingVout<Helper>(cp, heirtx, voutIndex, ownerPubkey, heirPubkey)) > 0 && // heir contract vout validation logic - not used since we moved to 2-eval vouts
|
||||||
!myIsutxo_spentinmempool(txid, voutIndex))
|
!myIsutxo_spentinmempool(txid, voutIndex))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user