How to control your Gridcoin wallet with command line
Hi everyone, you may have seen my guide to installing Gridcoin/BOINC on a Raspberry Pi the other day, if you followed that well done!
Of course I was quite horrible, in the sense that I got you all setup, then gave you no instructions on how to issue commands to control your Pi, and as its command line only, that wasnt particularly helpful. In my defence, its been sunny and I have been drinking beer in the garden; its not much of an excuse but its the truth.
In fact what follows is not unique to Raspberry Pi, or Linux, if you have a Windows system and you open a command prompt and go to the location where you installed Gridcoin (probably C:\Program Files (x86)\GridcoinResearch), you will see a program there called gridcoinresearchd too, which means so long as you have rpc settings in your gridcoinresearch.conf, you can control your wallet from command line. For this you will need your gridcoinresearch.conf to have these entries:
rpcuser=(a_username_here)
rpcpassword=(a_long_and_ideally_very_strong_random_password_here)
server=1
daemon=1
Even more interesting is that say you setup a VPN server on your Raspberry Pi, you could control your GridCoin daemon from anywhere in the world that has wifi or 4G, from your mobile phone with an SSH and VPN client.
You could even write some programs to control your Gridcoin daemon like I did here
Controlling Gridcoin
To find out general information like your coin balances, if you are connected to peers and your block height
gridcoinresearchd getinfo
To see if you are staking
gridcoinresearchd getstakinginfo
You may wish to get a new address for receiving a transaction
gridcoinresearchd getnewaddress
To unlock the wallet fully
gridcoinresearchd walletpassphrase (your_passphrase_here) 300
So lets just take a break and understand that a little more. By now you probably caught on that gridcoinresearchd always goes at the front to tell linux to issue a command to the daemon, and that walletpassphrase is a function (receive my passphrase) and then you actually put in your pasphrase without brackets of course, but what is the 300? Not a bunch of Greek warriors, but the number of seconds to unlock the wallet for; so you could put a 1 there, but the wallet would re-lock before you can issue any commands; to unlock the wallet forever you need to put the maximum number allowed which is 9999999, but thats crazy, why have a wallet unlocked forever....
To unlock the wallet for staking
gridcoinresearchd walletpassphrase (your_passphrase_here) 9999999 true
** Breaking that down, its almost the same.** We put 9999999 to unlock forever and the true at the end means unlock for staking only. Why? I dont know it just does, OK? Right lets move on.
To lock the wallet its
gridcoinresearchd walletlock
To send a transaction its
gridcoinresearchd sendtoaddress (receipient_address) (amount_of_GRC_to_send)
Now then, you probably will want your wallet staking most of the time, so if you try to send a transaction, your wallet is unlocked, but only for staking. If you try to unlock your wallet, you cant, its already unlocked (but only for staking); in this scenario then we need to issue multiple commands:
gridcoinresearchd walletlock
gridcoinresearchd walletpassphrase (your_passphrase_here) 300
gridcoinresearchd sendtoaddress (receipient_address) (amount_of_GRC_to_send)
This will output the transaction hash, which you can use to track your payment.
You will then probably want to immediately re-lock your wallet, and unlock it for staking again:
gridcoinresearchd walletlock
gridcoinresearchd walletpassphrase (your_passphrase_here) 9999999 true
There are many more commands, but these are the real essentials, you can see the full list here, and now we de-mystified the syntax, you should be able to continue exploring on your own.
Before You Try The Above
Look, Gridcoin is real money, if you arent sure what you are doing, take the time to make a test wallet with 1 GRC, so if you screw it up, then you wont have lost all your coins. The internet is littered with tales of woe, of people who lost money on crypto-currency through corrupted wallets, bad transactions and a host of other stuff. Im not a security expert, they may be flaws here, do your own due-dilligence.
I found this today when I really needed it. Thanks for posting it, I was having trouble getting going on a headless ubuntu server, now I'm going along great. Thanks.
It seems the "getstakinginfo" command has stopped working. Use "getmininginfo" instead.
Yup the latest version change some RPCs
Full list of commands is available here:
http://wiki.gridcoin.us/RPC_commands#gridcoinresearchd_commands