mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
bdb50539de
More info regarding KeePass: http://keepass.info/ KeePass integration will use KeePassHttp (https://github.com/pfn/keepasshttp/) to facilitate communications between the client and KeePass. KeePassHttp is a plugin for KeePass 2.x and provides a secure means of exposing KeePass entries via HTTP for clients to consume. The implementation is dependent on the following: - crypter.h for AES encryption helper functions. - rpcprotocol.h for handling RPC communications. Could only be used partially however due some static values in the code. - OpenSSL for base64 encoding. regular util.h libraries were not used for base64 encoding/decoding since they do not use secure allocation. - JSON Spirit for reading / writing RPC communications The following changes were made: - Added CLI options in help - Added RPC commands: keepass <genkey|init|setpassphrase> - Added keepass.h and keepass.cpp which hold the integration routines - Modified rpcwallet.cpp to support RPC commands The following new options are available for darkcoind and darkcoin-qt: -keepass Use KeePass 2 integration using KeePassHttp plugin (default: 0) -keepassport=<port> Connect to KeePassHttp on port <port> (default: 19455) -keepasskey=<key> KeePassHttp key for AES encrypted communication with KeePass -keepassid=<name> KeePassHttp id for the established association -keepassname=<name> Name to construct url for KeePass entry that stores the wallet passphrase The following rpc commands are available: - keepass genkey: generates a base64 encoded 256 bit AES key that can be used for the communication with KeePassHttp. Only necessary for manual configuration. Use init for automatic configuration. - keepass init: sets up the association between darkcoind and keepass by generating an AES key and sending an association message to KeePassHttp. This will trigger KeePass to ask for an Id for the association. Returns the association and the base64 encoded string for the AES key. - keepass setpassphrase <passphrase>: updates the passphrase in KeePassHttp to a new value. This should match the passphrase you intend to use for the wallet. Please note that the standard RPC commands walletpassphrasechange and the wallet encrption from the QT GUI already send the updates to KeePassHttp, so this is only necessary for manual manipulation of the password. Sample initialization flow from darkcoin-qt console (this needs to be done only once to set up the association): - Have KeePass running with an open database - Start darkcoin-qt - Open console - type: "keepass init" in darkcoin-qt console - (keepass pops up and asks for an association id, fill that in). Example: mydrkwallet - response: Association successful. Id: mydrkwalletdarkcoin - Key: AgQkcs6cI7v9tlSYKjG/+s8wJrGALHl3jLosJpPLzUE= - Edit darkcoin.conf and fill in these values keepass=1 keepasskey=AgQkcs6cI7v9tlSYKjG/+s8wJrGALHl3jLosJpPLzUE= keepassid=mydrkwallet keepassname=testwallet - Restart darkcoin-qt At this point, the association is made. The next action depends on your particular situation: - current wallet is not yet encrypted. Encrypting the wallet will trigger the integration and stores the password in KeePass (Under the 'KeePassHttp Passwords' group, named after keepassname. - current wallet is already encrypted: use "keepass setpassphrase <passphrase>" to store the passphrase in KeePass. At this point, the passphrase is stored in KeePassHttp. When Unlocking the wallet, one can use keepass as the passphrase to trigger retrieval of the password. This works from the RPC commands as well as the GUI.
198 lines
10 KiB
C++
198 lines
10 KiB
C++
// Copyright (c) 2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2014 The Bitcoin developers
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef _BITCOINRPC_SERVER_H_
|
|
#define _BITCOINRPC_SERVER_H_ 1
|
|
|
|
#include "uint256.h"
|
|
#include "rpcprotocol.h"
|
|
|
|
#include <list>
|
|
#include <map>
|
|
#include <stdint.h>
|
|
#include <string>
|
|
|
|
#include "json/json_spirit_reader_template.h"
|
|
#include "json/json_spirit_utils.h"
|
|
#include "json/json_spirit_writer_template.h"
|
|
|
|
class CBlockIndex;
|
|
|
|
/* Start RPC threads */
|
|
void StartRPCThreads();
|
|
/* Alternative to StartRPCThreads for the GUI, when no server is
|
|
* used. The RPC thread in this case is only used to handle timeouts.
|
|
* If real RPC threads have already been started this is a no-op.
|
|
*/
|
|
void StartDummyRPCThread();
|
|
/* Stop RPC threads */
|
|
void StopRPCThreads();
|
|
|
|
/*
|
|
Type-check arguments; throws JSONRPCError if wrong type given. Does not check that
|
|
the right number of arguments are passed, just that any passed are the correct type.
|
|
Use like: RPCTypeCheck(params, boost::assign::list_of(str_type)(int_type)(obj_type));
|
|
*/
|
|
void RPCTypeCheck(const json_spirit::Array& params,
|
|
const std::list<json_spirit::Value_type>& typesExpected, bool fAllowNull=false);
|
|
/*
|
|
Check for expected keys/value types in an Object.
|
|
Use like: RPCTypeCheck(object, boost::assign::map_list_of("name", str_type)("value", int_type));
|
|
*/
|
|
void RPCTypeCheck(const json_spirit::Object& o,
|
|
const std::map<std::string, json_spirit::Value_type>& typesExpected, bool fAllowNull=false);
|
|
|
|
/*
|
|
Run func nSeconds from now. Uses boost deadline timers.
|
|
Overrides previous timer <name> (if any).
|
|
*/
|
|
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds);
|
|
|
|
typedef json_spirit::Value(*rpcfn_type)(const json_spirit::Array& params, bool fHelp);
|
|
|
|
class CRPCCommand
|
|
{
|
|
public:
|
|
std::string name;
|
|
rpcfn_type actor;
|
|
bool okSafeMode;
|
|
bool threadSafe;
|
|
bool reqWallet;
|
|
};
|
|
|
|
/**
|
|
* Darkcoin RPC command dispatcher.
|
|
*/
|
|
class CRPCTable
|
|
{
|
|
private:
|
|
std::map<std::string, const CRPCCommand*> mapCommands;
|
|
public:
|
|
CRPCTable();
|
|
const CRPCCommand* operator[](std::string name) const;
|
|
std::string help(std::string name) const;
|
|
|
|
/**
|
|
* Execute a method.
|
|
* @param method Method to execute
|
|
* @param params Array of arguments (JSON objects)
|
|
* @returns Result of the call.
|
|
* @throws an exception (json_spirit::Value) when an error happens.
|
|
*/
|
|
json_spirit::Value execute(const std::string &method, const json_spirit::Array ¶ms) const;
|
|
};
|
|
|
|
extern const CRPCTable tableRPC;
|
|
|
|
//
|
|
// Utilities: convert hex-encoded Values
|
|
// (throws error if not hex).
|
|
//
|
|
extern uint256 ParseHashV(const json_spirit::Value& v, std::string strName);
|
|
extern uint256 ParseHashO(const json_spirit::Object& o, std::string strKey);
|
|
extern std::vector<unsigned char> ParseHexV(const json_spirit::Value& v, std::string strName);
|
|
extern std::vector<unsigned char> ParseHexO(const json_spirit::Object& o, std::string strKey);
|
|
|
|
extern void InitRPCMining();
|
|
extern void ShutdownRPCMining();
|
|
|
|
extern int64_t nWalletUnlockTime;
|
|
extern int64_t AmountFromValue(const json_spirit::Value& value);
|
|
extern json_spirit::Value ValueFromAmount(int64_t amount);
|
|
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
|
|
extern std::string HexBits(unsigned int nBits);
|
|
extern std::string HelpRequiringPassphrase();
|
|
extern std::string HelpExampleCli(std::string methodname, std::string args);
|
|
extern std::string HelpExampleRpc(std::string methodname, std::string args);
|
|
|
|
extern void EnsureWalletIsUnlocked();
|
|
|
|
extern json_spirit::Value getconnectioncount(const json_spirit::Array& params, bool fHelp); // in rpcnet.cpp
|
|
extern json_spirit::Value getpeerinfo(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value ping(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getnettotals(const json_spirit::Array& params, bool fHelp);
|
|
|
|
extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
|
extern json_spirit::Value importprivkey(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value dumpwallet(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fHelp);
|
|
|
|
extern json_spirit::Value getgenerate(const json_spirit::Array& params, bool fHelp); // in rpcmining.cpp
|
|
extern json_spirit::Value setgenerate(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getnetworkhashps(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value gethashespersec(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getmininginfo(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getwork(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getblocktemplate(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value submitblock(const json_spirit::Array& params, bool fHelp);
|
|
|
|
extern json_spirit::Value getnewaddress(const json_spirit::Array& params, bool fHelp); // in rpcwallet.cpp
|
|
extern json_spirit::Value getaccountaddress(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getrawchangeaddress(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value sendtoaddress(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value signmessage(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value verifymessage(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getreceivedbyaddress(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getreceivedbyaccount(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getbalance(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getunconfirmedbalance(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value movecmd(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value sendfrom(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value sendmany(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value addmultisigaddress(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value createmultisig(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value listreceivedbyaddress(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value listreceivedbyaccount(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value listtransactions(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value listaddressgroupings(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value listaccounts(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value listsinceblock(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value gettransaction(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value backupwallet(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value keypoolrefill(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value walletpassphrase(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value walletpassphrasechange(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value walletlock(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value encryptwallet(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value validateaddress(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getinfo(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getwalletinfo(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getblockchaininfo(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getnetworkinfo(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value keepass(const json_spirit::Array& params, bool fHelp);
|
|
|
|
extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp
|
|
extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value lockunspent(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value listlockunspent(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value createrawtransaction(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value decoderawtransaction(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value decodescript(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value signrawtransaction(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, bool fHelp);
|
|
|
|
extern json_spirit::Value getblockcount(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp
|
|
extern json_spirit::Value getbestblockhash(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value settxfee(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getrawmempool(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getblockhash(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value getblock(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value verifychain(const json_spirit::Array& params, bool fHelp);
|
|
|
|
|
|
extern json_spirit::Value darksend(const json_spirit::Array& params, bool fHelp);
|
|
extern json_spirit::Value masternode(const json_spirit::Array& params, bool fHelp);
|
|
|
|
|
|
#endif
|