Skip to content

Compare federation UTXOs with guardian wallet claims - #116

Open
bansalayush247 wants to merge 21 commits into
fedimint:masterfrom
bansalayush247:feature/federation-utxo-claims
Open

bansalayush247 wants to merge 21 commits into
fedimint:masterfrom
bansalayush247:feature/federation-utxo-claims

Conversation

@bansalayush247

Copy link
Copy Markdown
Member

Summary

Adds guardian wallet UTXO claim data to the federation UTXO API and surfaces observer-vs-guardian disagreements in the federation detail page.

Changes

  • Extend /federations/:id/utxos to return:
    • observer reconstructed UTXOs
    • guardian wallet summary claims
    • detected disagreements
  • Fetch wallet summaries from each guardian through the wallet module API.
  • Compare observed UTXOs against successful guardian claims for:
    • missing guardian claims
    • amount mismatches
    • guardian-only UTXOs
    • disagreement between successful guardians
  • Add frontend types and API service support for the expanded response.
  • Display guardian claim counts, claimed UTXO totals, claim states, and disagreement details in the UTXO tab.

Testing

  • Not run locally.

- Introduced  and  methods in the API service to retrieve gateway information based on federation ID and invite code.
- Updated API types to include , , and  for better structure and type safety.

feat(database): create gateway_poll_snapshots table

- Added a new table  to store snapshots of gateway visibility over time, including fields for federation ID, gateway ID, poll time, and visibility status.

feat(federation): implement gateway fetching logic

- Implemented  to aggregate gateway information from federation peers.
- Enhanced the  to periodically poll and store gateway data, including metrics for activity and uptime.

fix(federation): update gateway listing to include metrics

- Modified  to return additional metrics such as activity and uptime for specified time windows.
- Improved error handling and logging for gateway fetching operations.

refactor(federation): adjust module visibility

- Changed the visibility of the  module to  to restrict access to internal components only.
Port software-version tracking and React badges from 5ff0b7a. Preserve the optimized guardian lookup and gateway schema; include the nullable version column in v10 for fresh installs. Existing version-10 databases require the column to be present or added manually.
@bansalayush247
bansalayush247 force-pushed the feature/federation-utxo-claims branch 2 times, most recently from f662154 to 5aa71a4 Compare September 11, 2026 11:19
@bansalayush247
bansalayush247 force-pushed the feature/federation-utxo-claims branch from f24e269 to 19f4cd1 Compare September 11, 2026 13:27
- Updated SQL schema to improve wallet withdrawal address checks.
- Enhanced federation UTXO retrieval to exclude completed peg-out recipients.
- Introduced normalization of observed UTXO outpoints to handle legacy formats.
- Implemented background task for reconciling wallet UTXOs every 15 minutes.
- Added methods to repair incomplete wallet history and reconcile spent outpoints.
- Improved logging for missing federation sessions and UTXO reconciliation results.
- Refactored wallet withdrawal transaction recording to streamline input and output handling.
- Added tests for outpoint normalization and legacy handling.
- Updated  to clear observed UTXOs if wallet reconstruction is incomplete.
- Introduced  to enrich observed UTXOs with on-chain data and handle guardian claims.
- Added caching mechanism for Bitcoin UTXO verifications, including a new table .
- Implemented background task for refreshing Bitcoin verification cache and pruning stale entries.
- Modified SQL schema to support new UTXO verification logic and added recipient handling for wallet withdrawals.
- Bump Fedimint dependencies to version 0.12.0 in Cargo.toml.
- Remove on-chain resolution fields from FederationUtxo and GuardianClaimedUtxo structures in fmo_api_types.
- Refactor FederationDetail component in React to update UTXO states and views, changing terminology from 'unverified' to 'pending' and adjusting the logic for displaying UTXO statuses.
- Remove Bitcoin verification logic from the server, including related database schema and functions in federation modules.
- Clean up UTXO disagreement checks by removing on-chain resolution comparisons.
- Update tests to reflect the removal of on-chain verification logic and adjust assertions accordingly.
@bansalayush247
bansalayush247 marked this pull request as ready for review September 23, 2026 14:29
@bansalayush247

Copy link
Copy Markdown
Member Author

Update: final UTXO reconciliation approach

This PR now adds federation UTXO reconciliation between the observer’s reconstructed wallet inventory and live guardian wallet-summary claims.

Changes

  • Adds a safe UTXO reconstruction migration:

    • normalizes historical withdrawal transaction-id byte order
    • rebuilds the utxos materialized view from peg-ins and confidently identified change outputs
    • leaves ambiguous outputs unclassified rather than guessing ownership
    • resumes reconstruction incrementally per federation
  • Extends GET /federations/:id/utxos with:

    • reconstructed observer UTXOs
    • live wallet-summary claims from each guardian
    • detected reconciliation disagreements
  • Detects:

    • observer-only UTXOs
    • guardian-only UTXOs
    • observer/guardian amount mismatches
    • conflicting guardian claims
  • Adds a UTXO UI with clear states:

    • Verified — observer history and all responding guardians agree
    • Pending — wallet reconstruction or guardian data is still unavailable
    • Mismatch — responding guardian data conflicts with observer reconstruction

Safety

Recipient/change classification requires one unique match across federation, address, amount, and event order. Ambiguous withdrawals are intentionally not treated as federation-owned change.

Guardian wallet summaries are fetched live and are not persisted as current truth. UTXO status does not depend on external Bitcoin explorer or Mempool availability.

Testing

  • cargo clippy -p fmo_server -- -D warnings
  • Focused UTXO reconciliation tests: 6 passing
  • git diff --check

UI

image

- Removed  from  interface.
- Expanded  status options to include 'lagging' and added .
- Updated SQL schema to remove unnecessary columns and tables related to wallet withdrawal.
- Improved UTXO disagreement logic to account for new guardian claim statuses and session counts.
- Introduced caching for guardian wallet summaries to reduce redundant requests.
- Added tests for new guardian claim handling and lagging status detection.
- Updated the FederationUtxosResponse to include threshold and guardian reports.
- Replaced GuardianUtxoClaim with GuardianUtxoReport to provide detailed output discrepancies.
- Introduced UtxoComparisonRow for better representation of UTXO states and discrepancies.
- Implemented on-chain output checks with caching and concurrency control.
- Removed obsolete database columns and tables related to withdrawal addresses.
- Enhanced the observer's logic to handle UTXO comparisons and disagreements more effectively.

This branch has not been deployed

No deployments
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.

1 participant