Skip to content

[CT-04] Align Stellar anchoring strategy between NestJS backend and Rust verifier #857

Description

@mftee

Overview

The NestJS backend (backend/src/stellar/stellar.service.ts) anchors document hashes using Stellar's ManageData operation and reads them via account.data_attr. The Rust microservice (contract/src/stellar.rs) currently reads via the memo field of a transaction. These two approaches are mutually incompatible — a document anchored by the NestJS backend cannot be verified by the Rust verifier, and vice versa.

Background

NestJS writes: ManageData op with key "doc_" + hash[:58], stored in account.data_attr
Rust reads: transaction memo field via Horizon /transactions endpoint

Files involved:

  • backend/src/stellar/stellar.service.tsanchorHash() and verifyHash() (NestJS)
  • contract/src/stellar.rsStellarClient.verify_hash() (Rust)

Decision needed: Pick one canonical approach for both services. The recommended standard is the ManageData approach (used by NestJS) because:

  • It is account-scoped (data survives independent of transaction lookup)
  • It supports updates and revocations (via subsequent ManageData calls)
  • It is the more commonly used pattern for on-chain metadata

Work required:

  1. Update contract/src/stellar.rs verify_hash() to read from account.data_attr instead of memo
  2. Update GET /verify/:hash response to match the NestJS verification record format
  3. Ensure GET /verify/:hash/history reads all ManageData transfer entries (CT-03)
  4. Add a migration note in the README if existing testnet anchors used the memo approach

Acceptance Criteria

  • Both NestJS and Rust write and read Stellar data using the ManageData/data_attr approach
  • A document anchored by the NestJS POST /api/documents/:id/verify can be verified by the Rust GET /verify/:hash
  • A document anchored by the Rust POST /submit (CT-01) can be verified by GET /api/documents/:id/verification in NestJS
  • The old memo-based reading code in contract/src/stellar.rs is removed
  • GET /verify/:hash/history in Rust returns transfer records written by the NestJS transfer endpoint (or Rust CT-03)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions