#!/usr/bin/env bash
# Transaction logging utilities

LOG_DIR="${LOG_DIR:-/home/intlc/projects/proxmox/logs}"
LOG_FILE="$LOG_DIR/bridge-transactions-$(date +%Y%m%d).log"

log_transaction() {
    local tx_hash="$1"
    local chain="$2"
    local amount="$3"
    local status="$4"
    
    echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] $status | $chain | $amount | $tx_hash" >> "$LOG_FILE"
}

get_transaction_status() {
    local tx_hash="$1"
    local rpc_url="$2"
    cast tx "$tx_hash" --rpc-url "$rpc_url" 2>/dev/null | grep -E "status|blockNumber" || echo "Pending"
}
