Class: KeyRing

primitives.KeyRing(optionsopt, nullable)

Key Ring Represents a key ring which amounts to an address.

Constructor

new KeyRing(optionsopt, nullable)

Create a key ring.

Parameters:
Name Type Attributes Description
options Object <optional>
<nullable>
Source:

Members

(nullable) _keyAddress :Address

Type:
  • Address
Source:

(nullable) _keyHash :Hash

Type:
Source:

(nullable) _scriptAddress :Address

Type:
  • Address
Source:

(nullable) _scriptHash :Hash

Type:
Source:

(nullable) privateKey :Buffer

Type:
  • Buffer
Source:

(nullable) script :Script

Type:
  • Script
Source:

Methods

(static) fromKey(key) → {KeyRing}

Instantiate keyring from a public key.

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

(static) fromPrivate(key) → {KeyRing}

Instantiate keyring from a private key.

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

(static) fromPublic(publicKey) → {KeyRing}

Instantiate keyring from a public key.

Parameters:
Name Type Description
publicKey Buffer
Source:
Returns:
Type
KeyRing

(static) fromScript(key, script) → {KeyRing}

Instantiate keyring from script.

Parameters:
Name Type Description
key Buffer
script Script
Source:
Returns:
Type
KeyRing

(static) fromSecret(data, networknullable) → {KeyRing}

Instantiate a keyring from a serialized secret.

Parameters:
Name Type Attributes Description
data Base58String
network Network | NetworkType <nullable>
Source:
Returns:
Type
KeyRing

(static) generate() → {KeyRing}

Generate a keyring.

Source:
Returns:
Type
KeyRing

(static) isKeyRing(obj) → {Boolean}

Test whether an object is a KeyRing.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

format() → {Object}

Inspect keyring.

Source:
Returns:
Type
Object

fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

fromKey(key)

Inject data from public key.

Parameters:
Name Type Description
key Buffer
Source:

fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

fromPrivate(key)

Inject data from private key.

Parameters:
Name Type Description
key Buffer
Source:

fromPublic(key)

Inject data from public key.

Parameters:
Name Type Description
key Buffer
Source:

(private) fromScript(key, script)

Inject data from script.

Parameters:
Name Type Description
key Buffer
script Script
Source:

fromSecret(data, networkopt, nullable)

Inject properties from serialized secret.

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

generate() → {KeyRing}

Generate a keyring.

Source:
Returns:
Type
KeyRing

getAddress() → {Address}

Get base58 address.

Source:
Returns:
Type
Address

getHash() → {Buffer}

Get hash.

Source:
Returns:
Type
Buffer

getJSON(networkopt, nullable) → {Object}

Convert an KeyRing to a more json-friendly object.

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

getKeyAddress() → {Address}

Get pubkeyhash address.

Source:
Returns:
Type
Address

getKeyHash() → {Buffer}

Get public key hash.

Source:
Returns:
Type
Buffer

getPrivateKey() → {Buffer}

Get private key.

Source:
Returns:

Private key.

Type
Buffer

getPublicKey() → {Buffer}

Get public key.

Source:
Returns:
Type
Buffer

getRedeem(hash) → {Script|null}

Test a hash against script hashes to find the correct redeem script, if any.

Parameters:
Name Type Description
hash Buffer
Source:
Returns:
Type
Script | null

getScript() → {Script}

Get redeem script.

Source:
Returns:
Type
Script

getScriptAddress() → {Address}

Get scripthash address.

Source:
Returns:
Type
Address

getScriptHash() → {Buffer}

Get scripthash.

Source:
Returns:
Type
Buffer

getSecretSize() → {Number}

Calculate WIF serialization size.

Source:
Returns:
Type
Number

getSize() → {Number}

Calculate serialization size.

Source:
Returns:
Type
Number

getVersion() → {Number}

Get witness program version.

Source:
Returns:
Type
Number

ownHash(hash) → {Boolean}

Test an address hash against hash and program hash.

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

ownOutput(tx, indexopt, nullable) → {Boolean}

Check whether transaction output belongs to this address.

Parameters:
Name Type Attributes Description
tx TX | Output

Transaction or Output.

index Number <optional>
<nullable>

Output index.

Source:
Returns:
Type
Boolean

read(br)

Inject properties from buffer reader.

Parameters:
Name Type Description
br bio.BufferReader
Source:

refresh()

Clear cached key/script hashes.

Source:

sign(msg) → {Buffer}

Sign a message.

Parameters:
Name Type Description
msg Buffer
Source:
Returns:

Signature in DER format.

Type
Buffer

toSecret(networknullable) → {Base58String}

Convert key to a secret.

Parameters:
Name Type Attributes Description
network Network | NetworkType <nullable>
Source:
Returns:
Type
Base58String

verify(msg, sig) → {Boolean}

Verify a message.

Parameters:
Name Type Description
msg Buffer
sig Buffer

Signature in DER format.

Source:
Returns:
Type
Boolean

write(bw) → {BufioWriter}

Write the keyring to a buffer writer.

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