corr userCCaddr calc
This commit is contained in:
@@ -365,7 +365,7 @@ bool SetAssetOrigpubkey(std::vector<uint8_t> &origpubkey,int64_t &price,const CT
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate sell/buy owner's source token/asset address from ask/bid tx
|
// Calculate sell/buy owner's source token/asset address from ask/bid tx
|
||||||
bool GetAssetorigaddrs(struct CCcontract_info *cp, char *CCaddr, char *destaddr, const CTransaction& tx)
|
bool GetAssetorigaddrs(struct CCcontract_info *cp, char *userCCaddr, char *destaddr, const CTransaction& tx)
|
||||||
{
|
{
|
||||||
uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid;
|
uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid;
|
||||||
std::vector<uint8_t> origpubkey;
|
std::vector<uint8_t> origpubkey;
|
||||||
@@ -377,12 +377,16 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp, char *CCaddr, char *destaddr,
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
bool bGetCCaddr = false;
|
bool bGetCCaddr = false;
|
||||||
if (funcid == 's' || funcid == 'S')
|
if (funcid == 's' || funcid == 'S') {
|
||||||
bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey));
|
struct CCcontract_info *cpTokens, tokensC;
|
||||||
|
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
|
||||||
|
bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey));
|
||||||
|
//bGetCCaddr = GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey));
|
||||||
|
}
|
||||||
else if (funcid == 'b' || funcid == 'B') {
|
else if (funcid == 'b' || funcid == 'B') {
|
||||||
struct CCcontract_info *cpTokens, tokensC;
|
struct CCcontract_info *cpTokens, tokensC;
|
||||||
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
|
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
|
||||||
bGetCCaddr = GetCCaddress(cpTokens, CCaddr, pubkey2pk(origpubkey));
|
bGetCCaddr = GetCCaddress(cpTokens, userCCaddr, pubkey2pk(origpubkey));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cerr << "GetAssetorigaddrs incorrect funcid=" << (char)(funcid?funcid:' ') << std::endl;
|
std::cerr << "GetAssetorigaddrs incorrect funcid=" << (char)(funcid?funcid:' ') << std::endl;
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ bool ConstrainVout(CTxOut vout, int32_t CCflag, char *cmpaddr, int64_t nValue)
|
|||||||
}
|
}
|
||||||
else if ( cmpaddr != 0 && (Getscriptaddress(destaddr, vout.scriptPubKey) == 0 || strcmp(destaddr, cmpaddr) != 0) )
|
else if ( cmpaddr != 0 && (Getscriptaddress(destaddr, vout.scriptPubKey) == 0 || strcmp(destaddr, cmpaddr) != 0) )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"constrain vout error addr %s vs %s\n", cmpaddr!=0?cmpaddr:"", destaddr!=0?destaddr:"");
|
fprintf(stderr,"constrain vout error: check addr %s vs script addr %s\n", cmpaddr!=0?cmpaddr:"", destaddr!=0?destaddr:"");
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
else if ( nValue != 0 && nValue != vout.nValue ) //(nValue == 0 && vout.nValue < 10000) || (
|
else if ( nValue != 0 && nValue != vout.nValue ) //(nValue == 0 && vout.nValue < 10000) || (
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts;
|
int32_t i,starti,numvins,numvouts,preventCCvins,preventCCvouts;
|
||||||
int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector<uint8_t> origpubkey,tmporigpubkey,ignorepubkey;
|
int64_t remaining_price,nValue,assetoshis,outputs,inputs,tmpprice,totalunits,ignore; std::vector<uint8_t> origpubkey,tmporigpubkey,ignorepubkey;
|
||||||
uint8_t funcid, evalCodeInOpret;
|
uint8_t funcid, evalCodeInOpret;
|
||||||
char destaddr[64], origaddr[64], assetsCCaddr[64], tokensCCaddr[64], signleEvalTokensCCaddr[64];
|
char destaddr[64], origaddr[64], assetsCCaddr[64], userTokensCCaddr[64], signleEvalTokensCCaddr[64];
|
||||||
|
|
||||||
//return true;
|
//return true;
|
||||||
|
|
||||||
@@ -146,6 +146,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
outputs = inputs = 0;
|
outputs = inputs = 0;
|
||||||
preventCCvins = preventCCvouts = -1;
|
preventCCvins = preventCCvouts = -1;
|
||||||
|
|
||||||
|
if (numvouts == 0)
|
||||||
|
return eval->Invalid("AssetValidate: no vouts");
|
||||||
|
|
||||||
if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 )
|
if((funcid = DecodeAssetTokenOpRet(tx.vout[numvouts-1].scriptPubKey, evalCodeInOpret, assetid, assetid2, remaining_price, origpubkey)) == 0 )
|
||||||
return eval->Invalid("AssetValidate: invalid opreturn payload");
|
return eval->Invalid("AssetValidate: invalid opreturn payload");
|
||||||
|
|
||||||
@@ -322,9 +325,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
//vout.2: normal output for change (if any)
|
//vout.2: normal output for change (if any)
|
||||||
//vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid]
|
//vout.n-1: opreturn [EVAL_ASSETS] ['x'] [assetid]
|
||||||
|
|
||||||
if( (assetoshis = AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) // NOTE:
|
if( (assetoshis = AssetValidateSellvin(cpAssets, eval, tmpprice, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) // NOTE:
|
||||||
return(false);
|
return(false);
|
||||||
else if( ConstrainVout(tx.vout[0], 1, signleEvalTokensCCaddr, assetoshis) == 0 )
|
else if( ConstrainVout(tx.vout[0], 1, userTokensCCaddr, assetoshis) == 0 )
|
||||||
return eval->Invalid("invalid vout for cancel");
|
return eval->Invalid("invalid vout for cancel");
|
||||||
preventCCvins = 3;
|
preventCCvins = 3;
|
||||||
preventCCvouts = 1;
|
preventCCvouts = 1;
|
||||||
@@ -340,7 +343,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
//vout.3: normal output for change (if any)
|
//vout.3: normal output for change (if any)
|
||||||
//'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey]
|
//'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey]
|
||||||
|
|
||||||
if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 )
|
if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 )
|
||||||
return(false);
|
return(false);
|
||||||
else if( numvouts < 3 )
|
else if( numvouts < 3 )
|
||||||
return eval->Invalid("not enough vouts for fillask");
|
return eval->Invalid("not enough vouts for fillask");
|
||||||
@@ -384,7 +387,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
// eval->Invalid("asset2 inputs != outputs");
|
// eval->Invalid("asset2 inputs != outputs");
|
||||||
|
|
||||||
////////// not implemented yet ////////////
|
////////// not implemented yet ////////////
|
||||||
if( (assetoshis= AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 )
|
if( (assetoshis= AssetValidateSellvin(cpTokens, eval, totalunits, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 )
|
||||||
return(false);
|
return(false);
|
||||||
else if( numvouts < 3 )
|
else if( numvouts < 3 )
|
||||||
return eval->Invalid("not enough vouts for fillex");
|
return eval->Invalid("not enough vouts for fillex");
|
||||||
@@ -397,7 +400,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||||
////////// not implemented yet ////////////
|
////////// not implemented yet ////////////
|
||||||
{
|
{
|
||||||
if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, 0) == 0 )
|
if( ConstrainVout(tx.vout[2], 1, userTokensCCaddr, 0) == 0 )
|
||||||
return eval->Invalid("vout2 doesnt go to origpubkey fillex");
|
return eval->Invalid("vout2 doesnt go to origpubkey fillex");
|
||||||
else if( inputs != tx.vout[2].nValue + tx.vout[3].nValue )
|
else if( inputs != tx.vout[2].nValue + tx.vout[3].nValue )
|
||||||
{
|
{
|
||||||
@@ -406,7 +409,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
////////// not implemented yet ////////////
|
////////// not implemented yet ////////////
|
||||||
else if( ConstrainVout(tx.vout[2], 1, tokensCCaddr, inputs) == 0 )
|
else if( ConstrainVout(tx.vout[2], 1, userTokensCCaddr, inputs) == 0 )
|
||||||
return eval->Invalid("vout2 doesnt match inputs fillex");
|
return eval->Invalid("vout2 doesnt match inputs fillex");
|
||||||
else if( ConstrainVout(tx.vout[1], 0, 0, 0) == 0 )
|
else if( ConstrainVout(tx.vout[1], 0, 0, 0) == 0 )
|
||||||
return eval->Invalid("vout1 is CC for fillex");
|
return eval->Invalid("vout1 is CC for fillex");
|
||||||
|
|||||||
Reference in New Issue
Block a user