import type { KnownAddressTypeContents } from '@bitauth/libauth'; export type AddressType = 'P2PK' | 'P2PKH' | 'P2SH20' | 'P2SH32'; /** * Address Entity. */ export declare class Address { readonly addressContents: KnownAddressTypeContents; constructor(addressContents: KnownAddressTypeContents); /** * Decode a Cash Address or Legacy Address. * * @param address {string} The address to attempt to decode. * * @throws {Error} If address cannot be decoded. * * @returns {Address} Instance of Address. */ static from(address: string): Address; /** * Decode a CashAddr into an Address Entity. * * @param cashAddr The CashAddr to decode. * * @throws {Error} If address cannot be decoded. * * @returns {Address} Instance of Address. * * @example * const address = Address.fromCashAddr('bitcoincash:qpeqv9k9j3l7fepp9du24f9pr5jdu7c2mvn4wwldav') */ static fromCashAddr(cashAddr: string, tryPrefixes?: Array): Address; /** * Decode a Legacy Address into an Address Entity. * * @param legacyAddress The Legacy (Base58) Address to decode. * * @throws {Error} If address cannot be decoded. * * @returns {Address} Instance of Address. */ static fromLegacy(legacyAddress: string): Address; /** * Instantiate an address from Contract Bytecode. * * @param contractBytes The contract bytecode * * @throws {Error} If address cannot be instantiated from Contract Bytecode. * * @returns {Address} Instance of Address. */ static fromRedeemScript(contractBytes: Uint8Array, type?: 'P2SH20' | 'P2SH32'): Address; /** * Instantiate an address from Contract Bytecode as a hex string. * * @param hex The contract bytecode as hex * * @throws {Error} If address cannot be instantiated from Contract Bytecode. * * @returns {Address} Instance of Address. */ static fromRedeemScriptHex(hex: string, type?: 'P2SH20' | 'P2SH32'): Address; /** * Attempt to instantiate Address from Locking Bytecode. * * @param lockScript {Uint8Array} The lockscript bytes. * * @throws {Error} If lock script cannot be decoded into an address. * * @returns {Address} Instance of Address. */ static fromLockscriptBytes(lockScript: Uint8Array): Address; /** * Attempt to instantiate Address from Locking Bytecode as a hex string. * * @param hex {Uint8Array} The lockscript bytes as hex. * * @throws {Error} If lock script cannot be decoded into an address. * * @returns {Address} Instance of Address. */ static fromLockscriptHex(hex: string): Address; /** * Instantiate an address from a Ripemd160 hash. * * @param hash160 {Uint8Array} The hash to use. * @param type {AddressType} The type of the address to instantiate (e.g. P2PKH). * * @throws {Error} If hash160 is not 20 bytes. * * @returns {Address} Instance of Address. */ static fromHash160(hash160: Uint8Array, type?: AddressType): Address; /** * Instantiate an address from a Ripemd160 hash (as hex). * * @param hash160Hex {string} The hash to use (as hex). * @param type {AddressType} The type of the address to instantiate (e.g. P2PKH). * * @throws {Error} If hash160 is not 20 bytes. * * @returns {Address} Instance of Address. */ static fromHash160Hex(hash160Hex: string, type?: AddressType): Address; static fromRaw(addressContents: KnownAddressTypeContents): Address; static isValid(address: string): boolean; static isValidLegacy(address: string): boolean; static isValidCashAddr(address: string): boolean; /** * Gets the type of address (P2PKH, P2SH). * * @returns {AddressType} The type of Address. */ type(): AddressType; /** * Gets this address' raw Hash160 (Ripemd160) hash as a Uint8Array. * * @returns {Uint8Array} The Hash160 of this address. */ toHash160Bytes(): Uint8Array; /** * Gets this address' raw Hash160 (Ripemd16) hash as a hex string. * * @returns {Uint8Array} The Hash160 of this address. */ toHash160Hex(): string; /** * Converts this address to CashAddr format. * * @param networkPrefix {'bitcoincash' | 'bchtest' | 'bchreg'} The Cash Address Network prefix. * * @throws {Error} If address cannot be encoded as a CashAddr. * * @returns {string} The address in CashAddr format. */ toCashAddr(networkPrefix?: 'bitcoincash' | 'bchtest' | 'bchreg'): string; /** * Converts this address to a Tokens Address format. * * @param networkPrefix {'bitcoincash' | 'bchtest' | 'bchreg'} The Cash Address Network prefix. * * @throws {Error} If address cannot be encoded as a CashAddr. * * @returns {string} The address in Token Address format. */ toTokenAddress(networkPrefix?: 'bitcoincash' | 'bchtest' | 'bchreg'): string; /** * Converts this address to Legacy (Base58) Address format. * * @throws {Error} If address cannot be encoded as a Legacy Address (Base58). * * @returns {string} The address in Legacy Address format. */ toLegacy(): string; /** * Get the corresponding lockscript for this address as a Uint8Array. * * @returns {Uint8Array} The lockscript as a Uint8Array. */ toLockscriptBytes(): Uint8Array; /** * Get the corresponding lockscript for this address as a hex string. * * @returns {Uint8Array} The lockscript as a hex string. */ toLockscriptHex(): string; /** * Get the corresponding lockscript for this address as ASM. * * @returns {Uint8Array} The lockscript as ASN. */ toLockscriptAsm(): string; toRaw(): { type: `${import("@bitauth/libauth").LockingBytecodeType}`; payload: Uint8Array; }; }