Class: Address

primitives.Address(optionsnullable)

Address Represents an address.

Constructor

new Address(optionsnullable)

Create an address.

Parameters:
Name Type Attributes Description
options Object <nullable>
Properties:
Name Type Description
version Number
hash Buffer
Source:

Methods

(static) fromHash(hash, versionopt) → {Address}

Create a naked address from hash/version.

Parameters:
Name Type Attributes Default Description
hash Hash
version Number <optional>
-1
Source:
Throws:

on bad hash size

Returns:
Type
Address

(static) fromNulldata(data) → {Address}

Instantiate address from nulldata.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Address

(static) fromProgram(version, hash) → {Address}

Instantiate address from witness program.

Parameters:
Name Type Description
version Number
hash Buffer
Source:
Returns:
Type
Address

(static) fromPubkey(key) → {Address}

Instantiate address from pubkey.

Parameters:
Name Type Description
key Buffer
Source:
Returns:
Type
Address

(static) fromPubkeyhash(hash) → {Address}

Instantiate address from witness pubkeyhash.

Parameters:
Name Type Description
hash Buffer
Source:
Returns:
Type
Address

(static) fromScript(script) → {Address}

Instantiate address from script.

Parameters:
Name Type Description
script Script
Source:
Returns:
Type
Address

(static) fromScripthash(hash) → {Address}

Instantiate address from witness scripthash.

Parameters:
Name Type Description
hash Buffer
Source:
Returns:
Type
Address

(static) fromWitness(witness) → {Address|null}

Create an Address from a witness. Attempt to extract address properties from a witness.

Parameters:
Name Type Description
witness Witness
Source:
Returns:
Type
Address | null

(static) getHash(data, networknullable) → {Hash}

Get the hash of a base58 address or address-related object.

Parameters:
Name Type Attributes Description
data String | Address | Hash
network Network <nullable>
Source:
Returns:
Type
Hash

clone() → {Address}

Clone address.

Source:
Returns:
Type
Address

compare(addr) → {Boolean}

Compare against another address.

Parameters:
Name Type Description
addr Address
Source:
Returns:
Type
Boolean

equals(addr) → {Boolean}

Test equality against another address.

Parameters:
Name Type Description
addr Address
Source:
Returns:
Type
Boolean

format() → {Object}

Inspect the Address.

Source:
Returns:
Type
Object

(private) fromHash(hash, versionopt)

Inject properties from a hash.

Parameters:
Name Type Attributes Default Description
hash Buffer | Hash
version Number <optional>
-1
Source:
Throws:

on bad hash size

fromNulldata(data) → {Address}

Instantiate address from nulldata.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Address

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(private) fromProgram(version, hash) → {Address}

Inject properties from witness program.

Parameters:
Name Type Description
version Number
hash Buffer
Source:
Returns:
Type
Address

fromPubkey(key) → {Address}

Instantiate address from pubkey.

Parameters:
Name Type Description
key Buffer
Source:
Returns:
Type
Address

(private) fromPubkeyhash(hash) → {Address}

Inject properties from witness pubkeyhash.

Parameters:
Name Type Description
hash Buffer
Source:
Returns:
Type
Address

fromScript(script) → {Address}

Instantiate address from script.

Parameters:
Name Type Description
script Script
Source:
Returns:
Type
Address

(private) fromScripthash(hash) → {Address}

Inject properties from witness scripthash.

Parameters:
Name Type Description
hash Buffer
Source:
Returns:
Type
Address

(private) fromString(data, networknullable)

Inject properties from bech32 address.

Parameters:
Name Type Attributes Description
data String
network Network <nullable>
Source:
Throws:

Parse error

(private) fromWitness(witness)

Inject properties from witness.

Parameters:
Name Type Description
witness Witness
Source:

getHash() → {Hash}

Get the address hash.

Source:
Returns:
Type
Hash

getSigops(witness) → {Number}

Count the sigops in a script, taking into account witness programs.

Parameters:
Name Type Description
witness Witness
Source:
Returns:

sigop count

Type
Number

getSize() → {Number}

Calculate address size.

Source:
Returns:
Type
Number

inject(addr) → {Boolean}

Inject properties from another address.

Parameters:
Name Type Description
addr Address
Source:
Returns:
Type
Boolean

isNull() → {Boolean}

Test whether the address is null.

Source:
Returns:
Type
Boolean

isNulldata() → {Boolean}

Test whether the address is unspendable.

Source:
Returns:
Type
Boolean

isPubkeyhash() → {Boolean}

Test whether the address is witness pubkeyhash.

Source:
Returns:
Type
Boolean

isScripthash() → {Boolean}

Test whether the address is witness scripthash.

Source:
Returns:
Type
Boolean

isUnknown() → {Boolean}

Test whether the address is an unknown witness program.

Source:
Returns:
Type
Boolean

isUnspendable() → {Boolean}

Test whether the address is unspendable.

Source:
Returns:
Type
Boolean

isValid() → {Boolean}

Test address validity.

Source:
Returns:
Type
Boolean

read(br) → {Address}

Read address from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:
Returns:
Type
Address

toString({{NetworkType|Network)?}) → {String}

Compile the address object to a bech32 address.

Parameters:
Name Type Description
{{NetworkType|Network)?}

network

Source:
Throws:

Error on bad hash/prefix.

Returns:
Type
String

write(bw) → {BufferWriter}

Write address to buffer writer.

Parameters:
Name Type Description
bw BufferWriter
Source:
Returns:
Type
BufferWriter