diff --git a/index.html b/index.html
index 7ae713e..6291802 100644
--- a/index.html
+++ b/index.html
@@ -275,6 +275,29 @@
+
+
@@ -2784,8 +2807,13 @@
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)
+ activeChain = await new Promise(resolve => {
+ _blockchainResolve = resolve;
+ openPopup('ton_algo_select_popup');
+ });
+ if (!activeChain) return;
+
+ // Convert 128-char 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();
@@ -2810,7 +2838,13 @@
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') || privateKey.startsWith('5')) {
+ activeChain = await new Promise(resolve => {
+ _blockchainResolve = resolve;
+ openPopup('btc_bch_select_popup');
+ });
+ if (!activeChain) return;
+ }
else if (privateKey.startsWith('S') && privateKey.length === 56) activeChain = 'XLM';
else if (privateKey.startsWith('R')) activeChain = 'FLO';
else activeChain = 'UNKNOWN';
diff --git a/scripts/floCloudAPI.js b/scripts/floCloudAPI.js
index d484695..8482453 100644
--- a/scripts/floCloudAPI.js
+++ b/scripts/floCloudAPI.js
@@ -406,8 +406,8 @@
hash[0] != checksum[0] || hash[1] != checksum[1] || hash[2] != checksum[2] || hash[3] != checksum[3] ?
bytes = undefined : bytes.shift();
}
- // BTC/LTC Bech32 encoding (42 or 62 chars, not starting with 0x)
- else if (!address.startsWith("0x") && (address.length == 42 || address.length == 62) && !address.startsWith("addr1")) {
+ // BTC/LTC Bech32 encoding (bc1 or ltc1 prefix)
+ else if (/^(bc1|ltc1)[a-zA-HJ-NP-Z0-9]{25,62}$/.test(address)) {
if (typeof coinjs !== 'function')
throw "library missing (lib_btc.js)";
let decode = coinjs.bech32_decode(address);
diff --git a/scripts/floCrypto.js b/scripts/floCrypto.js
index 97a0485..8d23c28 100644
--- a/scripts/floCrypto.js
+++ b/scripts/floCrypto.js
@@ -299,7 +299,7 @@
return true;
else
return false;
- } else if (raw.type === 'ethereum') {
+ } else if (raw.type === 'ethereum' || raw.type === 'bch') {
return true
} else //unknown
return false;
@@ -439,6 +439,22 @@
type: 'ethereum',
bytes
}
+ } else if (address.length >= 34 && address.length <= 45 && /^q[a-z0-9]+$/.test(address)) { //BCH Address
+ try {
+ let addrBytes = [];
+ for (let i = 0; i < address.length; i++) {
+ addrBytes.push(address.charCodeAt(i));
+ }
+ let payload = ripemd160(Crypto.SHA256(addrBytes, { asBytes: true }));
+ return {
+ version: 1,
+ hex: Crypto.util.bytesToHex(payload),
+ type: 'bch',
+ bytes: payload
+ }
+ } catch (e) {
+ return null;
+ }
}
}
diff --git a/scripts/messenger.js b/scripts/messenger.js
index 262fb48..4b1d5a7 100644
--- a/scripts/messenger.js
+++ b/scripts/messenger.js
@@ -606,7 +606,7 @@
return new Promise(async (resolve, reject) => {
// All blockchain address IDs to listen on
let activeChain = localStorage.getItem(`${floGlobals.application}#activeChain`);
- const blockchainAddressIDs = [user.id]; // Always listen to FLO address (primary)
+ const blockchainAddressIDs = [floGlobals.myFloID || user.id]; // Always listen to FLO address (primary)
if (!activeChain) {
try {