@electrum-cash/application
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Introduction

The @electrum-cash/application library provides a robust framework for building SPV-validated tools and services.

  • Full SPV-validation of monitored transactions and blocks.
  • Rich notifications for each step in the transaction, block or address life-cycle.
  • You can ask for partial data without needing to understand how to acquire it.
  • Automatic handling of network edge-cases, fail-over and opportunistic caching.

For complete information on all typings, arguments and options available, read to the documentation generated from the source code.

Usage

Installation

Installation is easy, just get the library from NPM:

npm install @electrum-cash/application

Setup

// Import library features.
import { initializeElectrumApplication } from '@electrum-cash/application';

// Initialize the electrum application.
const electrumEvents = await initializeElectrumApplication('My Electrum Application');

Event handling

Tracking the blockchain

Once you have initialized the electrum application you can monitor when new blocks become available.

// Log when new block headers are available.
electrumEvents.on('BlockReceived', console.log);

// Log when new block headers have been verified.
electrumEvents.on('BlockVerified', console.log);

// Log what chain height and percent of the chain has been verified.
electrumEvents.on('ChainStatus', console.log);

Tracking transactions

After you monitor an address or transaction, you get events for each step in each transactions life-cycle.

// Log when new transactions are available.
electrumEvents.on('TransactionReceived', console.log);

// Log when new transactions are verified.
electrumEvents.on('TransactionVerified', console.log);

// Log when new transactions are doublespent.
electrumEvents.on('TransactionDoubleSpendDetected', console.log);

// Either monitor a specific transaction...
await monitorTransaction(transactionHash);

// .. or all pending transactions for a specific address.
await monitorAddress(address);

Tracking address history

After you monitor an address, you get events when an address history is updated.

// Log when the address history has changed.
electrumEvents.on('AddressUpdateReceived', console.log);

// TODO: Add events for address balance updates.

// Monitor a specific address.
await monitorAddress(address);

Requesting Data

Getting balance, UTXOs and transaction history.

...

Support

If you find bugs or have problems using this library, you can file issues on the Gitlab.

Readme

Keywords

none

Package Sidebar

Install

npm i @electrum-cash/application

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

216 kB

Total Files

9

Last publish

Collaborators

  • monsterbitar