From 45dbdb3b82c23228432f089107b39907a4f0641d Mon Sep 17 00:00:00 2001 From: /rootzoll Date: Tue, 28 May 2024 22:42:11 +0200 Subject: [PATCH] Add script for signing messages from specific address (#4582) * Add script for signing messages from specific address * use bitcoin-cli to check address * add CHANGES --- CHANGES.md | 1 + home.admin/config.scripts/lnd.signaddress.sh | 50 ++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 home.admin/config.scripts/lnd.signaddress.sh diff --git a/CHANGES.md b/CHANGES.md index d0ad0a884..77b4313cf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ ## What's new in Version 1.11.1 of RaspiBlitz? +- New: config.scripts/lnd.signaddress.sh to easy sign messages on addresses on LND [details](https://github.com/raspiblitz/raspiblitz/issues/4540) - Update: Specter Desktop 2.0.4 with reactivated UPDATE option [details](https://github.com/cryptoadvance/specter-desktop/releases/tag/v2.0.4) - Remove: Tallycoin-Connect [see service shutdown](https://x.com/djbooth007/status/1784409117563720082) - Remove: IP2Tor Shoplist [details](https://github.com/raspiblitz/raspiblitz/issues/4589) diff --git a/home.admin/config.scripts/lnd.signaddress.sh b/home.admin/config.scripts/lnd.signaddress.sh new file mode 100644 index 000000000..0c27682df --- /dev/null +++ b/home.admin/config.scripts/lnd.signaddress.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# This script allows users to sign a message from a specific Bitcoin address +# either by generating a new address or using an existing one. + +# Ask if a new address should be generated or an existing one should be entered +read -p "Do you want to generate a new address? (y/n) " generate_new + +# 1.a. If generating a new address, ask for the address type +if [ "$generate_new" == "y" ]; then + echo "Generate a wallet new address. Address-types has to be one of:" + echo "1. p2wkh: Pay to witness key hash" + echo "2. np2wkh: Pay to nested witness key hash" + echo "3. p2tr: Pay to taproot pubkey" + read -p "Enter the address type (1-3 or string): " address_type + case "$address_type" in + 1|"p2wkh") + address_type="p2wkh" + ;; + 2|"np2wkh") + address_type="np2wkh" + ;; + 3|"p2tr") + address_type="p2tr" + ;; + *) + echo "Error: Invalid address type." + exit 1 + ;; + esac + address=$(lncli newaddress $address_type) + address_variable=$(echo $address | jq -r '.address') +else + # 1.b. Check if the manually entered address is valid + read -p "Enter the existing address: " address + if ! bitcoin-cli validateaddress "$address" | grep -q "isvalid\": true"; then + echo "Error: The entered address is not valid." + exit 1 + fi + address_variable=$address +fi +# 2. Ask for the message to sign and save it to a variable +read -p "Enter the message to sign: " message_to_sign + +# 3. Execute the lncli wallet addresses signmessage command +signature_js=$(lncli wallet addresses signmessage --address $address_variable --msg "$message_to_sign") +signature=$(echo $signature_js | jq -r '.signature') +echo "The address is: $address_variable" +echo "The message to sign is: $message_to_sign" +echo "The signature is: $signature"