btcjson: apply defaults to optional params passed as null #2644
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.40) × (1 − Review Confidence (0.66)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 76 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.35 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.260
Real PR Conversation Timeline
2 items
Approved
Nice catch. LGTM.
allocz
Lrifton92
Change Description
UnmarshalCmdonly appliesjsonrpcdefaultvalues to trailing parameters that are omitted (populateDefaults,btcjson/cmdparse.go). An optional parameter sent as an explicit JSONnullis unmarshalled into a nil pointer instead, so the handler sees a different value than if the parameter had been left out.Example:
verifychain [null, null]reacheshandleVerifyChainwith nil level and depth, which it turns into level 0 over the whole chain instead of the defaults (level 3, depth 288). Thegetblockpanic in #2597 had the same root cause; #2600 fixed it in that one handler.This change treats a null optional parameter the same as an omitted one and assigns its default value. Bitcoin Core also treats null as "use the default" for optional RPC arguments. Required parameters and optional parameters without a default are unchanged.
Two existing test vectors (
searchrawtransactionswith a nullvinextra,createwallet - optional2) expected nil for a null optional parameter; they now expect the default.Found with a
FuzzUnmarshalCmdround-trip harness over all registered methods.Steps to Test
Without the fix,
TestUnmarshalCmdNullOptionalfails with e.g.got {"CheckLevel":null,"CheckDepth":null}, want {"CheckLevel":3,"CheckDepth":288}.Pull Request Checklist
Testing
Code Style and Documentation
🤖 Generated with Claude Code