Skill: sh1ftred/routstr-balance-management (version 1.0.0)

--- name: balance-management description: Manage Routstr balance by checking balance, creating Lightning invoices for top-up, and checking invoice payment status license: MIT compatibility: opencode --- ## What I do - Check current Routstr API balance (in sats and BTC) - Display usage statistics (total spent, total requests) - Create Lightning invoices for top-up payments - Check payment status of existing invoices - Top up balance using Cashu tokens ## When to use me Use this when you need to: - Check your current Routstr account balance - Top up your Routstr account by creating a Lightning invoice - Verify if a previously created invoice has been paid ## How to use me The shell scripts read API configuration from `~/.openclaw/openclaw.json`: - `check_balance.sh` - Run with no arguments to display current balance and usage - `create_invoice.sh <amount_sats>` - Create invoice for specified amount in satoshis - `invoice_status.sh <invoice_id>` - Check payment status of an invoice - `topup_cashu.sh <cashu_token>` - Top up balance using a Cashu token All amounts are displayed in both satoshis and BTC for convenience.

path: topup_cashu.sh
content: #!/bin/bash

# Top up balance with Cashu token
CONFIG_FILE="$HOME/.openclaw/openclaw.json"

# Check cashu token argument
if [ -z "$1" ]; then
  echo "Usage: $0 <cashu_token>"
  echo "Example: $0 cashuBo2FteCJodHRwczovL21pbnQubWluaWJpdHMuY2FzaC9CaXRjb2luYXVjc2F0YXSBomFpSAAQeTfbDMhlYXCBo2FhAWFzeEBkNWJjNWYxYmE2YmJlNDQ2NGM3YmI1NjQ4MzBhNWY1ZDRjZDU3ZjJhOTQ3ZGQwYmE0ZjJmYjgwZTNlMmI4NmNhYWNYIQObVC-sFR3tVKwD08eDbJGrvP6J_IZ7k6k2Yn4CjY5Bog"
  exit 1
fi

CASHU_TOKEN="$1"

# Extract base URL and API key from config
BASE_URL=$(jq -r '.models.providers.routstr.baseUrl' "$CONFIG_FILE")
API_KEY=$(jq -r '.models.providers.routstr.apiKey' "$CONFIG_FILE")

# Make topup request (cashu token in query params, not body)
echo "Topping up with Cashu token..."
RESPONSE=$(curl -s -X POST "${BASE_URL}/wallet/topup?cashu_token=$(echo "${CASHU_TOKEN}" | jq -sRr @uri)" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}")

# Display result
echo "$RESPONSE" | jq .

# Show success message if it worked
SUCCESS=$(echo "$RESPONSE" | jq -r '.success')
if [ "$SUCCESS" = "true" ]; then
  echo ""
  echo "Top-up successful!"
elif [ "$SUCCESS" = "null" ] || [ -z "$SUCCESS" ]; then
  # Check if there's an error message
  ERROR=$(echo "$RESPONSE" | jq -r '.error // .message // empty')
  if [ -n "$ERROR" ]; then
    echo ""
    echo "Error: $ERROR"
  fi
fi


path: create_invoice.sh
content: #!/bin/bash

# Create Lightning invoice for top-up
CONFIG_FILE="$HOME/.openclaw/openclaw.json"

# Check amount argument
if [ -z "$1" ]; then
  echo "Usage: $0 <amount_sats>"
  echo "Example: $0 1000"
  exit 1
fi

# Convert sats to msats (API expects msats)
AMOUNT_SATS="$1"
AMOUNT_MSATS=$((AMOUNT_SATS * 1000))

# Extract base URL and API key from config
BASE_URL=$(jq -r '.models.providers.routstr.baseUrl' "$CONFIG_FILE")
API_KEY=$(jq -r '.models.providers.routstr.apiKey' "$CONFIG_FILE")

# Create invoice (note: API expects amount in msats)
echo "Creating $AMOUNT_SATS sat invoice..."
RESPONSE=$(curl -s -X POST "${BASE_URL}/balance/lightning/invoice" \
  -H "Content-Type: application/json" \
  -d "{\"amount_sats\": ${AMOUNT_MSATS}, \"purpose\": \"topup\", \"api_key\": \"${API_KEY}\"}")

# Display result
echo "$RESPONSE" | jq .

# Show bolt11 separately for easy copying
BOLT11=$(echo "$RESPONSE" | jq -r '.bolt11')
if [ "$BOLT11" != "null" ] && [ -n "$BOLT11" ]; then
  echo ""
  echo "BOLT11 (pay this):"
  echo "$BOLT11"
fi


path: invoice_status.sh
content: #!/bin/bash

# Check Lightning invoice payment status
CONFIG_FILE="$HOME/.openclaw/openclaw.json"

# Check invoice_id argument
if [ -z "$1" ]; then
  echo "Usage: $0 <invoice_id>"
  echo "Example: $0 OnXsgW4-OvVTOt7LVDCD4A"
  exit 1
fi

INVOICE_ID="$1"

# Extract base URL and API key from config
BASE_URL=$(jq -r '.models.providers.routstr.baseUrl' "$CONFIG_FILE")

# Check status
curl -s "${BASE_URL}/balance/lightning/invoice/${INVOICE_ID}/status" | jq .


path: check_balance.sh
content: #!/bin/bash

# Check API balance (returns msats, convert to sats/BTC for display)
CONFIG_FILE="$HOME/.openclaw/openclaw.json"

# Extract base URL and API key from config
BASE_URL=$(jq -r '.models.providers.routstr.baseUrl' "$CONFIG_FILE")
API_KEY=$(jq -r '.models.providers.routstr.apiKey' "$CONFIG_FILE")

# Call balance endpoint
RESPONSE=$(curl -s -H "Authorization: Bearer $API_KEY" "${BASE_URL}/balance/info")

# Extract values (in msats)
MSATS=$(echo "$RESPONSE" | jq -r '.balance')
SPENT_MSATS=$(echo "$RESPONSE" | jq -r '.total_spent')
REQUESTS=$(echo "$RESPONSE" | jq -r '.total_requests')

# Convert to sats (divide by 1000)
SATS=$((MSATS / 1000))
SPENT_SATS=$((SPENT_MSATS / 1000))

# Convert to BTC (1 BTC = 100,000,000 sats) - using awk for decimal
BTC=$(awk "BEGIN {printf \"%.6f\", $SATS / 100000000}")
SPENT_BTC=$(awk "BEGIN {printf \"%.6f\", $SPENT_SATS / 100000000}")

# Display
echo "Balance: $SATS sats (~$BTC BTC)"
echo "Usage:"
echo "  • Total spent: $SPENT_SATS sats (~$SPENT_BTC BTC)"
echo "  • Total requests: $REQUESTS"


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)