Skip to content

fix(balance): add Decred support#140

Open
oritwoen wants to merge 1 commit intomainfrom
fix/decred-balance
Open

fix(balance): add Decred support#140
oritwoen wants to merge 1 commit intomainfrom
fix/decred-balance

Conversation

@oritwoen
Copy link
Owner

Summary

This finishes the remaining Decred half of #117.

  • add Decred balance fetching via dcrdata totals endpoint
  • map dcrdata invalid-address responses to boha's existing InvalidAddress error
  • cover the new path with ignored live tests for a known address and an invalid address

Verification

  • cargo test --all-features dcr -- --ignored
  • cargo test --all-features
  • cargo fmt --check
  • cargo clippy --all-features -- -D warnings
  • cubic review
  • coderabbit review (interactive TUI launched, no non-interactive verdict available here)

Closes #117.

@oritwoen oritwoen self-assigned this Mar 24, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Adding support for a new blockchain (Decred) involves external API integration and business logic changes that require human validation.

Architecture diagram
sequenceDiagram
    participant C as Caller
    participant B as balance::fetch
    participant D as dcrdata API (External)

    C->>B: fetch(address, Chain::Decred)
    
    B->>D: NEW: GET /api/address/{address}/totals
    
    alt Success (200 OK)
        D-->>B: { dcr_unspent: f64 }
        B->>B: NEW: Convert DCR to atomic units (f64 * 10^8)
        B-->>C: Ok(Balance)
    else Invalid Address (400 or 422)
        D-->>B: Error Status
        Note over B: CHANGED: is_invalid_address_status() helper
        B-->>C: Err(BalanceError::InvalidAddress)
    else Connection/Server Error
        D-->>B: Request Failure
        B-->>C: Err(BalanceError::Request)
    end

    Note over B,D: Also updates fetch_mempool_compatible to use 422 check
Loading

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.

Balance fetching for Litecoin and Decred

1 participant