Initial merge
This commit is contained in:
@@ -20,12 +20,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include "json/json_spirit_utils.h"
|
||||
#include "json/json_spirit_value.h"
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
#include "zcash/Address.hpp"
|
||||
|
||||
using namespace json_spirit;
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
@@ -41,6 +40,7 @@ using namespace std;
|
||||
*
|
||||
* Or alternatively, create a specific query method for the information.
|
||||
**/
|
||||
|
||||
uint64_t komodo_interestsum();
|
||||
int32_t komodo_longestchain();
|
||||
int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp);
|
||||
@@ -50,7 +50,7 @@ extern char ASSETCHAINS_SYMBOL[];
|
||||
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
|
||||
#define KOMODO_VERSION "0.1.0"
|
||||
|
||||
Value getinfo(const Array& params, bool fHelp)
|
||||
UniValue getinfo(const UniValue& params, bool fHelp)
|
||||
{
|
||||
uint256 notarized_hash,notarized_desttxid; int32_t notarized_height,longestchain,kmdnotarized_height,txid_height;
|
||||
if (fHelp || params.size() != 0)
|
||||
@@ -91,7 +91,7 @@ Value getinfo(const Array& params, bool fHelp)
|
||||
GetProxy(NET_IPV4, proxy);
|
||||
notarized_height = komodo_notarized_height(¬arized_hash,¬arized_desttxid);
|
||||
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("version", CLIENT_VERSION));
|
||||
obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
|
||||
obj.push_back(Pair("KMDversion", KOMODO_VERSION));
|
||||
@@ -149,41 +149,34 @@ Value getinfo(const Array& params, bool fHelp)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
class DescribeAddressVisitor : public boost::static_visitor<Object>
|
||||
class DescribeAddressVisitor : public boost::static_visitor<UniValue>
|
||||
{
|
||||
private:
|
||||
isminetype mine;
|
||||
|
||||
public:
|
||||
DescribeAddressVisitor(isminetype mineIn) : mine(mineIn) {}
|
||||
UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
|
||||
|
||||
Object operator()(const CNoDestination &dest) const { return Object(); }
|
||||
|
||||
Object operator()(const CKeyID &keyID) const {
|
||||
Object obj;
|
||||
UniValue operator()(const CKeyID &keyID) const {
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
CPubKey vchPubKey;
|
||||
obj.push_back(Pair("isscript", false));
|
||||
if (mine == ISMINE_SPENDABLE) {
|
||||
pwalletMain->GetPubKey(keyID, vchPubKey);
|
||||
if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) {
|
||||
obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
|
||||
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
Object operator()(const CScriptID &scriptID) const {
|
||||
Object obj;
|
||||
UniValue operator()(const CScriptID &scriptID) const {
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
CScript subscript;
|
||||
obj.push_back(Pair("isscript", true));
|
||||
if (mine != ISMINE_NO) {
|
||||
CScript subscript;
|
||||
pwalletMain->GetCScript(scriptID, subscript);
|
||||
if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) {
|
||||
std::vector<CTxDestination> addresses;
|
||||
txnouttype whichType;
|
||||
int nRequired;
|
||||
ExtractDestinations(subscript, whichType, addresses, nRequired);
|
||||
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
|
||||
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
|
||||
Array a;
|
||||
UniValue a(UniValue::VARR);
|
||||
BOOST_FOREACH(const CTxDestination& addr, addresses)
|
||||
a.push_back(CBitcoinAddress(addr).ToString());
|
||||
obj.push_back(Pair("addresses", a));
|
||||
@@ -195,7 +188,7 @@ public:
|
||||
};
|
||||
#endif
|
||||
|
||||
Value validateaddress(const Array& params, bool fHelp)
|
||||
UniValue validateaddress(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
@@ -228,7 +221,7 @@ Value validateaddress(const Array& params, bool fHelp)
|
||||
CBitcoinAddress address(params[0].get_str());
|
||||
bool isValid = address.IsValid();
|
||||
|
||||
Object ret;
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
ret.push_back(Pair("isvalid", isValid));
|
||||
if (isValid)
|
||||
{
|
||||
@@ -242,11 +235,9 @@ Value validateaddress(const Array& params, bool fHelp)
|
||||
#ifdef ENABLE_WALLET
|
||||
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
|
||||
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
|
||||
if (mine != ISMINE_NO) {
|
||||
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
|
||||
Object detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest);
|
||||
ret.insert(ret.end(), detail.begin(), detail.end());
|
||||
}
|
||||
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
|
||||
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
|
||||
ret.pushKVs(detail);
|
||||
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
|
||||
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name));
|
||||
#endif
|
||||
@@ -255,7 +246,7 @@ Value validateaddress(const Array& params, bool fHelp)
|
||||
}
|
||||
|
||||
|
||||
Value z_validateaddress(const Array& params, bool fHelp)
|
||||
UniValue z_validateaddress(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
@@ -302,7 +293,7 @@ Value z_validateaddress(const Array& params, bool fHelp)
|
||||
// address is invalid, nop here as isValid is false.
|
||||
}
|
||||
|
||||
Object ret;
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
ret.push_back(Pair("isvalid", isValid));
|
||||
if (isValid)
|
||||
{
|
||||
@@ -320,10 +311,10 @@ Value z_validateaddress(const Array& params, bool fHelp)
|
||||
/**
|
||||
* Used by addmultisigaddress / createmultisig:
|
||||
*/
|
||||
CScript _createmultisig_redeemScript(const Array& params)
|
||||
CScript _createmultisig_redeemScript(const UniValue& params)
|
||||
{
|
||||
int nRequired = params[0].get_int();
|
||||
const Array& keys = params[1].get_array();
|
||||
const UniValue& keys = params[1].get_array();
|
||||
|
||||
// Gather public keys
|
||||
if (nRequired < 1)
|
||||
@@ -381,7 +372,7 @@ CScript _createmultisig_redeemScript(const Array& params)
|
||||
return result;
|
||||
}
|
||||
|
||||
Value createmultisig(const Array& params, bool fHelp)
|
||||
UniValue createmultisig(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() < 2 || params.size() > 2)
|
||||
{
|
||||
@@ -417,14 +408,14 @@ Value createmultisig(const Array& params, bool fHelp)
|
||||
CScriptID innerID(inner);
|
||||
CBitcoinAddress address(innerID);
|
||||
|
||||
Object result;
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.push_back(Pair("address", address.ToString()));
|
||||
result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end())));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Value verifymessage(const Array& params, bool fHelp)
|
||||
UniValue verifymessage(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 3)
|
||||
throw runtime_error(
|
||||
@@ -478,7 +469,7 @@ Value verifymessage(const Array& params, bool fHelp)
|
||||
return (pubkey.GetID() == keyID);
|
||||
}
|
||||
|
||||
Value setmocktime(const Array& params, bool fHelp)
|
||||
UniValue setmocktime(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
@@ -492,10 +483,19 @@ Value setmocktime(const Array& params, bool fHelp)
|
||||
if (!Params().MineBlocksOnDemand())
|
||||
throw runtime_error("setmocktime for regression testing (-regtest mode) only");
|
||||
|
||||
LOCK(cs_main);
|
||||
// cs_vNodes is locked and node send/receive times are updated
|
||||
// atomically with the time change to prevent peers from being
|
||||
// disconnected because we think we haven't communicated with them
|
||||
// in a long time.
|
||||
LOCK2(cs_main, cs_vNodes);
|
||||
|
||||
RPCTypeCheck(params, boost::assign::list_of(int_type));
|
||||
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
|
||||
SetMockTime(params[0].get_int64());
|
||||
|
||||
return Value::null;
|
||||
uint64_t t = GetTime();
|
||||
BOOST_FOREACH(CNode* pnode, vNodes) {
|
||||
pnode->nLastSend = pnode->nLastRecv = t;
|
||||
}
|
||||
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user