beignet
- EAddressType
- EAvailableNetworks
- EBoostType
- EElectrumNetworks
- EFeeId
- EPaymentType
- EProtocol
- EScanningStrategy
- EUnit
- IAddInput
- IAddress
- IAddressData
- IAddressType
- IAddressTypeData
- IAddresses
- IBoostedTransaction
- IBoostedTransactions
- ICreateTransaction
- ICustomGetAddress
- ICustomGetScriptHash
- IElectrumGetAddressBalanceRes
- IFormattedPeerData
- IFormattedTransaction
- IFormattedTransactions
- IGenerateAddresses
- IGenerateAddressesResponse
- IGetAddress
- IGetAddressBalanceRes
- IGetAddressByPath
- IGetAddressHistoryResponse
- IGetAddressResponse
- IGetAddressScriptHashBalances
- IGetAddressScriptHashesHistoryResponse
- IGetAddressTxResponse
- IGetAddressesFromKeyPair
- IGetAddressesFromPrivateKey
- IGetDerivationPath
- IGetFeeEstimatesResponse
- IGetHeaderResponse
- IGetNextAvailableAddressResponse
- IGetTransactions
- IGetTransactionsFromInputs
- IGetUtxosResponse
- IHeader
- IIndexes
- IKeyDerivationPath
- IKeyDerivationPathData
- INewBlock
- IOnchainFees
- IOutput
- IPeerData
- IPrivateKeyInfo
- IRbfData
- ISend
- ISendTransaction
- ISendTx
- ISetupTransaction
- ISubscribeToAddress
- ISubscribeToHeader
- ISweepPrivateKey
- ISweepPrivateKeyRes
- ITargets
- ITransaction
- ITxHash
- ITxHashes
- IUtxo
- IVin
- IVout
- IWallet
- IWalletData
- ElectrumConnectionPubSub
- ElectrumConnectionSubscription
- InputData
- ObjectKeys
- Result
- TAddressIndexInfo
- TAddressLabel
- TAddressTxResponse
- TAddressType
- TAddressTypeContent
- TAddressTypes
- TAvailableNetworks
- TConnectToElectrumRes
- TDecodeRawTx
- TElectrumNetworks
- TGapLimitOptions
- TGetAddressHistory
- TGetByteCountInput
- TGetByteCountInputs
- TGetByteCountOutput
- TGetByteCountOutputs
- TGetData
- TGetTotalFeeObj
- TKeyDerivationAccount
- TKeyDerivationChange
- TKeyDerivationCoinType
- TKeyDerivationIndex
- TKeyDerivationPurpose
- TMessageDataMap
- TMessageKeys
- TOnMessage
- TProcessUnconfirmedTransactions
- TProtocol
- TServer
- TSetData
- TSetupTransactionResponse
- TStorage
- TSubscribedReceive
- TTransactionMessage
- TTxDetails
- TTxResponse
- TTxResult
- TUnspentAddressScriptHashData
- TWalletDataKeys
- availableNetworks
- constructByteCountParam
- decodeOpReturnMessage
- decodeRawTransaction
- err
- filterAddressesForGapLimit
- filterAddressesObjForGapLimit
- filterAddressesObjForSingleIndex
- filterAddressesObjForStartingIndex
- formatKeyDerivationPath
- formatPeerData
- generateMnemonic
- generateWalletId
- getAddressFromKeyPair
- getAddressFromScriptPubKey
- getAddressIndexDiff
- getAddressTypeFromPath
- getAddressesFromPrivateKey
- getByteCount
- getDataFallback
- getDefaultPort
- getDefaultWalletData
- getDefaultWalletDataKeys
- getElectrumNetwork
- getHighestUsedIndexFromTxHashes
- getKeyDerivationPath
- getKeyDerivationPathObject
- getKeyDerivationPathString
- getKeyValue
- getPeers
- getProtocolForPort
- getScriptHash
- getSeed
- getSeedHash
- getSha256
- getStorageKeyValues
- getTapRootAddressFromPublicKey
- getTxFee
- getWalletDataStorageKey
- isP2trPrefix
- isPositive
- isValidBech32mEncodedString
- objectKeys
- objectsMatch
- ok
- parseOnChainPaymentRequest
- reduceValue
- removeDustOutputs
- setReplaceByFee
- shuffleArray
- sleep
- validateAddress
- validateMnemonic
- validateTransaction
Ƭ ElectrumConnectionPubSub: Object
| Name | Type |
|---|---|
publish |
(isConnected: boolean) => void |
subscribe |
(callback: (isConnected: boolean) => void) => ElectrumConnectionSubscription |
Ƭ ElectrumConnectionSubscription: Object
| Name | Type |
|---|---|
remove |
() => void |
Ƭ InputData: Object
▪ [key: string]: { addresses: string[] ; value: number }
Ƭ ObjectKeys<T>: `${Exclude<keyof T, symbol>}`
| Name | Type |
|---|---|
T |
extends object |
Ƭ Result<T>: Ok<T> | Err<T>
Represents a result that can be successful (Ok) or contain an error (Err).
| Name |
|---|
T |
Ƭ TAddressIndexInfo: Object
| Name | Type |
|---|---|
addressIndex |
IAddress |
changeAddressIndex |
IAddress |
lastUsedAddressIndex |
IAddress |
lastUsedChangeAddressIndex |
IAddress |
Ƭ TAddressLabel: "bech32" | "segwit" | "legacy"
Ƭ TAddressTxResponse: Object
| Name | Type |
|---|---|
data |
string |
error? |
{ code: number ; message: string } |
error.code |
number |
error.message |
string |
id |
number |
jsonrpc |
string |
param |
string |
result |
TTxResult[] |
Ƭ TAddressType: "p2wpkh" | "p2sh" | "p2pkh"
Ƭ TAddressTypeContent<T>: { [key in EAddressType]: T }
| Name |
|---|
T |
Ƭ TAddressTypes: { [key in EAddressType]: Readonly<IAddressTypeData> }
Ƭ TAvailableNetworks: "bitcoin" | "testnet" | "regtest"
Ƭ TConnectToElectrumRes: string
Ƭ TDecodeRawTx: Object
| Name | Type |
|---|---|
locktime |
number |
size |
number |
tx_hash |
string |
txid |
string |
version |
number |
vin |
IVin[] |
vout |
IVout[] |
vsize |
number |
weight |
number |
Ƭ TElectrumNetworks: "bitcoin" | "bitcoinTestnet" | "bitcoinRegtest"
Ƭ TGapLimitOptions: Object
| Name | Type |
|---|---|
lookAhead |
number |
lookBehind |
number |
Ƭ TGetAddressHistory: Object
| Name | Type |
|---|---|
height |
number |
txid |
string |
Ƭ TGetByteCountInput: `MULTISIG-P2SH:${number}-${number}` | `MULTISIG-P2WSH:${number}-${number}` | `MULTISIG-P2SH-P2WSH:${number}-${number}` | "P2SH-P2WPKH" | "P2PKH" | "p2pkh" | "P2WPKH" | "p2wpkh" | "P2SH" | "p2sh" | "P2TR" | "p2tr"
Ƭ TGetByteCountInputs: { [key in TGetByteCountInput]?: number }
Ƭ TGetByteCountOutput: "P2SH" | "P2PKH" | "P2WPKH" | "P2WSH" | "p2wpkh" | "p2sh" | "p2pkh" | "P2TR" | "p2tr"
Ƭ TGetByteCountOutputs: { [key in TGetByteCountOutput]?: number }
Ƭ TGetData: <K>(key: string) => Promise<Result<IWalletData[K]>>
▸ <K>(key): Promise<Result<IWalletData[K]>>
| Name | Type |
|---|---|
K |
extends keyof IWalletData |
| Name | Type |
|---|---|
key |
string |
Promise<Result<IWalletData[K]>>
Ƭ TGetTotalFeeObj: Object
| Name | Type |
|---|---|
maxSatPerByte |
number |
satsPerByte |
number |
totalFee |
number |
transactionByteCount |
number |
Ƭ TKeyDerivationAccount: "0" | string
Ƭ TKeyDerivationChange: "0" | "1"
Ƭ TKeyDerivationCoinType: "0" | "1" | string
Ƭ TKeyDerivationIndex: string
Ƭ TKeyDerivationPurpose: "84" | "49" | "44" | string
Ƭ TMessageDataMap: Object
| Name | Type |
|---|---|
connectedToElectrum |
boolean |
newBlock |
INewBlock |
rbf |
string[] |
reorg |
IUtxo[] |
transactionConfirmed |
TTransactionMessage |
transactionReceived |
TTransactionMessage |
transactionSent |
TTransactionMessage |
Ƭ TMessageKeys: keyof TMessageDataMap
Ƭ TOnMessage: <K>(key: K, data: TMessageDataMap[K]) => void
▸ <K>(key, data): void
| Name | Type |
|---|---|
K |
extends keyof TMessageDataMap |
| Name | Type |
|---|---|
key |
K |
data |
TMessageDataMap[K] |
void
Ƭ TProcessUnconfirmedTransactions: Object
| Name | Type |
|---|---|
ghostTxs |
string[] |
outdatedTxs |
IUtxo[] |
unconfirmedTxs |
IFormattedTransactions |
Ƭ TProtocol: "tcp" | "ssl"
Ƭ TServer: Object
| Name | Type |
|---|---|
host |
string |
protocol |
EProtocol |
ssl |
number |
tcp |
number |
Ƭ TSetData: <K>(key: string, value: IWalletData[K]) => Promise<Result<boolean>>
▸ <K>(key, value): Promise<Result<boolean>>
| Name | Type |
|---|---|
K |
extends keyof IWalletData |
| Name | Type |
|---|---|
key |
string |
value |
IWalletData[K] |
Promise<Result<boolean>>
Ƭ TSetupTransactionResponse: Result<Partial<ISendTransaction>>
Ƭ TStorage: Object
| Name | Type |
|---|---|
getData? |
TGetData |
setData? |
TSetData |
Ƭ TSubscribedReceive: [string, string]
Ƭ TTransactionMessage: Object
| Name | Type |
|---|---|
transaction |
IFormattedTransaction |
Ƭ TTxDetails: Object
| Name | Type |
|---|---|
blockhash |
string |
blocktime? |
number |
confirmations |
number |
hash |
string |
hex |
string |
locktime |
number |
size |
number |
time? |
number |
txid |
string |
version |
number |
vin |
IVin[] |
vout |
IVout[] |
vsize |
number |
weight |
number |
Ƭ TTxResponse: Object
| Name | Type |
|---|---|
data |
IAddress |
id |
number |
jsonrpc |
string |
param |
string |
result |
TTxResult[] |
Ƭ TTxResult: Object
| Name | Type |
|---|---|
height |
number |
tx_hash |
string |
Ƭ TUnspentAddressScriptHashData: Object
▪ [x: string]: IUtxo | IAddress
Ƭ TWalletDataKeys: keyof IWalletData
• Const defaultElectrumPorts: string[]
• Const electrumConnection: ElectrumConnectionPubSub
Background task that checks the connection to the Electrum server with a PubSub If connection was lost this will try to reconnect in the specified interval
Param
▸ availableNetworks(): EAvailableNetworks[]
Returns an array of all available networks from the networks object.
▸ constructByteCountParam(addresses, increaseAddressCount?): TGetByteCountInputs | TGetByteCountOutputs
Constructs the parameter for getByteCount via an array of addresses.
| Name | Type | Default value |
|---|---|---|
addresses |
string[] |
undefined |
increaseAddressCount |
{ addrType: EAddressType ; count: number }[] |
[] |
TGetByteCountInputs | TGetByteCountOutputs
y
▸ decodeOpReturnMessage(opReturn?): string[]
| Name | Type | Default value |
|---|---|---|
opReturn |
string |
'' |
string[]
▸ decodeRawTransaction(hex, _network?): Result<TDecodeRawTx>
Attempts to decode a raw tx hex. Source: bitcoinjs/bitcoinjs-lib#1606 (comment)
| Name | Type |
|---|---|
hex |
string |
_network? |
EAvailableNetworks |
▸ err<T>(error): Err<T>
Construct a new Err result value.
| Name |
|---|
T |
| Name | Type | Description |
|---|---|---|
error |
string | Error |
The error message or Error object to be wrapped in an Err result. |
Err<T>
An Err result containing the given error.
▸ filterAddressesForGapLimit(«destructured»): IAddress[]
| Name | Type |
|---|---|
«destructured» |
Object |
› addresses |
IAddress[] |
› gapLimitOptions |
TGapLimitOptions |
› index |
number |
IAddress[]
▸ filterAddressesObjForGapLimit(«destructured»): IAddresses
| Name | Type |
|---|---|
«destructured» |
Object |
› addresses |
IAddresses |
› gapLimitOptions |
TGapLimitOptions |
› index |
number |
▸ filterAddressesObjForSingleIndex(«destructured»): IAddresses
| Name | Type |
|---|---|
«destructured» |
Object |
› addressIndex |
number |
› addresses |
IAddresses |
▸ filterAddressesObjForStartingIndex(«destructured»): IAddresses
| Name | Type |
|---|---|
«destructured» |
Object |
› addresses |
IAddresses |
› index |
number |
▸ formatKeyDerivationPath(«destructured»): Result<IKeyDerivationPathData>
Formats and returns the provided derivation path string and object.
| Name | Type |
|---|---|
«destructured» |
Object |
› addressType? |
EAddressType |
› changeAddress? |
boolean |
› index? |
string |
› network |
EAvailableNetworks |
› path |
string | IKeyDerivationPath |
› purpose? |
string |
Result<IKeyDerivationPathData>
Derivation Path Data
▸ formatPeerData(data): Result<IFormattedPeerData>
Formats the peer data response from an Electrum server.
| Name | Type |
|---|---|
data |
[string, string, [string, string, string]] |
Result
▸ generateMnemonic(strength?, rng?, wordlist?): string
Extends bip39's generateMnemonic function.
| Name | Type |
|---|---|
strength? |
number |
rng? |
(size: number) => Buffer |
wordlist? |
string[] |
string
▸ generateWalletId(seed): string
| Name | Type |
|---|---|
seed |
Buffer |
string
▸ getAddressFromKeyPair(«destructured»): Result<IGetAddressesFromKeyPair>
Get address from key pair.
| Name | Type |
|---|---|
«destructured» |
Object |
› addressType |
EAddressType |
› keyPair |
BIP32Interface | ECPairInterface |
› network |
Network |
Result<IGetAddressesFromKeyPair>
▸ getAddressFromScriptPubKey(scriptPubKey, selectedNetwork): string
Get address for a given scriptPubKey.
| Name | Type |
|---|---|
scriptPubKey |
string |
selectedNetwork |
EAvailableNetworks |
string
▸ getAddressIndexDiff(addrIndex1?, addrIndex2?): number
Returns the difference between two address indexes.
| Name | Type | Default value |
|---|---|---|
addrIndex1 |
number |
0 |
addrIndex2 |
number |
0 |
number
number
▸ getAddressTypeFromPath(path): Result<EAddressType>
Returns the address type from the specified derivation path.
| Name | Type |
|---|---|
path |
string | IKeyDerivationPath |
▸ getAddressesFromPrivateKey(«destructured»): Result<IGetAddressesFromPrivateKey>
Get addresses from a private key.
| Name | Type |
|---|---|
«destructured» |
Object |
› addrTypes? |
EAddressType[] |
› network? |
Network |
› privateKey |
string |
Result<IGetAddressesFromPrivateKey>
▸ getByteCount(inputs, outputs, message?, minByteCount?): number
| Name | Type | Default value |
|---|---|---|
inputs |
TGetByteCountInputs |
undefined |
outputs |
TGetByteCountOutputs |
undefined |
message? |
string |
undefined |
minByteCount |
number |
166 |
number
▸ getDataFallback<K>(key): Promise<Result<IWalletData[K]>>
| Name | Type |
|---|---|
K |
extends keyof IWalletData |
| Name | Type |
|---|---|
key |
string |
Promise<Result<IWalletData[K]>>
▸ getDefaultPort(selectedNetwork?, protocol?): number
Returns the default port for the given network and protocol.
| Name | Type |
|---|---|
selectedNetwork? |
EAvailableNetworks |
protocol? |
TProtocol |
number
▸ getDefaultWalletData(): IWalletData
Returns the default wallet data object.
▸ getDefaultWalletDataKeys(): keyof IWalletData[]
Returns the keys from the default wallet data object.
keyof IWalletData[]
▸ getElectrumNetwork(network?): EElectrumNetworks
Returns the network string for use with Electrum methods.
| Name | Type |
|---|---|
network? |
EAvailableNetworks |
▸ getHighestUsedIndexFromTxHashes(«destructured»): Result<IIndexes>
Returns the highest used index from the provided txHashes.
| Name | Type |
|---|---|
«destructured» |
Object |
› addressIndex |
IAddress |
› addresses |
IAddresses |
› changeAddressIndex |
IAddress |
› changeAddresses |
IAddresses |
› txHashes |
ITxHashes[] |
▸ getKeyDerivationPath(«destructured»): Result<IKeyDerivationPath>
Returns the derivation path object for the specified addressType and network.
| Name | Type |
|---|---|
«destructured» |
Object |
› addressType |
EAddressType |
› network |
EAvailableNetworks |
Result
▸ getKeyDerivationPathObject(«destructured»): Result<IKeyDerivationPath>
Parses a key derivation path in string format Ex: "m/84'/0'/0'/0/0" and returns IKeyDerivationPath.
| Name | Type |
|---|---|
«destructured» |
Object |
› changeAddress? |
boolean |
› index? |
string |
› network |
EAvailableNetworks |
› path |
string |
› purpose? |
string |
▸ getKeyDerivationPathString(«destructured»): Result<string>
Parses a key derivation path object and returns it in string format. Ex: "m/84'/0'/0'/0/0"
| Name | Type |
|---|---|
«destructured» |
Object |
› accountType? |
string | number |
› addressType |
EAddressType |
› changeAddress? |
boolean |
› index? |
string | number |
› network |
EAvailableNetworks |
› path? |
IKeyDerivationPath |
› purpose? |
string |
Result<string>
▸ getKeyValue(key): string
Returns last value between hyphens in a string.
| Name | Type |
|---|---|
key |
string |
string
▸ getPeers(selectedNetwork?): Promise<Result<IFormattedPeerData[]>>
Returns an array of peers. If unable to acquire peers from an Electrum server the method will default to the hardcoded peers in peers.json.
| Name | Type |
|---|---|
selectedNetwork? |
Object |
selectedNetwork.selectedNetwork |
EAvailableNetworks |
Promise<Result<IFormattedPeerData[]>>
Promise<Result<IFormattedPeerData[]>>
▸ getProtocolForPort(port?, network?): undefined | TProtocol
Returns the protocol for the given network and default port.
| Name | Type |
|---|---|
port? |
string |
network? |
EAvailableNetworks |
undefined | TProtocol
▸ getScriptHash(«destructured»): string
Get scriptHash for a given address
| Name | Type |
|---|---|
«destructured» |
Object |
› address |
string |
› network |
EAvailableNetworks |
string
▸ getSeed(mnemonic, bip39Passphrase): Buffer
Returns the seed for a given mnemonic and passphrase.
| Name | Type |
|---|---|
mnemonic |
any |
bip39Passphrase |
any |
Buffer
▸ getSeedHash(seed): string
Returns the seed hash for a given mnemonic and passphrase.
| Name | Type |
|---|---|
seed |
Buffer |
string
▸ getSha256(str): string
Get sha256 hash of a given string.
| Name | Type |
|---|---|
str |
string |
string
▸ getStorageKeyValues(storageKey): Object
| Name | Type |
|---|---|
storageKey |
string |
Object
| Name | Type |
|---|---|
network |
EAvailableNetworks |
value |
keyof IWalletData |
walletName |
string |
▸ getTapRootAddressFromPublicKey(«destructured»): Result<{ address: string ; internalPubkey: Buffer ; output: Buffer }>
Returns taproot address information from the provided public key.
| Name | Type |
|---|---|
«destructured» |
Object |
› network |
Network |
› publicKey |
Buffer |
Result<{ address: string ; internalPubkey: Buffer ; output: Buffer }>
▸ getTxFee(«destructured»): number
Returns the total fee in sats for a transaction at a given size (transactionByteCount) times the desired satsPerByte.
| Name | Type |
|---|---|
«destructured» |
Object |
› satsPerByte |
number |
› transactionByteCount |
number |
number
▸ getWalletDataStorageKey(name, network, key): string
| Name | Type |
|---|---|
name |
string |
network |
EAvailableNetworks |
key |
keyof IWalletData |
string
▸ isP2trPrefix(address): boolean
Quickly attempts to determine if the provided address is a valid p2tr/taproot address prefix. For a more robust check, use isValidBech32mEncodedString.
| Name | Type |
|---|---|
address |
string |
boolean
▸ isPositive(num): boolean
| Name | Type |
|---|---|
num |
number |
boolean
▸ isValidBech32mEncodedString(address): Object
Returns if the provided string is a valid Bech32m encoded string (taproot/p2tr address).
| Name | Type |
|---|---|
address |
string |
Object
| Name | Type |
|---|---|
isValid |
boolean |
network |
EAvailableNetworks |
▸ objectKeys<Type>(value): `${Exclude<keyof Type, symbol>}`[]
Returns the keys of a given object.
| Name | Type |
|---|---|
Type |
extends object |
| Name | Type |
|---|---|
value |
Type |
`${Exclude<keyof Type, symbol>}`[]
▸ objectsMatch(obj1, obj2): boolean
Determines if the two objects passed as params match.
| Name | Type |
|---|---|
obj1 |
any |
obj2 |
any |
boolean
boolean
▸ ok<T>(value): Ok<T>
Construct a new Ok result value.
| Name |
|---|
T |
| Name | Type | Description |
|---|---|---|
value |
T |
The value to be wrapped in an Ok result. |
Ok<T>
An Ok result containing the given value.
▸ parseOnChainPaymentRequest(data, network?): Result<{ address: string ; message: string ; network: EAvailableNetworks ; sats: number }>
| Name | Type |
|---|---|
data |
string |
network? |
EAvailableNetworks |
Result<{ address: string ; message: string ; network: EAvailableNetworks ; sats: number }>
▸ reduceValue<T>(«destructured»): Result<number>
Sum a specific value in an array of objects.
| Name |
|---|
T |
| Name | Type |
|---|---|
«destructured» |
Object |
› arr |
T[] |
› value |
keyof T |
Result<number>
▸ removeDustOutputs(outputs): IOutput[]
Removes outputs that are below the dust limit.
| Name | Type |
|---|---|
outputs |
IOutput[] |
IOutput[]
▸ setReplaceByFee(«destructured»): void
Sets RBF for the provided psbt.
| Name | Type |
|---|---|
«destructured» |
Object |
› psbt |
Psbt |
› setRbf |
boolean |
void
▸ shuffleArray<T>(array): T[]
Shuffles a given array.
| Name |
|---|
T |
| Name | Type |
|---|---|
array |
T[] |
T[]
▸ sleep(ms): Promise<void>
| Name | Type |
|---|---|
ms |
any |
Promise<void>
▸ validateAddress(«destructured»): Object
Validate address for a given network. If no address is provided, it will attempt to validate the address for all available networks.
| Name | Type |
|---|---|
«destructured» |
Object |
› address |
string |
› network? |
EAvailableNetworks |
Object
| Name | Type |
|---|---|
isValid |
boolean |
network |
EAvailableNetworks |
▸ validateMnemonic(mnemonic?): boolean
Attempts to validate the provided mnemonic.
| Name | Type | Default value |
|---|---|---|
mnemonic |
string |
'' |
boolean
▸ validateTransaction(transaction): Result<string>
Used to validate transaction form data.
| Name | Type |
|---|---|
transaction |
ISendTransaction |
Result<string>