beignet / Electrum
- _wallet
- batchDelay
- batchLimit
- connectedToElectrum
- connectionPollingInterval
- electrumNetwork
- latestConnectionState
- net
- network
- onReceive
- sendMessage
- servers
- tls
- broadcastTransaction
- checkConnection
- connectToElectrum
- disconnect
- getAddressBalance
- getAddressHistory
- getAddressScriptHashBalances
- getAddressScriptHashesHistory
- getBlockHashFromHex
- getBlockHeader
- getBlockHex
- getConnectedPeer
- getScriptPubKeyHistory
- getTransactionMerkle
- getTransactions
- getTransactionsFromInputs
- getUtxos
- isConnected
- listUnspentAddressScriptHashes
- publishConnectionChange
- startConnectionPolling
- stopConnectionPolling
- subscribeToAddresses
- subscribeToHeader
- transactionExists
• new Electrum(«destructured»
)
Name | Type |
---|---|
«destructured» |
Object |
› batchDelay? |
number |
› batchLimit? |
number |
› net? |
Server |
› network |
EAvailableNetworks |
› onReceive? |
(data : unknown ) => void |
› servers? |
TServer | TServer [] |
› tls? |
TLSSocket |
› wallet |
Wallet |
• Private
Readonly
_wallet: Wallet
• batchDelay: number
• batchLimit: number
• connectedToElectrum: boolean
• Private
connectionPollingInterval: null
| Timeout
• electrumNetwork: EElectrumNetworks
• Private
latestConnectionState: null
| boolean
= null
• Private
net: Server
• network: EAvailableNetworks
• Optional
onReceive: (data
: unknown
) => void
▸ (data
): void
Name | Type |
---|---|
data |
unknown |
void
• Private
sendMessage: TOnMessage
• Optional
servers: TServer
| TServer
[]
• Private
tls: TLSSocket
• get
wallet(): Wallet
▸ broadcastTransaction(«destructured»
): Promise
<Result
<string
>>
Name | Type |
---|---|
«destructured» |
Object |
› rawTx |
string |
› subscribeToOutputAddress? |
boolean |
Promise
<Result
<string
>>
▸ Private
checkConnection(): Promise
<void
>
Attempts to check the current Electrum connection.
Promise
<void
>
▸ connectToElectrum(«destructured»
): Promise
<Result
<string
>>
Name | Type |
---|---|
«destructured» |
Object |
› disableRegtestCheck? |
boolean |
› network? |
EAvailableNetworks |
› servers? |
TServer | TServer [] |
Promise
<Result
<string
>>
▸ disconnect(): Promise
<void
>
Promise
<void
>
▸ getAddressBalance(scriptHash
): Promise
<IElectrumGetAddressBalanceRes
>
Returns the balance in sats for a given address.
Name | Type |
---|---|
scriptHash |
string |
Promise
<IElectrumGetAddressBalanceRes
>
▸ getAddressHistory(«destructured»?
): Promise
<Result
<IGetAddressHistoryResponse
[]>>
Returns the available history for the provided address script hashes.
Name | Type |
---|---|
«destructured» |
Object |
› scanAllAddresses? |
boolean |
› scriptHashes? |
IAddress [] |
Promise
<Result
<IGetAddressHistoryResponse
[]>>
▸ getAddressScriptHashBalances(scriptHashes
): Promise
<IGetAddressScriptHashBalances
>
Name | Type |
---|---|
scriptHashes |
string [] |
Promise
<IGetAddressScriptHashBalances
>
▸ getAddressScriptHashesHistory(scriptHashes?
): Promise
<Result
<IGetAddressTxResponse
>>
Returns an array of tx_hashes and their height for a given array of address script hashes.
Name | Type | Default value |
---|---|---|
scriptHashes |
string [] |
[] |
Promise
<Result
<IGetAddressTxResponse
>>
▸ getBlockHashFromHex(«destructured»?
): string
Returns the block hash given a block hex. Leaving blockHex empty will return the last known block hash from storage.
Name | Type |
---|---|
«destructured» |
Object |
› blockHex? |
string |
string
▸ getBlockHeader(): IHeader
Returns last known block height, and it's corresponding hex from local storage.
▸ getBlockHex(«destructured»?
): Promise
<Result
<string
>>
Returns the block hex of the provided block height.
Name | Type |
---|---|
«destructured» |
Object |
› height? |
number |
Promise
<Result
<string
>>
▸ getConnectedPeer(): Promise
<Result
<IPeerData
>>
Returns currently connected peer.
▸ getScriptPubKeyHistory(scriptPubkey
): Promise
<TGetAddressHistory
[]>
Used to retrieve scriptPubkey history for LDK.
Name | Type |
---|---|
scriptPubkey |
string |
Promise
<TGetAddressHistory
[]>
▸ getTransactionMerkle(«destructured»
): Promise
<{ block_height
: number
; merkle
: string
[] ; pos
: number
}>
Returns the merkle branch to a confirmed transaction given its hash and height.
Name | Type |
---|---|
«destructured» |
Object |
› height |
number |
› tx_hash |
string |
Promise
<{ block_height
: number
; merkle
: string
[] ; pos
: number
}>
▸ getTransactions(txHashes
): Promise
<Result
<IGetTransactions
>>
Returns available transactions from electrum based on the provided txHashes.
Name | Type |
---|---|
txHashes |
Object |
txHashes.txHashes |
ITxHash [] |
Promise
<Result
<IGetTransactions
>>
▸ getTransactionsFromInputs(txHashes
): Promise
<Result
<IGetTransactionsFromInputs
>>
Returns transactions associated with the provided transaction hashes.
Name | Type |
---|---|
txHashes |
Object |
txHashes.txHashes |
ITxHash [] |
Promise
<Result
<IGetTransactionsFromInputs
>>
▸ getUtxos(«destructured»?
): Promise
<Result
<IGetUtxosResponse
>>
Returns UTXO's for a given wallet and network along with the available balance.
Name | Type |
---|---|
«destructured» |
Object |
› addressIndex? |
number |
› addressTypesToCheck? |
EAddressType [] |
› changeAddressIndex? |
number |
› scanningStrategy? |
EScanningStrategy |
Promise
<Result
<IGetUtxosResponse
>>
▸ isConnected(): Promise
<boolean
>
Promise
<boolean
>
▸ listUnspentAddressScriptHashes(«destructured»?
): Promise
<Result
<IGetUtxosResponse
>>
Queries Electrum to return the available UTXO's and balance of the provided addresses.
Name | Type |
---|---|
«destructured» |
Object |
› addresses |
TUnspentAddressScriptHashData |
Promise
<Result
<IGetUtxosResponse
>>
▸ Private
publishConnectionChange(isConnected
): void
Name | Type |
---|---|
isConnected |
boolean |
void
▸ startConnectionPolling(): void
void
▸ stopConnectionPolling(): void
void
▸ subscribeToAddresses(«destructured»?
): Promise
<Result
<string
>>
Subscribes to a number of address script hashes for receiving.
Name | Type |
---|---|
«destructured» |
Object |
› onReceive? |
(data : TSubscribedReceive ) => void |
› scriptHashes? |
string [] |
Promise
<Result
<string
>>
▸ subscribeToHeader(): Promise
<Result
<IHeader
>>
Subscribes to the current networks headers.
▸ transactionExists(txData
): boolean
Determines whether a transaction exists based on the transaction response from electrum.
Name | Type |
---|---|
txData |
ITransaction <IUtxo > |
boolean