Gatewaysmarkdone

This commit is contained in:
jl777
2018-09-12 08:36:01 -11:00
parent 11ce33e84f
commit 6bde696a31
6 changed files with 33 additions and 2 deletions

View File

@@ -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<uint8_t> withdrawpub,int64_t amount);
UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin);
std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid);
// CCcustom
UniValue GatewaysInfo(uint256 bindtxid);

View File

@@ -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);
}
}
}

View File

@@ -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<CPubKey> 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;

View File

@@ -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 },

View File

@@ -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);

View File

@@ -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;