forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4742 from vijaydasmp/bp2002
Merge bitcoin#17154,16569,17351,13716,17084,18391,16821,17140
- Loading branch information
Showing
36 changed files
with
288 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2018 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#if defined(HAVE_CONFIG_H) | ||
#include <config/dash-config.h> | ||
#endif | ||
|
||
#include <cstdio> // for fileno(), stdin | ||
|
||
#ifdef WIN32 | ||
#include <windows.h> // for SetStdinEcho() | ||
#include <io.h> // for isatty() | ||
#else | ||
#include <termios.h> // for SetStdinEcho() | ||
#include <unistd.h> // for SetStdinEcho(), isatty() | ||
#include <poll.h> // for StdinReady() | ||
#endif | ||
|
||
#include <compat/stdin.h> | ||
|
||
// https://stackoverflow.com/questions/1413445/reading-a-password-from-stdcin | ||
void SetStdinEcho(bool enable) | ||
{ | ||
#ifdef WIN32 | ||
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); | ||
DWORD mode; | ||
GetConsoleMode(hStdin, &mode); | ||
if (!enable) { | ||
mode &= ~ENABLE_ECHO_INPUT; | ||
} else { | ||
mode |= ENABLE_ECHO_INPUT; | ||
} | ||
SetConsoleMode(hStdin, mode); | ||
#else | ||
struct termios tty; | ||
tcgetattr(STDIN_FILENO, &tty); | ||
if (!enable) { | ||
tty.c_lflag &= ~ECHO; | ||
} else { | ||
tty.c_lflag |= ECHO; | ||
} | ||
(void)tcsetattr(STDIN_FILENO, TCSANOW, &tty); | ||
#endif | ||
} | ||
|
||
bool StdinTerminal() | ||
{ | ||
#ifdef WIN32 | ||
return _isatty(_fileno(stdin)); | ||
#else | ||
return isatty(fileno(stdin)); | ||
#endif | ||
} | ||
|
||
bool StdinReady() | ||
{ | ||
if (!StdinTerminal()) { | ||
return true; | ||
} | ||
#ifdef WIN32 | ||
return false; | ||
#else | ||
struct pollfd fds; | ||
fds.fd = 0; /* this is STDIN */ | ||
fds.events = POLLIN; | ||
return poll(&fds, 1, 0) == 1; | ||
#endif | ||
} | ||
|
||
NoechoInst::NoechoInst() { SetStdinEcho(false); } | ||
NoechoInst::~NoechoInst() { SetStdinEcho(true); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2018 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_COMPAT_STDIN_H | ||
#define BITCOIN_COMPAT_STDIN_H | ||
|
||
struct NoechoInst { | ||
NoechoInst(); | ||
~NoechoInst(); | ||
}; | ||
|
||
#define NO_STDIN_ECHO() NoechoInst _no_echo | ||
|
||
bool StdinTerminal(); | ||
bool StdinReady(); | ||
|
||
#endif // BITCOIN_COMPAT_STDIN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.