From 4df0d20a8e1b14d44c322d9b5fd02fd162165b40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 9 Sep 2018 21:56:03 -1100 Subject: [PATCH] -oracle_merklepair --- src/cc/CCinclude.h | 6 ------ src/cc/gateways.cpp | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 2405d2c11..79a1e0c75 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -76,12 +76,6 @@ struct CCcontract_info }; struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode); -struct oracle_merklepair -{ - CPubKey pk; - uint256 txid; -}; - struct oracleprice_info { CPubKey pk; diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 26711483c..7cc5ebdaf 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -52,19 +52,19 @@ CScript EncodeGatewaysBindOpRet(uint8_t funcid,std::string coin,uint256 tokenid, return(opret); } -CScript EncodeGatewaysOpRet(uint8_t funcid,std::string coin,uint256 bindtxid,std::vector publishers,int32_t height,uint256 cointxid,std::string deposithex,std::vectorproof,std::vector redeemscript,int64_t amount) +CScript EncodeGatewaysOpRet(uint8_t funcid,std::string coin,uint256 bindtxid,std::vector publishers,std::vectortxids,int32_t height,uint256 cointxid,std::string deposithex,std::vectorproof,std::vector redeemscript,int64_t amount) { CScript opret; uint8_t evalcode = EVAL_GATEWAYS; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << bindtxid << publishers << height << cointxid << deposithex << proof << redeemscript << amount); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << coin << bindtxid << publishers << txids << height << cointxid << deposithex << proof << redeemscript << amount); return(opret); } -uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey,std::string &coin,uint256 &bindtxid,std::vector &publishers,int32_t &height,uint256 &cointxid,std::string &deposithex,std::vector &proof,std::vector &redeemscript,int64_t &amount) +uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey,std::string &coin,uint256 &bindtxid,std::vector&publishers,std::vector&txids,,int32_t &height,uint256 &cointxid,std::string &deposithex,std::vector &proof,std::vector &redeemscript,int64_t &amount) { std::vector vopret; uint8_t *script,e,f; GetOpReturnData(scriptPubKey, vopret); script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> bindtxid; ss >> publishers; ss >> height; ss >> cointxid; ss >> deposithex; ss >> proof; ss >> redeemscript; ss >> amount) != 0 ) + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> bindtxid; ss >> publishers; ss >> txids; ss >> height; ss >> cointxid; ss >> deposithex; ss >> proof; ss >> redeemscript; ss >> amount) != 0 ) { return(f); } @@ -412,10 +412,10 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,std::string refco int64_t GatewaysDepositval(CTransaction tx) { - int32_t numvouts,height; int64_t amount; std::string coin,deposithex; std::vector publishers; uint256 bindtxid,cointxid; std::vector proof; std::vector claimpubkey; + int32_t numvouts,height; int64_t amount; std::string coin,deposithex; std::vector publishers; std::vectortxids; uint256 bindtxid,cointxid; std::vector proof; std::vector claimpubkey; if ( (numvouts= tx.vout.size()) > 0 ) { - if ( DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey,coin,bindtxid,publishers,height,cointxid,deposithex,proof,claimpubkey,amount) == 'D' ) + if ( DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey,coin,bindtxid,publishers,txids,height,cointxid,deposithex,proof,claimpubkey,amount) == 'D' ) { // coin, bindtxid, publishers fprintf(stderr,"need to validate deposittxid more\n"); @@ -427,7 +427,7 @@ int64_t GatewaysDepositval(CTransaction tx) std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,std::vectorpubkeys,int32_t height,std::string refcoin,uint256 cointxid,std::string deposithex,std::vectorproof,std::vector redeemscript,int64_t amount) { - CMutableTransaction mtx; CTransaction bindtx; CPubKey mypk,gatewayspk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CCcontract_info *cp,C; std::vector msigpubkeys; std::vector publishers; struct oracle_merklepair P; char str[65],depositaddr[64]; + CMutableTransaction mtx; CTransaction bindtx; CPubKey mypk,gatewayspk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CCcontract_info *cp,C; std::vector msigpubkeys,publishers; std::vectortxids; char str[65],depositaddr[64]; cp = CCinit(&C,EVAL_GATEWAYS); if ( txfee == 0 ) txfee = 10000; @@ -453,9 +453,8 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,std::vector merkleroot = mhash, m = 1; else if ( mhash == merkleroot ) m++; - P.pk = pubkeys[i]; - P.txid = txid; - publishers.push_back(P); + publishers.push_back(pubkeys[i]); + txids.push_back(txid); } } if ( merkleroot == zeroid || m < n/2 ) @@ -471,7 +470,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,std::vector if ( AddNormalinputs(mtx,mypk,2*txfee,60) > 0 ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,mypk)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysOpRet('D',coin,bindtxid,publishers,height,cointxid,deposithex,proof,redeemscript,amount))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysOpRet('D',coin,bindtxid,publishers,txids,height,cointxid,deposithex,proof,redeemscript,amount))); } fprintf(stderr,"cant find enough inputs\n"); return("");