git ssb

0+

cel / ledger-scripts



Commit 32bcd58af6ac1e096b87f0cf6e490ae1f18c8f2f

Add ethereum2ledger

Charles Lehner committed on 9/12/2016, 12:09:56 AM
Parent: 9392bf5811bd76643fc354d7b20dd16fc6344481

Files changed

README.mdchanged
ethereum2ledgeradded
README.mdView
@@ -69,8 +69,12 @@
6969 #### `paypal2ledger`
7070 Import full PayPal CSV transactions history (including shopping carts).
7171 Currently this script is buggy so the results have to be manually fixed.
7272
73+#### `ethereum2ledger`
74+Import Ethereum transaction history for an address, using etherscan.io's API.
75+Depends on jq.
76+
7377 #### Coinbase
7478
7579 Two scripts are provided for processing two types of CSV files that Coinbase
7680 exports. For best results, run both, merge the results, and then reconcile it
ethereum2ledgerView
@@ -1,0 +1,30 @@
1+#!/bin/sh
2+addr="${1?missing address}"
3+
4+acct_gas='Expenses:Broker:Miner Fees'
5+acct_eth='Assets:Ethereum'
6+eth=1000000000000000000
7+
8+curl -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' |\
10+while 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"
30+done

Built with git-ssb-web