Skip to content

chore(key-wallet): drop unnecesary codebase complexity removing the bincode dependency#498

Draft
ZocoLini wants to merge 1 commit intov0.42-devfrom
chore/drop-key-wallet-bincode
Draft

chore(key-wallet): drop unnecesary codebase complexity removing the bincode dependency#498
ZocoLini wants to merge 1 commit intov0.42-devfrom
chore/drop-key-wallet-bincode

Conversation

@ZocoLini
Copy link
Collaborator

@ZocoLini ZocoLini commented Mar 6, 2026

In this PR I remove all the bincode::Encode and bincode::Decode implementations, since we have serve::Deserialize and serve::Serialize it doesn't make sense to me to also have Bincode derives, you can always use bincode::serde:: to generate a bincode output using the serde framework. The only thing we were decoding with Bincode was the wallet, not I am using bincode's serde feature that does basically the same but through serde's framework

I didn't find any usage for the Bincode implementation in platform either so basically unnecesary logic if that is true

@ZocoLini ZocoLini marked this pull request as draft March 6, 2026 20:26
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4f4ecfba-ebd8-4939-8894-8f18abd9a61b

📥 Commits

Reviewing files that changed from the base of the PR and between e7c68d9 and f78f84c.

📒 Files selected for processing (35)
  • key-wallet-ffi/Cargo.toml
  • key-wallet-ffi/src/wallet_manager.rs
  • key-wallet-ffi/src/wallet_manager_serialization_tests.rs
  • key-wallet-ffi/src/wallet_manager_tests.rs
  • key-wallet-ffi/tests/test_import_wallet.rs
  • key-wallet/Cargo.toml
  • key-wallet/src/account/account_collection.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/account/bls_account.rs
  • key-wallet/src/account/coinjoin.rs
  • key-wallet/src/account/eddsa_account.rs
  • key-wallet/src/account/mod.rs
  • key-wallet/src/account/serialization.rs
  • key-wallet/src/bip32.rs
  • key-wallet/src/derivation_bls_bip32.rs
  • key-wallet/src/derivation_slip10.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/gap_limit.rs
  • key-wallet/src/lib.rs
  • key-wallet/src/managed_account/address_pool.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/managed_account/managed_platform_account.rs
  • key-wallet/src/managed_account/metadata.rs
  • key-wallet/src/managed_account/platform_address.rs
  • key-wallet/src/manager/mod.rs
  • key-wallet/src/mnemonic.rs
  • key-wallet/src/psbt/mod.rs
  • key-wallet/src/seed.rs
  • key-wallet/src/test_macros.rs
  • key-wallet/src/tests/mod.rs
  • key-wallet/src/tests/spent_outpoints_tests.rs
  • key-wallet/src/wallet/backup.rs
  • key-wallet/src/wallet/mod.rs
  • key-wallet/src/wallet/root_extended_keys.rs
  • key-wallet/tests/test_serialized_wallets.rs
💤 Files with no reviewable changes (27)
  • key-wallet/src/tests/mod.rs
  • key-wallet/src/lib.rs
  • key-wallet/src/derivation_bls_bip32.rs
  • key-wallet/src/test_macros.rs
  • key-wallet/src/tests/spent_outpoints_tests.rs
  • key-wallet/src/account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/account/coinjoin.rs
  • key-wallet/src/psbt/mod.rs
  • key-wallet/src/managed_account/metadata.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/seed.rs
  • key-wallet/src/managed_account/platform_address.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet/src/derivation_slip10.rs
  • key-wallet/src/account/bls_account.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/account/eddsa_account.rs
  • key-wallet/src/wallet/mod.rs
  • key-wallet/src/wallet/backup.rs
  • key-wallet/src/wallet/root_extended_keys.rs
  • key-wallet/src/managed_account/managed_platform_account.rs
  • key-wallet/src/managed_account/address_pool.rs
  • key-wallet/src/gap_limit.rs
  • key-wallet/src/account/serialization.rs
  • key-wallet/src/bip32.rs
  • key-wallet/src/mnemonic.rs

📝 Walkthrough

Walkthrough

This pull request transitions the key-wallet crate from bincode to serde as the primary serialization framework. It removes all conditional bincode feature compilation flags, trait implementations, and derive attributes across multiple files while updating feature dependencies and FFI entry points to use serde-compatible serialization.

Changes

Cohort / File(s) Summary
Feature Configuration
key-wallet-ffi/Cargo.toml, key-wallet/Cargo.toml
Updated default and feature flags: FFI now defaults to serde instead of bincode; removed serde_json from serde feature and made bincode depend on serde while keeping it optional. Removed serde_json dependency entirely.
FFI Entry Points & Tests
key-wallet-ffi/src/wallet_manager.rs, key-wallet-ffi/src/wallet_manager_tests.rs, key-wallet-ffi/src/wallet_manager_serialization_tests.rs, key-wallet-ffi/tests/test_import_wallet.rs
Switched conditional compilation of wallet serialization FFI functions and related tests from #[cfg(feature = "bincode")] to #[cfg(feature = "serde")].
Account Type Serialization
key-wallet/src/account/account_collection.rs, key-wallet/src/account/account_type.rs, key-wallet/src/account/bls_account.rs, key-wallet/src/account/eddsa_account.rs, key-wallet/src/account/coinjoin.rs, key-wallet/src/account/mod.rs
Removed bincode derive attributes and conditional imports from account-related structs and enums; deleted serialize()/deserialize() methods from BLSAccount and EdDSAAccount.
Core Serialization Module Removal
key-wallet/src/account/serialization.rs
Deleted entire module containing bincode-based to_bytes() and from_bytes() implementations for Account, BLSAccount, and EdDSAAccount (~149 lines).
BIP32 & Derivation Serialization
key-wallet/src/bip32.rs, key-wallet/src/derivation_bls_bip32.rs, key-wallet/src/derivation_slip10.rs
Removed all custom bincode::Encode, bincode::Decode, and bincode::BorrowDecode trait implementations from ChainCode, Fingerprint, ChildNumber, ExtendedPrivKey, ExtendedPubKey, DerivationPath, and Ed25519 key types.
Additional Type Serialization
key-wallet/src/dip9.rs, key-wallet/src/gap_limit.rs, key-wallet/src/mnemonic.rs, key-wallet/src/seed.rs
Removed bincode derive attributes and custom trait implementations from DerivationPathReference, gap-limit types, Mnemonic/Language, and Seed.
Managed Account Types
key-wallet/src/managed_account/address_pool.rs, key-wallet/src/managed_account/managed_account_type.rs, key-wallet/src/managed_account/managed_platform_account.rs, key-wallet/src/managed_account/metadata.rs, key-wallet/src/managed_account/platform_address.rs
Removed bincode derives and custom trait implementations from address pool, platform account, and related managed account types.
Wallet Management Updates
key-wallet/src/manager/mod.rs
Switched create_wallet_from_mnemonic_return_serialized_bytes() and import_wallet_from_bytes() from #[cfg(feature = "bincode")] to #[cfg(feature = "serde")]; updated serialization calls from bincode::encode_to_vec() to bincode::serde::encode_to_vec() (and decode equivalents).
Wallet Module Changes
key-wallet/src/wallet/mod.rs, key-wallet/src/wallet/backup.rs, key-wallet/src/wallet/root_extended_keys.rs
Removed backup module export and all bincode derives from WalletType and Wallet; deleted entire backup/restore module (~97 lines); removed custom bincode trait implementations for RootExtendedPrivKey and RootExtendedPubKey.
Test Utilities & Tests
key-wallet/src/lib.rs, key-wallet/src/test_macros.rs, key-wallet/src/tests/mod.rs, key-wallet/src/tests/spent_outpoints_tests.rs, key-wallet/src/psbt/mod.rs, key-wallet/tests/test_serialized_wallets.rs
Removed test_macros module declaration, deleted serde_round_trip! test macro, removed spent_outpoints_tests submodule and its entire file (~135 lines); removed a serde PSBT test (~119 lines); switched wallet serialization tests to serde feature.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hops of joy through serde's bright halls,
Bincode's binaries answered their calls,
Features refined, the defaults now clear,
Serialization's spring has surely appeared!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: removing bincode dependency and reducing codebase complexity across the key-wallet library, which is the primary objective reflected in all file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/drop-key-wallet-bincode

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.74%. Comparing base (e7c68d9) to head (f78f84c).
⚠️ Report is 4 commits behind head on v0.42-dev.

Files with missing lines Patch % Lines
key-wallet/src/manager/mod.rs 55.55% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #498      +/-   ##
=============================================
- Coverage      66.84%   66.74%   -0.10%     
=============================================
  Files            314      310       -4     
  Lines          65111    64366     -745     
=============================================
- Hits           43522    42960     -562     
+ Misses         21589    21406     -183     
Flag Coverage Δ
core 75.21% <ø> (ø)
ffi 37.47% <ø> (-0.98%) ⬇️
rpc 28.28% <ø> (ø)
spv 81.10% <ø> (+0.03%) ⬆️
wallet 66.71% <55.55%> (+0.15%) ⬆️
Files with missing lines Coverage Δ
key-wallet-ffi/src/wallet_manager.rs 61.24% <ø> (+7.42%) ⬆️
key-wallet/src/account/account_collection.rs 59.43% <ø> (+0.45%) ⬆️
key-wallet/src/account/account_type.rs 50.27% <ø> (+0.54%) ⬆️
key-wallet/src/account/bls_account.rs 55.59% <ø> (+1.77%) ⬆️
key-wallet/src/account/eddsa_account.rs 58.16% <ø> (+1.67%) ⬆️
key-wallet/src/account/mod.rs 63.00% <ø> (+0.20%) ⬆️
key-wallet/src/bip32.rs 84.17% <ø> (+3.53%) ⬆️
key-wallet/src/derivation_bls_bip32.rs 87.65% <ø> (-4.19%) ⬇️
key-wallet/src/derivation_slip10.rs 61.41% <ø> (+16.34%) ⬆️
key-wallet/src/dip9.rs 6.52% <ø> (+0.13%) ⬆️
... and 11 more

... and 14 files with indirect coverage changes

@github-actions
Copy link

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Mar 10, 2026
@ZocoLini ZocoLini force-pushed the chore/drop-key-wallet-bincode branch from 19e8895 to f78f84c Compare March 25, 2026 17:56
@github-actions github-actions bot removed the merge-conflict The PR conflicts with the target branch. label Mar 25, 2026
@ZocoLini ZocoLini marked this pull request as ready for review March 25, 2026 17:56
@ZocoLini ZocoLini marked this pull request as draft March 25, 2026 18:05
@github-actions
Copy link

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict The PR conflicts with the target branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant