Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/cashMethods.js
Show First 20 Lines • Show All 1,137 Lines • ▼ Show 20 Lines | return ( | ||||
ws && | ws && | ||||
'_ws' in ws && | '_ws' in ws && | ||||
'readyState' in ws._ws && | 'readyState' in ws._ws && | ||||
ws._ws.readyState === 1 && | ws._ws.readyState === 1 && | ||||
'_subs' in ws && | '_subs' in ws && | ||||
ws._subs.length > 0 | ws._subs.length > 0 | ||||
); | ); | ||||
}; | }; | ||||
export const hash160ToAddress = hash160 => { | |||||
const buffer = Buffer.from(hash160, 'hex'); | |||||
// Because ecashaddrjs only accepts Uint8Array as input type, convert | |||||
const hash160ArrayBuffer = new ArrayBuffer(buffer.length); | |||||
const hash160Uint8Array = new Uint8Array(hash160ArrayBuffer); | |||||
for (let i = 0; i < hash160Uint8Array.length; i += 1) { | |||||
hash160Uint8Array[i] = buffer[i]; | |||||
} | |||||
// Encode ecash: address | |||||
const ecashAddr = cashaddr.encode('ecash', 'P2PKH', hash160Uint8Array); | |||||
return ecashAddr; | |||||
}; |