Class: Address

primitives.Address(optionsopt, networkopt, nullable)

Address Represents an address.

Constructor

new Address(optionsopt, networkopt, nullable)

Create an address.

Parameters:
Name Type Attributes Description
options AddressOptions | String <optional>
network NetworkType | Network <optional>
<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>
0
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) → {Hash}

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

Parameters:
Name Type Description
data Address | Hash
Source:
Returns:
Type
Hash

clone() → {this}

Clone address.

Source:
Returns:
Type
this

compare(addr) → {Number}

Compare against another address.

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

equals(addr) → {Boolean}

Test equality against another address.

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

format() → {String}

Inspect the Address.

Source:
Returns:
Type
String

fromHash(hash, versionopt)

Inject properties from a hash.

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

on bad hash size

fromNulldata(data) → {Address}

Instantiate address from nulldata.

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

fromOptions(options, networkopt, nullable)

Inject properties from options object.

Parameters:
Name Type Attributes Description
options AddressOptions | String
network NetworkType | Network <optional>
<nullable>
Source:

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

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

fromScripthash(hash) → {Address}

Inject properties from witness scripthash.

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

fromString(data, networkopt, nullable)

Inject properties from bech32 address.

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

Parse error

fromWitness(witness) → {Address|null}

Inject properties from witness.

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

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) → {this}

Inject properties from another address.

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

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) → {this}

Read address from buffer reader.

Parameters:
Name Type Description
br bio.BufferReader
Source:
Returns:
Type
this

toString(networkopt, nullable) → {String}

Compile the address object to a bech32 address.

Parameters:
Name Type Attributes Description
network NetworkType | Network <optional>
<nullable>
Source:
Throws:

Error on bad hash/prefix.

Returns:
Type
String

write(bw) → {BufioWriter}

Write address to buffer writer.

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