Overview
The POST /submit endpoint in contract/src/lib.rs always returns 400 Bad Request with the body "Submit not yet implemented". This is the core function of the Rust microservice — anchoring a document hash to Stellar using a manageData operation. Without it, the Rust service has no production functionality.
Background
File: contract/src/stellar.rs — StellarClient struct, which already has verify_hash() and submit_transaction() as stubs.
Files to modify:
contract/src/lib.rs — submit_handler() function (currently returns 400)
contract/src/stellar.rs — StellarClient.anchor_hash() method (to be implemented)
Implementation approach:
- Parse the request body:
{ hash: string, publicKey: string }
- Build a Stellar transaction with a
ManageData operation:
- Key:
"doc_" + &hash[..58] (max 64 bytes, matching NestJS buildDataKey())
- Value: the full hash as bytes
- Sign with the service's Stellar secret key (
STELLAR_SECRET_KEY env var)
- Submit to Stellar Horizon (
stellar_sdk::Server.submit_transaction())
- On success: cache the result in Redis (
stellar:verify:{hash}) and return { txHash, ledger, anchoredAt }
- On Stellar error: return
502 with the Horizon error detail
Stellar SDK: Use the stellar-sdk Rust crate or reqwest-based direct Horizon API calls.
Acceptance Criteria
Overview
The
POST /submitendpoint incontract/src/lib.rsalways returns400 Bad Requestwith the body"Submit not yet implemented". This is the core function of the Rust microservice — anchoring a document hash to Stellar using amanageDataoperation. Without it, the Rust service has no production functionality.Background
File:
contract/src/stellar.rs—StellarClientstruct, which already hasverify_hash()andsubmit_transaction()as stubs.Files to modify:
contract/src/lib.rs—submit_handler()function (currently returns 400)contract/src/stellar.rs—StellarClient.anchor_hash()method (to be implemented)Implementation approach:
{ hash: string, publicKey: string }ManageDataoperation:"doc_" + &hash[..58](max 64 bytes, matching NestJSbuildDataKey())STELLAR_SECRET_KEYenv var)stellar_sdk::Server.submit_transaction())stellar:verify:{hash}) and return{ txHash, ledger, anchoredAt }502with the Horizon error detailStellar SDK: Use the
stellar-sdkRust crate orreqwest-based direct Horizon API calls.Acceptance Criteria
POST /submitwith a valid hash and public key returns{ txHash, ledger, anchoredAt }on successManageDatakey format matches exactly what NestJSbuildDataKey()produces (doc_+ first 58 chars of hash)200(idempotent)400for missing or malformed hash502with Horizon error details on Stellar network failure