Skip to content

Instantly share code, notes, and snippets.

@jasny
Last active May 5, 2022 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasny/d929838bb1278cd460aabb9a6ea76d30 to your computer and use it in GitHub Desktop.
Save jasny/d929838bb1278cd460aabb9a6ea76d30 to your computer and use it in GitHub Desktop.
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