Skip to content
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

Change Wallet API get_transaction to use wallet_id parameter. Add test. #17594

Closed
wants to merge 3 commits into from

Conversation

aqk
Copy link
Contributor

@aqk aqk commented Feb 21, 2024

Purpose:

WalletRpcApi.get_transaction() would never look at the wallet_id parameter, therefore returned Transactions were never filtered by wallet_id.

Breaking Change! See below.

Current Behavior:

Would always return requested transaction, regardless of requested wallet.

New Behavior:

Will only return the transaction if it belongs to the
Fails if an invalid wallet_id parameter is supplied, or if wallet_id is missing

Security Notes

checking the wallet_id does not confer any security benefits. Anyone with access to the wallet API likely has access to the wallet db.

Design Notes

Personally, I would remove the wallet_id parameter entirely. Its only use currently is a sanity check, and that check could be built into the RPC receiver. All TransactionRecords contain their wallet_id.

We need to get rid of the local wallet_id int for wallet identity purposes. One of the many issues this causes us is that wallet "IDs" can change after a wallet rebuild or chain reorg.

Code notes

I'm guessing get_transaction was introduced as a quick to implement alternative to extending get_transactions

If that is correct, and it is not used in many places, we might consider deprecating get_transaction, especially if all the current use is in-house.

We might want to consider folding this into get_transactions. I'll link the PR for that.

Testing Notes:

@aqk aqk added Changed Required label for PR that categorizes merge commit message as "Changed" for changelog Cleanup Code cleanup labels Feb 21, 2024
@aqk aqk requested a review from a team as a code owner February 21, 2024 18:50
@aqk
Copy link
Contributor Author

aqk commented Feb 21, 2024

By the way, I don't mind if we want to do away with the wallet_id parameter entirely, as it is not currently giving us any security (we would have to test API requests against the "currently logged in" key to be able to reject requests for other wallets than the current one.

As long as the expected API behaviour is specified.

@aqk
Copy link
Contributor Author

aqk commented Feb 21, 2024

Copy link
Contributor

@Quexington Quexington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an issue or something this was fixing? I don't see the wallet parameter being used prior to this change so this is technically breaking backwards compatibility.

@felixbrucker
Copy link
Contributor

I rely on this api and i do not send the wallet_id in the request as that was never required, as such this would be a breaking change indeed. I can't imagine i'm the only one using it.

Copy link
Contributor

@emlowe emlowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what wallet_rpc_client does in adding the wallet_id to the JSON is what is wrong and we should just change that - that is, go in the other direction from this PR. So it's a simple one-line change in wallet_rpc_client::get_transaction to fix up that call.

@aqk aqk mentioned this pull request Feb 22, 2024
@aqk
Copy link
Contributor Author

aqk commented Feb 22, 2024

See #17598

@aqk
Copy link
Contributor Author

aqk commented Feb 22, 2024

#17598

@aqk aqk closed this Feb 22, 2024
@aqk
Copy link
Contributor Author

aqk commented Feb 22, 2024

I rely on this api and i do not send the wallet_id in the request as that was never required, as such this would be a breaking change indeed. I can't imagine i'm the only one using it.

Thanks for your input. Ironically, I chose this implementation because I thought it was the most conservative for people who were using the wallet_id param, and thought that it was required.

I prefer the implementation in #17598

@aqk
Copy link
Contributor Author

aqk commented Feb 22, 2024

I think what wallet_rpc_client does in adding the wallet_id to the JSON is what is wrong and we should just change that - that is, go in the other direction from this PR. So it's a simple one-line change in wallet_rpc_client::get_transaction to fix up that call.

Thanks. That's what I wanted to do originally, but was trying to reduce surprises introduced during the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog Cleanup Code cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants