Constructor
new KeyRing(options)
Create a key ring.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Methods
(static) fromJSON(json) → {KeyRing}
Instantiate an KeyRing from a jsonified transaction object.
Parameters:
Name | Type | Description |
---|---|---|
json |
Object | The jsonified transaction object. |
- Source:
Returns:
- Type
- KeyRing
(static) fromKey(publicKey, compressnullable) → {KeyRing}
Instantiate keyring from a public key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
publicKey |
Buffer | ||
compress |
Boolean |
<nullable> |
- Source:
Returns:
- Type
- KeyRing
(static) fromMultisigScript(script, i) → {KeyRing}
Instantiate keyring from ith key in multisig script.
Parameters:
Name | Type | Description |
---|---|---|
script |
Script | |
i |
Number |
- Source:
Returns:
- Type
- KeyRing
(static) fromOptions(options) → {KeyRing}
Instantiate key ring from options.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Returns:
- Type
- KeyRing
(static) fromPrivate(key, compressnullable) → {KeyRing}
Instantiate keyring from a private key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
Buffer | ||
compress |
Boolean |
<nullable> |
- 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) fromRaw(data) → {KeyRing}
Instantiate a keyring from serialized data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
Returns:
- Type
- KeyRing
(static) fromReader(br) → {KeyRing}
Instantiate a keyring from buffer reader.
Parameters:
Name | Type | Description |
---|---|---|
br |
BufferReader |
- Source:
Returns:
- Type
- KeyRing
(static) fromScript(key, script, compressnullable) → {KeyRing}
Instantiate keyring from script.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
Buffer | ||
script |
Script | ||
compress |
Boolean |
<nullable> |
- Source:
Returns:
- Type
- KeyRing
(static) fromSecret(secret, networknullable) → {KeyRing}
Instantiate a keyring from a serialized CBitcoinSecret.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
secret |
Base58String | ||
network |
Network | NetworkType |
<nullable> |
- Source:
Returns:
- Type
- KeyRing
(static) generate(compressnullable) → {KeyRing}
Generate a keyring.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
compress |
Boolean |
<nullable> |
- 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
(private) fromJSON(json)
Inject properties from json object.
Parameters:
Name | Type | Description |
---|---|---|
json |
Object |
- Source:
(private) fromKey(privateKey, compressnullable)
Inject data from public key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
privateKey |
Buffer | ||
compress |
Boolean |
<nullable> |
- Source:
(private) fromMultisigScript(script, i) → {KeyRing}
Get ith public key from multisig script.
Parameters:
Name | Type | Description |
---|---|---|
script |
Script | |
i |
Number |
- Source:
Returns:
- Type
- KeyRing
(private) fromOptions(options)
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
(private) fromPrivate(key, compressnullable)
Inject data from private key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
Buffer | ||
compress |
Boolean |
<nullable> |
- Source:
(private) fromPublic(key)
Inject data from public key.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
(private) fromRaw(data)
Inject properties from serialized data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
(private) fromReader(br)
Inject properties from buffer reader.
Parameters:
Name | Type | Description |
---|---|---|
br |
BufferReader |
- Source:
(private) fromScript(key, script, compressnullable)
Inject data from script.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
Buffer | ||
script |
Script | ||
compress |
Boolean |
<nullable> |
- Source:
(private) fromSecret(secret, networknullable)
Inject properties from serialized CBitcoinSecret.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
secret |
Base58String | ||
network |
Network | NetworkType |
<nullable> |
- Source:
(private) generate(compressnullable) → {KeyRing}
Generate a keyring.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
compress |
Boolean |
<nullable> |
- Source:
Returns:
- Type
- KeyRing
getAddress(encnullable) → {Address|AddressString}
Get base58 address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Address | AddressString
getHash(encnullable) → {Buffer}
Get hash.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getKeyAddress(encnullable) → {Address|AddressString}
Get pubkeyhash address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Address | AddressString
getKeyHash(encnullable) → {Buffer}
Get public key hash.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getNestedAddress(encnullable) → {Address|AddressString}
Get address' scripthash address for witness program.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Address | AddressString
getNestedHash(encnullable) → {Buffer}
Get address' ripemd160 program scripthash (for witness programs behind a scripthash).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getPrivateKey(encnullable) → {Buffer}
Get private key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
Can be |
- Source:
Returns:
Private key.
- Type
- Buffer
getProgram() → {Buffer}
Get witness program.
- Source:
Returns:
- Type
- Buffer
getPublicKey(encnullable) → {Buffer}
Get public key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- 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(encnullable) → {Address|AddressString}
Get scripthash address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Address | AddressString
getScriptHash(encnullable) → {Buffer}
Get scripthash.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getScriptHash160(encnullable) → {Buffer}
Get ripemd160 scripthash.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getScriptHash256(encnullable) → {Buffer}
Get sha256 scripthash.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getSecretSize() → {Number}
Calculate WIF serialization size.
- Source:
Returns:
- Type
- Number
getSize() → {Number}
Calculate serialization size.
- Source:
Returns:
- Type
- Number
getType() → {ScriptType}
Get address type.
- Source:
Returns:
- Type
- ScriptType
getVersion() → {Number}
Get witness program version.
- Source:
Returns:
- Type
- Number
inspectSymbol() → {Object}
Inspect keyring.
- Source:
Returns:
- Type
- Object
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
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
toJSON() → {Object}
Convert an KeyRing to a more json-friendly object.
- Source:
Returns:
- Type
- Object
toRaw() → {Buffer}
Serialize the keyring.
- Source:
Returns:
- Type
- Buffer
toSecret(networknullable) → {Base58String}
Convert key to a CBitcoinSecret.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
network |
Network | NetworkType |
<nullable> |
- Source:
Returns:
- Type
- Base58String
toWriter(bw)
Write the keyring to a buffer writer.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufferWriter |
- Source:
verify(msg, sig) → {Boolean}
Verify a message.
Parameters:
Name | Type | Description |
---|---|---|
msg |
Buffer | |
sig |
Buffer | Signature in DER format. |
- Source:
Returns:
- Type
- Boolean