Get Masternode's position in the payment queue

xkcd

Active Member
Masternode Owner/Operator
Feb 19, 2017
233
198
103
australia
mnowatch.org
Dash Address
XpoZXRfr2iFxWhfRSAK3j1jww9xd4tJVez
A question that comes up time again is,
when is my MN gonna get paid??
Finally a simple function exists that let's you answer that question yourself and monitor your MN(s) progress through the payment queue!

Introducing mn_queue.sh this niftly little function allows you to find your place in the payment queue, let's look at some examples.

Run it on its own to print the entire list for your perusal. The first number is the position in the Payment Queue.

upload_2018-7-23_18-54-43.png

Together with grep, we can find an individual MN, replace the address seen with your MN address!

upload_2018-7-23_18-56-45.png

Or, if you have a bunch of MNs, we can search for a bunch as well like so,


upload_2018-7-23_18-59-38.png

Here I have shown an example where I only use the last few characters of the MN public key as it is usually enough to uniquely identify an MN.

So, how do we get you setup with this capability on your MN, stat?

Installation

Login to the VPS and change to the user that is running the MN, for example mine is simply called dash.
Verify you have dash-cli in your PATH.

Code:
which dash-cli
If this returns an error edit your ~/.profile file and ensure that PATH variable has the location of the directory containing dash-cli.

Next we will download the script,
Code:
cd /tmp
git clone https://github.com/kxcd/mn_queue/
cd mn_queue
chmod a+x mn_queue.sh
Now we can run it to test it like so,
Code:
. ./mn_queue.sh
mn_queue
On some machines the function will run after the first line, others will only execute it when both lines are entered. To make the changes permanent and why wouldn't you, continue with the below.
Code:
echo >> ~/.bashrc
tail -n +17 mn_queue.sh >> ~/.bashrc
Test it again with
Code:
mn_queue | head
To print out the first 10 MNs.

Please leave me feedback here in the forum, or if you want to chat or need support, you can contact me on the Dash Discord as xkcd#7307
 
Last edited:

xkcd

Active Member
Masternode Owner/Operator
Feb 19, 2017
233
198
103
australia
mnowatch.org
Dash Address
XpoZXRfr2iFxWhfRSAK3j1jww9xd4tJVez
Thanks to @moocowmoo, he re-factored the code and came up with a tighter faster way of printing the above list. If you already have followed the above steps in the guide and wish to use the below version, then edit your ~/.bashrc to remove the mn_queue function before proceeding with the below.

Create a script with the code for the mn_queue function.

Code:
cat >/tmp/mn_queue.sh <<"EOF"
#!/bin/sh
mn_queue(){
    dash-cli masternode list full \
        | grep "[^_]ENABLED 70213" \
        | awk -v date="$(date +%s)" '{as=date-$7; mst=(as>$8?as:$8); sep="\t" ; print mst sep date sep $5 sep $7 sep $8 sep as}' \
        | sort -s -k1,1n \
        | awk '{print NR "\t" $0}'
}
mn_queue
EOF
Make that file executable and test that it works.
Code:
chmod a+x /tmp/mn_queue.sh
/tmp/mn_queue.sh
You should see the full list of MNs and their relative position in the queue, if it is working execute the below command to make it permanent.

Code:
echo >>~/.bashrc
tail -n +2 /tmp/mn_queue.sh |head -7 >>~/.bashrc
Logout and log back in to your shell to make sure it gets loaded each time you login and test again with
Code:
mn_queue
Thanks to Mr. Cow for the time spent on optimising this code, much appreciated ! :)
 
Last edited:

brownbear

New Member
Feb 3, 2018
36
10
8
24
I have been checking the position in the queue at Dashcentral.org. I believe that's the easiest way. (is seems to be reliable, should one have any doubt?)

The Payment queue rank for one of my MN = "94/4890 (masternode has reached a queue rank > 10% and is now in random selection for the payment)," that was several hours ago, but now it says: Payment queue rank: 96/4890.

and it has been more than 16 days since last payment!!!

Is this normal? I don't think the rank should drop down!

Do I have to register my MN for the DIP003 masternode list? Is that step mandatory for payments?

I would appreciate your insights into this, thanks in advance!

BB
 

xkcd

Active Member
Masternode Owner/Operator
Feb 19, 2017
233
198
103
australia
mnowatch.org
Dash Address
XpoZXRfr2iFxWhfRSAK3j1jww9xd4tJVez
Hi BrownBear you have good reason to be concerned! DC is calculating the position incorrectly! The main bug I noted with DC is that if your masternode gets restarted and placed back to the end of the queue DC does not account for this. To find you actual position in the queue, use my script in the second post on this thread.
 
  • Like
Reactions: vazaki

brownbear

New Member
Feb 3, 2018
36
10
8
24
Yup! that's what I learned too! I double checked on my own server and on dashninja.pl, both of which were actually OK. And BTW, I got my pay offs today as well! ;-)

Thanks xkcd!
 
  • Like
Reactions: xkcd

toowboga

New Member
Jan 24, 2021
1
0
1
28
Thanks to @moocowmoo, he re-factored the code and came up with a tighter faster way of printing the above list. If you already have followed the above steps in the guide and wish to use the below version, then edit your ~/.bashrc to remove the mn_queue function before proceeding with the below.

Create a script with the code for the mn_queue function.

Code:
cat >/tmp/mn_queue.sh <<"EOF"
#!/bin/sh
mn_queue(){
    dash-cli masternode list full \
        | grep "[^_]ENABLED 70213" \
        | awk -v date="$(date +%s)" '{as=date-$7; mst=(as>$8?as:$8); sep="\t" ; print mst sep date sep $5 sep $7 sep $8 sep as}' \
        | sort -s -k1,1n \
        | awk '{print NR "\t" $0}'
}
mn_queue
EOF
Make that file executable and test that it works.
Code:
chmod a+x /tmp/mn_queue.sh
/tmp/mn_queue.sh
You should see the full list of MNs and their relative position in the queue, if it is working execute the below command to make it permanent.

Code:
echo >>~/.bashrc
tail -n +2 /tmp/mn_queue.sh |head -7 >>~/.bashrc
Logout and log back in to your shell to make sure it gets loaded each time you login and test again with
Code:
mn_queue
Thanks to Mr. Cow for the time spent on optimising this code, much appreciated ! :)

I just tested the script and unfortunately it is currently not working. No MN list is printed.
If I print the MN list with the simple command
Code:
dash-cli masternode list full
it works.

But with the script the output is empty. Anything significantly changed in the last year?
 

xkcd

Active Member
Masternode Owner/Operator
Feb 19, 2017
233
198
103
australia
mnowatch.org
Dash Address
XpoZXRfr2iFxWhfRSAK3j1jww9xd4tJVez
yes, the introduction of deterministic masternodes changed the way masternodes are paid these days, we no longer need the above script to determine the payment cycle. From the dash-cli masternode list full you can extract the field last_paid_block and from the number of ENABLED masternodes in dash-cli masternode count you can determine how long you have to wait until the next payment. You will be paid every ENABLED blocks. All nodes are paid in structured order, no randomisation anymore.