Skip to content

rpcserver: Refactor.#3503

Merged
JoeGruffins merged 5 commits intodecred:masterfrom
JoeGruffins:refactorrpc
Feb 11, 2026
Merged

rpcserver: Refactor.#3503
JoeGruffins merged 5 commits intodecred:masterfrom
JoeGruffins:refactorrpc

Conversation

@JoeGruffins
Copy link
Copy Markdown
Member

@JoeGruffins JoeGruffins commented Feb 9, 2026

Switch from position based to key:value and update some other things. Make easily usable by ai by adding a swagger file.

@JoeGruffins JoeGruffins force-pushed the refactorrpc branch 3 times, most recently from ae63ea4 to e05ce09 Compare February 10, 2026 06:56
Replace the CLI-style RawParams{PWArgs, Args} wire format with per-route
typed JSON parameter structs. This is a breaking wire format change from
positional string arrays to typed objects (e.g. {"appPass":"...","host":"...",
"isLimit":true,...}).

- Delete RawParams, errArgs, all 46 parseXxxArgs functions and helpers
- Add ~35 exported typed param structs with JSON tags in types.go
- Change handler signatures from func(s, *RawParams) to func(s, *msgjson.Message)
- Each handler unmarshals its own typed params from the message payload
- Simplify handleRequest to pass raw message directly to handlers
- Fix 4 inconsistent error constructors to use msgjson.NewError()
- Bump rpcSemverMajor from 0 to 1 (breaking change)
- Add bwctl/payload.go with buildPayload builders for CLI arg conversion
- Update bwctl/main.go to use buildPayload, bump requiredRPCServerVersion
- Rewrite handlers_test.go with typed params and makeMsg/makeBadMsg helpers
- Delete types_test.go (all tests referenced removed parse functions)
- Update rpcclient example to use HelpParams
- Add OpenAPI spec, Swagger UI endpoint, and README.md
Replace the hand-maintained helpMsg/helpMsgs system with a
reflection-based routeInfo/routeInfos system that auto-generates
parameter documentation from actual struct definitions. This makes it
structurally impossible for help text to drift from param types.

New reflection helpers (reflectFields, goTypeToHelpType, parseJSONTag)
walk param structs in declaration order, flatten embedded structs,
detect password fields (encode.PassBytes), and identify optional
fields (pointer/omitempty).

Bug fixes now automatic via correct param types:
- cancelRoute: no longer falsely claims appPass is required
- toggleWalletStatusRoute: no longer falsely claims appPass is required
- discoverAcctRoute: removed stale "register" reference, fixed typo
- setVotingPreferencesRoute: fixed incorrect summary
@JoeGruffins JoeGruffins force-pushed the refactorrpc branch 2 times, most recently from 523e937 to d441bbe Compare February 11, 2026 02:36
Add two new RPC endpoints that expose existing core methods:

- walletbalance: returns the balance for a single wallet by asset ID,
  calling core.AssetBalance. Avoids fetching all wallets when only one
  balance is needed.

- walletstate: returns the full state for a single wallet by asset ID,
  calling core.WalletState. Returns wallet open/running/disabled status,
  balance, address, and other details without pulling all wallets.
Replace ~50 individual buildXxx functions in payload.go with a single
generic buildFromStruct that uses reflection to walk param struct fields
in declaration order — the same order used by the help system. This
eliminates ordering mismatches between help output and CLI arg parsing.

Export FieldInfo, ReflectFields, ParamType, and RouteExists from
rpcserver so bwctl can derive field metadata at runtime. Auto-derive
password prompts and cert file arg indices from struct tags instead of
hardcoded maps. Complex routes register per-field custom parsers via
routeOverrides.
@JoeGruffins JoeGruffins merged commit 05bfe19 into decred:master Feb 11, 2026
5 checks passed
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.

1 participant