Repository navigation
refactor: key wallet clippy warnings #123
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
Changes from 1 commit
ef52ce3
6f3a964
05ac46b
1a4fb90
6870686
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3789,16 +3789,30 @@ void wallet_manager_free_addresses(char **addresses, | |||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||
| Encrypt a private key with BIP38 | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Safety | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| This function is unsafe because it dereferences raw pointers: | ||||||||||||||||||||||||||||||||||||||||||||
| - `private_key` must be a valid, null-terminated C string | ||||||||||||||||||||||||||||||||||||||||||||
| - `passphrase` must be a valid, null-terminated C string | ||||||||||||||||||||||||||||||||||||||||||||
| - `error` must be a valid pointer to an FFIError or null | ||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| char *bip38_encrypt_private_key(const char *private_key, | ||||||||||||||||||||||||||||||||||||||||||||
| const char *passphrase, | ||||||||||||||||||||||||||||||||||||||||||||
| FFINetwork network, | ||||||||||||||||||||||||||||||||||||||||||||
| FFINetwork _network, | ||||||||||||||||||||||||||||||||||||||||||||
| FFIError *error) | ||||||||||||||||||||||||||||||||||||||||||||
| ; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||
| Decrypt a BIP38 encrypted private key | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Safety | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| This function is unsafe because it dereferences raw pointers: | ||||||||||||||||||||||||||||||||||||||||||||
| - `encrypted_key` must be a valid, null-terminated C string | ||||||||||||||||||||||||||||||||||||||||||||
| - `passphrase` must be a valid, null-terminated C string | ||||||||||||||||||||||||||||||||||||||||||||
| - `error` must be a valid pointer to an FFIError or null | ||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
3808
to
3816
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FFI contract: document allocation/ownership for BIP38 decrypt State who frees the returned string and typical error path. -/*
- Decrypt a BIP38 encrypted private key
-
- # Safety
+/*
+ Decrypt a BIP38 encrypted private key
+
+ Returns: newly allocated C string (WIF) on success; NULL on error.
+ - Free the returned string with `string_free`.
+
+ # Safety
This function is unsafe because it dereferences raw pointers:
- `encrypted_key` must be a valid, null-terminated C string
- `passphrase` must be a valid, null-terminated C string
- `error` must be a valid pointer to an FFIError or null
*/📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| char *bip38_decrypt_private_key(const char *encrypted_key, | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
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.
BIP38 encrypt docs: document allocation/free and current unimplemented behavior
The header doesn’t say how to free the returned string and that this currently always returns NULL with WALLET_ERROR (feature disabled or not implemented). Please document both; also note
_networkis reserved/ignored.Apply this header doc tweak (mirror in Rust doc comments so cbindgen regenerates it):
📝 Committable suggestion
🤖 Prompt for AI Agents