Last active
October 12, 2022 01:27
-
-
Save jasny/1bdacc967d90f37b75a275b340a1f0d6 to your computer and use it in GitHub Desktop.
LTO get transactions of address as CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ADDRESS="$1" | |
TOTAL=$(curl -s -I "https://nodes.lto.network/index/transactions/addresses/$ADDRESS" | grep x-total | awk '{printf "%d",$2}') | |
seq -w 00000 100 $TOTAL | xargs -P 10 -I'{}' curl -s "https://nodes.lto.network/index/transactions/addresses/$ADDRESS?limit=100&offset={}" -o "$ADDRESS.{}.json" | |
jq -s add $ADDRESS.*.json > "$ADDRESS.json" | |
rm $ADDRESS.*.json | |
jq -r 'reverse | .[] | [.type, .version, .id, (.timestamp / 1000 | todateiso8601), .sender, .recipient, (if .type == 4 then .amount else 0 end) + (if .type == 11 and .sender == "'$ADDRESS'" then (.transfers | ([.[].amount] | add)) else 0 end) + (if .type == 11 and .sender != "'$ADDRESS'" then (.transfers | ([.[] | select(.recipient == "'$ADDRESS'") | .amount] | add)) else 0 end), .effectiveFee] | join(",")' < "$ADDRESS.json" > "$ADDRESS.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment