Function encodeCashAddress

  • Encode a payload as a CashAddress.

    Note: this function cannot prevent all implementation errors via types. The function will throw if payload is not a valid CashAddressSupportedLength. Confirm the length of untrusted inputs before providing them to this function.

    To encode a CashAddress with a custom/unknown prefix or type bit, see encodeCashAddressNonStandard. For other address standards that closely follow the CashAddress specification (but have alternative version byte requirements), use encodeCashAddressFormat.

    Parameters

    • prefix: "bitcoincash" | "bchtest" | "bchreg"

      the network for which to encode the address (a CashAddressNetworkPrefix)

    • type: "p2pkh" | "p2sh" | "p2pkhWithTokens" | "p2shWithTokens"

      the address type (a CashAddressType)

    • payload: Uint8Array

      the payload to encode – for P2PKH, the public key hash; for P2SH, the redeem bytecode hash

    Returns string

Generated using TypeDoc