git ssb

0+

cel / ledger-scripts



Tree: f1521af2d73e96acaa4e96dfc60dbfc50373845a

Files: f1521af2d73e96acaa4e96dfc60dbfc50373845a / ethereum2ledger

1008 bytesRaw
1#!/bin/sh
2addr="${1?missing address}"
3
4acct_gas='Expenses:Broker:Miner Fees'
5acct_eth='Assets:Ethereum'
6eth=1000000000000000000
7
8curl -s "https://api.etherscan.io/api?module=account&action=txlist&address=$addr&sort=asc" |\
9 jq -r '.result[] | .hash + " " + .timeStamp + " " + .from + " " + .to + " " + .value + " " + .gasUsed + " " + .gasPrice | @text' |\
10while read hash time from to value gas_used gas_price; do
11 if [ "$to" = "$addr" ]
12 then
13 type=Deposit
14 acct_from="$acct_eth"
15 acct_to=Income
16 else
17 type=Withdraw
18 acct_from="$acct_eth"
19 acct_to=Expenses
20 value="-$value"
21 fi
22 gas_eth="$(echo "($gas_used * $gas_price)/$eth" | bc -l)"
23 sent_eth="$(echo "-($value)/$eth" | bc -l)"
24 value_eth="$(echo "($value - ($gas_used * $gas_price))/$eth" | bc -l)"
25 date --date=@$time +"%Y/%m/%d $type"
26 echo " ; txid: $hash"
27 printf " %-32s %12.8f ETH\n" "$acct_to" "$sent_eth"
28 printf " %-32s %12.8f ETH\n" "$acct_gas" "$gas_eth"
29 printf " %-32s %12.8f ETH\n\n" "$acct_from" "$value_eth"
30done
31

Built with git-ssb-web