Author

Topic: bitcoin-cli help encryptwallet (Read 1219 times)

legendary
Activity: 1258
Merit: 1027
July 28, 2015, 09:46:47 PM
#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!
staff
Activity: 3374
Merit: 6530
Just writing some code
July 28, 2015, 09:00:37 PM
#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.
legendary
Activity: 1258
Merit: 1027
July 28, 2015, 08:15:00 PM
#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...
full member
Activity: 202
Merit: 100
July 28, 2015, 05: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.
legendary
Activity: 1358
Merit: 1000
https://gliph.me/hUF
July 28, 2015, 02: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.
legendary
Activity: 1258
Merit: 1027
July 28, 2015, 09:28:18 AM
#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
Jump to: