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. davecgh

    davecgh Hero Member
    Developer Organizer

    Dec 31, 2015
    642
    788
    Male
    United States
    I'm not 100% what you're asking, but I'll just explain what happens, so hopefully it answers your question indirectly.

    You purchase a ticket for X DCR. When you either vote or revoke a ticket, a "stakebase" transaction is created. When it's a vote, the output amount will be X+6% of the non-reduced block subsidy. When it's a revocation, the output amount is just X. Since it's a "stakebase" transaction in both cases, it has to wait out the 256 block maturity period.
     
  2. maxfunky

    maxfunky New Member

    Feb 9, 2016
    7
    0
    Male
    when I run getstakeinfo I get : -4: the wallet is currently syncing to the best block, please try again later
    why ??
     
  3. brencelj

    brencelj New Member

    Jan 10, 2016
    49
    17
    I think that your dcrd and dcrwallet aren't on the latest block.
     
  4. CarpeDecred

    CarpeDecred New Member

    Mar 16, 2016
    13
    1
    Male
    wait for your daemon and wallet to finish updating then try again.

    To anyone else, when i try and get my balance my locked decred amount shows up as zero even though it should be close to 200. Is this because I am using the stake pool? Does locked Decred being voted on by a hot wallet make it not show up when using the getbalance flags in the cold wallet?
     
  5. sambiohazard

    sambiohazard Sr. Member

    Jan 21, 2016
    844
    372
    you should probably try this command to see coin staking/earned from stakepool

    Code:
    --wallet getbalance imported 0 locked/spendable/all
    The script you get from stakepool is imported into your wallet so the coins used for staking are shown in "imported" account rather than "default account". To see coins from all accounts use

    Code:
    --wallet getbalance "*" 0 all/locked/spendable
     
  6. Kandiru

    Kandiru Member

    Feb 21, 2016
    207
    87
    Code:
    echo "scale=6;`dcrctl getticketpoolvalue`/`dcrctl --wallet getstakeinfo|grep "poolsize"|cut -f 4 -d" "|cut -f 1 -d","`"|bc
    
    I'm using this script to calculate the average price of all the tickets in the pool. This is useful to know if the current difficulty is reasonable or not!
     
  7. davecgh

    davecgh Hero Member
    Developer Organizer

    Dec 31, 2015
    642
    788
    Male
    United States
    Something you might find useful is jq. I prefer to use it for dealing with processing the JSON as it's not as susceptible to minor changes in the output format like cut and grep are.

    So, for example getting the poolsize using jq looks like this:

    Code:
    $ dcrctl --wallet getstakeinfo | jq .poolsize
    42390
    
    Thus your command is reduced to:
    Code:
    echo "scale=6;`dcrctl getticketpoolvalue`/`dcrctl --wallet getstakeinfo|jq .poolsize`"|bc
    
     
    root likes this.
  8. Kandiru

    Kandiru Member

    Feb 21, 2016
    207
    87
    Ah, I hadn't seen jq, that looks a lot easier than nested cuts! :)
     
  9. Kandiru

    Kandiru Member

    Feb 21, 2016
    207
    87
    #49 Kandiru, Jan 25, 2017
    Last edited: Jan 25, 2017
    For checking mempool fees, it's a little tricky using the default commands. I've been using this to see the next N tickets sorted by price. This helps you pitch your ticketfee as low as possible, while still getting included in the next few blocks.:
    mempool.sh
    Code:
    LENGTH=${1:-20}
    dcrctl --wallet getrawmempool true tickets|jq '.[]|.fee/.size*1000'|sort -n|tail -n $LENGTH
    
    Then you call it as "mempool.sh 100" to see the next 100 tickets, etc.

    Also, now that the price has changed to a e+06 display, to get the average price of tickets in the pool you need to do the following script:

    Code:
    echo "scale=6;`dcrctl getticketpoolvalue|sed -e 's/[eE]+*/\*10\^/'`/`dcrctl --wallet getstakeinfo|jq .poolsize`"|bc
     
    atweiden likes this.
  10. Kandiru

    Kandiru Member

    Feb 21, 2016
    207
    87
    Code:
    info=`dcrctl --wallet getstakeinfo` 
    balance=`dcrctl --wallet getbalance` 
    echo $info|jq .   
    echo $balance|jq 'reduce(.balances[]| to_entries[]) as $r ({};.[$r.key] +=$r.value)|.accountname="all"' 
    dcrctl estimatestakediff|jq . 
    averageOwned=$(echo "scale=6;$(echo $balance|jq ".balances|map(.lockedbytickets)|add") / $(echo $info|jq ".live+.immature")"|bc) 
    purchaseable=$(echo "scale=2;`echo $balance|jq ".balances|map(.spendable)|add"` / `echo $info|jq ".difficulty"`"|bc) 
    priceChange=$(echo $info|jq '144-.blockheight%144') 
    echo \{ \"averagePaid\": ${averageOwned}, \ 
    \"purchaseable\": ${purchaseable}, \ 
    \"priceChangeIn\": $priceChange\}|jq;
    
    I use this script to check on my staking. It adds up all of your different balances from different accounts, tells you how much your average ticket has cost, when the prices changes, and how many tickets you can buy at the current price.

    You need to have jq installed, so "sudo apt-get install jq" if needed. I run everything through jq to make it pr

    Thanks to @davecgh for the jq reduce syntax.
     

Share This Page