CPG-Core FSD Account

FSD — Core

A. Document controlA. Kiểm soát tài liệu

Doc IDCPG-FSD-CPG-Core_FSD_Account
VersionPhiên bản1.3
StatusTrạng tháiDraft
OwnerCPG BA / Architecture
AudienceĐối tượngBackend, QA, Product, Security, Load-test engineering
ClassificationPhân loạiInternal
Effective dateNgày hiệu lực01/12/2026
Related docs Core Index · BR/NFR Catalog

B. Version historyB. Lịch sử phiên bản

Version Date Author ChangesThay đổi
1.0 25/07/2026 Khoa Trinh Version 1.0, Initial FSD-Account (Doc02)
1.1 14/08/2026 Khoa Trinh Version 1.1: align with A4 v1.1: no xpub; TRON HD is one master seed per merchant (not one platform-wide root); uniqueness and derivation counter scoped per merchant; watch-only derive returns address + path alias only. (See highlight changes)
1.2 20/08/2026 Khoa Trinh Version 1.2: VA requires hot_wallet_id; freeze idempotency/natural-key, HTTP error mapping, issuance pause, VA re-activate, Sync HW watch default, NFR. See Changes in v1.2.
1.3 16/11/2026 Khoa Trinh Version 1.3: post-create HW/BW inactive for merchant compliance; merchant JWT must not activate HW to active; FlyPay/internal activate after ticket. See Changes in v1.3.

C. Table of contentsC. Mục lục

D. ContentD. Nội dung

1. Scope

The Account module is the sole owner of custody address issuance and the BR-02 address registry for CPG. It answers: which on-chain address belongs to which virtual account or hot wallet, on which chain, under which merchant, uniquely, without private keys in application storage, and with a Sync-consumable watched-address map.

1.1 In scope

  • Issue unique Tier 1 Virtual Account deposit addresses for tron (Phase 1) and bsc | eth | polygon (Phase 2)
  • Own and persist the BR-02 address registry (sequential derivation_index per (chain, merchant_id, purpose); DB uniqueness)
  • Create / manage Tier 2 Hot Wallets (EVM ForwarderV4 as-is; TRON dedicated hot-wallet addresses)
  • Tier 4 Beneficiary CRUD (merchant payout address binding + chain validation)
  • Bind ledger account metadata: treasury:virtual:{chain}:{va_id}, treasury:hot:{chain}:{hot_id}
  • Publish watched-address map for sync-service (internal API)
  • Activate / deactivate VA watch status without address reuse
  • Chain config for tron|bsc|eth|polygon × mainnet|testnet; assets USDT/6, USDC/6
  • Idempotent issuance with stable client keys
  • Tier 3 Warm/Cold addresses as config/metadata references only (no treasury transfer APIs)

1.5 Merchant compliance activation (v1.3)

  • After successful HW issuance (address + registry), merchant-visible status remains inactive for compliance until FlyPay Support resolves an activation ticket.
  • account-service exposes an internal activate that is idempotent on ticket_id / resource id. Merchant-facing activate-to-active is forbidden (403).
  • Beneficiary wallets created for merchants start inactive until a distinct merchant approver confirms (maker-checker); Core persists created_by for enforcement.

1.2 Out of scope

  • Ledger journal, Numscript templates, over-book prevention (FSD-Ledger)
  • Block scanning, finality, reorg un-credit (FSD-Sync)
  • MPC/HSM key ceremonies, Shamir DR, private-key material (A4)
  • Warm/Cold treasury sweeps, multisig governance execution, settlement signing
  • Merchant Portal / CRM UI screens (portal FSDs consume these APIs)
  • Smart-contract implementation details beyond predict/deploy orchestration
  • KYT, sweep job execution, settlement batching (downstream money-path services)

1.3 Actors (S2S)

Actor Role
account-service Issues VA/HW; owns registry; serves watched map; binds ledger metadata
merchant-service Fee schedules, fee wallets, operator/settlement/signer config for Forwarder init
ledger-service Authoritative chart accounts / metadata (`treasury:virtual
sync-service Pulls watched addresses; never issues
Custody adapter (MPC / HSM) Derive/predict addresses inside the vault from that merchant’s HD master; returns address + path alias only; never returns seed, xprv, xpub, or private keys
Platform ops Chain config, pause/deactivate, incident response hooks
Portal / transaction (JWT) Request VA/HW/beneficiary on behalf of merchants
FlyPay Support / CRM (internal) Approve/reject wallet_activation ticket; call internal HW activate

Fig 1: Actor S2S

1.4 Delivery phases

Phase Chains Address model
Phase 1 tron Dedicated Base58 addresses via that merchant’s HD master (m/44'/195'/\<purpose>'/0/\<index>, purpose 0=VA / 1=HW) or MPC address API; one master seed per merchant; off-chain lifecycle. No xpub in account-service.
Phase 2 bsc, eth, polygon VA: CREATE2 predict (VirtualAccountV1); HW: ForwarderV4 CREATE2 + deploy (existing)

Phase 1 acceptance does not depend on Phase 2 code. Shared contracts (registry schema, watched-address API, ledger path binding, error envelope, idempotency) are designed once so Phase 2 plugs in without redesigning TRON.
Custody tier coverage (A3):

Tier In this FSD Notes
1, Virtual Account Yes Issuance + registry + watched map
2, Hot Wallet Yes EVM Forwarder create; TRON dedicated HW
3, Warm / Cold Ref only Store platform treasury address refs in config/metadata; no ops APIs
4, Beneficiary Yes CRUD + validation; merchant holds key

2. Business Requirement

Source Need (summary) Solution location in this FSD
BR-02 / FR9 (FSD-Ledger) Absolute uniqueness of deposit addresses; sequential index; no UUID hash/mod §6.3; FEAT-REG-01; UC-ADR-01
A3 Tier 1 Per-customer VA; funds held until KYT; auto-sweep after approval FEAT-VA-01/02; §3.1
A3 Tier 2 Per-merchant hot wallet for settlement / fee split FEAT-HW-01/02; §3.2
A3 Tier 4 Merchant external payout address FEAT-BEN-01; §3.3
A4 §2 / §8 Hybrid MPC/HSM; TRON HD path; 100k derived addresses; no per-address root keys §6; §8; custody adapter ports
FSD-Sync Internal address map: chain, address, va_id, merchant_id, active FEAT-MAP-01; §7.6
Doc03 S8 account-service authenticates to ledger via Bearer API key §8

2.1 FSD coverage matrix

ID Level Coverage in this FSD
ACC-01 Unique VA issuance (BR-02) HARD FEAT-REG-01; UC-ADR-01; §6.3; 1M synthetic → 0 collisions
ACC-02 TRON VA (Phase 1) HARD FEAT-VA-01; UC-VA-01; HD/MPC derive
ACC-03 EVM VA (Phase 2) HARD (Phase 2) FEAT-VA-02; CREATE2 predict + registry
ACC-04 EVM hot wallet Forwarder HARD FEAT-HW-01; formalize existing flow
ACC-05 TRON hot wallet HARD (Phase 1) FEAT-HW-02; dedicated address via custody adapter
ACC-06 Beneficiary bind HARD FEAT-BEN-01; UC-BEN-01
ACC-07 Watched-address API for Sync HARD FEAT-MAP-01; UC-MAP-01; §7.6
ACC-08 Deactivate without reuse HARD FEAT-ACT-01
ACC-09 Idempotent issue HARD FEAT-IDM-01
ACC-10 No private keys in app DB/logs HARD §6; §8; A4 hybrid; no xpub; one TRON HD master per merchant stays in HSM/MPC
ACC-11 Ledger metadata bind HARD §3.1 / §3.2; `treasury:virtual
ACC-12 Warm/Cold ref only IMPORTANT Config/metadata; out of API scope

2.2 Verified reference anchors

Ref Relevance to Account
A3 §2 Tier summary EVM vs TRON implementation per tier; who holds keys
A3 §5 EVM Forwarder 2-of-3 for SET_BENEFICIARY; TRON off-chain governance before new deposits
A4 §3 / §6.4 Operator/settlement MPC; one TRON HD master per merchant in HSM; address derivation inside the vault (no xpub export)
A4 §11 TRON path m/44'/195'/\<purpose>'/0/\<index> (purpose 0=VA, 1=HW; merchant \= seed alias)
FSD-Ledger §6.3 Registry field contract and issuance algorithm
FSD-Sync §1.3 / §7.11 account-service address map as Sync dependency
account-service as-is POST /api/v1/accounts/crypto/hot-wallets; CREATE2 salt keccak256(merchant_id:service_id:wallet_name)

3. Flow

All address issuance that can receive customer deposits must go through account-service registry before the address is exposed to clients or Sync.
Canonical chain slugs: tron | bsc | eth | polygon.
Network types: mainnet | testnet.
Assets: USDT/6, USDC/6.

3.0 System context


Fig 2: System context

3.1 Issue Virtual Account (Tier 1)

Item Detail
Actor Portal / transaction-service (JWT); ops (internal)
Precondition Merchant + customer (or booking) identifiers valid; chain configured; custody adapter healthy; target Hot Wallet exists, is active, and matches chain/network
Idempotency Idempotency-Key is authoritative. If omitted, natural key (merchant_id, customer_id, blockchain, network_type) returns the existing active VA. A second active VA for the same customer+chain is CONFLICT.

Steps

  1. Validate inbound payload (chain slug, network, merchant/customer IDs, hot_wallet_id). Reject missing/inactive/network-mismatch Hot Wallet with VALIDATION_ERROR.
  2. If an idempotent hit exists → return prior VA (same address); do not allocate a new index. If no Idempotency-Key and an active VA already exists for the natural key → return CONFLICT (do not allocate a second active VA).
  3. Begin DB transaction: resolve merchant_id → merchant_seed_alias (must already exist from that merchant’s TRON HD ceremony); allocate next derivation_index from derivation_counter for (chain, merchant_id, purpose=VA) with row lock.
  4. Phase 1 TRON: call custody adapter DeriveAddress(chain, merchant_seed_alias, purpose=0, derivation_index) for path m/44'/195'/0'/0/\<index>. Adapter derives inside HSM/MPC from that merchant’s HD master and returns address + path alias only. No seed, xprv, or xpub is returned.
  5. Phase 2 EVM: compute CREATE2 salt (product-defined; must be unique per VA intent) and predict VirtualAccountV1 clone address (watch-only predict; deploy may be lazy or eager per product, FSD requires address known and registered before client exposure).
  6. Insert custody_address + virtual_account rows with UNIQUE (chain, address) and UNIQUE (chain, merchant_id, purpose, derivation_index). On unique violation → abort (do not expose address).
  7. Ensure ledger account path exists / metadata bound: treasury:virtual:{chain}:{va_id} via ledger-service (LEDGER_API_KEY).
  8. Commit; set active=true so Sync map includes the address.
  9. Return VA id, address, chain, ledger path to client.
Success Address unique; registry row present; ledger path bound; Sync can see active mapping
Failure Duplicate address → abort; custody timeout → no client exposure; ledger reject → compensating mark / retry metadata (address remains unexposed until bind succeeds per crash policy §3.5); inactive/mismatched Hot Wallet → VALIDATION_ERROR; issuance paused → ISSUANCE_PAUSED

3.2 Create Hot Wallet (Tier 2)

3.2.1 EVM ForwarderV4

Item Detail
Actor Merchant portal / authorized JWT caller
Endpoint POST /api/v1/accounts/crypto/hot-wallets
Salt keccak256(merchant_id:service_id:wallet_name)
Steps Validate EVM beneficiary → load merchant fee/wallet config → predict CREATE2 Forwarder address → deploy clone → verify predicted \== deployed → persist ledger (legacy + optional v2 treasury:hot:{chain}:{id}) → registry row tier=hot

Fee wallets / operator / settlement manager / 2-of-3 signers come from merchant-service config (A3 Tier 2 / A3 §5). Account-service does not perform settlement signing.

3.2.2 TRON dedicated hot wallet (Phase 1)

Item Detail
Actor Merchant portal / ops
Steps Allocate sequential index from counter (chain, merchant_id, purpose=HW) → custody adapter DeriveAddress(..., purpose=1, ...) from that merchant’s HD master → UNIQUE (chain, address) + UNIQUE (chain, merchant_id, purpose, derivation_index) insert tier=hot → bind treasury:hot:tron:{hot_id} → store beneficiary binding for off-chain settlement. No xpub.

No on-chain Forwarder clone on TRON; lifecycle and fee split are off-chain per A3 §5.3.

3.3 Set / rotate Beneficiary (Tier 4)

Item Detail
Actor Merchant (JWT) with permission; ops for emergency
Steps Validate address format for chain (EVM 0x + 40 hex; TRON Base58 T…) → persist beneficiary on hot wallet / merchant service scope → EVM: initiate or record SET_BENEFICIARY governance proposal requirement (2-of-3; A3 §5.1), account-service stores intended beneficiary and proposal status; on-chain apply is governance/ops → TRON: update off-chain config; block acceptance of new deposits against old beneficiary policy until ledger/config ack (A3 §5.3)

Beneficiary keys are merchant-held; CPG never stores beneficiary private keys.

3.4 Deactivate / re-activate Virtual Account

Item Detail
Actor Merchant / ops
Deactivate Set active=false on registry / VA; Sync map excludes address on next refresh; address and derivation_index remain reserved forever (no reuse)
Re-activate POST .../activate for the same va_id only. Address and derivation_index are never reassigned to another customer. New customer never receives a previously issued address.
Note In-flight deposits already observed by Sync continue per Sync/Ledger rules; new watch stops on deactivate

3.5 Crash recovery and ordering

Scenario Policy
Crash after index allocate, before derive Roll back transaction; index not committed
Crash after derive, before UNIQUE insert No client exposure; retry may re-derive same index in new tx
Crash after registry insert, before ledger bind Address not returned to client until ledger bind succeeds; background reconciler completes metadata; Sync may optionally see active=false until bind
Crash after EVM HW deploy, before ledger persist Reconcile by predicted address + deploy tx hash; idempotent ledger create; do not redeploy different salt
Duplicate Idempotency-Key Return original resource; no second index

Rule: Client-visible address ⇒ registry UNIQUE row committed. Prefer: registry commit → ledger bind → activate for Sync → respond.

3.6 Incident pause (A4 §7 hook)

On key-compromise / DR declare: ops sets chain-level or global issuance_paused and/or bulk-deactivates watched flags so Sync stops expanding risk surface. Account-service does not replace on-chain pause(); it coordinates off-chain issuance and watch flags.

Ops uses PUT /internal/v1/issuance-pause. While paused, POST create VA/HW returns HTTP 503 with error.code ISSUANCE_PAUSED. Existing registry rows and Sync map are unchanged unless ops also bulk-deactivates watch flags.

4. Features

4.1 Registry and issuance

FEAT-REG-01 Address registry + sequential index (BR-02 / FR9)

  • Persist registry with UNIQUE (chain, address) and UNIQUE (chain, merchant_id, purpose, derivation_index).
  • Allocate derivation_index via transactional counter (row lock / serial) per (chain, merchant_id, purpose); prohibit UUID hash/mod into BIP-32 space. Do not use a global per-chain index as if one platform HD root existed.
  • Acceptance: Synthetic 1M UUID/account issuances → 0 address collisions; no issue without prior registry confirmation of non-existence.

FEAT-VA-01 TRON Virtual Account issuance (Phase 1)

  • Derive dedicated TRON VA via custody adapter from that merchant’s HD master (path per A4 §11: purpose=0) or MPC address API. No xpub.
  • Bind treasury:virtual:tron:{va_id}; set watched active=true.
  • Acceptance: Issued address is Base58; appears on Sync map; replay with same idempotency key returns same address.

FEAT-VA-02 EVM Virtual Account issuance (Phase 2)

  • Predict CREATE2 VirtualAccountV1 address; register before client exposure.
  • Chains: bsc, eth, polygon.
  • Acceptance: Predicted address matches on-chain clone when deployed; UNIQUE constraints hold across chains independently.

FEAT-IDM-01 Idempotent issue

  • Support Idempotency-Key header on VA/HW create; natural key fallback documented in §3.1. Idempotency-Key is authoritative.
  • Acceptance: Parallel duplicate creates yield one registry row and one address.

4.2 Hot wallet and beneficiary

FEAT-HW-01 EVM Forwarder hot wallet create

  • Formalize existing flow: fee config → predict → deploy → verify → ledger.
  • Salt: keccak256(merchant_id:service_id:wallet_name).
  • Acceptance: Predicted \== deployed; ledger treasury:hot:{chain}:{id} metadata present when v2 enabled; invalid beneficiary → VALIDATION_ERROR.

FEAT-HW-02 TRON hot wallet dedicated address (Phase 1)

  • Provision merchant hot wallet via custody adapter; registry tier=hot; ledger bind.
  • Acceptance: Unique per merchant/service intent; Sync does not watch HW addresses by default (watch_hot=false). VA active=true is always published. HW is included only when watch_hot=true is explicitly set.

FEAT-BEN-01 Beneficiary CRUD + chain validation

  • Create/update/get beneficiary address per hot wallet / merchant service scope.
  • Validate format per chain; persist; surface governance/status fields for EVM.
  • Acceptance: Invalid checksum/format rejected; TRON/EVM cross-chain address rejected; rotation recorded with audit metadata (no secrets).

4.3 Sync map and lifecycle

FEAT-MAP-01 Watched-address publish API

  • Internal paginated API for Sync: chain, address, va_id, merchant_id, active.
  • Acceptance: Only active=true rows returned by default; deactivated addresses drop from default listing; Sync can full-refresh without receiving private keys or derivation seeds.

FEAT-ACT-01 Activate / deactivate without reuse

  • Soft-disable watch; never free derivation_index or address for reassignment.
  • Acceptance: After deactivate, address absent from default Sync map; re-activate allowed only for same va_id via POST .../activate; new customer never receives a previously issued address.

5. Usecases

Detailed use-case catalog for this module is maintained under 08_UC:Catalog use case chi tiết của module này được quản lý tại 08_UC:

6. Data Requirement (Data Model)

beneficiary_wallets

Field Type Required Description
wallet_id String No Beneficiary wallet identifier
merchant_id String Yes Owning merchant identifier
wallet_name String Yes Display name for the wallet
chain String Yes Blockchain slug (e.g. bsc, ethereum, polygon, tron)
network_type String Yes Network class (mainnet / testnet)
creation_type String Yes How the wallet was created (byow / web3auth / system)
wallet_address String Yes On-chain wallet address
status String Yes Beneficiary wallet status (inactive / active / rejected)
active Boolean Yes Whether the record is active for operations
created_at DateTime Yes Created timestamp (UTC)
updated_at DateTime Yes Last updated timestamp (UTC)
created_by_name String No Creator display name
created_by String No Creator user id

custody_addresses

Field Type Required Description
id UUID No Primary key
chain String Yes Blockchain slug (e.g. bsc, ethereum, polygon, tron)
merchant_id String Yes Owning merchant identifier
purpose String Yes Address purpose code (hot / va / custody purpose)
derivation_index Integer Yes HD derivation index used to issue the address
merchant_seed_alias String Yes Merchant custody seed alias
path_alias String Yes Derivation path alias
address String Yes On-chain address
owner_id String Yes Owning resource id (hot wallet / VA)
ledger_account String Yes Ledger account path for this address
network String Yes Network label / chain network
tier String Yes Custody / merchant tier label
watch_hot Boolean Yes Whether Sync should watch this hot address
active Boolean Yes Whether the record is active for operations
created_at DateTime Yes Created timestamp (UTC)

deploy_jobs

Field Type Required Description
id UUID No Primary key
kind String Yes Deploy job kind (va_deploy / related)
owner_id String Yes Owning resource id (hot wallet / VA)
merchant_id String Yes Owning merchant identifier
chain String Yes Blockchain slug (e.g. bsc, ethereum, polygon, tron)
network_type String Yes Network class (mainnet / testnet)
salt_hex String Yes CREATE2 salt (hex)
predicted String Yes Predicted contract / address before confirm
payload JSON Yes Job payload JSON
status String Yes Deploy job status (pending / running / succeeded / failed / cancelled)
attempts Integer Yes Retry attempt count
last_error String Yes Last failure message
tx_hash String Yes Related blockchain transaction hash
next_run_at DateTime Yes Next scheduled run time
locked_until DateTime No Worker lock expiry
created_at DateTime Yes Created timestamp (UTC)
updated_at DateTime Yes Last updated timestamp (UTC)
broadcast_tx_hash String Yes Broadcasted deploy transaction hash

derivation_counters

Field Type Required Description
chain String Yes Blockchain slug (e.g. bsc, ethereum, polygon, tron)
merchant_id String Yes Owning merchant identifier
purpose String Yes Address purpose code (hot / va / custody purpose)
next_index Integer Yes Next derivation index to allocate
updated_at DateTime Yes Last updated timestamp (UTC)

hot_wallets

Field Type Required Description
hot_id String No Hot wallet identifier
merchant_id String Yes Owning merchant identifier
wallet_name String Yes Display name for the wallet
service_id String Yes Payment / product service identifier
chain String Yes Blockchain slug (e.g. bsc, ethereum, polygon, tron)
network_type String Yes Network class (mainnet / testnet)
custody_address_id UUID No FK to custody address registry row
beneficiary_address String Yes Settlement destination address linked to the hot wallet
beneficiary_status String Yes Beneficiary link state (pending / active / rejected)
supported_assets String Yes Supported token symbols (e.g. USDT, USDC)
ledger_id String Yes Ledger instance / chart identifier
status String Yes Hot wallet status (active / inactive)
active Boolean Yes Whether the record is active for operations
created_at DateTime Yes Created timestamp (UTC)
updated_at DateTime Yes Last updated timestamp (UTC)
beneficiary_wallet_id String No Linked beneficiary wallet id
created_by_name String No Creator display name
cobo_wallet_id String No Cobo MPC wallet identifier
deployment_tx_hash String Yes On-chain deployment transaction hash

issuance_pauses

Field Type Required Description
scope String No Pause scope (global or chain)
paused Boolean Yes Issuance pause flag
updated_at DateTime Yes Last updated timestamp (UTC)

merchant_custody_aliases

Field Type Required Description
merchant_id String Yes Owning merchant identifier
chain String Yes Blockchain slug (e.g. bsc, ethereum, polygon, tron)
merchant_seed_alias String Yes Merchant custody seed alias
status String Yes Lifecycle status (active / inactive / domain-specific values)
created_at DateTime Yes Created timestamp (UTC)
updated_at DateTime Yes Last updated timestamp (UTC)

virtual_accounts

Field Type Required Description
va_id String No Virtual account identifier
merchant_id String Yes Owning merchant identifier
customer_id String Yes Merchant’s customer identifier
chain String Yes Blockchain slug (e.g. bsc, ethereum, polygon, tron)
network_type String Yes Network class (mainnet / testnet)
hot_wallet_id String Yes Linked hot wallet id
custody_address_id UUID Yes FK to custody address registry row
supported_assets String Yes Supported token symbols (e.g. USDT, USDC)
idempotency_key String No Client idempotency key for create
status String Yes Virtual account status (active / inactive)
active Boolean Yes Whether the record is active for operations
created_at DateTime Yes Created timestamp (UTC)
created_by_name String No Creator display name
deployment_tx_hash String Yes On-chain deployment transaction hash

Planned product entities (not in migrations through 012)

Entity Status
Payout Account (payout_accounts) Specified in MP/CRM Account FSD v2.3 / v1.2; no table in account-service migrations yet
Refund Account (refund_accounts) Same as Payout Account

7. Endpoints and Payloads

Method Route Description Request Response
GET /health Liveness {} {status, service, timestamp}
POST /api/v1/accounts/crypto/hot-wallets Create Hot Wallet {merchant_id, wallet_name, service_id, blockchain, network_type, beneficiary_address?, beneficiary_wallet_id?, supported_assets[]} {id, merchant_id, wallet_name, account_address, blockchain, network_type, beneficiary_address, beneficiary_wallet_id, beneficiary_status, service_id, supported_assets[], status, created_at, created_by_name, available_amount{}, total_amount{}, settled_amount{}, tx_hash}
GET /api/v1/accounts/crypto/hot-wallets List Hot Wallets {merchant_id?, blockchain?, network_type?, status?, page?, page_size?} (query) {items[], page, page_size, total}
GET /api/v1/accounts/crypto/hot-wallets/{hot_id} Get Hot Wallet {hot_id, merchant_id?} (path/query) {id, merchant_id, wallet_name, account_address, blockchain, network_type, beneficiary_*, service_id, supported_assets[], status, balances{}, tx_hash}
POST /api/v1/accounts/crypto/hot-wallets/{hot_id}/activate Activate Hot Wallet {hot_id, merchant_id?} {hot_id, status, account_address}
POST /api/v1/accounts/crypto/hot-wallets/{hot_id}/deactivate Deactivate Hot Wallet {hot_id, merchant_id?} {hot_id, status, account_address}
PUT /api/v1/accounts/crypto/hot-wallets/{hot_id}/beneficiary Set beneficiary link {beneficiary_address} {hot_id, blockchain, beneficiary_address, status, updated_at}
POST /api/v1/accounts/crypto/beneficiary-wallets Create Beneficiary Wallet {merchant_id, wallet_name, blockchain, network_type, creation_type, wallet_address} {id, wallet_id, merchant_id, wallet_name, wallet_address, blockchain, network_type, creation_type, status, created_by, created_by_name, created_at}
GET /api/v1/accounts/crypto/beneficiary-wallets List Beneficiary Wallets {merchant_id?, blockchain?, network_type?, status?, page?, page_size?} (query) {items[], page, page_size, total}
GET /api/v1/accounts/crypto/beneficiary-wallets/{wallet_id} Get Beneficiary Wallet {wallet_id, merchant_id?} {id, wallet_id, merchant_id, wallet_name, wallet_address, blockchain, network_type, creation_type, status, created_at}
POST /api/v1/accounts/crypto/beneficiary-wallets/{wallet_id}/activate Activate BW {wallet_id, merchant_id?} {wallet_id, status, wallet_address}
POST /api/v1/accounts/crypto/beneficiary-wallets/{wallet_id}/deactivate Deactivate BW {wallet_id, merchant_id?} {wallet_id, status, wallet_address}
POST /api/v1/accounts/crypto/virtual-accounts Create Virtual Account {merchant_id, customer_id, blockchain, network_type, hot_wallet_id, supported_assets[]} + header Idempotency-Key? {va_id, merchant_id, customer_id, account_address, blockchain, network_type, hot_wallet_id, ledger_account, supported_assets[], status, available_amount{}, total_amount{}, created_at, tx_hash}
GET /api/v1/accounts/crypto/virtual-accounts List Virtual Accounts {merchant_id?, customer_id?, blockchain?, network_type?, hot_wallet_id?, status?, page?, page_size?} (query) {items[], page, page_size, total}
GET /api/v1/accounts/crypto/virtual-accounts/{va_id} Get Virtual Account {va_id, merchant_id?} {va_id, merchant_id, customer_id, account_address, blockchain, network_type, hot_wallet_id, supported_assets[], status, balances{}, tx_hash}
POST /api/v1/accounts/crypto/virtual-accounts/{va_id}/activate Activate VA {va_id, merchant_id?} {va_id, status, active, account_address}
POST /api/v1/accounts/crypto/virtual-accounts/{va_id}/deactivate Deactivate VA {va_id, merchant_id?} {va_id, status, active, account_address}
GET /internal/v1/watched-addresses List watched addresses {chain?, cursor?, limit?} (query) {items[{chain, address, va_id, merchant_id, active}], next_cursor, has_more}
PUT /internal/v1/issuance-pause Set issuance pause {paused, chain?} {paused, chain?}
PUT /internal/v1/merchant-custody-aliases Upsert custody alias {merchant_id, chain, merchant_seed_alias} {merchant_id, chain, merchant_seed_alias, status}
POST /internal/v1/merchants/{merchant_id}/cobo-vault Create Cobo vault {merchant_id} {merchant_id, cobo_vault_id, …}
POST /internal/v1/virtual-accounts/{va_id}/deploy Deploy VA {va_id} {va_id, deploy_job_id, status, tx_hash?}

8. Security

8.1 Doc03 application security mapping

Fleet-wide controls: Doc03, Application Security. This FSD does not restate Doc03.

Doc03 area Relevance
Part A trust zones / identity planes Merchant JWT vs admin JWT vs S2S
APPSEC-ID-01 Authenticate public account APIs (JWT)
APPSEC-ID-08 Internal watched-address API authentication
APPSEC-ID-09 Ledger client Bearer API key (pkg/ledgerclient)
APPSEC-ID-13 / 14 Secrets via Vault; no hardcoded keys
APPSEC-ID-15 Stable error envelope
APPSEC-ID-16 Input validation (addresses, enums)
APPSEC-ID-18 request_id on errors
APPSEC-ID-20 No secrets / unnecessary PII in logs
Doc03 S8 account-service Ledger API key caller; business account APIs

8.2 Specific security (Account module)

Control Requirement Notes
AuthN public Merchant/admin JWT via pkg/auth Portal create/list/deactivate
AuthN internal Internal secret / service token for Sync map Do not expose /internal/* publicly
AuthZ Merchant scoped to own merchant_id; admin RBAC for ops Re-check ownership in service layer
No key material Never persist or log seeds, xprv, xpub / extended public keys, MPC shares, deployer keys A4 hybrid; one HD master per merchant stays in HSM/MPC; custody adapter returns address + path alias only
Address uniqueness Sequential registry + UNIQUE constraints FR9 / BR-02; FEAT-REG-01
Idempotency Create VA/HW safe under retry FEAT-IDM-01
SoD Account-service does not hold settlement signing authority Operator vs settlement vs governance per A3/A4
Beneficiary Merchant-controlled; validate format only Tier 4
Incident hooks Issuance pause + deactivate watch flags A4 §7

9. NFR (non-functional)

Parameter Planning value Account implication
Custody addresses ~100,000 Registry + Sync map sized for 100k; watched-address pagination mandatory
Peak signing 200 TPS Signing is MPC — not account-service; issuance API sized separately
Issuance uniqueness test 1M synthetic Load-test / CI job for FEAT-REG-01 / ACC-01 → 0 address collisions
Watched-address page Default/max limit 1000 Cursor pagination required; no unbounded full dump
Error envelope Canonical JSON Every non-2xx includes error.code and error.request_id

Idempotency keys required on create under parallel portal traffic.

E. ReferencesE. Tham chiếu