Bitcoin Forum
May 10, 2024, 05:07:35 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bitcoin-cli help encryptwallet  (Read 1219 times)
windpath (OP)
Legendary
*
Offline Offline

Activity: 1258
Merit: 1027


View Profile WWW
July 28, 2015, 01:28:18 PM
 #1

Running "bitcoin-cli help encryptwallet" returns the help page as expected if the wallet is not encrypted, however if the wallet has been encrypted "help encryptwallet" returns "unknown command".

It does not feel like this should be expected behavior, but maybe it is intentional?

Command:
Code:
bitcoin-cli help encryptwallet

Result if wallet is encrypted:
Code:
help: unknown command: encryptwallet

Result if wallet has not been encrypted:
Code:
encryptwallet "passphrase"

Encrypts the wallet with 'passphrase'. This is for first time encryption.
After this, any calls that interact with private keys such as sending or signing
will require the passphrase to be set prior the making these calls.
Use the walletpassphrase call for this, and then walletlock call.
If the wallet is already encrypted, use the walletpassphrasechange call.
Note that this will shutdown the server.

Arguments:
1. "passphrase" (string) The pass phrase to encrypt the wallet with. It must be at least 1 character, but should be long.

Examples:

Encrypt you wallet
> bitcoin-cli encryptwallet "my pass phrase"

Now set the passphrase to use the wallet, such as for signing or sending bitcoin
> bitcoin-cli walletpassphrase "my pass phrase"

Now we can so something like sign
> bitcoin-cli signmessage "bitcoinaddress" "test message"

Now lock the wallet again by removing the passphrase
> bitcoin-cli walletlock

As a json rpc call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "encryptwallet", "params": ["my pass phrase"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

Edit: Satoshi Client 0.11.0
1715317655
Hero Member
*
Offline Offline

Posts: 1715317655

View Profile Personal Message (Offline)

Ignore
1715317655
Reply with quote  #2

1715317655
Report to moderator
You get merit points when someone likes your post enough to give you some. And for every 2 merit points you receive, you can send 1 merit point to someone else!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715317655
Hero Member
*
Offline Offline

Posts: 1715317655

View Profile Personal Message (Offline)

Ignore
1715317655
Reply with quote  #2

1715317655
Report to moderator
Newar
Legendary
*
Offline Offline

Activity: 1358
Merit: 1001


https://gliph.me/hUF


View Profile
July 28, 2015, 06:16:16 PM
 #2


My guess would be that somebody who has their wallet encrypted knows how they did it and what it is for. Doesn't make that much sense, but... *shrug*

If you feel this could be improved upon, github is the place to go for opening issues.

OTC rating | GPG keyid 1DC91318EE785FDE | Gliph: lightning bicycle tree music | Mycelium, a swift & secure Bitcoin client for Android | LocalBitcoins
themerkle
Full Member
***
Offline Offline

Activity: 202
Merit: 100


View Profile
July 28, 2015, 09:11:04 PM
 #3

I found this: http://bitcoin.stackexchange.com/questions/3587/can-i-remove-the-passphrase-from-my-bitcoin-wallet

The Bitcoin.org client does not yet have the feature to remove encryption from a wallet. You can use a single space as the encryption key but there no way to get it to no longer use encryption.
That is expected to be implemented in a future release.
In the meantime, those that want this will create a new wallet and leave it unencrypted, and send their coins from the encrypted wallet to it.

So I am assuming the encryptwallet function no longer works once you encrypt your wallet. You can still change the passphrase but since there is no way to unencrypt it the function is not even in the scope.
windpath (OP)
Legendary
*
Offline Offline

Activity: 1258
Merit: 1027


View Profile WWW
July 29, 2015, 12:15:00 AM
 #4

I found this: http://bitcoin.stackexchange.com/questions/3587/can-i-remove-the-passphrase-from-my-bitcoin-wallet

The Bitcoin.org client does not yet have the feature to remove encryption from a wallet. You can use a single space as the encryption key but there no way to get it to no longer use encryption.
That is expected to be implemented in a future release.
In the meantime, those that want this will create a new wallet and leave it unencrypted, and send their coins from the encrypted wallet to it.

So I am assuming the encryptwallet function no longer works once you encrypt your wallet. You can still change the passphrase but since there is no way to unencrypt it the function is not even in the scope.

I'm aware, however it does not explain this behavior...

I'm talking about the HELP command, which when your wallet is encrypted returns "help: unknown command: encryptwallet".

While there is no "remove wallet encryption" command, I don't see why you would hide the explanation for that once the wallet is encrypted.

Whether your wallet is encrypted or not, the help for the command does not change...
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6631


Just writing some code


View Profile WWW
July 29, 2015, 01:00:37 AM
 #5

The root of the problem is in the method for that command here: https://github.com/bitcoin/bitcoin/blob/ca37e0f33980a1fe96ac4ed08fd7d692a7a592a5/src/wallet/rpcwallet.cpp#L1968

The statement determining whether to show the message or not is this
Code:
if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1))
            --snipped display message code--
As you can assume, this states that if the wallet is not encrypted and either help is true or parameters is not one, then display the help message. As you can see with that logic, since your wallet is encrypted, it will skip past this, even if help is true.

Help is set to true in this file: https://github.com/bitcoin/bitcoin/blob/240b30eaf0b94a0094b8943dd9c01448bc29c3ba/src/rpcserver.cpp by using the help command. The key part is at line 226 - 227 which are as follows
Code:
    if (strRet == "")
        strRet = strprintf("help: unknown command: %s\n", strCommand);
since the string that encryptwallet method returns is empty, this help output assumes that the command doesn't exist, so it prints the unknown command message.

This is clearly intentional. Why would they have a specific check for whether the wallet was encrypted or not for the help message. As to why that was done, I don't know.

windpath (OP)
Legendary
*
Offline Offline

Activity: 1258
Merit: 1027


View Profile WWW
July 29, 2015, 01:46:47 AM
Last edit: July 29, 2015, 02:28:11 AM by windpath
 #6

This is clearly intentional. Why would they have a specific check for whether the wallet was encrypted or not for the help message. As to why that was done, I don't know.

I believe there is a good chance it may have been, would like to know why...

Edit: Thanks for taking the time to look up the code references!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!