From 7f6e1b02a1c73d6b0f0b29e74d3cc8f33412cf3a Mon Sep 17 00:00:00 2001 From: void-57 Date: Fri, 12 Dec 2025 18:34:41 +0530 Subject: [PATCH] feat: Add Stellar secret key validation and improve error messages for invalid private key formats. --- index.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 89f1ac9..1ff1afc 100644 --- a/index.html +++ b/index.html @@ -806,13 +806,16 @@ const hexOnly = /^[0-9a-fA-F]+$/.test(privateKey); const isHexKey = hexOnly && (privateKey.length === 64 || privateKey.length === 128); const isWifKey = !hexOnly && !(/^[A-Z2-7]+$/.test(privateKey)) && privateKey.length >= 51 && privateKey.length <= 52; + const isStellarSecret = privateKey.startsWith('S') && privateKey.length === 56 && /^[A-Z2-7]+$/.test(privateKey); // Reject if it's not a valid private key format - if (!isHexKey && !isWifKey) { + if (!isHexKey && !isWifKey && !isStellarSecret) { if (/^[A-Z2-7]+$/.test(privateKey) && privateKey.length === 52) { showNotification('⚠️ This looks like a transaction ID, not a private key. Private keys cannot be recovered from transaction IDs.', 'error'); + } else if (privateKey.startsWith('G') && privateKey.length === 56) { + showNotification('⚠️ This is a Stellar public address, not a secret key. Please enter the secret key (starts with S).', 'error'); } else { - showNotification('⚠️ Invalid private key format. Please enter a valid private key', 'error'); + showNotification('⚠️ Invalid private key format. Please enter a valid private key (hex, WIF, or Stellar secret key starting with S)', 'error'); } return; }