How to use the bech32.encode 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 iotexproject / iotex-antenna / src / crypto / address.ts View on Github external
public string(): string {
    // @ts-ignore
    const grouped = bech32.toWords(this.payload);
    return bech32.encode(AddressV1.prefix(), grouped);
  }
github cjdelisle / PacketCrypt / js / btc2pkt.js View on Github external
/**
 * (C) Copyright 2019
 * Caleb James DeLisle
 *
 * SPDX-License-Identifier: (LGPL-2.1-only OR LGPL-3.0-only)
 */
const Bech32 = require('bech32');

const addr = process.argv.pop();
try {
    const b = Bech32.decode(addr);
    if (b.prefix === 'bc') {
        console.log(Bech32.encode('pkt', b.words));
    } else if (b.prefix === 'pkt') {
        console.log(Bech32.encode('bc', b.words));
    } else {
        console.log("I don't understand prefix: [" + b.prefix + "]");
    }
} catch (e) {
    console.log(e);
    console.log("Usage: ptc2pkt ");
    console.log("prints the equivilent pkt address");
}
github irisnet / irisnet-crypto / src / chains / cosmos / stake.js View on Github external
MsgBeginRedelegate.prototype.GetSignBytes = function () {
    let msg = {
        delegator_address: BECH32.encode(Config.cosmos.bech32.accAddr,this.DelegatorAddress),
        validator_src_address: BECH32.encode(Config.cosmos.bech32.valAddr,this.ValidatorSrcAddress),
        validator_dst_address: BECH32.encode(Config.cosmos.bech32.valAddr,this.ValidatorDstAddress),
        amount: this.Amount
    };
    let sortMsg = Utils.sortObjectKeys(msg);
    return Amino.MarshalJSON(this.type, sortMsg)
};
github forbole / big_dipper / imports / ui / ledger / ledger.js View on Github external
function bech32ify(address, prefix) {
    const words = bech32.toWords(address)
    return bech32.encode(prefix, words)
}
github bitcoinjs / bolt11 / payreq.js View on Github external
return (words) => ({
    tagCode: parseInt(tagCode),
    words: bech32.encode('unknown', words, Number.MAX_SAFE_INTEGER)
  })
}
github irisnet / irisnet-crypto / src / chains / cosmos / stake.js View on Github external
MsgDelegate.prototype.GetSignBytes = function () {
    let msg = {
        delegator_address: BECH32.encode(Config.cosmos.bech32.accAddr,this.DelegatorAddress),
        validator_address: BECH32.encode(Config.cosmos.bech32.valAddr,this.ValidatorAddress),
        amount: this.Amount
    };
    let sortMsg = Utils.sortObjectKeys(msg);
    return Amino.MarshalJSON(this.type, sortMsg)
};
github coreyphillips / rn-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 irisnet / irisnet-crypto / src / util / codec.js View on Github external
static toBech32(prefix, str) {
        let strByte = BECH32.toWords(Buffer.from(str, 'hex'));
        return BECH32.encode(prefix, strByte)
    }
github irisnet / irisnet-crypto / src / chains / cosmos / distribution.js View on Github external
MsgWithdrawDelegatorReward.prototype.GetDisplayContent = function (){
    let delegatorAddress = BECH32.encode(Config.cosmos.bech32.accAddr,this.DelegatorAddress);
    let validatorAddress = BECH32.encode(Config.cosmos.bech32.valAddr,this.ValidatorAddress);

    return {
        i18n_tx_type:"i18n_withdraw_delegation_reward",
        i18n_delegator_addr:delegatorAddress,
        i18n_validator_addr:validatorAddress,
    }
};
github bitcoinjs / bitcoinjs-lib / ts_src / payments / p2wsh.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', () => {

bech32

Bech32 encoding / decoding

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis