Skip to content

feat(magma,lndg): migrate to modern Amboss Magma GraphQL API and add test suites - #44

Open
TrezorHannes wants to merge 5 commits into
mainfrom
feat/magma-api-migration-and-tests
Open

feat(magma,lndg): migrate to modern Amboss Magma GraphQL API and add test suites#44
TrezorHannes wants to merge 5 commits into
mainfrom
feat/magma-api-migration-and-tests

Conversation

@TrezorHannes

Copy link
Copy Markdown
Owner

Summary of Changes

1. Amboss Magma API Migration

  • Migrated Magma/magma_sale_process.py, Magma/magma_market_fee.py, and LNDg/amboss_pull.py from legacy monolithic endpoints to the dedicated https://magma.amboss.tech/graphql and https://api.amboss.space/graphql endpoints.
  • Introspected and live-validated exact GraphQL schemas:
    • Query: market.offer.offers (SimpleMarketOffer with node { pubkey, alias }, total_amount, locked_amount, and fee details).
    • Query: user.market.orders.sales and user.market.orders.purchases using OrderInput and SimpleMarketOrder fields.
    • Query: user.market.orders.get_order(order_id: ...) with full MarketOrder and promises.
    • Mutations: SellerAcceptOrdersInput!, SellerRejectOrdersInput!, SellerAddTransactionInput!, CreateOfferInput!, UpdateOfferInput!, ToggleOfferInput!.

2. Deterministic Mathematical SCID Fallback

  • Implemented mathematical bit-shift conversion in LNDg/amboss_pull.py ((block << 40) | (tx << 16) | out) ensuring channel clustering succeeds even during Amboss Space API downtime.

3. Unit Test Suites & CI/CD

  • Added comprehensive pytest suites:
    • tests/Magma/test_magma_sale_process.py (17 tests)
    • tests/Magma/test_magma_market_fee.py (8 tests)
    • tests/LNDg/test_amboss_pull.py (9 tests)
    • tests/test_fee_adjuster.py (4 tests)
  • Total tests passing locally: 38 / 38.
  • Updated .github/workflows/tests.yml matrix for Python 3.10, 3.11, and 3.12.

4. Architecture & Documentation

  • Added .agents/agents.md documenting script architecture and API mappings.
  • Overhauled and restructured README.md.

@TrezorHannes TrezorHannes added documentation Improvements or additions to documentation enhancement New feature or request python Pull requests that update python code labels Aug 27, 2026
@TrezorHannes TrezorHannes self-assigned this Aug 27, 2026
…suites

- Migrated magma_sale_process.py and magma_market_fee.py to target https://magma.amboss.tech/graphql
- Replaced legacy queries/mutations with user.market.orders.sales, market.order.seller.accept/reject/add_transaction, and market.offer.offers/create/update/toggle
- Added extract_order_info and extract_market_offer_info normalizers supporting nested SatoshiValue objects with backward compatibility
- Expanded unit test suites for magma_sale_process and magma_market_fee with full mock coverage
- Updated GitHub Actions CI test workflow with Python 3.10/3.11/3.12 matrix
- Added .agents/agents.md architecture guide and overhauled README.md

Tests passing: 29/29
…L schema

- Verified schema directly against live https://magma.amboss.tech/graphql endpoint
- Adjusted GetPublicOffers to query SimpleMarketOffer node, total_amount, and locked_amount
- Adjusted GetSales to use OrderInput and SimpleMarketOrder fields
- Corrected mutation input types to SellerAcceptOrdersInput and SellerRejectOrdersInput
- Updated unit test suites to assert live-validated field shapes

Tests passing: 29/29
…SCID fallback

- Migrated Magma orders query from legacy monolithic getUser.market.offer_orders to https://magma.amboss.tech/graphql (sales and purchases)
- Maintained https://api.amboss.space/graphql for getEdgeInfoBatch bulk channel ID conversions
- Implemented deterministic mathematical bit-shift conversion fallback for Lightning SCIDs (block << 40 | tx << 16 | out)
- Refactored into modular, testable units with robust error handling and fail-safe file persistence
- Added complete unit test suite in tests/LNDg/test_amboss_pull.py

Tests passing: 38/38
@TrezorHannes
TrezorHannes force-pushed the feat/magma-api-migration-and-tests branch from f0ca566 to a6d8f62 Compare August 27, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant