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

Function bech32Encode

src/utils/transform.ts:91–103  ·  view source on GitHub ↗
(prefix: string, words: number[])

Source from the content-addressed store, hash-verified

89}
90
91function bech32Encode(prefix: string, words: number[]): string {
92 prefix = prefix.toLowerCase()
93 let chk = bech32PrefixChk(prefix)
94 let result = prefix + '1'
95 for (const w of words) {
96 chk = bech32PolymodStep(chk) ^ w
97 result += BECH32_ALPHABET[w]
98 }
99 for (let i = 0; i < 6; ++i) { chk = bech32PolymodStep(chk) }
100 chk ^= 1
101 for (let i = 0; i < 6; ++i) { result += BECH32_ALPHABET[(chk >> ((5 - i) * 5)) & 0x1f] }
102 return result
103}
104
105export const toJSON = (input: any) => JSON.stringify(input)
106

Callers 1

toBech32Function · 0.85

Calls 2

bech32PrefixChkFunction · 0.85
bech32PolymodStepFunction · 0.85

Tested by

no test coverage detected