Extension: Cash Provider (ATM liquidity funding) #15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implement a Lightning.Pub extension that tracks cash liquidity providers for ATMs. Providers physically fund ATM cartridges with fiat and receive BTC as customers do cash-out transactions. The machine tracks how much it owes each provider and settles in BTC automatically.
This replaces the LNbits
satmachineadminDCA system with a Nostr-native approach — no SSH tunnels, no database polling, no separate admin/client extensions.How It Works
Provider funds the ATM
Customer does cash-out (sells BTC for cash)
Multiple providers
Proportional distribution when cash-out happens. If provider A has $3,000 remaining and provider B has $2,000 remaining, a $100 cash-out settles 60% to A and 40% to B.
Data Model
RPC Methods
Provider methods (auth: user pubkey)
Operator methods (auth: admin)
ExtensionContext API Usage
registerMethod()onPaymentReceived()payInvoice()sendEncryptedDM()getDatabase()onNostrEvent()log()Provider Dashboard (via RPC)
Providers query their balance from any Nostr client. Responses are NIP-44 encrypted — only the provider sees their data.
Commission Integration
Commission calculation ties to two other systems:
The cash provider extension owns the settlement logic: after commission is extracted and split, the remaining BTC goes to providers proportionally.
Nostr Transport
All communication uses existing Lightning.Pub extension RPC (kind 21000):
Exception: the extension subscribes to kind 30079 (transaction records) from the ATM via
onNostrEvent()to detect when cash-outs happen.Key Differences from LNbits satmachineadmin
fundMachine+confirmDepositRPCpayInvoice()via ExtensionContextComplexity
MEDIUM — ~2000-3000 lines TypeScript. The commission math and proportional distribution are well-defined. The main complexity is the settlement state machine (funding → deposit → partial settlements → fully settled).
Related Issues
Enhancement: Per-provider commission rates
Each cash provider should be able to set their own desired commission rate when funding a machine. For example:
When a customer does a cash-out, each provider's share of the BTC settlement has their own commission deducted — not a flat rate for all providers.
Data model change
Add
commission_ratetoCashFunding:Settlement calculation
UX
Provider specifies their rate in the
fundMachinecall:This creates a competitive dynamic — providers who accept lower commission are more attractive to operators, while providers who want higher margins can set their own price. The operator can also set a minimum/maximum commission range per machine to keep rates reasonable.