From f81291ae82be4dfa844dda630f856553a40bb928 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Sep 2018 07:28:33 -1100 Subject: [PATCH] Gateways claim --- src/cc/CCGateways.h | 2 +- src/cc/gateways.cpp | 5 ++++- src/wallet/rpcwallet.cpp | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cc/CCGateways.h b/src/cc/CCGateways.h index 9414ba0ed..799259f5c 100644 --- a/src/cc/CCGateways.h +++ b/src/cc/CCGateways.h @@ -22,7 +22,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys); std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,std::vectorpubkeys,int32_t height,std::string refcoin,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,std::vector redeemscript,int64_t amount); -std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string coin,uint256 deposittxid,std::string claimaddr,int64_t amount); +std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,std::vector redeemscript,int64_t amount); std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,std::vector withdrawpub,int64_t amount); // CCcustom diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index b77518172..e3b53d40c 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -98,6 +98,9 @@ gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof redeemscript amount numpks oraclepks ./komodo-cli -ac_name=AT5 gatewaysdeposit e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e 1003776 KMD bc41a00e429db741c3199f17546a48012fd3b7eea45dfc6bc2f5228278133009 0 010000000149964cdcd17fe9b1cae4d0f3b5f5db301d9b4f54099fdf4d34498df281757094010000006a4730440220594f3a630dd73c123f44621aa8bb9968ab86734833453dd479af6d79ae6f584202207bb5e35f13b337ccc8a88d9a006c8c5ddb016c0a6f4f2dc44357a8128623d85d01210223154bf53cd3a75e64d86697070d6437c8f0010a09c1df35b659e31ce3d79b5dffffffff0310270000000000001976a91447d2e323a14b0c3be08698aa46a9b91489b189d688ac701de52d000000001976a91459fdba29ea85c65ad90f6d38f7a6646476b26b1688acb0a86a00000000001976a914f9a9daf5519dae38b8b61d945f075da895df441d88ace18d965b proofhere 76a91447d2e323a14b0c3be08698aa46a9b91489b189d688ac 7.6999 1 02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92 + -> acc58b4552c4696406b681eb853b0c9a80ef8f02e3ec0e7bbd407b9261ecba81 + + */ // start of consensus code @@ -545,7 +548,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,std::vector return(""); } -std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,std::vector claimpubkey,int64_t amount) +std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,std::vector redeemscript,int64_t amount) { CMutableTransaction mtx; CTransaction tx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C,*assetscp,C2; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; int64_t totalsupply,depositamount,inputs,CCchange=0; int32_t numvouts; uint256 hashBlock,assetid,oracletxid; char str[65],depositaddr[64]; cp = CCinit(&C,EVAL_GATEWAYS); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bf8ba4556..148501ac2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5480,8 +5480,18 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp) UniValue gatewaysclaim(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); std::string hex; - // std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string coin,uint256 deposittxid,std::string claimaddr,int64_t amount) + UniValue result(UniValue::VOBJ); std::string hex,coin; uint256 bindtxid,deposittxid; std::vectorredeemscript; int64_t amount; + if ( fHelp || params.size() != 11 ) + throw runtime_error("gatewaysclaim bindtxid coin deposittxid redeemscript amount\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + bindtxid = Parseuint256((char *)params[0].get_str().c_str()); + coin = params[1].get_str(); + deposittxid = Parseuint256((char *)params[3].get_str().c_str()); + proof = ParseHex(params[4].get_str()); + redeemscript = ParseHex(params[5].get_str()); + amount = atof((char *)params[6].get_str().c_str()) * COIN; + hex = GatewaysClaim(0,bindtxid,coin,deposittxid,redeemscript,amount); if ( hex.size() > 0 ) { result.push_back(Pair("result", "success"));