File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 33// Accepts empty string because empty byte arrays are valid in Bitcoin.
44const PURE_HEX_REGEX = / ^ [ 0 - 9 a - f A - F ] * $ /
55
6- export function assertValidHex ( msg : string ) : void {
6+ export function assertValidHex ( msg : string ) : void {
77 if ( typeof msg !== 'string' ) {
8- console . error ( " assertValidHex FAIL (non-string):" , msg )
8+ console . error ( ' assertValidHex FAIL (non-string):' , msg )
99 throw new Error ( 'Invalid hex string' )
1010 }
1111
1212 // allow empty
1313 if ( msg . length === 0 ) return
1414
1515 if ( ! PURE_HEX_REGEX . test ( msg ) ) {
16- console . error ( " assertValidHex FAIL (bad hex):" , msg )
16+ console . error ( ' assertValidHex FAIL (bad hex):' , msg )
1717 throw new Error ( 'Invalid hex string' )
1818 }
1919}
2020
21- export function normalizeHex ( msg : string ) : string {
22- assertValidHex ( msg ) ;
21+ export function normalizeHex ( msg : string ) : string {
22+ assertValidHex ( msg )
2323
2424 // If empty, return empty — never force to "00"
2525 if ( msg . length === 0 ) return ''
Original file line number Diff line number Diff line change 11import BigNumber from './BigNumber.js'
22import { hash256 } from './Hash.js'
3- import { assertValidHex , normalizeHex } from './hex.js'
3+ import { assertValidHex } from './hex.js'
44
55const BufferCtor =
66 typeof globalThis !== 'undefined' ? ( globalThis as any ) . Buffer : undefined
77const CAN_USE_BUFFER =
88 BufferCtor != null && typeof BufferCtor . from === 'function'
9- const PURE_HEX_REGEX = / ^ [ 0 - 9 a - f A - F ] + $ /
109
1110/**
1211 * Prepends a '0' to an odd character length word to ensure it has an even number of characters.
@@ -232,7 +231,7 @@ export const toUTF8 = (arr: number[]): string => {
232231 result += String . fromCharCode ( byte1 )
233232 continue
234233 }
235- const emitReplacement = ( ) => {
234+ const emitReplacement = ( ) : void => {
236235 result += replacementChar
237236 }
238237 if ( byte1 >= 0xc0 && byte1 <= 0xdf ) {
You can’t perform that action at this time.
0 commit comments