From 6bde696a3136716adaaa2a1eb69e15fbf5ad2ed6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Sep 2018 08:36:01 -1100 Subject: [PATCH] Gatewaysmarkdone --- src/cc/CCGateways.h | 1 + src/cc/dapps/oraclefeed.c | 4 ++-- src/cc/gateways.cpp | 11 +++++++++++ src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 17 +++++++++++++++++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/cc/CCGateways.h b/src/cc/CCGateways.h index f0c094080..1d7bef9d5 100644 --- a/src/cc/CCGateways.h +++ b/src/cc/CCGateways.h @@ -26,6 +26,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount); std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,std::vector withdrawpub,int64_t amount); UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin); +std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid); // CCcustom UniValue GatewaysInfo(uint256 bindtxid); diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c index 37da19101..fa67989bf 100644 --- a/src/cc/dapps/oraclefeed.c +++ b/src/cc/dapps/oraclefeed.c @@ -632,7 +632,7 @@ void update_gatewayspending(char *acname,char *oraclestxidstr,char *coin) if ( bits256_nonz(withtxid) != 0 ) { fprintf(stderr,"withdraw %s %s %s %.8f processed\n",coin,bits256_str(str,withtxid),withdrawaddr,(double)satoshis/SATOSHIDEN); - gatewaystxid2(acname,origtxid); + gatewaysmarkdone(acname,origtxid); processed++; } else @@ -644,7 +644,7 @@ void update_gatewayspending(char *acname,char *oraclestxidstr,char *coin) else if ( retval > 0 ) { fprintf(stderr,"already did withdraw %s %s %.8f processed\n",coin,withdrawaddr,(double)satoshis/SATOSHIDEN); - gatewaystxid2(acname,origtxid); + gatewaysmarkdone(acname,origtxid); } } } diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 969018312..b366db6ba 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -762,6 +762,17 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin return(""); } +std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid) +{ + CMutableTransaction mtx; CScript opret; + cp = CCinit(&C,EVAL_GATEWAYS); + if ( txfee == 0 ) + txfee = 10000; + mypk = pubkey2pk(Mypubkey()); + mtx.vin.push_back(CTxIn(withdrawtxid,2,CScript())); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); +} + UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) { UniValue result(UniValue::VOBJ),pending(UniValue::VARR),obj(UniValue::VOBJ); CTransaction tx; std::string coin; CPubKey mypk,gatewayspk; std::vector msigpubkeys; uint256 hashBlock,assetid,txid,oracletxid; uint8_t M,N,taddr,prefix,prefix2; char depositaddr[64],withmarker[64],coinaddr[64],destaddr[64],str[65],withaddr[64],numstr[32],txidaddr[64],signeraddr[64]; int32_t i,n,numvouts,vout,numqueued,queueflag; int64_t totalsupply; struct CCcontract_info *cp,C; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 49b7d529c..c4c8d378b 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -418,6 +418,7 @@ static const CRPCCommand vRPCCommands[] = { "gateways", "gatewaysclaim", &gatewaysclaim, true }, { "gateways", "gatewayswithdraw", &gatewayswithdraw, true }, { "gateways", "gatewayspending", &gatewayspending, true }, + { "gateways", "gatewaysmarkdone", &gatewaysmarkdone, true }, /* dice */ { "dice", "dicelist", &dicelist, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index bb3266881..a697ee4ee 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -243,6 +243,7 @@ extern UniValue gatewaysdeposit(const UniValue& params, bool fHelp); extern UniValue gatewaysclaim(const UniValue& params, bool fHelp); extern UniValue gatewayswithdraw(const UniValue& params, bool fHelp); extern UniValue gatewayspending(const UniValue& params, bool fHelp); +extern UniValue gatewaysmarkdone(const UniValue& params, bool fHelp); extern UniValue channelsinfo(const UniValue& params, bool fHelp); extern UniValue channelsbind(const UniValue& params, bool fHelp); extern UniValue channelsopen(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index eee5e0594..d3825388c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5512,6 +5512,23 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp) return(result); } +UniValue gatewaysmarkdone(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); uint256 withdrawtxid; std::string hex; + if ( fHelp || params.size() != 1 ) + throw runtime_error("gatewaysmarkdone withdrawtxid\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"); + withdrawtxid = Parseuint256((char *)params[0].get_str().c_str()); + hex = GatewaysMarkdone(0,withdrawtxid); + if ( hex.size() > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("hex", hex)); + } else ERR_RESULT("couldnt gatewaysmarkdone"); + return(result); +} + UniValue gatewayspending(const UniValue& params, bool fHelp) { uint256 bindtxid; std::string coin;