Code: Select all
#!/bin/bash
# Replace with your Stellar wallet address
STELLAR_WALLET="YOUR_WALLET_ADDRESS"
# Get the current time in UTC and subtract one hour
ONE_HOUR_AGO=$(date -u -d "1 hour ago" +"%Y-%m-%dT%H:%M:%SZ")
# Fetch payment transactions for the Stellar account
response=$(curl -s "https://horizon.stellar.org/accounts/$STELLAR_WALLET/payments?order=desc&limit=200")
# Function to get memo for a transaction
get_memo() {
TX_HASH=$1
MEMO=$(curl -s "https://horizon.stellar.org/transactions/$TX_HASH" | jq -r '.memo // "No Memo"')
echo "$MEMO"
}
# Process received payments
echo "Payments received in the last hour:"
echo "$response" | jq -r --arg TIME "$ONE_HOUR_AGO" '
._embedded.records[] |
select(.created_at > $TIME and .to == "'$STELLAR_WALLET'") |
"\(.created_at[0:10])|\(.created_at[11:19])|\(.from)|\(.asset_code // "XLM")|\(.amount)|\(.transaction_hash)"' |
while IFS="|" read -r DATE TIME FROM ASSET AMOUNT TX_HASH; do
MEMO=$(get_memo "$TX_HASH")
echo "$DATE | $TIME | $FROM | $ASSET | $AMOUNT | $MEMO"
done | column -t -s "|"
# Process sent payments
echo -e "\nPayments sent in the last hour:"
echo "$response" | jq -r --arg TIME "$ONE_HOUR_AGO" '
._embedded.records[] |
select(.created_at > $TIME and .from == "'$STELLAR_WALLET'") |
"\(.created_at[0:10])|\(.created_at[11:19])|\(.to)|\(.asset_code // "XLM")|\(.amount)|\(.transaction_hash)"' |
while IFS="|" read -r DATE TIME TO ASSET AMOUNT TX_HASH; do
MEMO=$(get_memo "$TX_HASH")
echo "$DATE | $TIME | $TO | $ASSET | $AMOUNT | $MEMO"
done | column -t -s "|"
exit 0