Skip to content

feat(wallet): implement Wallet Management Module#16

Merged
akargi merged 10 commits into
Chulilee:mainfrom
RUKAYAT-CODER:feature/wallet-management-module
Jul 20, 2026
Merged

feat(wallet): implement Wallet Management Module#16
akargi merged 10 commits into
Chulilee:mainfrom
RUKAYAT-CODER:feature/wallet-management-module

Conversation

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Summary

Implements a comprehensive Wallet Management Module for the Stellar network as described in the issue requirements.

Changes

New Module: src/modules/wallet/

  • entities/wallet.entity.ts - Wallet TypeORM entity linked to User, stores the Stellar public key, AES-256-GCM encrypted secret key (select: false), cached balance, sync timestamp, primary flag, status, and optional multi-sig configuration (threshold + cosigner array).

  • dto/create-wallet.dto.ts - DTO for wallet creation (optional label and primary flag).

  • dto/update-wallet.dto.ts - DTO for updating label, status, or primary flag.

  • dto/sign-transaction.dto.ts - DTO accepting a base64-encoded unsigned XDR envelope.

  • dto/multisig-config.dto.ts - DTO for configuring threshold and co-signer public keys.

  • wallet.service.ts - Core business logic:

    • Key generation via Keypair.random() from the Stellar SDK
    • AES-256-GCM encryption/decryption of secret keys (key never exposed via API)
    • Multi-account support per user with atomic primary-wallet promotion (transactional)
    • Balance synchronisation via StellarService.getAccount() with cached result
    • Transaction signing via TransactionBuilder.fromXDR() + Keypair.sign() (synchronous, sub-100 ms)
    • Account recovery via public key retrieval endpoint
    • Multi-sig configuration (threshold + cosigners stored as JSONB)
    • Soft-delete (status ? INACTIVE) to preserve wallet state across restarts
  • wallet.controller.ts - REST controller (/wallets) with JWT guard, @currentuser decorator, full CRUD + balance sync, sign-transaction, public-key, and multisig endpoints.

  • wallet.module.ts - NestJS module wiring TypeORM, StellarModule, service and controller.

  • wallet.service.spec.ts - Unit tests covering create, findAll, findOne, syncBalance, remove, and configureMultisig with mock repository and service.

Updated

  • src/app.module.ts - WalletModule added to AppModule imports.

Acceptance Criteria Coverage

Criterion Implementation
Multiple accounts per user Each wallet is a separate entity linked by userId
Key material encrypted, never exposed AES-256-GCM encryption; encryptedSecretKey has select: false
Balance sync within 5 s syncBalance() calls Horizon directly and updates cached value
Transaction signing within 100 ms Synchronous ransaction.sign(keypair) call
Multi-sig support multisigThreshold + cosigners JSONB column + config endpoint
Account recovery GET /wallets/:id/public-key endpoint
Wallet state persistence TypeORM entity persisted in PostgreSQL
Unit tests wallet.service.spec.ts covering all wallet operations

closes #7

@akargi
akargi merged commit e499bfe into Chulilee:main Jul 20, 2026
1 check passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 20, 2026
9 tasks
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.

Implement Wallet Management Module

2 participants