Repository navigation
Monitor a Payment
sucks less edited this page Sep 8, 2026
·
19 revisions
#!/bin/bash
WATCHDIR="/tmp/mywallet/transactions"
known=""
# Function to handle reading from a pipe
read_pipe() {
local dir="$1"
local file="$2"
local amount
# Set timeout for cat command (125 minutes)
if ! amount=$(timeout 125m cat "${dir}/${file}"); then
# Handle timeout - write to syslog and exit
echo "Timeout occurred while reading from $file" >&2
logger "Timeout occurred while reading from $file"
exit 1
fi
echo "Received from $file: $amount"
}
while true; do
for fifo in $(find "$WATCHDIR" -type p 2>/dev/null); do
if [[ ! "$known" =~ "$fifo" ]]; then
echo "New transaction detected: $fifo"
known="$known $fifo"
(
read_pipe "$(dirname "$fifo")" "$(basename "$fifo")"
) &
fi
done
sleep 1
done#!/bin/bash
TX="/tmp/mywallet/transactions"
FIFO="/tmp/mywallet/txid"
echo "Waiting for incoming transaction in $FIFO ..."
while true; do
if read -r txid address <"$FIFO"; then
piconero=$(cat "$TX/$txid/$address")
x=$(echo $piconero 1000000000000 | awk '{ printf "%.12f\n", $1 / $2 }')
echo "Received $x XMR"
fi
done#!/bin/bash
FIFO="/tmp/mywallet/double_spend_alert"
echo "Waiting for alert in $FIFO ..."
while true; do
if read -r txid address <"$FIFO"; then
echo "Alert at: $txid $address"
fi
doneFIFO="/tmp/mywallet/rpc_connection_alert"
MNP="/usr/local/bin/mnp"
while true; do
if read -r txid < "$FIFO"; then
printf '%s\n' "$txid" |
"$MNP" --retry --notify-at 1
fi
donemnp exposes transaction state and alert events through POSIX FIFOs using a small, line-oriented interface designed for direct consumption by standard Unix tools and shell scripts.
| Entry | Content | Meaning |
|---|---|---|
txid |
TXID (PAYMENT_ID | ADDRESS) |
Processed transaction and identifier/address |
rpc_connection_alert |
TXID |
Wallet RPC communication failed for the transaction |
double_spend_alert |
TXID (PAYMENT_ID | ADDRESS) |
A double-spend condition was reported |
transactions/<TXID>/<PAYMENT_ID|ADDRESS> |
AMOUNT |
Received amount in Monero atomic units |
cat /tmp/mywallet/txidcat /tmp/mywallet/rpc_connection_alertfind /tmp/mywallet/transactions -type p -exec cat {} \;mnp --retry < /tmp/mywallet/rpc_connection_alert
sucks less