new KeyRing(options)
Represents a key ring which amounts to an address. Used for Wallet.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Methods
(static) fromJSON(json, passphrasenullable) → {KeyRing}
Instantiate an KeyRing from a jsonified transaction object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
json |
Object | The jsonified transaction object. |
|
passphrase |
String |
<nullable> |
KeyRing passphrase |
- Source:
Returns:
- Type
- KeyRing
(static) fromRaw() → {KeyRing}
Instantiate a keyring from serialized data.
- 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
addKey(key)
Add a key to shared keys.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
compile(hash, typenullable, versionnullable) → {Base58Address}
Compile a hash to an address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
hash |
Hash | Buffer | ||
type |
AddressType |
<nullable> |
|
version |
Number |
<nullable> |
Witness version. |
- Source:
Throws:
Error on bad hash/prefix.
Returns:
- Type
- Base58Address
getAddress() → {Base58Address}
Get base58 address.
- Source:
Returns:
- Type
- Base58Address
getAddressMap() → {AddressMap}
Create the address map for testing txs.
- Source:
Returns:
- Type
- AddressMap
getHash(encnullable) → {Buffer}
Get hash.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getKeyAddress() → {Base58Address}
Get pubkeyhash address.
- Source:
Returns:
- Type
- Base58Address
getKeyHash(encnullable) → {Buffer}
Get public key hash.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getProgram() → {Buffer}
Get witness program.
- Source:
Returns:
- Type
- Buffer
getProgramAddress() → {Base58Address}
Get address' scripthash address for witness program.
- Source:
Returns:
- Type
- Base58Address
getProgramHash(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
getPublicKey(encnullable) → {Buffer}
Get public key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Buffer
getScript() → {Script}
Get redeem script.
- Source:
Returns:
- Type
- Script
getScriptAddress() → {Base58Address}
Get scripthash address.
- Source:
Returns:
- Type
- Base58Address
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
ownInput(tx, indexnullable) → {Boolean}
Check whether transaction input belongs to this address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tx |
TX | Output | Transaction or Output. |
|
index |
Number |
<nullable> |
Output index. |
- 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
removeKey(key)
Remove a key from shared keys.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
scriptInputs(tx, indexnullable) → {Number}
Build input scripts templates for a transaction (does not sign, only creates signature slots). Only builds scripts for inputs that are redeemable by this address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tx |
MTX | ||
index |
Number |
<nullable> |
Index of input. If not present, it will attempt to sign all redeemable inputs. |
- Source:
Returns:
Total number of scripts built.
- Type
- Number
sign(tx, key, indexnullable, typenullable) → {Number}
Build input scripts and sign inputs for a transaction. Only attempts to build/sign inputs that are redeemable by this address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tx |
MTX | ||
key |
HDPrivateKey | KeyPair | Buffer | Private key. |
|
index |
Number |
<nullable> |
Index of input. If not present, it will attempt to build and sign all redeemable inputs. |
type |
SighashType |
<nullable> |
- Source:
Returns:
Total number of inputs scripts built and signed.
- Type
- Number
toJSON(passphrasenullable) → {Object}
Convert an KeyRing to a more json-friendly object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
passphrase |
String |
<nullable> |
KeyRing passphrase |
- Source:
Returns:
- Type
- Object
toRaw() → {Buffer}
Serialize the keyring.
- Source:
Returns:
- Type
- Buffer