This module provides functions for braids, which is how we define
a group of xpubs with some additional multisig information to define
a multisig setup. Sometimes, the word wallet
is used here, but we
view the traditional use of the word 'wallet' as a collection of Braids.
Classes
Methods
(static) braidAddressType(braid) → {string}
Returns the braid's addressType
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
Returns:
address type p2sh/p2sh-p2wsh/p2wsh
- Type
- string
(static) braidConfig(braid) → {string}
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | A Braid struct to be 'exported' |
Returns:
string of JSON data which can used to reconstitute the Braid later
- Type
- string
(static) braidExtendedPublicKeys(braid) → {Array.<ExtendedPublicKey>}
Returns the braid's extendedPublicKeys
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
Returns:
array of ExtendedPublicKeys in the braid
- Type
- Array.<ExtendedPublicKey>
(static) braidIndex(braid) → {string}
Returns the braid's index
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
Returns:
index (singular) for the braid: 0 = deposit, 1 = change
- Type
- string
(static) braidNetwork(braid) → {string}
Returns the braid's network
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
Returns:
network string testnet/mainnet
- Type
- string
(static) braidRequiredSigners(braid) → {number}
Returns the braid's requiredSigners
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
Returns:
number of required signers
- Type
- number
(static) deriveMultisigByIndex(braid, index) → {module:multisig.Multisig}
Returns a braid-aware Multisig object at particular index
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
index |
number | what suffix to generate the multisig at |
Returns:
braid-aware MULTISIG object at index
- Type
- module:multisig.Multisig
(static) deriveMultisigByPath(braid, path) → {module:multisig.Multisig}
Returns a braid-aware Multisig object at particular path (respects index)
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
path |
string | what suffix to generate the multisig at |
Returns:
braid-aware MULTISIG object at path
- Type
- module:multisig.Multisig
(static) generateBip32DerivationByIndex(braid, index) → {Array.<Object>}
Returns the braid's bip32PathDerivation at a particular index (array of bip32 info)
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
index |
number | what suffix to generate bip32PathDerivation at |
Returns:
array of getBip32Derivation objects
- Type
- Array.<Object>
(static) generateBip32DerivationByPath(braid, path) → {Array.<Object>}
Returns the braid's bip32PathDerivation (array of bip32 infos)
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
path |
string | what suffix to generate bip32PathDerivation at |
Returns:
array of getBip32Derivation objects
- Type
- Array.<Object>
(static) generateBraid(network, addressType, extendedPublicKeys, requiredSigners, index) → {Braid}
Generate a braid from its parts
Parameters:
Name | Type | Description |
---|---|---|
network |
string | mainnet or testnet |
addressType |
string | P2SH/P2SH-P2WSH/P2WSH |
extendedPublicKeys |
Array.<module:keys.ExtendedPublicKey> | array of xpubs that make up the braid |
requiredSigners |
number | number signers needed to sign |
index |
string | (usually deposit/change) - e.g. '0' or '1' |
Returns:
Braid struct is returned
- Type
- Braid
(static) generatePublicKeysAtIndex(braid, index) → {Array.<string>}
Returns the braid's pubkeys at particular index under the index
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
index |
number | the suffix to generate pubkeys at |
Returns:
array of public keys at a particular index from the braid
- Type
- Array.<string>
(static) generatePublicKeysAtPath(braid, path) → {Array.<string>}
Returns the braid's pubkeys at particular path (respects the index)
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
path |
string | the suffix to generate pubkeys at |
Returns:
array of sorted (BIP67) public keys at a particular index from the braid
- Type
- Array.<string>
(static) validateBip32PathForBraid(braid, path) → {void}
Validate that a requested path is derivable from a particular braid e.g. it's both a valid bip32path and its first index is the same as the index
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
path |
string | the path to validate |
Returns:
the assertions will fire errors if invalid
- Type
- void
(inner) derivePublicKeyObjectsAtPath(braid, path) → {Object}
Returns an object with a braid's pubkeys + bip32derivation info at a particular path (respects the index)
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
path |
string | what suffix to generate pubkeys at |
Returns:
Object where the keys make up an array of public keys at a particular path and the values are the bip32Derivations (used in other places)
- Type
- Object
(inner) generateBraidAwareMultisigFromPublicKeys(braid, pubkeys, bip32Derivation) → {module:multisig.Multisig}
Returns a braid-aware Multisig object from a set of public keys
Parameters:
Name | Type | Description |
---|---|---|
braid |
Braid | the braid to interrogate |
pubkeys |
Array.<string> | what suffix to generate the multisig at |
bip32Derivation |
Array.<Object> | this is the array of bip32info for each member of the multisig |
Returns:
braid-aware MULTISIG object
- Type
- module:multisig.Multisig