#!/bin/bash
# Define the function to get the unlocked balance
getUnlockedBalance() {
# Monero wallet RPC endpoint
local WALLET_RPC_ENDPOINT="http://127.0.0.1:18082/json_rpc"
# JSON RPC request payload
local REQUEST_PAYLOAD='{
"jsonrpc":"2.0",
"id":"0",
"method":"get_balance",
"params": {
"account_index": 0
}
}'
# Perform the request
local RESPONSE=$(curl -s "$WALLET_RPC_ENDPOINT" -d "$REQUEST_PAYLOAD" -H 'Content-Type: application/json')
# Extract and display the unlocked balance from the response
echo "Response: $RESPONSE"
local UNLOCKED_BALANCE=$(echo $RESPONSE | jq '.result.unlocked_balance')
echo "Unlocked Balance: $UNLOCKED_BALANCE atomic units"
# Convert the unlocked balance from atomic units to XMR (1 XMR = 1e12 atomic units)
local UNLOCKED_BALANCE_XMR=$(bc <<< "scale=12; $UNLOCKED_BALANCE/1000000000000")
echo "Unlocked Balance: $UNLOCKED_BALANCE_XMR XMR"
}
# Example usage:
getUnlockedBalance
#!/bin/bash
# Function to divide the output of generateNumber by the number of lines in a file
divideByNumberOfLines() {
local filename="$1"
# Ensure the file exists
if [[ ! -f "$filename" ]]; then
echo "File does not exist: $filename" >&2
return 1
fi
# Get the number from the generateNumber function
local number=$(getUnlockedBalance)
# Count the number of lines in the file
local lines=$(wc -l < "$filename")
# Calculate the division, forcing floating point arithmetic
local result=$(echo "scale=2; $number / $lines" | bc -l)
echo $result
}
# Usage example
# Replace 'yourfile.txt' with the path to your actual file
divideByNumberOfLines "destinations.txt"
#!/bin/bash
# Monero wallet RPC endpoint
WALLET_RPC_ENDPOINT="http://127.0.0.1:18082/json_rpc"
# File containing destination addresses, one per line
ADDRESS_FILE="destinations.txt"
# Amount to send to each destination, in atomic units (1 XMR = 1e12 atomic units)
AMOUNT=divideByNumberOfLines "destinations.txt" # Example amount of 1 XMR
# Read addresses from the file and build the JSON array of destinations
JSON_DESTINATIONS="["
while IFS= read -r DEST; do
# Skip empty lines
[[ -z "$DEST" ]] && continue
JSON_DESTINATIONS+="{\"amount\":$AMOUNT,\"address\":\"$DEST\"},"
done < "$ADDRESS_FILE"
# Remove the last comma
JSON_DESTINATIONS=${JSON_DESTINATIONS%,}
JSON_DESTINATIONS+="]"
# JSON RPC request payload
REQUEST_PAYLOAD="{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"transfer_split\",\"params\":{\"destinations\":$JSON_DESTINATIONS,\"account_index\":0,\"subaddr_indices\":[0],\"priority\":0,\"ring_size\":7,\"get_tx_keys\":true}}"
# Perform the request
curl -s "$WALLET_RPC_ENDPOINT" -d "$REQUEST_PAYLOAD" -H 'Content-Type: application/json'
#!/bin/bash
# Monero wallet RPC endpoint
WALLET_RPC_ENDPOINT="http://127.0.0.1:18082/json_rpc"
# File containing destination addresses, one per line
ADDRESS_FILE="destinations.txt"
# Amount to send to each destination, in atomic units (1 XMR = 1e12 atomic units)
AMOUNT=1000000000000 # Example amount of 1 XMR
# Read addresses from the file and build the JSON array of destinations
JSON_DESTINATIONS="["
while IFS= read -r DEST; do
# Skip empty lines
[[ -z "$DEST" ]] && continue
JSON_DESTINATIONS+="{\"amount\":$AMOUNT,\"address\":\"$DEST\"},"
done < "$ADDRESS_FILE"
# Remove the last comma
JSON_DESTINATIONS=${JSON_DESTINATIONS%,}
JSON_DESTINATIONS+="]"
# JSON RPC request payload
REQUEST_PAYLOAD="{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"transfer_split\",\"params\":{\"destinations\":$JSON_DESTINATIONS,\"account_index\":0,\"subaddr_indices\":[0],\"priority\":0,\"ring_size\":7,\"get_tx_keys\":true}}"
# Perform the request
curl -s "$WALLET_RPC_ENDPOINT" -d "$REQUEST_PAYLOAD" -H 'Content-Type: application/json'
undebugged
by
Tags:
Leave a Reply