From 5a4fd8b15eb6e69edc56884cf06622b7a50873d3 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 18 Jan 2019 17:56:59 +0700 Subject: [PATCH 1/3] fixed token tests --- qa/rpc-tests/cryptoconditions_token.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 630d8f6e3..254868670 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -18,18 +18,29 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): rpc = self.nodes[0] result = rpc.tokenaddress() assert_success(result) - for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress']: + for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress']: assert_equal(result[x][0], 'R') result = rpc.tokenaddress(self.pubkey) assert_success(result) + for x in ['TokensCCaddress', 'myCCaddress', 'Tokensmarker', 'myaddress', 'CCaddress']: + assert_equal(result[x][0], 'R') + + result = rpc.assetsaddress() + assert_success(result) + for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress']: + assert_equal(result[x][0], 'R') + + result = rpc.assetsaddress(self.pubkey) + assert_success(result) for x in ['AssetsCCaddress', 'myCCaddress', 'Assetsmarker', 'myaddress', 'CCaddress']: assert_equal(result[x][0], 'R') + # there are no tokens created yet result = rpc.tokenlist() assert_equal(result, []) - # trying to create token with negaive supply + # trying to create token with negative supply result = rpc.tokencreate("NUKE", "-1987420", "no bueno supply") assert_error(result) @@ -50,12 +61,9 @@ class CryptoconditionsTokenTest(CryptoconditionsTestFramework): result = rpc.tokenorders() assert_equal(result, []) - # getting token balance for pubkey + # getting token balance for non existing tokenid result = rpc.tokenbalance(self.pubkey) - assert_success(result) - assert_equal(result['balance'], 0) - assert_equal(result['CCaddress'], 'RCRsm3VBXz8kKTsYaXKpy7pSEzrtNNQGJC') - assert_equal(result['tokenid'], self.pubkey) + assert_error(result) # get token balance for token with pubkey result = rpc.tokenbalance(tokenid, self.pubkey) From 0a84522ad08ffdd67f44ce5b5d39dd42d1a26d3a Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 21 Jan 2019 11:08:59 +0100 Subject: [PATCH 2/3] Channel close fix. Adding CCError print to all RPCs. --- src/cc/channels.cpp | 92 +++++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 32 deletions(-) diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index a375edbda..6cd379eed 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -502,6 +502,8 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 if (tokenid!=zeroid && tokens>funds) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,tokens-funds,mypk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('O',tokenid,zeroid,mypk,destpub,numpayments,payment,hashchain))); } + CCerror = strprintf("error adding funds"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } @@ -520,25 +522,29 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 mypk = pubkey2pk(Mypubkey()); if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { - fprintf(stderr, "invalid channel open txid\n"); - return (""); + CCerror = strprintf("invalid channel open txid"); + fprintf(stderr,"%s\n",CCerror.c_str()); + return(""); } if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, totalnumpayments, payment, hashchain)=='O') { if (mypk != srcpub && mypk != destpub) { - fprintf(stderr,"this is not our channel\n"); + CCerror = strprintf("this is not our channel"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } else if (amount % payment != 0 || amount 0) @@ -552,11 +558,13 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 { if (numpayments > prevdepth) { - fprintf(stderr,"not enough funds in channel for that amount\n"); + CCerror = strprintf("not enough funds in channel for that amount"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } else if (numpayments == 0) { - fprintf(stderr,"invalid amount\n"); + CCerror = strprintf("invalid amount"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (secret!=zeroid) @@ -570,7 +578,8 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 endiancpy((uint8_t * ) & gensecret, hashdest, 32); if (gensecret!=hashchain) { - fprintf(stderr,"invalid secret supplied\n"); + CCerror = strprintf("invalid secret supplied"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } @@ -592,7 +601,8 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 } else { - fprintf(stderr,"invalid previous tx\n"); + CCerror = strprintf("invalid previous tx"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub)); @@ -605,11 +615,13 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 } else { - fprintf(stderr,"error adding CC inputs\n"); + CCerror = strprintf("error adding CC inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } - fprintf(stderr,"error adding normal inputs\n"); + CCerror = strprintf("error adding normal inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } @@ -629,36 +641,41 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) mypk = pubkey2pk(Mypubkey()); if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { - fprintf(stderr, "invalid channel open txid\n"); + CCerror = strprintf("invalid channel open txid"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { - fprintf(stderr, "invalid channel open tx\n"); + CCerror = strprintf("invalid channel open tx"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (mypk != srcpub) { - fprintf(stderr,"cannot close, you are not channel owner\n"); + CCerror = strprintf("cannot close, you are not channel owner"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) { - if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds-txfee>0) + if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0) { - if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub)); - else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub)); + if (tokenid!=zeroid) mtx.vout.push_back(MakeTokensCC1of2vout(EVAL_CHANNELS, funds, mypk, destpub)); + else mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, funds, mypk, destpub)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',tokenid,opentxid,mypk,destpub,(funds-txfee)/payment,payment,zeroid))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',tokenid,opentxid,mypk,destpub,funds/payment,payment,zeroid))); } else { - fprintf(stderr,"error adding CC inputs\n"); + CCerror = strprintf("error adding CC inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } - fprintf(stderr,"error adding normal inputs\n"); + CCerror = strprintf("error adding normal inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } @@ -678,61 +695,72 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) mypk = pubkey2pk(Mypubkey()); if (GetTransaction(closetxid,channelCloseTx,hashblock,false) == 0) { - fprintf(stderr, "invalid channel close txid\n"); + CCerror = strprintf("invalid channel close txid"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if ((numvouts=channelCloseTx.vout.size()) < 1 || DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,param1,param2,param3)!='C') { - fprintf(stderr, "invalid channel close tx\n"); + CCerror = strprintf("invalid channel close tx"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (txid!=opentxid) { - fprintf(stderr, "open and close txid are not from same channel\n"); + CCerror = strprintf("open and close txid are not from same channel"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) { - fprintf(stderr, "invalid channel open txid\n"); + CCerror = strprintf("invalid channel open txid"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,numpayments,payment,hashchain)!='O') { - fprintf(stderr, "invalid channel open tx\n"); + CCerror = strprintf("invalid channel open tx"); + fprintf(stderr,"%s\n",CCerror.c_str()); return (""); } if (mypk != srcpub) { - fprintf(stderr,"cannot refund, you are not the channel owenr\n"); + CCerror = strprintf("cannot refund, you are not the channel owner"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) { - if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds-txfee>0) + if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0) { if ((GetTransaction(prevtxid,prevTx,hashblock,false) != 0) && (numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, param1, param2, param3) != 0) { mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - if (tokenid!=zeroid) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,funds-txfee,mypk)); - else mtx.vout.push_back(CTxOut(funds-txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',tokenid,opentxid,mypk,destpub,param1,payment,closetxid))); + if (tokenid!=zeroid) mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,funds,mypk)); + else mtx.vout.push_back(CTxOut(funds,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',tokenid,opentxid,mypk,destpub,funds/payment,payment,closetxid))); } else { - fprintf(stderr,"previous tx is invalid\n"); + CCerror = strprintf("previous tx is invalid"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } else { - fprintf(stderr,"error adding CC inputs\n"); + CCerror = strprintf("error adding CC inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } } + CCerror = strprintf("error adding normal inputs"); + fprintf(stderr,"%s\n",CCerror.c_str()); return(""); } + UniValue ChannelsList() { UniValue result(UniValue::VOBJ); std::vector > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid; From a34fc260986882b86830afd2919c705a68f7e2d1 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 21 Jan 2019 11:57:52 +0100 Subject: [PATCH 3/3] Fix canceling partially filled orders by anyone. (#11) * Fix * Fix --- src/cc/CCassetstx.cpp | 46 +++++++++++++++++++++---------------------- src/cc/CCutils.cpp | 1 - src/cc/assets.cpp | 15 +++++++++----- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 968775d38..9d83beb2c 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -477,14 +477,10 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CTransaction vintx; - uint64_t mask; - uint256 hashBlock; - int64_t bidamount; - CPubKey mypk; - struct CCcontract_info *cpAssets, C; - - uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; + CTransaction vintx; uint64_t mask; + uint256 hashBlock; int64_t bidamount; + CPubKey mypk; struct CCcontract_info *cpAssets, C; + uint8_t funcid,dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; cpAssets = CCinit(&C, EVAL_ASSETS); @@ -501,9 +497,12 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) bidamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(bidtxid, 0, CScript())); // coins in Assets - if( DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 'b') - mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); // spend marker if funcid='b' (not 'B') - // TODO: spend it also in FillBuyOffer? + if((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey))!=0) + { + + if (funcid == 's') mtx.vin.push_back(CTxIn(bidtxid, 1, CScript())); // spend marker if funcid='b' + else if (funcid=='S') mtx.vin.push_back(CTxIn(bidtxid, 3, CScript())); // spend marker if funcid='B' + } mtx.vout.push_back(CTxOut(bidamount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -523,12 +522,9 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CTransaction vintx; uint64_t mask; - uint256 hashBlock; - int64_t askamount; - CPubKey mypk; - struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; - - uint8_t dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; + uint256 hashBlock; int64_t askamount; + CPubKey mypk; struct CCcontract_info *cpTokens, *cpAssets, tokensC, assetsC; + uint8_t funcid,dummyEvalCode; uint256 dummyAssetid, dummyAssetid2; int64_t dummyPrice; std::vector dummyOrigpubkey; cpAssets = CCinit(&assetsC, EVAL_ASSETS); @@ -545,9 +541,11 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid, 0, CScript())); - if (DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey) == 's') - mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' (not 'S') - // TODO: spend it also in FillSell? + if ((funcid=DecodeAssetTokenOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, dummyEvalCode, dummyAssetid, dummyAssetid2, dummyPrice, dummyOrigpubkey))!=0) + { + if (funcid == 's') mtx.vin.push_back(CTxIn(asktxid, 1, CScript())); // marker if funcid='s' + else if (funcid=='S') mtx.vin.push_back(CTxIn(asktxid, 3, CScript())); // marker if funcid='S' + } mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, askamount, mypk)); // one-eval token vout mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -607,7 +605,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) + if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) @@ -637,9 +635,10 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS, bidamount - paid_amount, unspendableAssetsPk)); // vout0 coins remainder mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); // vout1 coins to normal mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, fillamount, pubkey2pk(origpubkey))); // vout2 single-eval tokens sent to the buyer + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,txfee,origpubkey)); // vout3 marker to origpubkey if (CCchange != 0) - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // vout3 change in single-eval tokens + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, CCchange, mypk)); // vout4 change in single-eval tokens fprintf(stderr,"FillBuyOffer remaining %llu -> origpubkey\n", (long long)remaining_required); @@ -698,7 +697,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) + if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) @@ -747,6 +746,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a //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(MakeCC1vout(EVAL_ASSETS,txfee,origpubkey)); //vout.3 marker to origpubkey // not implemented if (CCchange != 0) { diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index e9c30acc1..07ce11154 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -602,7 +602,6 @@ bool komodo_txnotarizedconfirmed(uint256 txid) CPubKey check_signing_pubkey(CScript scriptSig) { - bool found = false; CPubKey pubkey; diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 3ccafa34f..2433473b9 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -153,8 +153,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("AssetValidate: invalid opreturn payload"); // find dual-eval tokens unspendable addr: - char tokensUnspendableAddr[64]; + char tokensUnspendableAddr[64],origpubkeyCCaddr[64]; GetTokensCCaddress(cpAssets, tokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); + GetCCaddress(cpAssets, origpubkeyCCaddr, origpubkey); // we need this for validating single-eval tokens' vins/vous: struct CCcontract_info *cpTokens, tokensC; @@ -258,7 +259,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if( (nValue = AssetValidateBuyvin(cpAssets, eval, totalunits, tmporigpubkey, assetsCCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if( numvouts < 3 ) + else if( numvouts < 4 ) return eval->Invalid("not enough vouts for fillbuy"); else if( tmporigpubkey != origpubkey ) return eval->Invalid("mismatched origpubkeys for fillbuy"); @@ -266,17 +267,19 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti { if( nValue != tx.vout[0].nValue + tx.vout[1].nValue ) return eval->Invalid("locked value doesnt match vout0+1 fillbuy"); - else if( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) + else if( tx.vout[4].scriptPubKey.IsPayToCryptoCondition() != 0 ) { if( ConstrainVout(tx.vout[2], 1, assetsCCaddr, 0) == 0 ) // tokens on user cc addr return eval->Invalid("vout2 doesnt go to origpubkey fillbuy"); - else if ( inputs != tx.vout[2].nValue + tx.vout[3].nValue ) + else if ( inputs != tx.vout[2].nValue + tx.vout[4].nValue ) return eval->Invalid("asset inputs doesnt match vout2+3 fillbuy"); } else if( ConstrainVout(tx.vout[2], 1, assetsCCaddr, inputs) == 0 ) // tokens on user cc addr return eval->Invalid("vout2 doesnt match inputs fillbuy"); else if( ConstrainVout(tx.vout[1],0,0,0) == 0 ) return eval->Invalid("vout1 is CC for fillbuy"); + else if( ConstrainVout(tx.vout[3], 1, origpubkeyCCaddr, 10000) == 0 ) + return eval->Invalid("invalid marker for original pubkey"); else if( ValidateBidRemainder(remaining_price, tx.vout[0].nValue, nValue, tx.vout[1].nValue, tx.vout[2].nValue, totalunits) == false ) return eval->Invalid("mismatched remainder for fillbuy"); else if( remaining_price != 0 ) @@ -345,7 +348,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, userTokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); - else if( numvouts < 3 ) + else if( numvouts < 4 ) return eval->Invalid("not enough vouts for fillask"); else if( tmporigpubkey != origpubkey ) return eval->Invalid("mismatched origpubkeys for fillask"); @@ -359,6 +362,8 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillask"); else if( ConstrainVout(tx.vout[2], 0, origaddr, 0) == 0 ) return eval->Invalid("normal vout1 for fillask"); + else if( ConstrainVout(tx.vout[3], 1, origpubkeyCCaddr, 10000) == 0 ) + return eval->Invalid("invalid marker for original pubkey"); else if( remaining_price != 0 ) { //char tokensUnspendableAddr[64];