-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpc help list commands #705
Conversation
This comment has been minimized.
This comment has been minimized.
Tested and works nicely. Definitely much cleaner execution than #550 but the drawback is that the commands are just listed, not explained. For reference, the REST API help returns explanations:
Also worth noting that Bitcoin Core generates the "help list" algorithmically, each method has its own definition property and they are all aggregated for And finally, as long as this is open for review again we also need a related fix for bclient, see bcoin-org/bcurl#7 |
@pinheadmz I agree it would be good to have a single line description with the command, as in #550 though it would be good to have them generated, as in this PR. Each command could have short description, category, and full help text that could be used for generated output. For example |
@rsbondi see Braydon's suggestion here... is that something you are comfortable adding to this PR? If not I could look into it and either submit a PR to your branch or just take over the branch from here? I feel like it might involve adding properties to to |
I agree that it appears that I could do this locally, but it really seems like it should be at the base class, not sure how you coordinate the 2 repos? |
Yeah sometimes we need to make PRs in multiple repos that are linked :-) Another approach to this, which may be kilnda silly, but each RPC function could parse the
Then in |
It may not need to be defined at the same time as the api call, but would map with the name of the command. For example: this.addHelp(<commandname>, <category>, <summary>, <text>); |
looking at core RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples); compare doc to code they are generating the separate sections: arguments, results and examples, and use the arguments to generate the signature as well. Not sure if you want to go that far, but I could write a script that could generate the javascript code for all the core functions from a core node, and then manually add any bcoin extras, and generate help from that, but not sure how in sync the bcoin/bitcoin commands are. core help with no args
which is similar to what I have done without the categories or args but a deviation from |
Having a list of commands is an improvement over what is currently without info. How many details are included initially may be something to look at to see what becomes too much info. Right now I reference: https://github.com/bcoin-org/bcoin/blob/master/lib/node/rpc.js#L149 to see what is available, and will dig into the implemented method for details. And then https://github.com/bcoin-org/bcoin/blob/master/lib/wallet/rpc.js#L120 for the wallet side. |
I made a proof of concept branch as a potential path. this separates the help data to a separate file, Using a separate data file for help would eliminate needing to set via an This will mimic the bitcoind node, except I did not separate out arguments and examples, just combined in Note: this is a proof of concept to open the discussion, not linter of file structure friendly and I only applied the detail to |
Also, a lot of the result and arguments are documented at, for example |
@rsbondi Thanks for the info. I'm wondering if a simple description and list of arguments would be enough, and then external documentation for the rest of the response as in the API Docs. |
I think the gist looks good, you could generate the signature from the arguments for when My personal opinion is that the signature is usually more valuable than a description, so at the minimum list that so in other words, |
here is example output from clightning, I think this format is good, you get call, args and description in a simple readable format.
|
With the arguments defined, the help and argument check can be implemented for all methods, with something such as: if (help || args.length < cmd.required.length || args.length > cmd.args.length) {
const required = cmd.required.join(' ');
const optional = cmd.optional.join(' ');
throw new RPCError(errs.MISC_ERROR, `${cmd.name} ${required} (${optional})`);
} And then it wouldn't need to be implemented within each method that is sometimes prone to mistakes. |
How about we bring in this PR so that there is at the least some basic info on which commands to select, and the follow up with other PRs and improvements. We can also have #550 be for fixes to the RPC interface, and separate out updates to the help command for additional follow-up. Lot's of good ideas here. |
If you want to address the nit, and squash the commits it should be good to go, I think. |
This will also close #538 |
Thanks again @rsbondi !!!!! |
No description provided.