qusal/salt/sys-bitcoin/files/client/bin/bitcoin-tx-notify
Ben Grande 1b2f1ba941
fix: avoid operand evaluation as argument
Explicit end option parsing as the shell can be quite dangerous without
it.
2024-08-06 17:13:25 +02:00

25 lines
624 B
Bash
Executable File

#!/bin/sh
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
set -eu
qube="$(qubesdb-read /name)"
txid="${1}"
wallet="${2}"
block_hash="${3}"
block_height="${4-}"
title="${qube}: wallet: ${wallet}"
date="$(date +%FT%H:%m:%SZ)"
if test "${block_hash}" = "unconfirmed"; then
body="TXID ${txid} is ${block_hash}"
else
body="TXID ${txid} is in block ${block_height} ${block_hash}"
fi
echo "${date} ${title}: ${body}" | tee -- ~/.bitcoin/walletnotify.log
if command -v notify-send >/dev/null; then
notify-send -t 10000 "${title}" "${body}"
fi