Skip to content

Instantly share code, notes, and snippets.

@matheusd
Created September 5, 2018 12:30
Show Gist options
  • Save matheusd/5daba897798139dee1d6c68d8a6dd422 to your computer and use it in GitHub Desktop.
Save matheusd/5daba897798139dee1d6c68d8a6dd422 to your computer and use it in GitHub Desktop.
Ticket Status Report

Procedure to generate a report on ticket status. You need access via rpc to a dcrd node and the jq tool installed.

This might take a long time to run if you have many tickets.

  1. Grab the list of transactions of the wallet:
$ dcrctl --wallet listtransactions "*" 999999999 > txs.txt
  1. Grab the individual transaction hashes for tickets from the wallet:
$ cat txs.txt | jq ".[] | select(.txtype == \"ticket\") | .txid" | uniq | tac > txids.txt
  1. Create an aux script called "ticketstats.sh":
#!/bin/bash
ctl='dcrctl'
TXHASH=$1
REVERSED=$(echo "$TXHASH" | fold -w2 | tac | tr -d "\n")
ISLIVE=`$ctl existsliveticket $TXHASH`
ISMISSED=`$ctl existsmissedtickets $REVERSED`
ISEXPIRED=`$ctl existsexpiredtickets $REVERSED`
echo $TXHASH $ISLIVE $ISMISSED $ISEXPIRED
  1. Run the script for each ticket
$ cat txids.txt | xargs -n 1 ./ticketstatus.sh

Each resulting line will look like the following:

0102030405060708091011121314151617181920212223242526272829303132 false 00 00

That's the ticket hash, whether the ticket is live, whether it's missed (and not revoked) and if it has expired (and may or may not be revoked).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment