Markdone with cointxid
This commit is contained in:
@@ -26,7 +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 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);
|
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);
|
UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin);
|
||||||
std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid);
|
std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid,std::string refcoin,uint256 cointxid);
|
||||||
|
|
||||||
// CCcustom
|
// CCcustom
|
||||||
UniValue GatewaysInfo(uint256 bindtxid);
|
UniValue GatewaysInfo(uint256 bindtxid);
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *oraclestxidstr)
|
|||||||
/// if enough sigs, sendrawtransaction and when it confirms spend marker (txid.2)
|
/// if enough sigs, sendrawtransaction and when it confirms spend marker (txid.2)
|
||||||
/// if not enough sigs, post partially signed to acname with marker2
|
/// if not enough sigs, post partially signed to acname with marker2
|
||||||
// monitor marker2, for the partially signed withdraws
|
// monitor marker2, for the partially signed withdraws
|
||||||
cJSON *retjson,*pending,*item; char str[65],*coinstr,*txidaddr,*signeraddr,*withdrawaddr; int32_t i,n,retval,processed = 0; bits256 txid,withtxid,origtxid; int64_t satoshis;
|
cJSON *retjson,*pending,*item; char str[65],*coinstr,*txidaddr,*signeraddr,*withdrawaddr; int32_t i,n,retval,processed = 0; bits256 txid,cointxid,origtxid; int64_t satoshis;
|
||||||
if ( (retjson= get_gatewayspending("KMD",acname,oraclestxidstr)) != 0 )
|
if ( (retjson= get_gatewayspending("KMD",acname,oraclestxidstr)) != 0 )
|
||||||
{
|
{
|
||||||
if ( jint(retjson,"queueflag") != 0 && (coinstr= jstr(retjson,"coin")) != 0 && strcmp(coinstr,refcoin) == 0 )
|
if ( jint(retjson,"queueflag") != 0 && (coinstr= jstr(retjson,"coin")) != 0 && strcmp(coinstr,refcoin) == 0 )
|
||||||
@@ -640,16 +640,16 @@ void update_gatewayspending(char *refcoin,char *acname,char *oraclestxidstr)
|
|||||||
if ( bits256_nonz(txid) != 0 && coinaddrexists("KMD",acname,txidaddr) > 0 )
|
if ( bits256_nonz(txid) != 0 && coinaddrexists("KMD",acname,txidaddr) > 0 )
|
||||||
{
|
{
|
||||||
// the actual withdraw
|
// the actual withdraw
|
||||||
withtxid = sendtoaddress(refcoin,"",withdrawaddr,satoshis);
|
cointxid = sendtoaddress(refcoin,"",withdrawaddr,satoshis);
|
||||||
if ( bits256_nonz(withtxid) != 0 )
|
if ( bits256_nonz(cointxid) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"withdraw %s %s %s %.8f processed\n",refcoin,bits256_str(str,withtxid),withdrawaddr,(double)satoshis/SATOSHIDEN);
|
fprintf(stderr,"withdraw %s %s %s %.8f processed\n",refcoin,bits256_str(str,cointxid),withdrawaddr,(double)satoshis/SATOSHIDEN);
|
||||||
gatewaysmarkdone("KMD",acname,origtxid);
|
gatewaysmarkdone("KMD",acname,origtxid,refcoin,cointxid);
|
||||||
processed++;
|
processed++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ERROR withdraw %s %s %s %.8f processed\n",refcoin,bits256_str(str,withtxid),withdrawaddr,(double)satoshis/SATOSHIDEN);
|
fprintf(stderr,"ERROR withdraw %s %s %s %.8f processed\n",refcoin,bits256_str(str,cointxid),withdrawaddr,(double)satoshis/SATOSHIDEN);
|
||||||
}
|
}
|
||||||
} else fprintf(stderr,"error sending %s txidaddr.%s -> %s exists.%d\n",acname,txidaddr,bits256_str(str,txid),coinaddrexists(refcoin,acname,txidaddr));
|
} else fprintf(stderr,"error sending %s txidaddr.%s -> %s exists.%d\n",acname,txidaddr,bits256_str(str,txid),coinaddrexists(refcoin,acname,txidaddr));
|
||||||
}
|
}
|
||||||
@@ -759,7 +759,7 @@ int32_t main(int32_t argc,char **argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
printf("set refcoin <- %s [%s]\n",refcoin,REFCOIN_CLI);
|
printf("set refcoin <- %s [%s]\n",refcoin,REFCOIN_CLI);
|
||||||
} //else printf("clijson.(%s)\n",jprint(clijson,0));
|
}
|
||||||
if ( (regjson= jarray(&n,clijson,"registered")) != 0 )
|
if ( (regjson= jarray(&n,clijson,"registered")) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n; i++)
|
||||||
|
|||||||
@@ -18,9 +18,8 @@
|
|||||||
/*
|
/*
|
||||||
prevent duplicate bindtxid via mempool scan
|
prevent duplicate bindtxid via mempool scan
|
||||||
wait for notarization for oraclefeed and validation of gatewaysdeposit
|
wait for notarization for oraclefeed and validation of gatewaysdeposit
|
||||||
|
debug multisig and do partial signing
|
||||||
validation
|
validation
|
||||||
non-KMD coins to be bound
|
|
||||||
|
|
||||||
string oracles
|
string oracles
|
||||||
*/
|
*/
|
||||||
@@ -763,7 +762,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
|
|||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid)
|
std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid,std::string refcoin,uint256 cointxid)
|
||||||
{
|
{
|
||||||
CMutableTransaction mtx; CScript opret; CPubKey mypk; struct CCcontract_info *cp,C;
|
CMutableTransaction mtx; CScript opret; CPubKey mypk; struct CCcontract_info *cp,C;
|
||||||
cp = CCinit(&C,EVAL_GATEWAYS);
|
cp = CCinit(&C,EVAL_GATEWAYS);
|
||||||
@@ -772,6 +771,7 @@ std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid)
|
|||||||
mypk = pubkey2pk(Mypubkey());
|
mypk = pubkey2pk(Mypubkey());
|
||||||
mtx.vin.push_back(CTxIn(withdrawtxid,2,CScript()));
|
mtx.vin.push_back(CTxIn(withdrawtxid,2,CScript()));
|
||||||
mtx.vout.push_back(CTxOut(5000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
|
mtx.vout.push_back(CTxOut(5000,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
|
||||||
|
opret << OP_RETURN << E_MARSHAL(ss << cp->evalcode << 'M' << cointxid << refcoin);
|
||||||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret));
|
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,7 +825,6 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin)
|
|||||||
obj.push_back(Pair("depositaddr",depositaddr));
|
obj.push_back(Pair("depositaddr",depositaddr));
|
||||||
Getscriptaddress(signeraddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG);
|
Getscriptaddress(signeraddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG);
|
||||||
obj.push_back(Pair("signeraddr",signeraddr));
|
obj.push_back(Pair("signeraddr",signeraddr));
|
||||||
// numqueued += GatewaysAddQueue(refcoin,txid,tx.vout[1].scriptPubKey,tx.vout[0].nValue);
|
|
||||||
}
|
}
|
||||||
pending.push_back(obj);
|
pending.push_back(obj);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5516,11 +5516,13 @@ UniValue gatewaysmarkdone(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); uint256 withdrawtxid; std::string hex;
|
UniValue result(UniValue::VOBJ); uint256 withdrawtxid; std::string hex;
|
||||||
if ( fHelp || params.size() != 1 )
|
if ( fHelp || params.size() != 1 )
|
||||||
throw runtime_error("gatewaysmarkdone withdrawtxid\n");
|
throw runtime_error("gatewaysmarkdone withdrawtxid coin cointxid\n");
|
||||||
if ( ensure_CCrequirements() < 0 )
|
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");
|
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());
|
withdrawtxid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
hex = GatewaysMarkdone(0,withdrawtxid);
|
coin = params[1].get_str();
|
||||||
|
cointxid = Parseuint256((char *)params[2].get_str().c_str());
|
||||||
|
hex = GatewaysMarkdone(0,withdrawtxid,coin,cointxid);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
{
|
{
|
||||||
result.push_back(Pair("result", "success"));
|
result.push_back(Pair("result", "success"));
|
||||||
|
|||||||
Reference in New Issue
Block a user