test
This commit is contained in:
@@ -703,7 +703,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
memset(kmdheights,0,sizeof(kmdheights));
|
||||
memset(otherheights,0,sizeof(otherheights));
|
||||
tokomodo = (komodo_is_issuer() == 0);
|
||||
if ( opretbuf[0] == 'K' )
|
||||
if ( opretbuf[0] == 'K' && opretlen != 40 )
|
||||
{
|
||||
uint16_t keylen,valuesize; uint8_t *key,*value; struct komodo_kv *ptr;
|
||||
iguana_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen);
|
||||
|
||||
@@ -414,6 +414,9 @@ Value kvsearch(const Array& params, bool fHelp)
|
||||
LOCK(cs_main);
|
||||
if ( (keylen= (int32_t)strlen(params[0].get_str().c_str())) > 0 )
|
||||
{
|
||||
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
|
||||
ret.push_back(Pair("height", (int64_t)chainActive.Tip()->nHeight));
|
||||
ret.push_back(Pair("key",params[0].get_str()));
|
||||
if ( keylen < sizeof(key) )
|
||||
{
|
||||
memcpy(key,params[0].get_str().c_str(),keylen);
|
||||
@@ -424,10 +427,7 @@ Value kvsearch(const Array& params, bool fHelp)
|
||||
valuestr = (char *)val.data();
|
||||
memcpy(valuestr,value,valuesize);
|
||||
valuestr[valuesize] = 0;
|
||||
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
|
||||
ret.push_back(Pair("key",params[0].get_str()));
|
||||
ret.push_back(Pair("value",val));
|
||||
ret.push_back(Pair("height", (int64_t)chainActive.Tip()->nHeight));
|
||||
} else ret.push_back(Pair("error",(char *)"cant find key"));
|
||||
} else ret.push_back(Pair("error",(char *)"key too big"));
|
||||
} else ret.push_back(Pair("error",(char *)"null key"));
|
||||
|
||||
@@ -113,6 +113,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "notaries", 1 },
|
||||
{ "minerids", 1 },
|
||||
{ "kvsearch", 1 },
|
||||
{ "kvupdate", 2 },
|
||||
};
|
||||
|
||||
class CRPCConvertTable
|
||||
|
||||
@@ -306,6 +306,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "blockchain", "notaries", ¬aries, true },
|
||||
{ "blockchain", "minerids", &minerids, true },
|
||||
{ "blockchain", "kvsearch", &kvsearch, true },
|
||||
{ "blockchain", "kvupdate", &kvupdate, true },
|
||||
|
||||
/* Mining */
|
||||
{ "mining", "getblocktemplate", &getblocktemplate, true },
|
||||
|
||||
@@ -248,6 +248,7 @@ extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp)
|
||||
extern json_spirit::Value notaries(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value minerids(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value kvsearch(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value kvupdate(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxprice(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxpending(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxprices(const json_spirit::Array& params, bool fHelp);
|
||||
|
||||
@@ -475,6 +475,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
|
||||
return wtx.GetHash().GetHex();
|
||||
}
|
||||
|
||||
#define IGUANA_MAXSCRIPTSIZE 10001
|
||||
uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
|
||||
int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
|
||||
#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA"
|
||||
@@ -557,6 +558,45 @@ Value paxwithdraw(const Array& params, bool fHelp)
|
||||
return wtx.GetHash().GetHex();
|
||||
}
|
||||
|
||||
Value kvupdate(const Array& params, bool fHelp)
|
||||
{
|
||||
Object ret; uint8_t keyvalue[IGUANA_MAXSCRIPTSIZE],opretbuf[IGUANA_MAXSCRIPTSIZE]; int32_t opretlen,j;
|
||||
uint16_t keylen,valuesize; uint8_t *key,*value=0; struct komodo_kv *ptr; uint64_t fee;
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return 0;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
if ( (keylen= (int32_t)strlen(params[0].get_str().c_str())) > 0 )
|
||||
{
|
||||
key = (uint8_t *)params[0].get_str().c_str();
|
||||
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
|
||||
ret.push_back(Pair("height", (int64_t)chainActive.Tip()->nHeight));
|
||||
ret.push_back(Pair("key",params[0].get_str()));
|
||||
if ( params.size() == 2 && params[1].get_str().c_str() != 0 )
|
||||
{
|
||||
ret.push_back(Pair("value",params[1].get_str()));
|
||||
value = (uint8_t *)params[1].get_str().c_str();
|
||||
}
|
||||
iguana_rwnum(1,&keyvalue[0],sizeof(keylen),&keylen);
|
||||
iguana_rwnum(1,&keyvalue[2],sizeof(valuesize),&valuesize);
|
||||
memcpy(&keyvalue[4],key,keylen);
|
||||
if ( value != 0 )
|
||||
memcpy(&keyvalue[4 + keylen],value,valuesize);
|
||||
opretlen = komodo_opreturnscript(opretbuf,'W',keyvalue,sizeof(uint16_t)*2+keylen+valuelen);
|
||||
for (i=0; i<opretlen; i++)
|
||||
printf("%02x",opretbuf[i]);
|
||||
printf(" opretbuf\n");
|
||||
EnsureWalletIsUnlocked();
|
||||
if ( (fee= opretlen * opretlen / keylen) < 100000 )
|
||||
fee = 100000;
|
||||
CBitcoinAddress destaddress(CRYPTO777_KMDADDR);
|
||||
if (!destaddress.IsValid())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address");
|
||||
SendMoney(destaddress.Get(),10000,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fee);
|
||||
return wtx.GetHash().GetHex();
|
||||
} else ret.push_back(Pair("error",(char *)"null key"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
Value listaddressgroupings(const Array& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
|
||||
Reference in New Issue
Block a user