Skip to content

Conversation

@kallewoof
Copy link
Contributor

This PR

  • adds -stdinwalletpassphrase for use with walletpasshprase(change)
  • adds no-echo for passwords (-stdinrpcpass and above)

It may not be ideal, but it's better than having to clear the screen whenever you unlock the wallet.

@kallewoof kallewoof force-pushed the stdinwalletpassphrase branch 2 times, most recently from 6644848 to 64eb9b5 Compare July 19, 2018 18:04
@practicalswift
Copy link
Contributor

Concept ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 22, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@hebasto
Copy link
Member

hebasto commented Aug 5, 2018

There are conflicting pull requests:

  • this one adds new features and, as a side effect, fixes one of two bugs in bitcoin-cli --help output;
  • #13879 fixes all found bugs in bitcoin-cli --help output and is safe for the whole code.

So, #13879 can be merged regardless of this pull request.

src/util.cpp Outdated
Copy link
Member

@laanwj laanwj Sep 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is only used in bitcoin-cli, it doesn't need to be in util.cpp (which is shared between the server and client), would be better in a client-specific utility, e.g. compat/noecho.{cpp,h} or something like that, that is only linked into -cli.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixing.

src/util.cpp Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this generally supported on all UNIX, or does it need checks in the build system?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

termios.h? It seems to be pretty standard FWICT.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to test on FreeBSD and OpenBSD

@laanwj
Copy link
Member

laanwj commented Sep 10, 2018

Concept ACK

@kallewoof kallewoof force-pushed the stdinwalletpassphrase branch from fb1f6c9 to abd986f Compare September 11, 2018 06:35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • need to re-enable echoing before the normal -stdin processing
  • make sure that this is not called unless either -stdinrpcpass or -stdinwalletpassphrase is called to avoid interfering with scripts that pipe in data, not attached to a TTY

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points. Addressed both.

@kallewoof
Copy link
Contributor Author

@Sjors

Nit: return \n after password entry.

Hitting enter adds a newline on my mac. Where do you want one to be added? After the std::getline call?

@Sjors
Copy link
Member

Sjors commented Feb 13, 2019

@kallewoof it didn't return a new line for me (macOS 10.14.3):
schermafbeelding 2019-02-13 om 10 11 12

schermafbeelding 2019-02-13 om 10 17 12

re-tACK 110e821

@kallewoof
Copy link
Contributor Author

Oh, okay! So this is the case for pre-existing -stdinrpcpass as well. Fixed in d1688c9.

@Sjors
Copy link
Member

Sjors commented Feb 14, 2019

re-tACK d1688c9

@kallewoof kallewoof force-pushed the stdinwalletpassphrase branch 2 times, most recently from e80b84a to 404beda Compare August 3, 2019 02:57
@laanwj laanwj added the Feature label Sep 30, 2019
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use fputs here (same below) and avoid introducing the locale dependency exception

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tfm::format(std::cerr, ... should work as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, yeah. Removing linter changes and using fputs.

Copy link
Member

@laanwj laanwj Sep 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please only print this extra newline if stdin terminal is detected, and not when, say, piping in from a script (same below 2x)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I think the latest version achieves this. (See StdinTerminal().)

$ ./bitcoin-cli -datadir=d -regtest encryptwallet foobar38
wallet encrypted; The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.
$ ./bitcoin-cli -datadir=d -regtest -stdinwalletpassphrase walletpassphrase 10
Wallet passphrase>
$ echo foobar38 | ./bitcoin-cli -datadir=d -regtest -stdinwalletpassphrase walletpassphrase 10
$ echo xfoobar38 | ./bitcoin-cli -datadir=d -regtest -stdinwalletpassphrase walletpassphrase 10
error code: -14
error message:
Error: The wallet passphrase entered was incorrect.

@kallewoof kallewoof force-pushed the stdinwalletpassphrase branch from f42176b to 50c4afa Compare October 1, 2019 03:31
@laanwj
Copy link
Member

laanwj commented Oct 1, 2019

Thanks, LGTM now
code review ACK 50c4afa

laanwj added a commit that referenced this pull request Oct 2, 2019
…passwords

50c4afa add newline after -stdin* (Karl-Johan Alm)
7f11fba cli: add -stdinwalletpassphrase for (slightly more) secure CLI (Karl-Johan Alm)
0da503e add stdin helpers for password input support (Karl-Johan Alm)

Pull request description:

  This PR
  * adds `-stdinwalletpassphrase` for use with `walletpasshprase(change)`
  * adds no-echo for passwords (`-stdinrpcpass` and above)

  It may not be ideal, but it's better than having to clear the screen whenever you unlock the wallet.

ACKs for top commit:
  laanwj:
    code review ACK 50c4afa

Tree-SHA512: 473db8a303ff360ffaa36ac81a2f82be2136fa82696df0bc4f33cb44033a3ae258b5aa5bbcc1f101f88ae9abe9598ed564ce52877ab139bd5d709833f5275ec6
@laanwj laanwj merged commit 50c4afa into bitcoin:master Oct 2, 2019
@kallewoof kallewoof deleted the stdinwalletpassphrase branch October 8, 2019 07:23
MarkLTZ added a commit to litecoinz-core/litecoinz that referenced this pull request Nov 17, 2019
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 25, 2020
Summary:
This helpers will be used for no-echo input when typing passwords in a terminal.

This is a backport of Core [[bitcoin/bitcoin#13716 | PR13716]] [1/3]
Commit bitcoin/bitcoin@0da503e

Test Plan: `cmake .. -GNinja && ninja`

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8106
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 25, 2020
Summary:
> This PR
>
>  - adds -stdinwalletpassphrase for use with walletpasshprase(change)
>  - adds no-echo for passwords (-stdinrpcpass and above)

This is a backport of Core [[bitcoin/bitcoin#13716 | PR13716]] [2/3]
Commit: bitcoin/bitcoin@7f11fba
Depends D8106

Test Plan:
```
src/bitcoin-cli -help
src/bitcoin-cli -stdinrpcpass getnetworkinfo
src/bitcoin-cli -stdinrpcpass -stdinwalletpassphrase walletpassphrase
```

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8107
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 26, 2020
Summary:
This is a backport of Core [[bitcoin/bitcoin#13716 | PR13716]] [3/3]
Commit: bitcoin/bitcoin@50c4afa
Depends on D8107

Test Plan:
Verify that newlines are added between the two passwords:
`src/bitcoin-cli -stdinrpcpass -stdinwalletpassphrase walletpassphrase`

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8108
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants