Skip to content

Instantly share code, notes, and snippets.

@jasny
Last active May 27, 2022 10:52
Show Gist options
  • Save jasny/3cdf73e96badd77211712d0193529253 to your computer and use it in GitHub Desktop.
Save jasny/3cdf73e96badd77211712d0193529253 to your computer and use it in GitHub Desktop.
Transfer full LTO node balance to own wallet
#!/bin/bash
if [ -z "$1" ]; then
echo "USAGE: $0 RECIPIENT" >&2
exit 1
fi
RECIPIENT="$1"
WALLET_ADDRESS=$(curl -sS http://localhost:6869/wallet/addresses | jq -r '[0]')
BALANCE=$(curl -sS http://localhost:6869/addresses/balance/$WALLET_ADDRESS | jq -r '.balance')
AMOUNT=$((BALANCE - 100000000))
curl -sS http://localhost:6869/transactions/submit/transfer --header "X-Api-Key: $LTO_API_KEY" --header "Content-Type: application/json" --data "{\"sender\": \"$WALLET_ADDRESS\", \"recipient\": \"$RECIPIENT\", \"amount\": $AMOUNT, \"fee\": 100000000}"
@jasny
Copy link
Author

jasny commented May 27, 2022

Transfer full LTO node balance to own wallet

Install

Download lto-transfer-all and store it in ~/.bin or /usr/local/bin.

Make the file executable

chmod +x ~/.bin/lto-transfer-all

Cron

Add a cronjob to transfer the full balance of your node to your cold wallet once a week.

0 0 * * 0  ~/.bin/lto-transfer-all MY_COLD_WALLET

Change MY_COLD_WALLET to your cold wallet address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment