Files
dchain/client-app
vsecoder 6425b5cffb feat(feed/chat): lazy-render + pagination for long scrolls
Server pagination
  - blockchain.PostsByAuthor signature extended with beforeTs int64;
    passing 0 keeps the previous "everything, newest first" behaviour,
    non-zero skips posts with CreatedAt >= beforeTs so clients can
    paginate older results.
  - node.FeedConfig.PostsByAuthor callback type updated; the two
    /feed endpoints that use it (timeline + author) now accept
    `?before=<unix_seconds>` and forward it through. /feed/author
    limit default dropped from 50 to 30 to match the client's page
    size.
  - node/api_common.go: new queryInt64 helper for parsing the cursor
    param safely (matches the queryInt pattern already used).

Client infinite scroll (Feed tab)
  - lib/feed.ts: fetchTimeline / fetchAuthorPosts accept
    `{limit?, before?}` options. Old signatures still work for other
    callers (fetchForYou / fetchTrending / fetchHashtag) — those are
    ranked feeds that don't have a stable cursor so they stay
    single-shot.
  - feed/index.tsx: tracks loadingMore / exhausted state. onEndReached
    (threshold 0.6) fires loadMore() which fetches the next 20 posts
    using the oldest currently-loaded post's created_at as `before`.
    Deduplicates on post_id before appending. Stops when the server
    returns < PAGE_SIZE items. ListFooterComponent shows a small
    spinner during paginated fetches.
  - FlatList lazy-render tuning on all feed lists (index + hashtag):
    initialNumToRender:10, maxToRenderPerBatch:8, windowSize:7,
    removeClippedSubviews — first paint stays quick even with 100+
    posts loaded.

Chat lazy render
  - chats/[id].tsx FlatList: initialNumToRender:25 (~1.5 screens),
    maxToRenderPerBatch:12, windowSize:10, removeClippedSubviews.
    Keeps initial chat open snappy on conversations with thousands
    of messages; RN re-renders a small window around the viewport
    and drops the rest.

Tests
  - chain_test.go updated for new PostsByAuthor signature.
  - All 7 Go packages green.
  - tsc --noEmit clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 21:51:43 +03:00
..

DChain Messenger — React Native Client

E2E-encrypted mobile/desktop messenger built on the DChain blockchain stack.

Stack: React Native · Expo · NativeWind (Tailwind) · TweetNaCl · Zustand

Quick Start

cd client-app
npm install
npx expo start          # opens Expo Dev Tools
# Press 'i' for iOS simulator, 'a' for Android, 'w' for web

Requirements

  • Node.js 18+
  • Expo Go on your phone (for Expo tunnel), or iOS/Android emulator
  • A running DChain node (see root README for docker compose up --build -d)

Project Structure

client-app/
├── app/
│   ├── _layout.tsx           # Root layout — loads keys, sets up nav
│   ├── index.tsx             # Welcome / onboarding
│   ├── (auth)/
│   │   ├── create.tsx        # Generate new Ed25519 + X25519 keys
│   │   ├── created.tsx       # Key created — export reminder
│   │   └── import.tsx        # Import existing key.json
│   └── (app)/
│       ├── _layout.tsx       # Tab bar — Chats · Wallet · Settings
│       ├── chats/
│       │   ├── index.tsx     # Chat list with contacts
│       │   └── [id].tsx      # Individual chat with E2E encryption
│       ├── requests.tsx      # Incoming contact requests
│       ├── new-contact.tsx   # Add contact by @username or address
│       ├── wallet.tsx        # Balance + TX history + send
│       └── settings.tsx      # Node URL, key export, profile
├── components/ui/            # shadcn-style components (Button, Card, Input…)
├── hooks/
│   ├── useMessages.ts        # Poll relay inbox, decrypt messages
│   ├── useBalance.ts         # Poll token balance
│   └── useContacts.ts        # Load contacts + poll contact requests
└── lib/
    ├── api.ts                # REST client for all DChain endpoints
    ├── crypto.ts             # NaCl box encrypt/decrypt, Ed25519 sign
    ├── storage.ts            # SecureStore (keys) + AsyncStorage (data)
    ├── store.ts              # Zustand global state
    ├── types.ts              # TypeScript interfaces
    └── utils.ts              # cn(), formatAmount(), relativeTime()

Cryptography

Operation Algorithm Library
Transaction signing Ed25519 TweetNaCl sign
Key exchange X25519 (Curve25519) TweetNaCl box
Message encryption NaCl box (XSalsa20-Poly1305) TweetNaCl box
Key storage Device secure enclave expo-secure-store

Messages are encrypted as:

Envelope {
  sender_pub:    <X25519 hex>   // sender's public key
  recipient_pub: <X25519 hex>   // recipient's public key
  nonce:         <24-byte hex>  // random per message
  ciphertext:    <hex>          // NaCl box(plaintext, nonce, sender_priv, recipient_pub)
}

Connect to your node

  1. Start the DChain node: docker compose up --build -d
  2. Open the app → Settings → Node URL → http://YOUR_IP:8081
  3. If using Expo Go on physical device: your PC and phone must be on the same network, or use npx expo start --tunnel

Key File Format

The key.json exported/imported by the app:

{
  "pub_key":     "26018d40...",   // Ed25519 public key (64 hex chars)
  "priv_key":    "...",           // Ed25519 private key (128 hex chars)
  "x25519_pub":  "...",           // X25519 public key (64 hex chars)
  "x25519_priv": "..."            // X25519 private key (64 hex chars)
}

This is the same format as the Go node's --key flag.