refactor: move Credentials out of wallet implementation#455
Conversation
in preparation for lwk
|
Warning Rate limit exceeded@jackstar12 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 58 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis change migrates wallet credential structures and related interfaces from the Changes
Sequence Diagram(s)sequenceDiagram
participant RPCServer
participant Database
participant Onchain
RPCServer->>Onchain: ImportWallet(credentials: *WalletCredentials)
Onchain->>Onchain: Encrypt/Decrypt credentials
RPCServer->>Database: Store/Retrieve WalletCredentials
Database-->>RPCServer: Return WalletCredentials
RPCServer->>Onchain: Login(credentials: *WalletCredentials)
Onchain-->>RPCServer: Wallet instance or error
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
internal/database/wallet.go(5 hunks)internal/onchain/encrypt.go(1 hunks)internal/onchain/encrypt_test.go(1 hunks)internal/onchain/onchain.go(0 hunks)internal/onchain/wallet.go(1 hunks)internal/onchain/wallet/wallet.go(1 hunks)internal/onchain/wallet/wallet_test.go(7 hunks)internal/rpcserver/router.go(7 hunks)internal/rpcserver/rpcserver_test.go(1 hunks)internal/rpcserver/serializer.go(1 hunks)internal/test/test.go(1 hunks)
💤 Files with no reviewable changes (1)
- internal/onchain/onchain.go
🧰 Additional context used
🧬 Code Graph Analysis (4)
internal/rpcserver/serializer.go (2)
internal/onchain/wallet.go (1)
WalletCredentials(67-74)pkg/boltzrpc/boltzrpc.pb.go (3)
WalletCredentials(4309-4320)WalletCredentials(4335-4335)WalletCredentials(4350-4352)
internal/rpcserver/rpcserver_test.go (3)
internal/onchain/wallet.go (1)
WalletCredentials(67-74)internal/test/test.go (1)
WalletCredentials(52-63)pkg/boltzrpc/boltzrpc.pb.go (3)
WalletCredentials(4309-4320)WalletCredentials(4335-4335)WalletCredentials(4350-4352)
internal/rpcserver/router.go (7)
internal/onchain/wallet.go (2)
WalletCredentials(67-74)Wallet(47-57)internal/test/test.go (1)
WalletCredentials(52-63)pkg/boltzrpc/boltzrpc.pb.go (6)
WalletCredentials(4309-4320)WalletCredentials(4335-4335)WalletCredentials(4350-4352)Wallet(5777-5788)Wallet(5803-5803)Wallet(5818-5820)internal/database/wallet.go (1)
Wallet(9-12)internal/onchain/wallet/wallet.go (1)
Wallet(61-68)internal/onchain/onchain.go (1)
Id(19-19)internal/database/database.go (1)
Id(327-327)
internal/onchain/wallet.go (3)
internal/onchain/onchain.go (2)
Id(19-19)Currency(71-76)internal/test/test.go (1)
WalletCredentials(52-63)internal/onchain/wallet/wallet.go (1)
Subaccount(53-59)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: CI (ubuntu-latest, 1.24.x)
🔇 Additional comments (14)
internal/onchain/encrypt.go (1)
1-1: LGTM! Package refactoring aligns with PR objectives.The package declaration change from
wallettoonchainis consistent with the refactoring goal of movingCredentialsout of the wallet implementation into the broader onchain package.internal/onchain/encrypt_test.go (1)
1-1: LGTM! Package refactoring with comprehensive test coverage.The package declaration change from
wallettoonchainis consistent with the refactoring objectives. The test provides excellent coverage for the encryption functionality, including both success and failure scenarios.internal/rpcserver/rpcserver_test.go (1)
1725-1725: LGTM! Field name updated to match new credential structure.The field name change from
CredentialstoWalletCredentialscorrectly reflects the updated database schema that now embedsonchain.WalletCredentialsinstead of the legacywallet.Credentialstype.internal/rpcserver/serializer.go (1)
240-240: LGTM! Function signature updated to use new credential type.The parameter type change from
*wallet.Credentialsto*onchain.WalletCredentialsis consistent with the refactoring effort. The function body remains unchanged, indicating that the field structure between the old and new types is compatible for serialization purposes.internal/onchain/wallet/wallet_test.go (1)
146-257: LGTM! Consistent type reference updates.The changes correctly update all references from
onchainWallet.Credentialstoonchain.WalletCredentialswhile preserving the test logic and structure. The refactoring is applied consistently across all test cases.internal/test/test.go (1)
52-54: LGTM! Clean type migration in test utility.The function signature and return type are correctly updated to use
onchain.WalletCredentialswhile maintaining the same functionality and structure.internal/database/wallet.go (5)
6-6: LGTM! Import updated correctly.The import path is properly updated to reference the new
onchainpackage instead of thewalletpackage.
10-10: LGTM! Embedded struct type updated correctly.The embedded struct approach is maintained while using the new
onchain.WalletCredentialstype, preserving the inheritance of credential fields.
31-43: LGTM! Function signature updated consistently.The
UpdateWalletCredentialsfunction parameter type is correctly updated to useonchain.WalletCredentialswhile maintaining the same functionality.
47-47: LGTM! Struct initialization updated correctly.The initialization properly creates the new
onchain.WalletCredentialstype within the embedded struct pattern.
95-116: LGTM! Return type and logic updated consistently.The
QueryWalletCredentialsfunction correctly:
- Returns the new type
[]*onchain.WalletCredentials- Uses the proper variable declaration
- Accesses the embedded credential via
wallet.WalletCredentialsinternal/onchain/wallet/wallet.go (1)
441-508:Details
✅ Verification successful
LGTM! Login function updated to use new credential type.
The
Loginfunction parameter is correctly updated to accept*onchain.WalletCredentialswhile preserving all the existing logic for credential validation, wallet connection, and subaccount handling.Let me verify that this refactoring was applied consistently across the entire codebase:
🏁 Script executed:
#!/bin/bash # Description: Verify that all references to the old credential type have been updated # Expected: No remaining references to onchainWallet.Credentials or wallet.Credentials in wallet context echo "Checking for any remaining references to old credential types..." # Search for old credential type references rg "onchainWallet\.Credentials" --type go # Search for wallet.Credentials that might be related to this refactoring rg "wallet\.Credentials" --type go # Verify new type is being used echo -e "\nVerifying new type usage:" rg "onchain\.WalletCredentials" --type go -C 2Length of output: 7361
Refactoring of Credential Type Verified
I ran a global search and confirmed there are no remaining references to the old credential types (
onchainWallet.Credentialsorwallet.Credentials). All authentication and serialization logic now uniformly uses*onchain.WalletCredentialsacross:
- internal/rpcserver/serializer.go
- internal/rpcserver/router.go
- internal/onchain/wallet/wallet.go & wallet_test.go
- internal/database/wallet.go
No further changes required.
internal/rpcserver/router.go (1)
1393-1393: LGTM! Consistent refactoring to useonchain.WalletCredentials.All references to
wallet.Credentialshave been properly updated to useonchain.WalletCredentials, and the database interactions have been adjusted to use theWalletCredentialsfield. The variable rename fromcredstodbWalletimproves code clarity.Also applies to: 1428-1428, 1451-1461, 1810-1824, 1907-1907, 1924-1924, 2009-2011
internal/onchain/wallet.go (1)
1-118: Well-structured wallet types and interfaces.The new
onchainpackage provides a clean separation of wallet-related types and interfaces. TheWalletCredentialsstruct properly extendsWalletInfowith sensitive data fields, and the encryption/decryption methods handle different credential types appropriately. This refactoring successfully centralizes wallet management functionality.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
in preparation for lwk
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Tests