10 Commits
Author SHA1 Message Date
DanS 58ee8e29c3 Merge branch 'fix/grpc-dos-hardening' 2026-11-08 11:22:49 -06:00
DanSandClaude Opus 4.8 cbda810849 frontend: guard nil Block in GetTransaction (empty TxFilter crash)
An empty TxFilter (Hash==nil, Block==nil) fell through to 'if txf.Block.Hash'
which dereferenced a nil Block and panicked the server (grpc-go v1.24.0 has no
handler recover) -- one unauthenticated request killed the process. Guard
txf.Block before dereferencing and return InvalidArgument for a request that
carries neither a txid nor a usable block filter.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 10:39:41 -05:00
DanSandClaude Opus 4.8 6f52ff0969 frontend: harden the gRPC handlers against malformed and oversized requests
Three unauthenticated issues from a security review of the published
lightwalletd, all in frontend/service.go, now fixed and validated end to end
against a regtest dragonxd backend:

- GetBlockRange and GetAddressTxids dereferenced the request's range
  (Start/End) with no nil check, so one request with an empty BlockRange
  nil-panicked and, because grpc-go v1.24.0 does not recover handler panics,
  took the whole process down. Reject a missing range with InvalidArgument
  before touching it. (Verified: an empty-range request killed the old binary;
  the fixed binary answers InvalidArgument and stays up.)
- Neither method bounded the span, so one request could walk the entire
  uncached range -- one backend RPC per height. Reject end<start and cap the
  span at maxBlockRangeSpan (10000; honest syncs are far below it). (Verified:
  a 9,000,000-block span is now refused with InvalidArgument up front.)
- GetTransaction returned Internal ("Marshal called with nil") for a missing
  transaction: strconv.ParseInt overwrote err and both branches returned a
  typed nil. Parse into a separate variable and return a real status. The
  backend reports a missing tx as -5 ("No information available about
  transaction") and a not-yet-available height as -8; map both to NotFound,
  everything else to Internal with the backend message. (Verified: a bogus
  txid returned Internal before and returns NotFound after.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-29 01:10:25 -05:00
DanSandClaude Opus 4.8 2bab58c6d2 lightwalletd: adaptive reorg-lag tip + non-blocking startup coinsupply
Adaptive-lag: advertise a tip that trails the real tip by a reorg-rate-driven
lag (GetLatestBlock/GetLightdInfo) so wallets anchor shielded spends at a
settled height during reorg churn. Configurable via
-adaptive-lag/-lag-min/-lag-max/-lag-window; monitor_lwd.sh runs
-lag-min 4 -lag-max 12 -lag-window 30.

Startup coinsupply: the informational startup coinsupply RPC (result used only
for a log line) blocked the gRPC bind for minutes on a node whose supply index
is cold, keeping the lite endpoint down on every restart while it also starved
the block-cache ingestor. Run it in a goroutine so the bind is never blocked;
clients still get coinsupply on demand via the GetCoinsupply RPC.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 01:05:10 -05:00
DanSandClaude Opus 4.8 b1b0d4559b feat(frontend): implement GetMempoolStream for 0-conf lightwallet txs
The CompactTxStreamer service did not implement any mempool RPC, so
lightwallets (SilentDragonXLite / ObsidianDragonLite) received UNIMPLEMENTED
from get_mempool_stream and permanently stopped their mempool monitor. As a
result the lite wallet could not see 0-confirmation transactions and only
surfaced incoming shielded chat messages after they were mined (~1 block).

Add GetMempoolStream(Empty) returns (stream RawTransaction). A single
process-wide monitor (frontend/mempool.go) polls the node's getrawmempool and
fetches each new tx via getrawtransaction (full serialized bytes, so shielded
memos are preserved -- CompactTx's 52-byte prefix would not carry a memo), then
fans the tx out to every subscribed stream. This avoids polling the node once
per connected wallet: N clients share one poll loop. The monitor starts lazily
on the first subscription, idles without touching the node when no clients are
connected, and closes all subscriber streams when a new block is mined (the
semantics the client's monitor loop expects; the client re-syncs and reconnects).

Purely additive and wire-compatible: RawTransaction field numbers and the
cash.z.wallet.sdk.rpc package match the deployed client; existing clients that
never call GetMempoolStream are unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 20:10:26 -05:00
DanS ec1c479156 Increase block cache size to 400k for faster wallet sync
- Increase default cache-size from 40,000 to 400,000 blocks
- Add Python gRPC protobuf bindings for testing
2026-03-21 03:50:55 -05:00
DanS aae94a4f3c changes 2026-03-20 06:55:27 -05:00
DanS 3355c1ea85 stop server script 2026-03-20 06:26:15 -05:00
DanS ebc38c9369 Fix lightwalletd sync loop for DragonX wallet
- Handle missing Sapling upgrade in getblockchaininfo response by
  defaulting activation height to 1 (DragonX has Sapling active from
  genesis but uses NO_ACTIVATION_HEIGHT in chainparams)
- Override consensus branch ID to Sapling (76b809bb) when node reports
  Sprout (00000000) due to disabled activation heights
- Include full serialized block header in CompactBlock so the SDK can
  validate hashFinalSaplingRoot against the Sapling commitment tree
- Set CompactBlock ProtoVersion to 1
2026-03-20 06:24:54 -05:00
DanS f4ef38c42f fix sapling activation height and consensus branch id 2026-03-20 06:11:38 -05:00