Documentation
@bamotf/server

@bamotf/server

A server that exposes a REST API to create and manage payments in Bitcoin.

alt

Notes

  • tolerance is a percentage of the amount that is allowed to be lost to during the payment process. Users might pay less than the amount due to exchange rate fluctuations or their wallet might be using a different price index than the one used by this server. For example, if amount is 100 USD and tolerance is 0.05, then the payment will be considered successful if the user pays between 95 and 100 USD given the price when the payment was sent to the mempool. DEFAULT: 0.02 (2%)

  • confirmations is the number of confirmations required for the payment to be considered successful. Confirmations add up when blocks are added to the blockchain. DEFAULT: 1

  • currency is the currency in which the amount is expressed. List of supported currencies can be found here. DEFAULT: BTC

Configuration

When starting you server, you need to certain environment variables for it to run:

POSTGRES_URL // is the url to the postgres database
REDIS_URL // is the url to the redis server
BITCOIN_CORE_URL // is the url to the bitcoin core node
 
/* optionals */
PRICE_DATA_SERVER_CLEARNET_URL // default: price data will be fetched from the bisq network
SESSION_SECRET // default: a random string will be used

REST APIs

Requests

  • [GET] /api/payment-intents - List all payment intents
  • [POST] /api/payment-intents - Create a new payment intent
    • Body:
      {
          address: string;
          amount: Decimal;
          confirmations: number;
          tolerance: Decimal;
          currency: "BTC" | "AED" | "AUD" | "BDT" | "BHD" | "BMD" | "BRL" | "CAD" | "CHF" | "CLP" | ... 32 more ... | "VND";
          description?: string | null | undefined;
      }
  • [GET] /api/payment-intents/:id - Get a specific payment intent
  • [POST] /api/payment-intents/:id - Update a specific payment intent
    • Body:
      {
          address?: string | undefined;
          amount?: Decimal | undefined;
          confirmations?: number | undefined;
          tolerance?: Decimal | undefined;
          currency?: "BTC" | "AED" | "AUD" | ... 40 more ... | undefined;
          description?: string | null | undefined;
      }
  • [POST] /api/payment-intents/:id/cancel - Cancel a specific payment intent
    • Body:
      {
          cancellationReason?: string | undefined;
      }
  • [GET] /api/price/:currency - Get the price of Bitcoin in a specific currency