check for raw mode before any printf.
This commit is contained in:
parent
cbf919fb1d
commit
8809be2d8c
@ -180,6 +180,8 @@ extern std::string DecodeDumpString(const std::string &str);
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
using namespace node;
|
using namespace node;
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
|
||||||
@ -615,6 +617,13 @@ static bool
|
|||||||
get_block_by_tx_unspent(const std::string itxid, CBlock& rcblock, CBlockIndex **rcblock_index);
|
get_block_by_tx_unspent(const std::string itxid, CBlock& rcblock, CBlockIndex **rcblock_index);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
static bool
|
||||||
|
is_raw(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions
|
* Functions
|
||||||
*/
|
*/
|
||||||
@ -801,7 +810,9 @@ start_node_thread(void) {
|
|||||||
argv[argc] = arg;
|
argv[argc] = arg;
|
||||||
argc++;
|
argc++;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "bitcoind.js: Bad -datadir value.");
|
if (!is_raw()) {
|
||||||
|
fprintf(stderr, "bitcoind.js: Bad -datadir value.\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,23 +838,29 @@ start_node_thread(void) {
|
|||||||
ParseParameters((const int)argc, (const char **)argv);
|
ParseParameters((const int)argc, (const char **)argv);
|
||||||
|
|
||||||
if (!boost::filesystem::is_directory(GetDataDir(false))) {
|
if (!boost::filesystem::is_directory(GetDataDir(false))) {
|
||||||
fprintf(stderr,
|
if (!is_raw()) {
|
||||||
"bitcoind.js: Specified data directory \"%s\" does not exist.\n",
|
fprintf(stderr,
|
||||||
mapArgs["-datadir"].c_str());
|
"bitcoind.js: Specified data directory \"%s\" does not exist.\n",
|
||||||
|
mapArgs["-datadir"].c_str());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
ReadConfigFile(mapArgs, mapMultiArgs);
|
||||||
} catch(std::exception &e) {
|
} catch(std::exception &e) {
|
||||||
fprintf(stderr,
|
if (!is_raw()) {
|
||||||
"bitcoind.js: Error reading configuration file: %s\n", e.what());
|
fprintf(stderr,
|
||||||
|
"bitcoind.js: Error reading configuration file: %s\n", e.what());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SelectParamsFromCommandLine()) {
|
if (!SelectParamsFromCommandLine()) {
|
||||||
fprintf(stderr,
|
if (!is_raw()) {
|
||||||
"bitcoind.js: Invalid combination of -regtest and -testnet.\n");
|
fprintf(stderr,
|
||||||
|
"bitcoind.js: Invalid combination of -regtest and -testnet.\n");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,9 +870,13 @@ start_node_thread(void) {
|
|||||||
boost::bind(&DetectShutdownThread, &threadGroup));
|
boost::bind(&DetectShutdownThread, &threadGroup));
|
||||||
fRet = AppInit2(threadGroup);
|
fRet = AppInit2(threadGroup);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
fprintf(stderr, "bitcoind.js: AppInit(): std::exception");
|
if (!is_raw()) {
|
||||||
|
fprintf(stderr, "bitcoind.js: AppInit(): std::exception\n");
|
||||||
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
fprintf(stderr, "bitcoind.js: AppInit(): other exception");
|
if (!is_raw()) {
|
||||||
|
fprintf(stderr, "bitcoind.js: AppInit(): other exception\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fRet) {
|
if (!fRet) {
|
||||||
@ -4783,13 +4804,15 @@ NAN_METHOD(WalletEncrypt) {
|
|||||||
// unencrypted private keys. So:
|
// unencrypted private keys. So:
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
|
|
||||||
printf(
|
if (!is_raw()) {
|
||||||
"bitcoind.js:"
|
printf(
|
||||||
" wallet encrypted; bitcoind.js stopping,"
|
"bitcoind.js:"
|
||||||
" restart to run with encrypted wallet."
|
" wallet encrypted; bitcoind.js stopping,"
|
||||||
" The keypool has been flushed, you need"
|
" restart to run with encrypted wallet."
|
||||||
" to make a new backup.\n"
|
" The keypool has been flushed, you need"
|
||||||
);
|
" to make a new backup.\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
NanReturnValue(Undefined());
|
NanReturnValue(Undefined());
|
||||||
}
|
}
|
||||||
@ -6659,6 +6682,36 @@ SatoshiFromAmount(const CAmount& amount) {
|
|||||||
return (int64_t)amount;
|
return (int64_t)amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
static bool
|
||||||
|
is_raw(void) {
|
||||||
|
termios raw;
|
||||||
|
|
||||||
|
if (tcgetattr(STDIN_FILENO, &raw)) {
|
||||||
|
return true; // failsafe
|
||||||
|
}
|
||||||
|
|
||||||
|
// libuv sets:
|
||||||
|
// raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
|
||||||
|
// raw.c_oflag |= (ONLCR);
|
||||||
|
// raw.c_cflag |= (CS8);
|
||||||
|
// raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
|
||||||
|
// raw.c_cc[VMIN] = 1;
|
||||||
|
// raw.c_cc[VTIME] = 0;
|
||||||
|
|
||||||
|
if ((raw.c_oflag & ONLCR)
|
||||||
|
&& (raw.c_cflag & CS8)
|
||||||
|
&& raw.c_cc[VMIN] == 1
|
||||||
|
&& raw.c_cc[VTIME] == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init()
|
* Init()
|
||||||
* Initialize the singleton object known as bitcoindjs.
|
* Initialize the singleton object known as bitcoindjs.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user