MCPcopy Create free account
hub / github.com/cameri/nostream / bech32PrefixChk

Function bech32PrefixChk

src/utils/transform.ts:35–46  ·  view source on GitHub ↗
(prefix: string)

Source from the content-addressed store, hash-verified

33}
34
35function bech32PrefixChk(prefix: string): number {
36 let chk = 1
37 for (let i = 0; i < prefix.length; ++i) {
38 const c = prefix.charCodeAt(i)
39 chk = bech32PolymodStep(chk) ^ (c >> 5)
40 }
41 chk = bech32PolymodStep(chk)
42 for (let i = 0; i < prefix.length; ++i) {
43 chk = bech32PolymodStep(chk) ^ (prefix.charCodeAt(i) & 0x1f)
44 }
45 return chk
46}
47
48function bech32Convert(data: number[], inBits: number, outBits: number, pad: boolean): number[] {
49 let value = 0, bits = 0

Callers 2

bech32DecodeFunction · 0.85
bech32EncodeFunction · 0.85

Calls 1

bech32PolymodStepFunction · 0.85

Tested by

no test coverage detected