Skip to content

Latest commit

 

History

History
108 lines (89 loc) · 2.18 KB

File metadata and controls

108 lines (89 loc) · 2.18 KB

Payment Notifier

Sends a Pushover notification when funds are received by the provided addresses

import { createPaymentNotifierService } from '@cardano-ogmios-examples/payment-notifier'
import onDeath from 'death'

createPaymentNotifierService(
  ['addr...'],
  {
    host: 'localhost',
    port: 1338
  },
  {
    notifications: {
      pushover: {
        credentials: {
          token: process.ENV.PUSHOVER_TOKEN,
          user: process.ENV.PUSHOVER_USER
        }
      }
    }
  }
).then(service => {
  service.start().catch(error => console.error(error))
  onDeath(service.shutdown)
})

Web Service

Build and Run via Docker Compose

  1. Create two text files with Pushover credentials in ./secrets
    • pushover_token
    • pushover_user
  2. From the top-level of this repository:
mainnet
yarn mainnet:up
# OR
docker-compose -p mainnet_payment-notifier up
testnet
yarn testnet:up
# OR
NETWORK=testnet OGMIOS_PORT=1338 docker-compose -p testnet_payment-notifier up

ℹ️ Override the API_PORT env if you have a clash on 3000

Down

mainnet
yarn mainnet:down
# OR
docker-compose -p mainnet_payment-notifier down
testnet
yarn testnet:down
# OR
docker-compose -p testnet_payment-notifier down

Build with yarn

yarn build

Service Config

  • API_PORT
  • OGMIOS_HOST
  • OGMIOS_PORT
  • PUSHOVER_TOKEN_FILE - Path to a text file containing a Pushover token
  • PUSHOVER_USER_FILE - Path to a text file containing a Pushover token

Run

{CONFIG} node ./dist/index.js

Endpoints

Start

curl -X POST http://localhost:3000/start -H 'Content-Type: application/json' -d '{"addresses": ["addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g"]}'

Shutdown

curl -X POST http://localhost:3000/shutdown -H 'Content-Type: application/json'