Repository navigation
Conversation
Change encrypt_message_a, decrypt_message_a, encrypt_message_b, and decrypt_message_b to borrow arguments they do not consume. - encrypt_message_a: body Vec<u8> -> &[u8] - decrypt_message_a: receiver_sk HpkeSecretKey -> &HpkeSecretKey - encrypt_message_b: plaintext Vec<u8> -> &[u8] - decrypt_message_b: sender_sk HpkeSecretKey -> &HpkeSecretKey decrypt_message_b keeps receiver_pk owned because OpModeR::Auth consumes the inner key. Removes unnecessary .clone() calls at all call sites in send/v2 and receive/v2.
The cert_der parameter is only passed to Certificate::from_der which borrows it, so accept &[u8] instead of Vec<u8>. Fix call sites in payjoin-cli and payjoin-test-utils accordingly. Other pub fns in io.rs and ohttp.rs keep ownership where consumed (ohttp_context, impl IntoUrl).
Since encrypt_message_a now borrows its body argument, extract_request no longer needs to own the Vec<u8>. Change body parameter from Vec<u8> to &[u8]. Other pub fns in send/ keep ownership where consumed (builder/typestate patterns, PsbtContextBuilder storage).
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit the public API to take arguments by reference where possible, following C-CALLER-CONTROL from the Rust API guidelines. Functions that previously took
&Tbut internally cloned are changed to takeTby value, letting the caller decide whether to clone or move.Closes payjoin#402
Approach
Swept all pub fn signatures across payjoin, payjoin-cli, and payjoin-test-utils. Four commits cover HPKE, fetch_ohttp_keys, send::v2, and typestate documentation. Functions where ownership is intentional (persistence, crypto consumption) are documented rather than changed.
Open questions
None.
Pull Request Checklist
Disclosure: co-authored by Claude