…igiByte-Core#34)
estimatecollateral read system health from a static cache
(GetSystemMetrics) that is only populated when ScanUTXOSet() runs
inside getdigidollarstats or getprotectionstatus. If estimatecollateral
ran first, the cache had totalDDSupply=0, causing the health check to
hardcode systemHealth=0 (emergency) and apply a 2x DCA multiplier.
This doubled the reported collateral requirement even when the system
was healthy at 475-528%.
The mint transaction builder uses the same path, so valid mints were
rejected with "Insufficient funds for collateral and fees."
Fix: read totalCollateral and totalDDSupply from the digidollar stats
index (fast, already synced) or fall back to ScanUTXOSet(), matching
the pattern getdigidollarstats and getprotectionstatus already use.
Also change the totalDD==0 case from health=0 to health=30000 (max)
since an empty system has nothing at risk.
Tested on testnet21: estimatecollateral now returns health=510 / DCA=1x
matching getdigidollarstats and getprotectionstatus. Tier-4 mint that
previously required 134K DGB now correctly requires 67K and succeeds.
Confirmed still present in RC29 (RH-36a fixed a different cache race).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
estimatecollateralreports system_health=0 / emergency / DCA=2x when the system is actually healthy at 475-528%. Doubles the reported collateral requirement, blocking valid mints with "Insufficient funds."estimatecollateralcallsGetSystemMetrics()which reads a static cache that is only populated whenScanUTXOSet()runs insidegetdigidollarstatsorgetprotectionstatus. If neither has run, the cache hastotalDDSupply=0, and line 2579 hardcodessystemHealth=0.totalCollateralandtotalDDSupplyfrom the digidollar stats index (fast path) or fall back toScanUTXOSet()(slow path), matching the patterngetdigidollarstatsandgetprotectionstatusalready use. Also change thetotalDD==0fallback fromhealth=0tohealth=30000(max) — an empty system has nothing at risk.src/rpc/digidollar.cppEvidence — same node, same moment
getdigidollarstatsgetprotectionstatusestimatecollateralSystem has 15 active positions, 1.69M DGB locked, 150K cents DD supply.
Test plan
GetSystemMetrics()code path)estimatecollateralreturns health=510 / DCA=1x, matching other RPCsgetdigidollarstats,getprotectionstatusbehavior unchanged🤖 Generated with Claude Code