Skip to content

Commit

Permalink
info.feereport.sh shows fees earned as a Maker
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms committed Sep 17, 2020
1 parent 43f95c6 commit eab0653
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/_commands.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/bin/bash

# SHORTCUT COMMANDS for the user 'joinmarket' from terminal
# SHORTCUT COMMANDS for the user 'joinmarket'

# command: menu
# calls directly the main menu
function menu() {
cd /home/joinmarket
./menu.sh
$HOME/menu.sh
}

# command: torthistx
Expand All @@ -21,3 +20,8 @@ function torthistx() {
echo "Not running behind Tor"
fi
}
# command: fees
# shows the fees earned as a Maker
function fees() {
$HOME/info.feereport.sh
}
55 changes: 55 additions & 0 deletions scripts/info.feereport.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# shows the fees earned as a Maker

INPUT=$HOME/.joinmarket/logs/yigen-statement.csv
allEarned=0
allCoinjoins=0
monthEarned=0
monthCoinjoins=0
weekEarned=0
weekCoinjoins=0
dayEarned=0
dayCoinjoins=0
unixtimeMonthAgo=$(date -d "1 month ago" +%s)
unixtimeWeekAgo=$(date -d "1 week ago" +%s)
unixtimeDayAgo=$(date -d "1 day ago" +%s)
OLDIFS=$IFS
IFS=","
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
#timestamp cj amount/satoshi my input count my input value/satoshi cjfee/satoshi earned/satoshi confirm time/min notes
while read -r timestamp cj_amount_satoshi my_input_count my_input_value_satoshi cjfee_satoshi earned_satoshi confirm_time_min notes
do
unixtimeEvent=$(date -d "$timestamp" +%s 2>/dev/null)
if [ "$earned_satoshi" -gt 0 ]; then
allEarned=$(( allEarned + earned_satoshi ))
allCoinjoins=$(( allCoinjoins + 1 ))
if [ "$unixtimeEvent" -gt "$unixtimeMonthAgo" ]; then
monthEarned=$(( monthEarned + earned_satoshi ))
monthCoinjoins=$(( monthCoinjoins + 1 ))
if [ "$unixtimeEvent" -gt "$unixtimeWeekAgo" ]; then
weekEarned=$(( weekEarned + earned_satoshi ))
weekCoinjoins=$((weekCoinjoins+1))
if [ "$unixtimeEvent" -gt "$unixtimeDayAgo" ]; then
dayEarned=$((dayEarned+earned_satoshi))
dayCoinjoins=$((dayCoinjoins+1))
fi
fi
fi
fi 2>/dev/null
done < "$INPUT"
IFS=$OLDIFS

echo "
coinjoins as a Maker
day: $dayCoinjoins
week: $weekCoinjoins
month: $monthCoinjoins
all: $allCoinjoins
sats earned
day: $dayEarned
week: $weekEarned
month: $monthEarned
all: $allEarned
"
Empty file modified scripts/menu.payjoin.sh
100644 → 100755
Empty file.

0 comments on commit eab0653

Please sign in to comment.