Resolve "feat(Docs): Add BlockchainElectrum Tool"
This commit is contained in:
@@ -48,6 +48,11 @@ export type BlockchainElectrumOpts = {
|
||||
application: string;
|
||||
};
|
||||
|
||||
export type BlockchainElectrumParams = {
|
||||
store?: BaseStore;
|
||||
opts?: Partial<BlockchainElectrumOpts>;
|
||||
};
|
||||
|
||||
export class BlockchainElectrum extends BaseBlockchain {
|
||||
// Composables.
|
||||
electrumClient!: ElectrumClient<ElectrumProtocolEvents>;
|
||||
@@ -60,18 +65,43 @@ export class BlockchainElectrum extends BaseBlockchain {
|
||||
addressSubscriptions: Map<string, Set<AddressCallback>> = new Map();
|
||||
transactionSubscriptions: Map<string, Set<TransactionCallback>> = new Map();
|
||||
|
||||
// Options
|
||||
store: BaseStore;
|
||||
opts: BlockchainElectrumOpts;
|
||||
|
||||
constructor(
|
||||
public readonly store: BaseStore = new StoreInMemory(),
|
||||
public readonly opts: BlockchainElectrumOpts = {
|
||||
public readonly params: BlockchainElectrumParams = {},
|
||||
) {
|
||||
super();
|
||||
|
||||
// Set the store, or use the memory store by default.
|
||||
this.store = params.store ?? new StoreInMemory();
|
||||
|
||||
// Combine provided options with default options.
|
||||
this.opts = {
|
||||
servers: [
|
||||
'bch.imaginary.cash',
|
||||
'cashnode.bch.ninja',
|
||||
'electrum.imaginary.cash',
|
||||
],
|
||||
application: 'XOApp',
|
||||
},
|
||||
) {
|
||||
super();
|
||||
...params.opts,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new BlockchainElectrum instance.
|
||||
* @param {BlockchainElectrumParams} params - The parameters for the BlockchainElectrum instance.
|
||||
* @returns {BlockchainElectrum} A new BlockchainElectrum instance.
|
||||
*/
|
||||
static async from(
|
||||
params: BlockchainElectrumParams = {},
|
||||
): Promise<BlockchainElectrum> {
|
||||
const blockchain = new BlockchainElectrum(params);
|
||||
|
||||
await blockchain.start();
|
||||
|
||||
return blockchain;
|
||||
}
|
||||
|
||||
async start() {
|
||||
|
||||
Reference in New Issue
Block a user