Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.56 KB

002-lnx.md

File metadata and controls

47 lines (37 loc) · 1.56 KB

Endpoints

  • create quote
    • fiat to btc: supply base currency and ln invoice, return quote id
    • btc to fiat: supply quote currency and amount, return ln invoice
  • create order: supply quote id; only used when converting from fiat to btc

Fiat to Bitcoin

When converting fiat to Bitcoin, the Lightning Invoice to paid must be supplied along with the currency that is being converted. With this information, LNX will compute how much of that currency will be deducted from Core's balance.

sequenceDiagram
    Participant Core
    Participant LNX
    Participant Lightning Network
    Core->>LNX: LN invoice & Fiat currency
    LNX->>LNX: Generates quote
    LNX-->>Core: Quote
    opt Approve
        Core->>LNX: Create order from quote
        LNX->>Lightning Network: Pays LN Invoice
        LNX-->>Core: Webhook
    end
Loading

Bitcoin to Fiat

When converting Bitcoin to fiat, LNX must receive what fiat currency to convert to and the amount of that fiat currency to target. LNX returns an LN invoice, and no longer a quote record since the LN invoice is the quote.

sequenceDiagram
    Participant Core
    Participant LNX
    Core->>LNX: Target fiat currency and amount
    LNX-->>Core: LN Invoice
    opt LN Invoice is paid
        LNX->>LNX: Updates Core's balance
        LNX-->>Core: Webhook
    end
Loading

Balance

Because there is no real-time settlement in fiat that can be done with reasonable cost, a ledger is kept on LNX to keep track of Core's balance.

This is useful for reconciliation, whether or not LNX is run as the same entity as Core.