Join GitHub today
RPC refactoring: Access wallet using new GetWalletForJSONRPCRequest #8775
I don't like the coupling and the
I think we should pack the request path (URI) into the
Instead of the
That sounds nice, but greatly complicates the implementation. :(
referenced this pull request
Sep 22, 2016
changed the title from
RPC refactoring: Never access wallet directly, only via new CRPCRequestInfo
RPC refactoring: Access wallet using new GetWalletForJSONRPCRequest
Nov 12, 2016
added a commit
this pull request
Dec 31, 2016
So in some cases in the RPC you get the wallet pointer from json but then the check if it's available is far below. This is begging for someone to insert code that uses a potentially null pointer between to two and doesn't notice because their function doesn't get tested with a missing wallet. I would recommend moving the creation of that local pointer down to the point where you're going to test it.
Alternatively or in addition, rename GetWalletForJSONRPCRequest to TryGetWalletForJSONRPCRequest and make GetWalletForJSONRPCRequest a wrapper for it that throws when it fails?
Other than this nit that perhaps getting the pointer and testing it are too separated in some cases, utACK.
I liked the TryGetWalletForJSONRPCRequest/GetWalletForJSONRPCRequest refactor idea, but I don't see any clean way to do it without changing the
So I moved the one case EnsureWalletIsAvailable was delayed up, and removed the blank line between them and GetWalletForJSONRPCRequest.
Please do not tag the 4th commit "Trivial". We usually define trivial as doesnt touch any code.
As for the 6th commit: please do not do this. nothing in src/wallet is built when ENABLE_WALLET is off, so generally src/wallet/* should never be included outside of src/wallet/*
Aside from the (partial-revert) of "Move wallet RPC declarations to rpcwallet.h" and the printing of the raw pointers to debug log, this looks good to me at d9aff6e.