Skip to content

Conversation

@krrish-sehgal
Copy link
Contributor

fixes: #1372

Add Database Storage for BOLT12 Offers

Solution Implemented

Database Layer

  • New offers table with proper schema:
    • offer_id: Unique identifier (currently SHA256 hash, future: extracted from BOLT12)
    • offer_string: Complete BOLT12 offer string
    • description: Human-readable description
    • created_at/updated_at: Timestamps
  • Database migration (202509271400_create_offers_table) with proper rollback
  • Indexes on offer_id and created_at for performance

API Layer

  • Enhanced MakeOffer: Automatically stores offer details when created
  • New GetOffers: Retrieves all stored offers from database
  • Error handling: Graceful fallback if storage fails (doesn't break offer creation)

HTTP Layer

  • New endpoint: GET /api/offers to list all stored offers
  • Authentication: Uses existing read-only API group (requires JWT)

Models

  • New Offer struct in db/models.go with GORM tags
  • Interface update: Added GetOffers to API interface

Next Steps

  1. BOLT12 Parsing: Replace SHA256 hash with actual offer_id extraction from BOLT12 offer string
  2. Transaction Linking: Update payment flow to reference stored offer_id in transaction metadata
  3. Frontend UI: Add offers management page to display offer history

Demo:

Screen.Recording.2025-09-27.at.10.51.37.PM.mov

@krrish-sehgal
Copy link
Contributor Author

@rolznz , I believe my implmentation here is a little vague and I would appreciate any help understanding the deliverables for this issue/PR. Currently the offer_id from the transaction metadata is not moved , cz transactions are not getting linked to the table, I am working on understanding it further , but let me know how does this much implementation looks(which just stored the offer when a user makes one!

Thanks!

@rolznz
Copy link
Contributor

rolznz commented Sep 28, 2025

@krrish-sehgal thanks for the PR. Further BOLT12 support has not been prioritized by the Alby Team yet, so we might not get to this immediately unfortunately.

Please do ask on larger issues before picking them up.

@krrish-sehgal
Copy link
Contributor Author

@rolznz , that's okay! I'll make sure to check in ahead from next time.
Thanks for informing!

@rolznz rolznz marked this pull request as draft September 30, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offers table + move offer_id from transaction metadata to proper column

2 participants