75 lines
2.6 KiB
Bash
75 lines
2.6 KiB
Bash
#!/bin/bash
|
|
|
|
# Test if the master key format is valid
|
|
MASTER_KEY="xprv9s21ZrQH143K3bjynHVk6hBTZLmV9wjqWScL3UyENBYK6RaFo75zu5jnWQtBi932zKbD7c2WARWLJNjBbE3Td2Cc44ym3dmp343qKKFXwxS"
|
|
|
|
echo "Testing master key format..."
|
|
echo "Key: $MASTER_KEY"
|
|
echo ""
|
|
|
|
# Check basic format
|
|
if [[ "$MASTER_KEY" =~ ^xprv[a-zA-Z0-9]+ ]]; then
|
|
echo "✓ Basic format is correct (starts with xprv)"
|
|
else
|
|
echo "✗ Invalid format"
|
|
exit 1
|
|
fi
|
|
|
|
# Check length (should be 111 characters for xprv)
|
|
LENGTH=${#MASTER_KEY}
|
|
echo "Key length: $LENGTH characters"
|
|
if [[ $LENGTH -eq 111 ]]; then
|
|
echo "✓ Length is correct for extended private key"
|
|
else
|
|
echo "⚠ Length is $LENGTH, expected 111 for xprv"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Testing with a temporary wallet..."
|
|
TEMP_WALLET="test_key_wallet_$(date +%s)"
|
|
|
|
# Create temp wallet
|
|
CREATE_RESPONSE=$(curl -s -u "rinrpc:745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"jsonrpc": "2.0", "id": "createwallet", "method": "createwallet", "params": ["'$TEMP_WALLET'", false, false, "", false, false, true]}' \
|
|
"http://localhost:9556")
|
|
|
|
if echo "$CREATE_RESPONSE" | grep -q '"error":null'; then
|
|
echo "✓ Temp wallet created"
|
|
|
|
# Try to set HD seed
|
|
SEED_RESPONSE=$(curl -s -u "rinrpc:745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"jsonrpc": "2.0", "id": "sethdseed", "method": "sethdseed", "params": [true, "'$MASTER_KEY'"]}' \
|
|
"http://localhost:9556/wallet/$TEMP_WALLET")
|
|
|
|
echo "Seed response: $SEED_RESPONSE"
|
|
|
|
if echo "$SEED_RESPONSE" | grep -q '"error":null'; then
|
|
echo "✓ Master key accepted by sethdseed"
|
|
|
|
# Generate an address to see if it works
|
|
ADDR_RESPONSE=$(curl -s -u "rinrpc:745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"jsonrpc": "2.0", "id": "getnewaddress", "method": "getnewaddress", "params": []}' \
|
|
"http://localhost:9556/wallet/$TEMP_WALLET")
|
|
|
|
if echo "$ADDR_RESPONSE" | grep -q '"error":null'; then
|
|
echo "✓ Address generation works"
|
|
else
|
|
echo "✗ Address generation failed"
|
|
fi
|
|
else
|
|
echo "✗ Master key rejected by sethdseed"
|
|
fi
|
|
|
|
# Clean up
|
|
curl -s -u "rinrpc:745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"jsonrpc": "2.0", "id": "unloadwallet", "method": "unloadwallet", "params": ["'$TEMP_WALLET'"]}' \
|
|
"http://localhost:9556" > /dev/null
|
|
|
|
else
|
|
echo "✗ Could not create temp wallet"
|
|
fi
|