Add outgoing payments API and frontend#1
Merged
martinsaposnic merged 3 commits intomasterfrom Mar 30, 2026
Merged
Conversation
Add REST endpoints to list and query outgoing payments (on-chain and
Lightning), with immediate visibility for on-chain sends before chain
sync picks them up.
API:
- GET /payments/outgoing - list outgoing payments with pagination
- GET /payments/outgoing/{payment_id} - get single outgoing payment
- Both are read-only (work with either auth tier)
- Response includes kind (onchain with txid, or lightning with
payment_hash), status, amount, fee, and timestamp
- Auto-documented via OpenAPI at /scalar
On-chain send tracking:
- New mdk_outgoing_sends SQLite table stores txid, address, amount,
and timestamp immediately when sendtoaddress returns
- Outgoing list merges LDK payment store with local records,
deduplicating by txid, so sends appear instantly as PENDING
before LDK chain sync confirms them
Frontend (wallet.html):
- Outgoing Payments section added to Payments tab with pagination
- Columns: Status, Type, Amount, Fee, Updated, ID
- Txid is click-to-copy with hover highlight
- Auto-refreshes after on-chain sends
3aaf38a to
8bb561b
Compare
Flatten response shape to match phoenixd's outgoing payment format: - paymentId, paymentHash, preimage, txId, isPaid, sent, fees, invoice, completedAt, createdAt - Add from/to/all query params to GET /payments/outgoing - Update frontend to use new field names
Verify that: - The outgoing payment appears immediately after send (before chain sync) - The txid and amount match the send request - After confirmation, isPaid is true with fees and completedAt set
amackillop
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability to list and track outgoing payments (on-chain sends) through both the REST API and the demo wallet frontend.
Problem
After calling
POST /sendtoaddress, the only feedback was the TXID string in the response. There was no way to:Additionally, LDK's internal payment store doesn't register on-chain sends until the next chain sync cycle, meaning there was a gap between "transaction broadcast" and "transaction visible" - sometimes several minutes on signet/mainnet.
Solution
New API endpoints (read-only, both auth tiers):
GET /payments/outgoing- List all outgoing payments withlimit/offsetpagination. Returns on-chain sends and any outbound Lightning payments.GET /payments/outgoing/{payment_id}- Get a single outgoing payment by LDK payment ID.Both are auto-documented at
/scalar(OpenAPI 3.1).Response shape:
{ "id": "hex-encoded payment id", "kind": { "onchain": { "txid": "..." } }, "status": "pending" | "succeeded" | "failed", "amountSat": 1000, "feeSat": 143, "updatedAt": 1774888707 }For Lightning outbound payments,
kindwould be{ "lightning": { "paymentHash": "..." } }.Immediate visibility for on-chain sends:
A new
mdk_outgoing_sendsSQLite table stores the txid, address, amount, and timestamp immediately whensendtoaddressreturns. The outgoing list merges LDK's payment store with these local records (deduplicating by txid), so sends appear instantly as PENDING before LDK chain sync confirms them.Frontend (wallet.html):
Files changed
src/types.rsOutgoingPaymentResponse,OutgoingPaymentKind,OutgoingPaymentStatus,ListOutgoingPaymentsRequesttypessrc/api/mod.rslist_outgoing_paymentsandget_outgoing_paymentsrc/api/invoices.rshandle_list_outgoing_payments,handle_get_outgoing_payment, andpayment_to_outgoingconversion logicsrc/api/onchain.rshandle_send_to_addressnow stores the send inmdk_outgoing_sendsimmediately after broadcastsrc/store/invoice_metadata.rsmdk_outgoing_sendstable,OutgoingSendRecordstruct,insert_outgoing_sendandlist_outgoing_sendsmethodswallet.htmlDesign decisions
CREATE TABLE IF NOT EXISTSfor idempotent schema creation.Test plan
cargo build --features demopassesGET /payments/outgoingreturns correct data