11

I'm using JSON-RPC to send commands to my bitcoind, and it works fine.

Now I want to encrypt my wallet. When I've done that, I will need to send the passphrase when calling SendToAddress. How do I do that?

Right now I send these parameters:

  • address
  • amount
  • comment
  • commentTo

which are put into an array in the order above.

Will the passphrase be another parameter that I append as the last element in that array?

11

Not in the current code. The way it works now, you have to make two RPC calls -- one to unlock the wallet for a period of time (walletpassphrase) and one to do the transaction (sendtoaddress). You can follow up with a command to lock the wallet immediately, if desired (walletlock).

  walletpassphrase <passphrase> <timeout>
  Stores the wallet decryption key in memory for <timeout> seconds.

  walletlock
  Removes the wallet encryption key from memory, locking the wallet.
  After calling this method, you will need to call walletpassphrase again
  before being able to call any methods which require the wallet to be unlocked.
  • Thanks, David, it's working for me. One problem is that the timeout does not seem to work - so I always do "walletlock". This however creates the necessity to do walletpassphrase-sendtoaddress-walletlock inside a critical section, otherwise there would be a race condition. Also - "walletpassphrase" returns an error when called the second time, without having called "walletlock" in between... Do you know if this is by design? It would make life easier if "walletpassphrase" was idempotent. – bitboy9999 Oct 27 '11 at 11:32
  • You can treat error -15 (wallet already unlocked) as a form of success. Unfortunately, it seems this RPC is kind of in a sad state (or there's some 'right' way to use it neither of us know). I would suggest modifying 'sendtoaddress' to take a passphrase. – David Schwartz Oct 27 '11 at 11:39
  • 1
    Absolutely, if "sendtoaddress" simply accepted a passphrase, it would be awesome! – bitboy9999 Oct 27 '11 at 13:20

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.