Storage Backends
DeroPay uses a pluggable storage system for invoice persistence. Two backends are included, and you can implement your own.
Built-in Backends
The default backend — stores everything in memory. Data is lost when the process restarts.
import { InvoiceEngine, MemoryInvoiceStore } from "dero-pay/server";
// MemoryInvoiceStore is the default — no config needed
const engine = new InvoiceEngine({
walletRpcUrl: "http://127.0.0.1:10103/json_rpc",
daemonRpcUrl: "http://127.0.0.1:10102/json_rpc",
// store defaults to new MemoryInvoiceStore()
});Good for: development, testing, prototyping.
Custom Storage
Implement the InvoiceStore interface to use any database:
import type { InvoiceStore, Invoice } from "dero-pay/server";
const myStore: InvoiceStore = {
async save(invoice: Invoice): Promise<void> {
// Persist the invoice
},
async get(id: string): Promise<Invoice | null> {
// Retrieve by ID
},
async getByPaymentId(paymentId: string): Promise<Invoice | null> {
// Retrieve by payment ID (used by the monitor)
},
async update(id: string, updates: Partial<Invoice>): Promise<void> {
// Update invoice fields
},
async list(filter?: InvoiceFilter): Promise<Invoice[]> {
// List invoices with optional filtering
},
};This makes it straightforward to use PostgreSQL, MySQL, Redis, or any other storage backend your application already uses.