From 5b59877146c503a054324638b1b44e1658754fea Mon Sep 17 00:00:00 2001 From: Jimmy Kiselak Date: Mon, 26 Oct 2015 15:51:10 -0400 Subject: [PATCH] combine getvalueforname and gettxinfoforname --- src/rpcncctrie.cpp | 38 ++++++++------------------------------ src/rpcserver.cpp | 1 - src/rpcserver.h | 1 - 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/rpcncctrie.cpp b/src/rpcncctrie.cpp index 74bffe86f..aca63dccd 100644 --- a/src/rpcncctrie.cpp +++ b/src/rpcncctrie.cpp @@ -44,36 +44,6 @@ UniValue getnametrie(const UniValue& params, bool fHelp) return ret; } -UniValue gettxinfoforname(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw std::runtime_error( - "gettxinfoforname \"name\"\n" - "Return information about the transaction that has successfully claimed a name, if one exists\n" - "Arguments:\n" - "1. \"name\" (string) the name about which to return info\n" - "Result: \n" - "\"txid\" (string) the hash of the transaction which successfully claimed the name\n" - "\"n\" (numeric) vout value\n" - "\"amount\" (numeric) txout amount\n" - "\"height\" (numeric) the height of the block in which this transaction is located\n" - ); - LOCK(cs_main); - - std::string name = params[0].get_str(); - - UniValue ret(UniValue::VOBJ); - CNodeValue val; - if (pnccTrie->getInfoForName(name, val)) - { - ret.push_back(Pair("txid", val.txhash.GetHex())); - ret.push_back(Pair("n", (int)val.nOut)); - ret.push_back(Pair("amount", val.nAmount)); - ret.push_back(Pair("height", val.nHeight)); - } - return ret; -} - UniValue getvalueforname(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -84,6 +54,10 @@ UniValue getvalueforname(const UniValue& params, bool fHelp) "1. \"name\" (string) the name to look up\n" "Result: \n" "\"value\" (string) the value of the name, if it exists\n" + "\"txid\" (string) the hash of the transaction which successfully claimed the name\n" + "\"n\" (numeric) vout value\n" + "\"amount\" (numeric) txout amount\n" + "\"height\" (numeric) the height of the block in which this transaction is located\n" ); LOCK(cs_main); std::string name = params[0].get_str(); @@ -113,6 +87,10 @@ UniValue getvalueforname(const UniValue& params, bool fHelp) } std::string sValue(vvchParams[1].begin(), vvchParams[1].end()); ret.push_back(Pair("value", sValue)); + ret.push_back(Pair("txid", val.txhash.GetHex())); + ret.push_back(Pair("n", (int)val.nOut)); + ret.push_back(Pair("amount", val.nAmount)); + ret.push_back(Pair("height", val.nHeight)); return ret; } diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 5f753992e..b427adfae 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -381,7 +381,6 @@ static const CRPCCommand vRPCCommands[] = /* NCC trie */ { "nametrie", "getnametrie", &getnametrie, true }, - { "nametrie", "gettxinfoforname", &gettxinfoforname, true }, { "nametrie", "getvalueforname", &getvalueforname, true }, { "nametrie", "gettotalclaimednames", &gettotalclaimednames, true }, { "nametrie", "gettotalclaims", &gettotalclaims, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index a65330716..9fd6c550f 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -242,7 +242,6 @@ extern UniValue invalidateblock(const UniValue& params, bool fHelp); extern UniValue reconsiderblock(const UniValue& params, bool fHelp); extern UniValue getnametrie(const UniValue& params, bool fHelp); // in rpcncctrie.cpp -extern UniValue gettxinfoforname(const UniValue& params, bool fHelp); extern UniValue getvalueforname(const UniValue& params, bool fHelp); extern UniValue gettotalclaimednames(const UniValue& params, bool fHelp); extern UniValue gettotalclaims(const UniValue& params, bool fHelp);