fix wallet load/dump/list

This commit is contained in:
Dobromir Popov
2025-09-29 23:16:06 +03:00
parent dc8f69c5c3
commit e272755015
7 changed files with 352 additions and 40 deletions

View File

@@ -24,21 +24,34 @@ RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
-d "$RPC_REQUEST" \
"http://$RPC_HOST:$RPC_PORT")
# Check for errors
ERROR=$(echo "$RESPONSE" | jq -r '.error' 2>/dev/null)
if [ "$ERROR" != "null" ] && [ -n "$ERROR" ]; then
echo "Error: $(echo "$ERROR" | jq -r '.message')"
exit 1
fi
# Show raw response for debugging
echo "Raw response: $RESPONSE"
echo ""
# Get wallet list
WALLETS=$(echo "$RESPONSE" | jq -r '.result[]' 2>/dev/null)
if [ -n "$WALLETS" ]; then
echo "Loaded wallets:"
echo "$WALLETS" | while read -r wallet; do
echo " - $wallet"
done
# Check for errors (without jq)
if echo "$RESPONSE" | grep -q '"error":null'; then
echo "No errors in response"
# Extract wallet names from the result array
# Look for pattern: "result":["wallet1","wallet2"]
WALLET_SECTION=$(echo "$RESPONSE" | grep -o '"result":\[[^]]*\]')
if [ -n "$WALLET_SECTION" ]; then
# Extract wallet names between quotes
WALLETS=$(echo "$WALLET_SECTION" | grep -o '"[^"]*"' | grep -v '"result"' | sed 's/"//g')
if [ -n "$WALLETS" ]; then
echo "Loaded wallets:"
echo "$WALLETS" | while read -r wallet; do
echo " - $wallet"
done
else
echo "No wallets are currently loaded."
fi
else
echo "No wallet result found in response."
fi
else
echo "No wallets are currently loaded."
echo "Error in response: $RESPONSE"
fi