Valiate merkleroot

This commit is contained in:
jl777
2018-09-11 00:59:17 -11:00
parent c742ef4c93
commit 7f9283e5b1
4 changed files with 68 additions and 45 deletions

View File

@@ -5445,9 +5445,9 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp)
UniValue gatewaysdeposit(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); int32_t i,claimvout,height,numpks; int64_t amount; std::string hex,coin,deposithex; uint256 bindtxid,cointxid; std::vector<CPubKey>pubkeys; std::vector<uint8_t>proof,redeemscript,pubkey;
UniValue result(UniValue::VOBJ); int32_t i,claimvout,height,numpks; int64_t amount; std::string hex,coin,deposithex; uint256 bindtxid,cointxid; std::vector<CPubKey>pubkeys; std::vector<uint8_t>proof,destpub,pubkey;
if ( fHelp || params.size() != 11 )
throw runtime_error("gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof redeemscript amount numpks oraclepks\n");
throw runtime_error("gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof destpub amount numpks oraclepks\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());
@@ -5457,7 +5457,7 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp)
claimvout = atoi((char *)params[4].get_str().c_str());
deposithex = params[5].get_str();
proof = ParseHex(params[6].get_str());
redeemscript = ParseHex(params[7].get_str());
destpub = ParseHex(params[7].get_str());
amount = atof((char *)params[8].get_str().c_str()) * COIN;
numpks = atoi((char *)params[9].get_str().c_str());
if ( amount <= 0 || numpks <= 0 || claimvout < 0 )
@@ -5469,7 +5469,7 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp)
pubkey = ParseHex(params[10+i].get_str().c_str());
pubkeys.push_back(pubkey2pk(pubkey));
}
hex = GatewaysDeposit(0,bindtxid,pubkeys,height,coin,cointxid,claimvout,deposithex,proof,redeemscript,amount);
hex = GatewaysDeposit(0,bindtxid,pubkeys,height,coin,cointxid,claimvout,deposithex,proof,pubkey2pk(destpub),amount);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
@@ -5480,7 +5480,7 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp)
UniValue gatewaysclaim(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); std::string hex,coin; uint256 bindtxid,deposittxid; std::vector<uint8_t>redeemscript; int64_t amount;
UniValue result(UniValue::VOBJ); std::string hex,coin; uint256 bindtxid,deposittxid; std::vector<uint8_t>destpub; int64_t amount;
if ( fHelp || params.size() != 5 )
throw runtime_error("gatewaysclaim bindtxid coin deposittxid redeemscript amount\n");
if ( ensure_CCrequirements() < 0 )
@@ -5488,9 +5488,9 @@ UniValue gatewaysclaim(const UniValue& params, bool fHelp)
bindtxid = Parseuint256((char *)params[0].get_str().c_str());
coin = params[1].get_str();
deposittxid = Parseuint256((char *)params[2].get_str().c_str());
redeemscript = ParseHex(params[3].get_str());
destpub = ParseHex(params[3].get_str());
amount = atof((char *)params[4].get_str().c_str()) * COIN;
hex = GatewaysClaim(0,bindtxid,coin,deposittxid,redeemscript,amount);
hex = GatewaysClaim(0,bindtxid,coin,deposittxid,pubkey2pk(destpub),amount);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));