From ae643c4f9393fb3d13fa6ff0ad13894559ba9659 Mon Sep 17 00:00:00 2001 From: void-57 Date: Mon, 23 Feb 2026 02:08:26 +0530 Subject: [PATCH] feat: Add Hedera (HBAR) blockchain support and enhance private key validation and processing for hex and WIF formats, including TON. --- index.html | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index d87b3b5..5d86372 100644 --- a/index.html +++ b/index.html @@ -263,6 +263,7 @@ +
@@ -2723,9 +2724,16 @@ getRef('private_key_field').setAttribute('placeholder', 'Enter Blockchain Private Key'); getRef('private_key_field').customValidation = (value) => { if (!value) return { isValid: false, errorText: 'Please enter a private key' } + let isValid = false; + let checkVal = value.startsWith('0x') ? value.substring(2) : value; + if (/^[0-9a-fA-F]{64}$/.test(checkVal) || /^[0-9a-fA-F]{128}$/.test(checkVal)) { + isValid = true; + } else { + try { isValid = !!floCrypto.getPubKeyHex(value); } catch (e) { } + } return { - isValid: floCrypto.getPubKeyHex(value), - errorText: `Invalid private key.
It's a long string of random characters usually starting with 'R'.` + isValid, + errorText: `Invalid private key.
Please enter a valid WIF or Hex string.` } }; } @@ -2734,9 +2742,12 @@ } getRef('sign_in_button').onclick = async () => { let privateKey = getRef('private_key_field').value.trim(); + // For users who prefix their hex keys with 0x + if (privateKey.startsWith('0x')) privateKey = privateKey.substring(2); + let activeChain = null; - if (/^[0-9a-fA-F]{64}$/.test(privateKey)) { //if hex private key might be ethereum, ADA, SOL, TRON, DOT + if (/^[0-9a-fA-F]{64}$/.test(privateKey)) { //if hex private key might be ethereum, ADA, SOL, TRON, DOT, HBAR activeChain = await new Promise(resolve => { _blockchainResolve = resolve; openPopup('blockchain_select_popup'); @@ -2748,12 +2759,18 @@ let key = new Bitcoin.ECKey(privateKey); key.setCompressed(true); privateKey = key.getBitcoinWalletImportFormat(); + } else if (/^[0-9a-fA-F]{128}$/.test(privateKey)) { + activeChain = 'TON'; + // Convert 128-char TON ed25519 key to workable FLO WIF using the first 32-bytes (seed) + let key = new Bitcoin.ECKey(privateKey.substring(0, 64)); + key.setCompressed(true); + privateKey = key.getBitcoinWalletImportFormat(); } else { if (privateKey.startsWith('suiprivkey1')) activeChain = 'SUI'; else if (privateKey.startsWith('s')) activeChain = 'XRP'; else if (privateKey.startsWith('Q')) activeChain = 'DOGE'; else if (privateKey.startsWith('T') && privateKey.length === 51) activeChain = 'LTC'; - else if (privateKey.startsWith('K') || privateKey.startsWith('L') ) activeChain = 'BTC'; + else if (privateKey.startsWith('K') || privateKey.startsWith('L')) activeChain = 'BTC'; else if (privateKey.startsWith('S') && privateKey.length === 56) activeChain = 'XLM'; else if (privateKey.startsWith('R')) activeChain = 'FLO'; else activeChain = 'UNKNOWN';