Due to the high likelihood of runtime errors in a variety of use cases (e.g.
attempting to convert P2PK or arbitrary data outputs to CashAddresses for
display in a transaction viewer or block explorer), this function returns
encoding errors in a type-safe way (as a string) rather than via thrown
Error objects.
For applications in which the input to lockingBytecodeToCashAddress is
trusted (e.g. the application is encoding an address for self-generated
locking bytecode), consider using assertSuccess to simplify error handling:
Encode a locking bytecode as a CashAddress.
If
bytecodematches a standard pattern, it is encoded using the proper address type and returned as a CashAddressResult.If
bytecodecannot be encoded as an address (i.e. because the pattern is not standard), an error message is returned as astring.For the reverse, see cashAddressToLockingBytecode.
Due to the high likelihood of runtime errors in a variety of use cases (e.g. attempting to convert P2PK or arbitrary data outputs to CashAddresses for display in a transaction viewer or block explorer), this function returns encoding errors in a type-safe way (as a
string) rather than via thrownErrorobjects.For applications in which the input to
lockingBytecodeToCashAddressis trusted (e.g. the application is encoding an address for self-generated locking bytecode), consider usingassertSuccessto simplify error handling: