Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get balances and rewards
#!/bin/bash
ADDRESS=$1
MAX_HEIGHT=$(curl -sS http://testnet.lto.network/blocks/height | jq '.height')
MIN_HEIGHT=$((MAX_HEIGHT - 1999))
curl -sS "https://testnet.lto.network/addresses/balance/history/$ADDRESS" | jq -r '.[] | (.height|tostring) + "," + (.balance|tostring)' > balance.csv
BLOCKS=$(for ((HEIGHT=MIN_HEIGHT; HEIGHT<MAX_HEIGHT; HEIGHT=HEIGHT+100)); do curl -sS "http://testnet.lto.network/blocks/address/$ADDRESS/$HEIGHT/$((HEIGHT + 99))" | jq -r '.[].height'; done)
(for BLOCK in $BLOCKS; do curl -sS "http://testnet.lto.network/blocks/at/$BLOCK"; done) | jq -r 'select(.generatorReward > 0) | (.height|tostring) + "," + (.generatorReward|tostring)' > reward.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment