Skip to content

Latest commit

 

History

History
91 lines (68 loc) · 2.97 KB

README.md

File metadata and controls

91 lines (68 loc) · 2.97 KB

Satsback Module for LaWallet

License Stars Forks

This module is used to send cashback in sats to users who purchase with LaWallet through LaPOS using LaCard.

Table of Contents

Flow

  1. Bob pays with LaCard in LaPOS (only payments with LaCard are valid, payments with QR code don't work).
  2. LaPOS sends an HTTP POST request to the /publish endpoint of LaWallet withinternal-transaction-start, containing Bob's payment to LaPOS
  3. Ledger recive the payment and confirms it by sending internal-transaction-ok to LaWallet relay (wss://relay.lawallet.ar).
  4. The satsback module subscribes to LaWallet relay to listen for internal-transaction-ok emmited by the Ledger and directed to LaPOS.
  5. The module receives the internal-transaction-ok.
  6. The module sends an HTTP POST request to /publish endpoint of LaWallet with internal-transaction-start, containing the satsback for Bob.
  7. Ledger send internal-transaction-ok to LaWallet relay and Bob recive your satsback. (Don't showing in the map).

NOTE: The satsback module MUST have a LaWallet account.

satsback flow

Configuration

1. Setup environment variables

Copy .env.example to .env and fill the MODULE_PRIVATE_KEY with the private key of LaWallet account

It's necessary to have a LaWallet account to send internal transactions.

cp .env.example .env

2. Setup

Use correct node version

nvm use

Install the dependencies

pnpm i

3. Run in dev mode

pnpm dev

To Do

  • Fix minimum amount of satsback
  • Add database
    • Add list of volunteers walias (pubkey and sats of voucher)
  • Add satsback percentages (normal and volunteers) to environment variables
  • makeEvent
    • Volunteers handle
      • Search in db
      • Handle sats remaining
    • Encrypt metadata of conent of event for the ledger send interal transaction
    • Save id of payments to LaPOS in db
    • Save the last timestamp of the last payment in db
  • Subscribe to relay with the last timestamp
  • Check if events are already recive satsback
  • Cache for prisma
    • Volunteers model
    • Events model
  • Endpoint to add volunteer
  • Add documentation
    • Of the filters
    • Of event that the module can handle and emit
    • Of the database
    • How avoid double satsback
    • How handle relay disconnection
  • Dockerize