How to use the bech32.toWords function in bech32

To help you get started, we’ve selected a few bech32 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github forbole / big_dipper / imports / startup / server / util.js View on Github external
pubkeyToBech32: function(pubkey, prefix) {
        // '1624DE6420' is ed25519 pubkey prefix
        let pubkeyAminoPrefix = Buffer.from('1624DE6420', 'hex')
        let buffer = Buffer.alloc(37)
        pubkeyAminoPrefix.copy(buffer, 0)
        Buffer.from(pubkey.value, 'base64').copy(buffer, pubkeyAminoPrefix.length)
        return bech32.encode(prefix, bech32.toWords(buffer))
    },
    bech32ToPubkey: function(pubkey) {
github irisnet / irisnet-crypto / util / bech32.js View on Github external
static toBech32(prefix, str) {
        let strByte = BECH32.toWords(Buffer.from(str, 'hex'))
        return BECH32.encode(prefix, strByte)
    }
}
github andrerfneves / lightning-decoder / src / lib / bolt11.js View on Github external
function hexToWord (hex) {
  let buffer = hexToBuffer(hex)
  return bech32.toWords(buffer)
}
github coreyphillips / rn-bitcoinjs-lib / src / payments / p2wpkh.js View on Github external
lazy.prop(o, 'address', () => {
    if (!o.hash) return;
    const words = bech32.toWords(o.hash);
    words.unshift(0x00);
    return bech32.encode(network.bech32, words);
  });
  lazy.prop(o, 'hash', () => {
github bitcoinjs / bolt11 / payreq.js View on Github external
function purposeCommitEncoder (data) {
  let buffer
  if (data !== undefined && (typeof data === 'string' || data instanceof String)) {
    if (data.match(/^([a-zA-Z0-9]{2})*$/)) {
      buffer = Buffer.from(data, 'hex')
    } else {
      buffer = sha256(Buffer.from(data, 'utf8'))
    }
  } else {
    throw new Error('purpose or purpose commit must be a string or hex string')
  }
  return bech32.toWords(buffer)
}
github bitcoinjs / bolt11 / payreq.js View on Github external
function hexToWord (hex) {
  let buffer = hexToBuffer(hex)
  return bech32.toWords(buffer)
}
github forbole / big_dipper / imports / ui / magpie / magpie.js View on Github external
export function getBech32Address(hash, prefix='desmos') {
    if (!hash) return ''
    let address = Buffer.from(hash, `hex`)
    let words = bech32.toWords(address)
    return bech32.encode(prefix, words)
}
github bitcoinjs / bitcoinjs-lib / src / address.js View on Github external
function toBech32(data, version, prefix) {
    const words = bech32.toWords(data);
    words.unshift(version);
    return bech32.encode(prefix, words);
}
exports.toBech32 = toBech32;
github bitcoinjs / bitcoinjs-lib / ts_src / payments / p2wpkh.ts View on Github external
lazy.prop(o, 'address', () => {
    if (!o.hash) return;

    const words = bech32.toWords(o.hash);
    words.unshift(0x00);
    return bech32.encode(network.bech32, words);
  });
  lazy.prop(o, 'hash', () => {
github andrerfneves / lightning-decoder / src / lib / bolt11.js View on Github external
function purposeCommitEncoder (data) {
  let buffer
  if (data !== undefined && (typeof data === 'string' || data instanceof String)) {
    if (data.match(/^([a-zA-Z0-9]{2})*$/)) {
      buffer = Buffer.from(data, 'hex')
    } else {
      buffer = sha256(Buffer.from(data, 'utf8'))
    }
  } else {
    throw new Error('purpose or purpose commit must be a string or hex string')
  }
  return bech32.toWords(buffer)
}

bech32

Bech32 encoding / decoding

MIT
Latest version published 4 years ago

Package Health Score

73 / 100
Full package analysis