Files
mines/rin/wallet/cmd/get_transaction.sh
Dobromir Popov dc8f69c5c3 code moved from scripts repo;
dump works
2025-09-29 22:23:38 +03:00

50 lines
1.2 KiB
Bash

#!/bin/bash
# Script to get RIN transaction details
# Usage: ./get_transaction.sh <txid> [rpc_user] [rpc_password] [rpc_host] [rpc_port]
if [ $# -lt 1 ]; then
echo "Usage: $0 <transaction_id> [rpc_user] [rpc_password] [rpc_host] [rpc_port]"
echo "Example: $0 a1b2c3d4... user password localhost 8332"
exit 1
fi
TXID=$1
RPC_USER=${2:-"rinrpc"}
RPC_PASSWORD=${3:-"password"}
RPC_HOST=${4:-"localhost"}
RPC_PORT=${5:-"8332"}
# JSON-RPC request
RPC_REQUEST='{
"jsonrpc": "2.0",
"id": "gettransaction",
"method": "gettransaction",
"params": ["'"$TXID"'"]
}'
echo "Getting transaction details for: $TXID"
# Make the RPC call
RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
-H "Content-Type: application/json" \
-d "$RPC_REQUEST" \
"http://$RPC_HOST:$RPC_PORT")
# Check for errors
ERROR=$(echo "$RESPONSE" | jq -r '.error' 2>/dev/null)
if [ "$ERROR" != "null" ] && [ -n "$ERROR" ]; then
echo "Error: $(echo "$ERROR" | jq -r '.message')"
exit 1
fi
# Display transaction details
RESULT=$(echo "$RESPONSE" | jq -r '.result' 2>/dev/null)
if [ "$RESULT" != "null" ]; then
echo "Transaction Details:"
echo "$RESPONSE" | jq '.result'
else
echo "Unexpected response: $RESPONSE"
exit 1
fi