Skip to content

feat: trigger fiat payout to Stellar Anchors (#943) - #1001

Closed
pixels26 wants to merge 7 commits into
Fracverse:masterfrom
pixels26:trigger-fiat-payout
Closed

feat: trigger fiat payout to Stellar Anchors (#943)#1001
pixels26 wants to merge 7 commits into
Fracverse:masterfrom
pixels26:trigger-fiat-payout

Conversation

@pixels26

Copy link
Copy Markdown
Contributor

Summary

Trigger fiat payout to Stellar Anchors** by replacing the stub AnchorRegistry with real HTTP calls to Stellar Anchor API endpoints.
Close #943

Changes

Backend — Anchor API Integration (backend/src/stellar_anchor.rs)

  • AnchorRegistry::create_payout() — sends POST {ANCHOR_API_URL}/transactions with SEP-31-style payload (amount, asset_code, destination_asset, beneficiary bank details). Parses response for exchange rate, fiat amount, and anchor fee. Falls back to simulated payout when API is unconfigured.
  • AnchorRegistry::get_payout() — sends GET {ANCHOR_API_URL}/transactions/{id} to retrieve payout status.
  • AnchorRegistry::list_payouts() — sends GET {ANCHOR_API_URL}/transactions with optional sender_id filter.
  • Added AnchorError enum with Http, Api, NotConfigured, NotFound, InvalidResponse variants.
  • Status mapping handles pending, processing/in_progress, completed/success, failed/error/rejected.

Configuration

  • backend/src/config.rs — added anchor_api_url and anchor_api_key fields.
  • backend/.env.example — added ANCHOR_API_URL and ANCHOR_API_KEY env vars.

Database Migration

  • backend/migrations/20260726000000_add_anchor_payout_id.up.sql — adds nullable anchor_payout_id TEXT column to payouts table with index.
  • backend/migrations/20260726000000_add_anchor_payout_id.down.sql — reverses the migration.

Payout Flow (backend/src/api.rs)

  • trigger_payout handler now calls state.anchor.create_payout(req).await and stores the returned anchor payout ID in the payouts table.
  • PayoutRow now includes anchor_payout_id: Option<String> in responses.
  • get_anchor_payouts endpoint includes anchor_payout_id in results.

Tests & Setup

  • main.rs, api_tests.rs, kyc_webhook_test.rs updated to pass config to new AnchorRegistry::new(api_url, api_key) constructor.

Usage

Set these environment variables to connect to a Stellar Anchor:

ANCHOR_API_URL=https://anchor.example.com/api
ANCHOR_API_KEY=your-api-key

When ANCHOR_API_URL is unset, the system falls back to simulated payouts (development mode).

@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@pixels26 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@ONEONUORA

Copy link
Copy Markdown
Contributor

@pixels26
Run cargo fmt --all -- --check and clippy

@ONEONUORA

Copy link
Copy Markdown
Contributor

@pixels26
Update on this PR
You will be unassigned at the end of today

@pixels26

Copy link
Copy Markdown
Contributor Author

@ONEONUORA please check now, my apologies for the delay

@ONEONUORA

Copy link
Copy Markdown
Contributor

@pixels26
Run cargo fmt --all -- --check

@pixels26

Copy link
Copy Markdown
Contributor Author

on it now

@pixels26

Copy link
Copy Markdown
Contributor Author

please check @ONEONUORA

@ONEONUORA

Copy link
Copy Markdown
Contributor

@pixels26
Run cargo clippy --all-targets --all-features -- -D warnings

pixels26 added 5 commits July 29, 2026 06:52
- Implement AnchorRegistry with real HTTP calls to anchor API endpoints
  (POST /transactions, GET /transactions/:id, GET /transactions)
- Add ANCHOR_API_URL and ANCHOR_API_KEY configuration
- Add anchor_payout_id column to payouts table for tracking anchor refs
- Update trigger_payout handler to call anchor API and store returned ID
- Add proper error types (AnchorError) and status mapping
- Fall back to simulated payout when anchor API is not configured
- Update tests and main.rs for new AnchorRegistry constructor
@pixels26
pixels26 force-pushed the trigger-fiat-payout branch from 9bf2d7e to 8ab01e4 Compare July 29, 2026 05:54
@pixels26

Copy link
Copy Markdown
Contributor Author

@ONEONUORA please check now

@ONEONUORA

Copy link
Copy Markdown
Contributor

@pixels26
Run cargo clippy --all-targets --all-features -- -D warnings

@pixels26

Copy link
Copy Markdown
Contributor Author

please check

@ONEONUORA

Copy link
Copy Markdown
Contributor

@pixels26
Run cargo clippy --all-targets --all-features -- -D warnings

@pixels26

Copy link
Copy Markdown
Contributor Author

i'm fixing now

@pixels26

Copy link
Copy Markdown
Contributor Author

@ONEONUORA

@ONEONUORA

Copy link
Copy Markdown
Contributor

@pixels26
Run cargo fmt --all -- --check
also run clippy

@pixels26 pixels26 closed this Jul 29, 2026
@pixels26
pixels26 deleted the trigger-fiat-payout branch July 29, 2026 08:27
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.

[Backend] Issue #34: Trigger Fiat payout to Stellar Anchors

2 participants