From eab065373b833385357f1fa7d2d0ef82da9b0ff3 Mon Sep 17 00:00:00 2001 From: openoms Date: Thu, 17 Sep 2020 19:57:49 +0100 Subject: [PATCH] info.feereport.sh shows fees earned as a Maker --- scripts/_commands.sh | 10 ++++--- scripts/info.feereport.sh | 55 +++++++++++++++++++++++++++++++++++++++ scripts/menu.payjoin.sh | 0 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100755 scripts/info.feereport.sh mode change 100644 => 100755 scripts/menu.payjoin.sh diff --git a/scripts/_commands.sh b/scripts/_commands.sh index 187cc2c..cf33d50 100755 --- a/scripts/_commands.sh +++ b/scripts/_commands.sh @@ -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 @@ -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 +} \ No newline at end of file diff --git a/scripts/info.feereport.sh b/scripts/info.feereport.sh new file mode 100755 index 0000000..9e38cd0 --- /dev/null +++ b/scripts/info.feereport.sh @@ -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 +" \ No newline at end of file diff --git a/scripts/menu.payjoin.sh b/scripts/menu.payjoin.sh old mode 100644 new mode 100755