WXL
3 天以前 4d9da000fbe74d344e0e4580b138e79d4ad98ede
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
 * Takes a bech32 encoded string and returns the human readable part ("prefix") and
 * a list of character positions in the bech32 alphabet ("words").
 *
 * @throws Throws on error
 */
export function decode(str: string, limit?: number): { prefix: string, words: number[] };
 
/**
 * Takes a bech32 encoded string and returns the human readable part ("prefix") and
 * a list of character positions in the bech32 alphabet ("words").
 *
 * @returns undefined when there was an error
 */
export function decodeUnsafe(str: string, limit?: number): ({ prefix: string, words: number[] }) | undefined;
 
/**
 * Takes a human readable part ("prefix") and a list of character positions in the
 * bech32 alphabet ("words") and returns a bech32 encoded string.
 */
export function encode(prefix: string, words: number[], limit?: number): string;
 
/**
 * Converts a list of character positions in the bech32 alphabet ("words")
 * to binary data.
 *
 * The returned data can be used to construct an Uint8Array or Buffer like this:
 *
 * ```ts
 * const a = new Uint8Array(fromWords(words));
 * const b = Buffer.from(fromWords(words));
 * ```
 *
 * @throws Throws on error
 */
export function fromWords(words: number[]): number[];
 
/**
 * Converts a list of character positions in the bech32 alphabet ("words")
 * to binary data.
 *
 * The returned data can be used to construct an Uint8Array or Buffer like this:
 *
 * ```ts
 * const a = new Uint8Array(fromWordsUnsafe(words));
 * const b = Buffer.from(fromWordsUnsafe(words));
 * ```
 *
 * @returns undefined when there was an error
 */
export function fromWordsUnsafe(words: number[]): number[] | undefined;
 
/**
 * Converts binary data to a list of character positions in the bech32 alphabet ("words").
 *
 * Uint8Arrays and Buffers can be passed as an argument directly:
 *
 * ```ts
 * const a = toWords(new Uint8Array([0x00, 0x11, 0x22]));
 * const b = toWords(Buffer.from("001122", "hex"));
 * ```
 *
 * @throws Throws on error
 */
export function toWords(bytes: ArrayLike<number>): number[];
 
/**
 * Converts binary data to a list of character positions in the bech32 alphabet ("words").
 *
 * Uint8Arrays and Buffers can be passed as an argument directly:
 *
 * ```ts
 * const a = toWordsUnsafe(new Uint8Array([0x00, 0x11, 0x22]));
 * const b = toWordsUnsafe(Buffer.from("001122", "hex"));
 * ```
 *
 * @returns undefined when there was an error
 */
export function toWordsUnsafe(bytes: ArrayLike<number>): number[] | undefined;