MCPcopy
hub / github.com/BlueWallet/BlueWallet / hexToUint8Array

Function hexToUint8Array

blue_modules/uint8array-extras/index.js:230–252  ·  view source on GitHub ↗
(hexString)

Source from the content-addressed store, hash-verified

228};
229
230export function hexToUint8Array(hexString) {
231 assertString(hexString);
232
233 if (hexString.length % 2 !== 0) {
234 throw new Error('Invalid Hex string length.');
235 }
236
237 const resultLength = hexString.length / 2;
238 const bytes = new Uint8Array(resultLength);
239
240 for (let index = 0; index < resultLength; index++) {
241 const highNibble = hexToDecimalLookupTable[hexString[index * 2]];
242 const lowNibble = hexToDecimalLookupTable[hexString[index * 2 + 1]];
243
244 if (highNibble === undefined || lowNibble === undefined) {
245 throw new Error(`Invalid Hex character encountered at position ${index * 2}`);
246 }
247
248 bytes[index] = (highNibble << 4) | lowNibble; // eslint-disable-line no-bitwise
249 }
250
251 return bytes;
252}
253
254/**
255@param {DataView} view

Callers 15

SelfTestClass · 0.90
_onReadUniformResourceFunction · 0.90
onBarCodeReadFunction · 0.90
WalletsAddFunction · 0.90
cosign.test.tsFile · 0.90
openRealmKeyValueMethod · 0.90
authenticateMethod · 0.90
getXpubMethod · 0.90

Calls 1

assertStringFunction · 0.85

Tested by

no test coverage detected