项目作者: dolcalmi

项目描述 :
Stellar payment watcher library for nodejs
高级语言: JavaScript
项目地址: git://github.com/dolcalmi/stellar-payment-watcher.git
创建时间: 2020-01-12T18:01:23Z
项目社区:https://github.com/dolcalmi/stellar-payment-watcher

开源协议:MIT License

下载


Stellar payment watcher

Version
Build Status
Coverage Status
David
David
Try on RunKit

Stellar payment watcher library for nodejs.

Installation

Install the package with:

  1. npm i stellar-payment-watcher

Usage

Initialization

  1. import PaymentWatcher from 'stellar-payment-watcher';
  2. // optional params
  3. const options = {
  4. allowHttp: false, // Horizon server param
  5. appName: null, // Horizon server param
  6. appVersion: null, // Horizon server param
  7. horizonServerURL: 'https://horizon.stellar.org',
  8. limit: 100, // amount of transactions to load from given cursor
  9. reconnectTimeout: 15 * 1000, // Time in milliseconds before restart the watcher
  10. useTestNet: false, // only required to parse transaction object
  11. }
  12. const watcher = new PaymentWatcher(options);

Watch all payments

Watch all payments using Horizon payments stream.

  1. // optional params
  2. const options = {
  3. onmessage: (payment) => console.log(payment),
  4. onerror: (error) => console.error(error),
  5. }
  6. watcher.start(options);

Watch all payments from cursor

Watch all payments from given cursor and then use Horizon payments stream.

  1. // optional params
  2. const options = {
  3. cursor: '118556627971530752',
  4. onmessage: (payment) => console.log(payment),
  5. onerror: (error) => console.error(error),
  6. }
  7. watcher.start(options);

Watch all payments for given accounts

Watch all payments for given accounts using Horizon payments stream.

  1. // optional params
  2. const options = {
  3. accounts: ['GCBRK7UAKYJ2MG3NNPGHLW6P7LXM5YHB5G4UZA3YTWJ7PTCH6F4VJDH6', 'GDI47LBSD65TNLLH3R36SKLRTSEM4T7OMCZIHHMN2FEQPVSIBBKUNZMY'],
  4. onmessage: (payment) => console.log(payment),
  5. onerror: (error) => console.error(error),
  6. }
  7. watcher.start(options);

Watch all payments for given accounts from cursor

Watch all payments for given accounts using Horizon payments stream.

  1. // optional params
  2. const options = {
  3. cursor: '118556627971530752',
  4. accounts: ['GCBRK7UAKYJ2MG3NNPGHLW6P7LXM5YHB5G4UZA3YTWJ7PTCH6F4VJDH6', 'GDI47LBSD65TNLLH3R36SKLRTSEM4T7OMCZIHHMN2FEQPVSIBBKUNZMY'],
  5. onmessage: (payment) => console.log(payment),
  6. onerror: (error) => console.error(error),
  7. }
  8. watcher.start(options);

Development

Run all tests:

  1. $ npm i
  2. $ npm test

Run a single test suite:

  1. $ npm run mocha -- test/lib/watcher.spec.js

Run a single test (case sensitive):

  1. $ npm run mocha -- test/lib/watcher.spec.js --grep 'allowHttp'

Library based on Stellar Notifier