reddcoin-project / reddcoin-3.10

Reddcoin: the digital social currency
http://www.reddcoin.com
MIT License
287 stars 114 forks source link

Wallet daemon and staking only mode #36

Closed samvaughton closed 10 years ago

samvaughton commented 10 years ago

When sending money via the daemon and the wallet is locked it will throw an RPC error code of RPC_WALLET_UNLOCK_NEEDED which is -13.

When the wallet is staking only locked it will throw an error code of RPC_WALLET_ERROR which is -4.

This generic wallet error code that does not help me to distinguish the type of error (apart from comparing strings which I do not want to do). To be able to prompt the user to enter a password for to send coins in staking mode I need the code to be either -13 or a new RPC code introduced.

I've taken a look at the source code, but don't feel comfortable trying this and I don't know the best option to take. But it looks as if the actual wallet.cpp SendMoney function produces this generic error.

In the RPC command sendtoaddress there is this snippet:

if (pwalletMain->IsLocked())
    throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");

I would assume just adding an or condition with pwalletMain->fWalletUnlockStakingOnly would work but I am not confident and need to properly read the codebase before I do any pull requests.

Thoughts on this?

laudney commented 10 years ago

Fixed in https://github.com/reddcoin-project/reddcoin/commit/5c29644fdcb5b974704e49a1e050a2aaf198278a. Now it returns -13 if the wallet is unlocked for staking only.