0

I am a new BitcoinJ user, I have few questions related about its wallet, can anyone please help:

  1. Is there any way to encrypt the .wallet file? will anyone obtain a copy of the file be able to spend all bitcoin in it?

  2. Is there a chance of damaging the file if I stop my application often or incorrectly?

Thanks a lot.

2
  1. Yes, you can encrypt the wallet

It’s a good idea to encrypt your private keys if you only spend money from your wallet rarely. The Wallet.encrypt("password") method will derive an AES key from an Scrypt hash of the given password string and use it to encrypt the private keys in the wallet, you can then provide the password when signing transactions or to fully decrypt the wallet. You can also provide your own AES keys if you don’t want to derive them from a password, and you can also customize the Scrypt hash parameters.

  1. Yes, you can corrupt the wallet, but not if you do things the right way.

By default the Wallet is just an in-memory object, it won’t save by itself. You can use saveToFile() or saveToOutputStream() when you want to persist the wallet. It’s best to use saveToFile() if possible because this will write to a temporary file and then atomically rename it, giving you assurance that the wallet won’t be half-written or corrupted if something goes wrong half way through the saving process.

Source: https://bitcoinj.github.io/working-with-the-wallet

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.