Commit 7a9116f
committed
rpc: convert settxfee to RPCHelpMan, fix below-minimum error path
Convert settxfee to the RPCHelpMan pattern landed in gridcoin-community#2923. As a
side effect, fix the below-minimum-amount UX bug: today the help
condition is `fHelp || params.size() < 1 || params.size() > 1 ||
AmountFromValue(params[0]) < nMinFee`, so a below-min amount throws
the help text wrapped as RPC_MISC_ERROR (-1) — useless to the caller.
Hoist the AmountFromValue and minimum-fee check out of the help
condition; below-min now throws JSONRPCError(RPC_INVALID_PARAMETER,
"txfee X below minimum Y") with both values formatted, so the caller
gets actionable feedback. The 0-arg path is unchanged in behavior:
IsValidNumArgs(0) returns false and the help is thrown, just as the
short-circuit `params.size() < 1` produced before.
Add a per-command help-render test in rpchelpman_tests.cpp asserting
that fHelp=true throws a runtime_error whose message contains the
expected RPCHelpMan markers.
Refs: gridcoin-community#29221 parent c98f5d0 commit 7a9116f
2 files changed
Lines changed: 48 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
839 | 840 | | |
840 | 841 | | |
841 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
842 | 859 | | |
843 | 860 | | |
844 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
845 | 869 | | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
| 870 | + | |
859 | 871 | | |
860 | 872 | | |
861 | 873 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
15 | 24 | | |
16 | 25 | | |
17 | 26 | | |
| |||
319 | 328 | | |
320 | 329 | | |
321 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
322 | 345 | | |
0 commit comments