Constructor
new KeyRing(options)
Create a key ring.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Methods
(static) fromKey(publicKey) → {KeyRing}
Instantiate keyring from a public key.
Parameters:
Name | Type | Description |
---|---|---|
publicKey |
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(secret, networknullable) → {KeyRing}
Instantiate a keyring from a serialized secret.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
secret |
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
(private) fromJSON(json)
Inject properties from json object.
Parameters:
Name | Type | Description |
---|---|---|
json |
Object |
- Source:
(private) fromKey(privateKey)
Inject data from public key.
Parameters:
Name | Type | Description |
---|---|---|
privateKey |
Buffer |
- Source:
(private) fromOptions(options)
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
(private) fromPrivate(key)
Inject data from private key.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
(private) 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:
(private) fromSecret(secret, networknullable)
Inject properties from serialized secret.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
secret |
Base58String | ||
network |
Network | NetworkType |
<nullable> |
- Source:
(private) 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() → {Object}
Convert an KeyRing to a more json-friendly object.
- 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, indexnullable) → {Boolean}
Check whether transaction output belongs to this address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tx |
TX | Output | Transaction or Output. |
|
index |
Number |
<nullable> |
Output index. |
- Source:
Returns:
- Type
- Boolean
(private) read(br)
Inject properties from buffer reader.
Parameters:
Name | Type | Description |
---|---|---|
br |
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)
Write the keyring to a buffer writer.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufferWriter |
- Source: