本文整理汇总了TypeScript中bech32.decode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript decode函数的具体用法?TypeScript decode怎么用?TypeScript decode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fromBech32
export function fromBech32(address: string): Bech32Result {
const result = bech32.decode(address);
const data = bech32.fromWords(result.words.slice(1));
return {
version: result.words[0],
prefix: result.prefix,
data: Buffer.from(data),
};
}
示例2:
const _address = lazy.value(() => {
const result = bech32.decode(a.address);
const version = result.words.shift();
const data = bech32.fromWords(result.words);
return {
version,
prefix: result.prefix,
data: Buffer.from(data),
};
});
示例3:
import * as bech32 from 'bech32';
// Test decode
const testString = 'abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw';
const decoded = bech32.decode(testString);
// Test decode with limit
bech32.decode(testString, testString.length);
decoded.prefix;
decoded.words;
// Test convert from/to words
const words: Buffer = bech32.toWords(Buffer.from('foobar', 'utf8'));
bech32.fromWords(words);
// Test encode
const testPrefix = 'foo';
bech32.encode(testPrefix, words);
// Test encode with limit
bech32.encode(testPrefix, words, testPrefix.length + 7 + words.length);