Title: recommended way to test if wallet is encrypted using rpc Post by: mav on July 20, 2012, 06:13:50 AM I'm using rpc to access remote wallets, and I want to ensure those wallets are encrypted before I store any details about how to access them.
Currently I'm calling getnewaddress and then dumpprivkey with that address, and if dumpprivkey returns an error I assume that the wallet is encrypted. If it gives me a private key, I assume the wallet is not encrypted. This is a pretty terrible way of testing whether a wallet is encrypted. Does anyone have a suggested 'best practice' way to achieve my goal? Title: Re: recommended way to test if wallet is encrypted using rpc Post by: koin on July 20, 2012, 06:30:38 AM Does anyone have a suggested 'best practice' way to achieve my goal? yes. write a patch. Title: Re: recommended way to test if wallet is encrypted using rpc Post by: dooglus on July 20, 2012, 06:36:03 AM Kind of ugly still, but better than what you're doing:
Quote $ bitcoind walletpassphrase '' 1 # not encrypted error: {"code":-15,"message":"Error: running with an unencrypted wallet, but walletpassphrase was called."} $ bitcoind walletpassphrase '' 1 # encrypted and locked error: {"code":-1,"message":"walletpassphrase <passphrase> <timeout>\nStores the wallet decryption key in memory for <timeout> seconds."} $ bitcoind walletpassphrase '' 1 # encrypted an unlocked error: {"code":-17,"message":"Error: Wallet is already unlocked."} Title: Re: recommended way to test if wallet is encrypted using rpc Post by: mav on July 20, 2012, 06:51:01 AM Kind of ugly still, but better than what you're doing: Quote $ bitcoind walletpassphrase '' 1 # not encrypted error: {"code":-15,"message":"Error: running with an unencrypted wallet, but walletpassphrase was called."} $ bitcoind walletpassphrase '' 1 # encrypted and locked error: {"code":-1,"message":"walletpassphrase <passphrase> <timeout>\nStores the wallet decryption key in memory for <timeout> seconds."} $ bitcoind walletpassphrase '' 1 # encrypted an unlocked error: {"code":-17,"message":"Error: Wallet is already unlocked."} Excellent thanks a lot for this suggestion, it's definitely better than what I was doing. Not sure why I didn't think to do this in the first place. |