From c6be35e427f5285c19b7a00a7cfafa20ed46ca0e Mon Sep 17 00:00:00 2001 From: openoms Date: Sat, 6 Mar 2021 11:11:45 +0000 Subject: [PATCH] INFO: menu options for m0, m4 and to show the DOCS related: https://github.com/openoms/joininbox/issues/33 --- scripts/_functions.bitcoincore.sh | 0 scripts/_functions.sh | 2 - scripts/menu.info.sh | 95 +++++++++++++++++++++++++++++++ scripts/menu.sh | 38 +------------ scripts/menu.tools.sh | 15 +---- 5 files changed, 98 insertions(+), 52 deletions(-) mode change 100644 => 100755 scripts/_functions.bitcoincore.sh create mode 100755 scripts/menu.info.sh diff --git a/scripts/_functions.bitcoincore.sh b/scripts/_functions.bitcoincore.sh old mode 100644 new mode 100755 diff --git a/scripts/_functions.sh b/scripts/_functions.sh index f80a75f..c3c52ec 100755 --- a/scripts/_functions.sh +++ b/scripts/_functions.sh @@ -107,8 +107,6 @@ function chooseWallet() { echo "# Make sure to type the full filename of the wallet." echo "# eg.: wallet.jmdat" echo - echo "# Type 'menu' to return" - echo exit 1 else echo "# OK - the wallet file is present." diff --git a/scripts/menu.info.sh b/scripts/menu.info.sh new file mode 100755 index 0000000..888f588 --- /dev/null +++ b/scripts/menu.info.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# INFO menu options + +source /home/joinmarket/joinin.conf +source /home/joinmarket/_functions.sh + +function cacheAndShowQR() { + # cache wallet data + walletData=$(mktemp -p /dev/shm/) + clear + /home/joinmarket/start.script.sh wallet-tool "$(cat $wallet)" nomethod 0 2>&1 | tee $walletData + firstNewAddress=$(cat "$walletData" | grep "0.00000000 new" | sed -n 1p | awk '{print $2}') + echo + if [ ${#firstNewAddress} -eq 0 ]; then + echo "# Error: missing address data" + echo + echo "# Type 'menu' to return" + echo + exit 1 + fi + # display data + cat "$walletData" + echo + echo "Fund the wallet on the first 'new' address to get started (displayed as a QR code also):" + echo "$firstNewAddress" + echo + qrencode -t ANSIUTF8 "${firstNewAddress}" + echo + shred $wallet $mixdepth $walletData + sudo rm -f /dev/shm/* +} + +# BASIC MENU INFO +HEIGHT=9 +WIDTH=52 +CHOICE_HEIGHT=21 +TITLE="Wallet management options" +BACKTITLE="Wallet management options" +MENU="" +OPTIONS=() + +# Basic Options +OPTIONS+=( + m0 "Show the first mixdepth to deposit to" + m4 "Show the content of all mixdepths" + DOCS "Link to the documentation" +) + +CHOICE=$(dialog --clear \ + --backtitle "$BACKTITLE" \ + --title "$TITLE" \ + --ok-label "Select" \ + --cancel-label "Back" \ + --menu "$MENU" \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" \ + 2>&1 >/dev/tty) + +case $CHOICE in + + m0) + checkRPCwallet + # wallet + chooseWallet + cacheAndShowQR + echo + echo "Press ENTER to return to the menu" + read key + ;; + m4) + checkRPCwallet + # wallet + chooseWallet + /home/joinmarket/start.script.sh wallet-tool "$(cat $wallet)" + echo "" + echo "Fund the wallet on addresses labeled 'new' to avoid address reuse." + echo "" + echo "Press ENTER to return to the menu..." + read key + /home/joinmarket/menu.sh + ;; + DOCS) + datastring="https://github.com/openoms/joininbox#more-info" + clear + echo + echo "Find a collection of written documentation and links to videos at:" + echo "$datastring" + echo + qrencode -t ANSIUTF8 "${datastring}" + echo + echo "Press ENTER to return to the menu..." + read key + ;; +esac \ No newline at end of file diff --git a/scripts/menu.sh b/scripts/menu.sh index 68728f0..a7f7bea 100755 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -45,42 +45,8 @@ CHOICE=$(dialog --clear \ case $CHOICE in INFO) - checkRPCwallet - # wallet - chooseWallet - # mixdepth - mixdepth=$(mktemp -p /dev/shm/) - dialog --backtitle "Choose a mixdepth" \ - --title "Choose a mixdepth" \ - --inputbox " -Enter a number between 0 to 4 to limit the visible mixdepths -Leave the box empty to show the addresses in all five" 10 64 2> $mixdepth - openMenuIfCancelled $? - # cache wallet data - walletData=$(mktemp -p /dev/shm/) - clear - /home/joinmarket/start.script.sh wallet-tool "$(cat $wallet)" nomethod "$(cat $mixdepth)" 2>&1 | tee $walletData - firstNewAddress=$(cat "$walletData" | grep "0.00000000 new" | sed -n 1p | awk '{print $2}') - echo - if [ ${#firstNewAddress} -eq 0 ]; then - echo "# Error: missing address data" - echo - echo "# Type 'menu' to return" - echo - exit 1 - fi - # display data - cat "$walletData" - echo - echo "Fund the wallet on the first 'new' address to get started (displayed as a QR code also):" - echo "$firstNewAddress" - echo - qrencode -t ANSIUTF8 "${firstNewAddress}" - echo - shred $wallet $mixdepth $walletData - sudo rm -f /dev/shm/* - echo "Press ENTER to return to the menu..." - read key + /home/joinmarket/menu.info.sh + waitKeyOnExit1 $? /home/joinmarket/menu.sh ;; WALLET) diff --git a/scripts/menu.tools.sh b/scripts/menu.tools.sh index ab06c0e..c68291c 100755 --- a/scripts/menu.tools.sh +++ b/scripts/menu.tools.sh @@ -33,7 +33,7 @@ function getQRstring { } # BASIC MENU INFO -HEIGHT=13 +HEIGHT=12 WIDTH=55 CHOICE_HEIGHT=20 TITLE="Tools" @@ -48,7 +48,6 @@ if [ "${runningEnv}" = standalone ]; then fi OPTIONS+=( QR "Display a QR code from any text" - DOCS "Show a link to the documentation" CUSTOMRPC "Run a custom bitcoin RPC with curl" BOLTZMANN "Analyze the entropy of a transaction" PASSWORD "Change the ssh password" @@ -82,18 +81,6 @@ case $CHOICE in echo "Press ENTER to return to the menu..." read key ;; - DOCS) - datastring="https://github.com/openoms/joininbox#more-info" - clear - echo - echo "Find a collection of written documentation and links to videos at:" - echo "$datastring" - echo - qrencode -t ANSIUTF8 "${datastring}" - echo - echo "Press ENTER to return to the menu..." - read key - ;; BOLTZMANN) installBoltzmann getTXID