-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
API does not accept seed or public key for account #4404
API does not accept seed or public key for account #4404
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thanks. I'm not sure I would have removed the public_key methods. That isn't a security concern, but I also understand the motivation - I don't object too strongly. I left a few suggestions. Nice job on this.
087a80f
to
ef7dae7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 nice job on this.
if (!accountID) | ||
{ | ||
rpcError(rpcACT_MALFORMED); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accountID
is not really an optional. It's always seated if valid. Consider something like this:
auto const id = parseBase58<AccountID>(params[jss::account].asString()); if (!id) { rpcError(rpcACT_MALFORMED); } AccountID const accountID{std::move(id.value())};
It also results in fewer code changes. Other handlers have a similar code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed.
visitData.raDstAccount == (*sleCur)[sfDestination])) | ||
(*sleCur)[sfAccount] == *accountID && | ||
(!visitData.raDstAccount || | ||
*visitData.raDstAccount == (*sleCur)[sfDestination])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can simplify:
visitData.raDstAccount <= (*sleCur)[sfDestination])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we check if DstAccount is provided or DstAccount == (*sleCur)[sfDestination]
.
Your suggestion seems to change the intention of this check. Would it work as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I'm taking back this suggestion.
(!visitData.hasPeer || | ||
visitData.raPeerAccount == | ||
(!visitData.raPeerAccount || | ||
*visitData.raPeerAccount == |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can simplify: visitData.raPeerAccount <= line->getAccountIDPeer()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we check if peerAccount is not provided or peerAccount == line->getAccountIDPeer()
.
Your suggestion seems to change the intention of this check. Would it work as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I'm taking back this suggestion.
auto const id = parseBase58<AccountID>(j.asString()); | ||
|
||
if (id) | ||
if (auto const id = parseBase58<AccountID>(j.asString()); id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to check id
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check currently exists. If we don't check, would we accept malformed accountID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code is:
auto const id = parseBase58<AccountID>(j.asString());
if (id)
{
hotWallets.insert(*id);
return true;
}
In this case it does need to be checked. In case of if
with initializer it's checked if there is no other condition.
ef7dae7
to
958a3e6
Compare
@drlongle it isn't necessary to rebase and force-push (though you can if you prefer - it's just a little trickier for reviewers to follow the changes). Using merge commits is fine if we're going to squash this PR when merging it. |
(Status: I believe drlongle still needs to respond to gregtatcam's suggestions) |
AccountID accountID; // out param | ||
if (auto jvAccepted = RPC::accountFromString(accountID, strIdent, bStrict)) | ||
return jvAccepted; | ||
auto const accountID = parseBase58<AccountID>(strIdent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AccountID
is not really optional. Please consider the updated suggested in AccountChannels.cpp
comment. I will not repeat this comment for other files. All changed files under rpc/handlers
have a similar code block: AccountInfo.cpp, AccountLines.cpp, AccountObjects.cpp, AccountOffers.cpp, DepositAuthorized.cpp, GatewayBalances.cpp, NoRipplecheck.cpp, OwnerInfo.cpp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have applied your suggested changes across the board. Let me know if you find any further issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
High Level Overview of Change
This PR resolves #3329, #3330 and #4337. Currently,
seeds
andpublic keys
can be used in place ofaccounts
at several locations in the API. This increases the API's complexity because the API needs to guess whether the input is a seed, a public key or an address. This PR prevents the API from accepting a seed or a public key as account ID. Since the API does not interpretaccount
asseed
, the optionstrict
in several API methods is no longer needed and is removed.Context of Change
Documentation needs to be updated.
Type of Change