From 38e9a59c2c389a03cfb8132fca65884e3ea4be6c Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 25 Jun 2018 14:16:08 -0400 Subject: [PATCH 1/2] add help doc for KV --- src/rpcblockchain.cpp | 23 ++++++++++++++++++++++- src/wallet/rpcwallet.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index fc6092e03..8e13fb666 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -767,7 +767,28 @@ UniValue kvsearch(const UniValue& params, bool fHelp) { UniValue ret(UniValue::VOBJ); uint32_t flags; uint8_t value[IGUANA_MAXSCRIPTSIZE],key[IGUANA_MAXSCRIPTSIZE]; int32_t duration,j,height,valuesize,keylen; uint256 refpubkey; static uint256 zeroes; if (fHelp || params.size() != 1 ) - throw runtime_error("kvsearch key"); + throw runtime_error( + "kvsearch key\n" + "\nSearch for a key stored via the kvupdate command. This feature is only available for asset chains.\n" + "\nArguments:\n" + "1. key (string, required) search the chain for this key\n" + "\nResult:\n" + "{\n" + " \"coin\": \"xxxxx\", (string) chain the key is stored on\n" + " \"currentheight\": xxxxx, (numeric) current height of the chain\n" + " \"key\": \"xxxxx\", (string) key\n" + " \"keylen\": xxxxx, (string) length of the key \n" + " \"owner\": \"xxxx\" (string) hex string representing the owner of the key \n" + " \"height\": xxxxx, (numeric) height the key was stored at\n" + " \"expiration\": xxxxx, (numeric) height the key will expire\n" + " \"flags\": x (numeric) 1 if the key was created with a password; 0 otherwise.\n" + " \"value\": \"xxxxx\", (string) stored value\n" + " \"valuesize\": xxxxx (string) amount of characters stored\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("kvsearch", "examplekey") + + HelpExampleRpc("kvsearch", "examplekey") + ); LOCK(cs_main); if ( (keylen= (int32_t)strlen(params[0].get_str().c_str())) > 0 ) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7187b8fe8..c8b350b73 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -509,7 +509,31 @@ UniValue kvupdate(const UniValue& params, bool fHelp) CWalletTx wtx; UniValue ret(UniValue::VOBJ); uint8_t keyvalue[IGUANA_MAXSCRIPTSIZE],opretbuf[IGUANA_MAXSCRIPTSIZE]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct komodo_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig; if (fHelp || params.size() < 3 ) - throw runtime_error("kvupdate key value flags/passphrase"); + throw runtime_error( + "kvupdate key \"value\" days passphrase\n" + "\nStore a key value. This feature is only available for asset chains.\n" + "\nArguments:\n" + "1. key (string, required) key\n" + "2. \"value\" (string, required) value\n" + "3. days (numeric, required) amount of days(1440 blocks/day) before the key expires. Minimum 1 day\n" + "4. passphrase (string, optional) passphrase required to update this key\n" + "\nResult:\n" + "{\n" + " \"coin\": \"xxxxx\", (string) chain the key is stored on\n" + " \"height\": xxxxx, (numeric) height the key was stored at\n" + " \"expiration\": \"xxxxx\", (numeric) height the key will expire\n" + " \"flags\": xxxxx, (string) amount of days the key will be stored \n" + " \"key\": xxxxx, (numeric) stored key\n" + " \"keylen\": xxxxx, (numeric) length of the key\n" + " \"value\": x (numeric) stored value\n" + " \"valuesize\": \"xxxxx\", (string) length of the stored value\n" + " \"fee\": xxxxx (string) transaction fee paid to store the key\n" + " \"txid\": xxxxx (string) transaction id\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("kvupdate", "examplekey \"examplevalue\" 2 examplepassphrase") + + HelpExampleRpc("kvupdate", "examplekey \"examplevalue\" 2 examplepassphrase") + ); if (!EnsureWalletIsAvailable(fHelp)) return 0; if ( ASSETCHAINS_SYMBOL[0] == 0 ) From 6f3db929c641b64c6810f720c720a9c1e408ba83 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 25 Jun 2018 14:42:07 -0400 Subject: [PATCH 2/2] fix KV help --- src/rpcblockchain.cpp | 2 +- src/wallet/rpcwallet.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8e13fb666..cfb89815b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -778,7 +778,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp) " \"currentheight\": xxxxx, (numeric) current height of the chain\n" " \"key\": \"xxxxx\", (string) key\n" " \"keylen\": xxxxx, (string) length of the key \n" - " \"owner\": \"xxxx\" (string) hex string representing the owner of the key \n" + " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" " \"height\": xxxxx, (numeric) height the key was stored at\n" " \"expiration\": xxxxx, (numeric) height the key will expire\n" " \"flags\": x (numeric) 1 if the key was created with a password; 0 otherwise.\n" diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c8b350b73..bbbc9d897 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -521,14 +521,14 @@ UniValue kvupdate(const UniValue& params, bool fHelp) "{\n" " \"coin\": \"xxxxx\", (string) chain the key is stored on\n" " \"height\": xxxxx, (numeric) height the key was stored at\n" - " \"expiration\": \"xxxxx\", (numeric) height the key will expire\n" - " \"flags\": xxxxx, (string) amount of days the key will be stored \n" - " \"key\": xxxxx, (numeric) stored key\n" + " \"expiration\": xxxxx, (numeric) height the key will expire\n" + " \"flags\": x, (string) amount of days the key will be stored \n" + " \"key\": \"xxxxx\", (numeric) stored key\n" " \"keylen\": xxxxx, (numeric) length of the key\n" - " \"value\": x (numeric) stored value\n" - " \"valuesize\": \"xxxxx\", (string) length of the stored value\n" + " \"value\": \"xxxxx\" (numeric) stored value\n" + " \"valuesize\": xxxxx, (string) length of the stored value\n" " \"fee\": xxxxx (string) transaction fee paid to store the key\n" - " \"txid\": xxxxx (string) transaction id\n" + " \"txid\": \"xxxxx\" (string) transaction id\n" "}\n" "\nExamples:\n" + HelpExampleCli("kvupdate", "examplekey \"examplevalue\" 2 examplepassphrase")