Compile List Of Useful Pos Commands

Discussion in 'Proof-of-stake Mining' started by sw1, Feb 23, 2016.

  1. 2017/12/15 - Decred v1.1.2 released! → Release Notes  → Downloads
  1. sw1

    sw1 Jr. Member

    Dec 31, 2015
    90
    39
    Male
    Sydney, Australia
    #1 sw1, Feb 23, 2016
    Last edited: Mar 6, 2016
    G,day there decred community.

    I'd like to open this up to all PoS miners out there and compile a list of useful commands you use, then add it to a sticky in this forum area.

    Just put commands that have been helpful for you and explain what they mean next to it. I'll then make a list of them all so new users can access that instead of posting "my balance is ZERO! after enablestakemining" on the tech support page.

    EDIT: Collating info into this post.

    If you are running dcrwallet v0.4 or later, the command below will pretty much give you all the info you need:-

    dcrctl --wallet getstakeinfo

    If running an earlier verison of dcrwallet:-

    --wallet getbalance "default" 0 all
    Wallet balance including mature and immature ticket values.

    dcrctl --wallet getstakedifficulty
    Shows current cost of PoS ticket

    Linux specific commands

    ./dcrctl --wallet gettickets 1 |grep "," -c
    Gets you the number of (mature and immature) tickets in your wallet

    ./dcrctl --wallet gettickets 1 >temp;for line in `./dcrctl --wallet missedtickets|grep ","`;do cat temp|grep $line;done
    This will save all the tickets you own to a file called "temp" then check to see if any of them are in the missedtickets list.
    If this command gives you any hashes, they have been missed tickets.


    ./dcrd > /dev/null &
    disown
    ./dcrwallet --enablestakemining > /dev/null &
    disown

    Running dcrd & dcrwallet in background (linux only)

    Check out @brencelj 's posts in thread for full bash scripts to get similar info as dcrctl --wallet getstakeinfo for those running on older dcrwallet versions (FYI the scripts are for linux users only).

    Thanks to contributors:
    @Kandiru
    @brencelj
    @drunkenmugsy

    Please keep posting in thread any other useful PoS commands and I will add them to this first post every couple of weeks or so.
     
    rohit pawar and sambiohazard like this.
  2. Kandiru

    Kandiru Member

    Feb 21, 2016
    206
    87
    #2 Kandiru, Feb 23, 2016
    Last edited: Feb 23, 2016
    Some linux specific commands:

    ./dcrctl --wallet gettickets 1 |grep "," -c

    Gets you the number of (mature and immature) tickets in your wallet

    ./dcrctl --wallet gettickets 1 >temp;for line in `./dcrctl --wallet missedtickets|grep ","`;do cat temp|grep $line;done

    This will save all the tickets you own to a file called "temp" then check to see if any of them are in the missedtickets list. If this command gives you any hashes, they have been missed tickets.
     
  3. drunkenmugsy

    drunkenmugsy Sr. Member
    Advocate (Reddit)

    Dec 28, 2015
    405
    218
    Male
    It might also be useful to compile a list all in one place of relevant block time frames such as ticket maturity, stake and stake reward return, difficulty change rate, avg/max stake vote time, etc etc.

    Here is an explanation of pool size and difficulty change from another thread https://forum.decred.org/threads/wh...ulty-will-be-after-block-4096.771/#post-11398

     
    sw1 likes this.
  4. Tivra

    Tivra Member
    Advocate (BitcoinTalk)

    Dec 30, 2015
    120
    60
    Europe
    Great initiative, this thread, thanks for the effort of making it. It will help us noobs.

    The --walet getbalance "default" 0 all command shows different values at different times, and it's less than it should be, it's less than my total DCR I had before staking, is this how it's supposed to be? Shouldn't it be equal to my total amount of DCR staked and not ?

    The blockchain explorer shows I got 2 transactions of 2 DCR each, but that happened in the first 2 hours of my mining, and after that, I got nothing for 12 hours. I'm confused - what are good ways to monitor how your stake mining is going ?
     
  5. sw1

    sw1 Jr. Member

    Dec 31, 2015
    90
    39
    Male
    Sydney, Australia
    When you enable stakemining it will lock all your coins in the wallet, showing 0 balance for first 24 hours or so.

    This can change based on how many tickets you buy as blocks are mined. There are only 20 tickets per block so you may not be able to purchase a lot of tickets straight away.

    You pay a 0.05 dcr fee per ticket, so thats why you may show a lower balance than total ticket value of your wallet.
     
    Tivra likes this.
  6. brencelj

    brencelj New Member

    Jan 10, 2016
    49
    17
    I did this small bash script that shows me some info. but you have to run your wallet like this
    Code:
    ./dcrwallet --enablestakemining --balancetomaintain=(yours) --ticketmaxprice=(yours) | tee -a wallet.log
    Code:
    #! /bin/sh
    
    cd (to location of your decred folder)
    balanceall=`./dcrctl --wallet getbalance 'default' 0 all`
    balancelocked=`./dcrctl --wallet getbalance 'default' 0 locked`
    balancespendable=`./dcrctl --wallet getbalance 'default' 0 spendable`
    
    ticketsallcount=`./dcrctl --wallet gettickets 1 | grep "," -c`
    ticketsmaturecount=`./dcrctl --wallet gettickets 0 | grep "," -c`
    
    votescount=`cat wallet.log | grep Voted | wc -l`
    buycount=`cat wallet.log | grep SStx | wc -l`
    failedvotescount=`cat wallet.log | grep Revoked | wc -l`
    
    echo ""
    echo "########## Decred report ##########"
    echo ""
    echo "             **Money**"
    echo "   All: $balanceall"
    echo "   Locked: $balancelocked"
    echo "   Spendable: $balancespendable"
    echo ""
    echo "            **Tickets**"
    echo "   All: $ticketsallcount"
    echo "   Mature: $ticketsmaturecount"
    echo ""
    echo "            **Votes**"
    echo "   Done: $votescount"
    echo "   Failed: $failedvotescount"
    echo "   Bought: $buycount"
    echo ""
    echo "###################################"
    echo ""
     
    Artem and sw1 like this.
  7. drunkenmugsy

    drunkenmugsy Sr. Member
    Advocate (Reddit)

    Dec 28, 2015
    405
    218
    Male
    I like this. I was doing something similar just at the CLI. But no reason to log to a file. You would not get everything from start, only session? There is a log at .dcwallet/wallet/logs/mainnet you could use for this. I think I might actually switch to yours and modify the data location. Then cron it every 5 mins or something.
     
    brencelj likes this.
  8. brencelj

    brencelj New Member

    Jan 10, 2016
    49
    17
    #8 brencelj, Feb 24, 2016
    Last edited: Feb 24, 2016
    I did it that way since I didn't knew about this :). Thank you @drunkenmugsy. I'll do some updates as well
     
  9. Kandiru

    Kandiru Member

    Feb 21, 2016
    206
    87
    #9 Kandiru, Feb 24, 2016
    Last edited: Feb 24, 2016
    Linux commands for remote servers:

    When you want to run the wallet and dcrd and have them stay running after you logout, you need to get it to run in the background, and disown the process. You do this as follows:

    Code:
    ./dcrd > /dev/null &
    disown
    ./dcrwallet --enablestakemining > /dev/null &
    disown
    Then when you logout and login, you should see dcrd still running merrily. I think piping the output to /dev/null is good practise, since the output is logged to ~/.dcrd/logs/mainnet anyway. Don't want the output to stdout to clog up a buffer or take up excess RAM.

    If you already have the programs running and you want to change them to background mode, you can do "Ctrl+z" to suspend them, then enter "bg" to set them to run in the background. Then type "disown" to keep them alive after you logout.

    An alternative to this is to use screen to launch and keep jobs running after you logout, but that's slightly more complicated than the background and disown method.
     
    sw1, rohit pawar and brencelj like this.
  10. Tivra

    Tivra Member
    Advocate (BitcoinTalk)

    Dec 30, 2015
    120
    60
    Europe
    Yay, just got my first vote ... "Voted on block ... " - does this mean it was successfully completed and I got a reward ? How can I verify this, and is the reward always worth 2 DCR ?
     
  11. sw1

    sw1 Jr. Member

    Dec 31, 2015
    90
    39
    Male
    Sydney, Australia
    Hey Tivra. Just take the TX ID and search it in the block chain search. Mainnet.decred.org
    That will tell you how much you received for staking. The 2 decred is your stake you get back. Plus normally about 1.7 decreds as reward for stake mining.
     
    Tivra likes this.
  12. sw1

    sw1 Jr. Member

    Dec 31, 2015
    90
    39
    Male
    Sydney, Australia
    If you are using linux you can also use screen to launch background windows. screen -S "windowname", I make 3 screen sessions, one for daemon, one for wallet and one for query. Then make sure you detach from each session before shutting down. crtl+a+d to detach.

    Then the daemon and wallet will continue running in background. :)

    Just use screen -r command to reattach to any session in future
     
    Halestorm likes this.
  13. Halestorm

    Halestorm Jr. Member

    Jan 22, 2016
    83
    32
    Male
    Data Center
    Texas, USA
    This is how I run mine, I put in cron jobs to automatically start the daemon & wallet using screen and then unlock my wallet on boot. I rarely need to actually access the screen, I just cat the log file whenever I want to see what's going on.
     
    sw1 likes this.
  14. Kandiru

    Kandiru Member

    Feb 21, 2016
    206
    87
    I'm a lubuntu person, so no screen installed by default. Keep it lean and fast! & disown does the job! :)
     
    sw1 and Halestorm like this.
  15. Halestorm

    Halestorm Jr. Member

    Jan 22, 2016
    83
    32
    Male
    Data Center
    Texas, USA
    Eh, can't argue with that approach! I guess it doesn't matter how you get it done so long as it works for you and meets your needs. :D
     
    Kandiru likes this.
  16. brencelj

    brencelj New Member

    Jan 10, 2016
    49
    17
    #16 brencelj, Feb 25, 2016
    Last edited: Feb 26, 2016
    I did some updates to my script it gives more information now. I hope someone will find it useful.
    If you have any fixes or ideas how I can improve it pleas do tell I want to make it a bit more useful and a bit better ;)
    Code:
    #! /bin/sh
    
    dcrwalletLogFolder="/home/(YOUR USER)/.dcrwallet/logs/mainnet/"
    decredFolder="(YOUR PATH TO DECRED)"
    
    cd $dcrwalletLogFolder
    votescount=`cat dcrwallet.log | grep Voted | wc -l`
    votedticketsperday=`cat dcrwallet.log | grep Voted | grep -o "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" | uniq -c`
    buycount=`cat dcrwallet.log | grep SStx | wc -l`
    boughtticketsperday=`cat dcrwallet.log | grep SStx | grep -o "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" | uniq -c`
    failedvotescount=`cat dcrwallet.log | grep Revoked | wc -l`
    failedticketsperday=`cat dcrwallet.log | grep Revoked | grep -o "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" | uniq -c`
    
    cd $decredFolder
    balanceall=`./dcrctl --wallet getbalance 'default' 0 all`
    balancelocked=`./dcrctl --wallet getbalance 'default' 0 locked`
    balancespendable=`./dcrctl --wallet getbalance 'default' 0 spendable`
    
    ticketsallcount=`./dcrctl --wallet gettickets 1 | grep "," -c`
    ticketsmaturecount=`./dcrctl --wallet gettickets 0 | grep "," -c`
    ticketprice=`./dcrctl getstakedifficulty`
    
    echo ""
    echo "########## Decred report ##########"
    echo ""
    echo "             **Money**"
    echo "      All:          $balanceall"
    echo "      Locked:       $balancelocked"
    echo "      Spendable:  $balancespendable"
    echo ""
    echo "            **Tickets**"
    echo "      All:          $ticketsallcount"
    echo "      Mature:       $ticketsmaturecount"
    echo "      Price Now:   $ticketprice"
    echo ""
    echo "       **Bought Tickets Per Day**"
    echo "$boughtticketsperday"
    echo ""
    echo "            **Votes**"
    echo "      Done:         $votescount"
    echo "      Failed:       $failedvotescount"
    echo "      Bought:       $buycount"
    echo ""
    echo "       **Voted Tickets Per Day**"
    echo "$votedticketsperday"
    echo ""
    echo "       **Failed Tickets Per Day**"
    echo "$failedticketsperday"
    echo ""
    echo "###################################"
    echo ""
     
    sambiohazard and sw1 like this.
  17. Kandiru

    Kandiru Member

    Feb 21, 2016
    206
    87
    You can call ./dcrctl getstakedifficulty rather than parsing the last block and looking for the sbits string in the getblock of that!
     
    brencelj likes this.
  18. brencelj

    brencelj New Member

    Jan 10, 2016
    49
    17
    Thank you for this and will fix it in the previous post code as well.
     
  19. dave

    dave New Member

    Jan 11, 2016
    27
    10
    if you update to newest binaries, you can use --wallet getstakeinfo for alot of this info
     
    anonminer likes this.
  20. sambiohazard

    sambiohazard Sr. Member

    Jan 21, 2016
    844
    372
    If you can do the same for windows, i will send you 2 stake rewards - exorbitant tx fees. Is that reasonable?
     

Share This Page