2013-10-11 23:09:59 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
|
|
// Copyright (c) 2009-2013 The Bitcoin developers
|
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "init.h"
|
2013-11-20 14:18:57 +01:00
|
|
|
#include "rpcclient.h"
|
2013-10-11 23:09:59 +02:00
|
|
|
#include "ui_interface.h" /* for _(...) */
|
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <boost/filesystem/operations.hpp>
|
|
|
|
|
2013-10-11 23:09:59 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Start
|
|
|
|
//
|
|
|
|
static bool AppInitRPC(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Parameters
|
|
|
|
//
|
|
|
|
ParseParameters(argc, argv);
|
|
|
|
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ReadConfigFile(mapArgs, mapMultiArgs);
|
|
|
|
|
|
|
|
if (argc<2 || mapArgs.count("-?") || mapArgs.count("--help"))
|
|
|
|
{
|
|
|
|
// First part of help message is specific to RPC client
|
|
|
|
std::string strUsage = _("Bitcoin RPC client version") + " " + FormatFullVersion() + "\n\n" +
|
|
|
|
_("Usage:") + "\n" +
|
|
|
|
" bitcoin-cli [options] <command> [params] " + _("Send command to Bitcoin server") + "\n" +
|
|
|
|
" bitcoin-cli [options] help " + _("List commands") + "\n" +
|
|
|
|
" bitcoin-cli [options] help <command> " + _("Get help for a command") + "\n";
|
|
|
|
|
|
|
|
strUsage += "\n" + HelpMessage(HMM_BITCOIN_CLI);
|
|
|
|
|
|
|
|
fprintf(stdout, "%s", strUsage.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(!AppInitRPC(argc, argv))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
catch (std::exception& e) {
|
|
|
|
PrintExceptionContinue(&e, "AppInitRPC()");
|
|
|
|
} catch (...) {
|
|
|
|
PrintExceptionContinue(NULL, "AppInitRPC()");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(!CommandLineRPC(argc, argv))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
catch (std::exception& e) {
|
|
|
|
PrintExceptionContinue(&e, "CommandLineRPC()");
|
|
|
|
} catch (...) {
|
|
|
|
PrintExceptionContinue(NULL, "CommandLineRPC()");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|