feat: add optional birthday#6975
Conversation
WalkthroughThe changes introduce support for an optional "birthday" parameter throughout the Minotari console wallet. This parameter can be provided via the CLI, interactively prompted during wallet initialization, and is now included in relevant wallet data structures. The wallet's birthday is also serialized when exporting view and spend keys, and is used to determine the starting point for UTXO scanning. Logic and method signatures are updated to propagate this optional birthday value, ensuring it is consistently available and utilized across wallet creation, export, and scanning operations. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant WalletInit
participant WalletDB
participant UTXOScanner
User->>CLI: Start wallet with --birthday or interactively
CLI->>WalletInit: Passes birthday (if provided)
WalletInit->>WalletDB: Stores/uses birthday in wallet creation
WalletInit->>UTXOScanner: Passes birthday for scanning start
UTXOScanner->>WalletDB: Uses birthday to determine scan height
UTXOScanner->>CLI: Scanning starts from birthday-derived block
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
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:
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: 0
🧹 Nitpick comments (1)
applications/minotari_console_wallet/src/init/mod.rs (1)
795-804: Consider improving the wallet birthday prompt message.The prompt message could be more descriptive to better explain what the wallet birthday represents (block height) and its purpose (scanning starting point).
- let mut birthday = InputPrompt::<u16>::new() - .with_prompt("Please enter wallet birth, or enter to skip ") + let mut birthday = InputPrompt::<u16>::new() + .with_prompt("Please enter wallet birthday (block height for scanning), or enter to skip ")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
applications/minotari_console_wallet/src/automation/commands.rs(2 hunks)applications/minotari_console_wallet/src/cli.rs(1 hunks)applications/minotari_console_wallet/src/init/mod.rs(7 hunks)applications/minotari_console_wallet/src/lib.rs(1 hunks)base_layer/common_types/src/wallet_types.rs(1 hunks)base_layer/wallet/src/utxo_scanner_service/utxo_scanner_task.rs(2 hunks)integration_tests/src/wallet_process.rs(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
applications/minotari_console_wallet/src/automation/commands.rs (1)
base_layer/key_manager/src/cipher_seed.rs (1)
birthday(330-332)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: ci
🔇 Additional comments (15)
applications/minotari_console_wallet/src/lib.rs (1)
110-110: Properly added optional birthday field.The addition of the optional
birthdayfield set toNoneis consistent with other changes in the codebase. This ensures the wallet initialization can properly handle the optional birthday parameter introduced for wallet creation and scanning.base_layer/common_types/src/wallet_types.rs (1)
57-57: Correctly extended ProvidedKeysWallet with optional birthday field.The addition of the
birthday: Option<u16>field to theProvidedKeysWalletstruct provides the necessary data structure support for the wallet birthday feature. The field is appropriately typed as optional and usingu16is suitable for a blockchain height offset or related metric.integration_tests/src/wallet_process.rs (1)
238-238: Updated test CLI structure with birthday field.The integration test's default CLI setup has been correctly updated to include the new optional
birthdayfield set toNone, ensuring test consistency with the application code.applications/minotari_console_wallet/src/cli.rs (1)
102-103: Added CLI support for optional wallet birthday parameter.The new CLI option for
birthdayhas been correctly implemented as an optionalu16with the#[clap(long)]attribute. This allows users to specify the wallet birthday via the--birthdaycommand-line argument, which will be used to determine the starting point for UTXO scanning.applications/minotari_console_wallet/src/automation/commands.rs (2)
2519-2519: Birthday value retrieved and incorporated into wallet export functionalityThe addition of retrieving the wallet birthday from the database integrates well with the broader changes to support wallet birthday throughout the codebase.
2525-2525: Complete wallet birthday support in export functionalityThe birthday field has been consistently added to the ViewKeyFile struct, populated when creating the ViewKeyFile instance, and included in console output when not exporting to a file.
Also applies to: 2531-2531, 2542-2542
base_layer/wallet/src/utxo_scanner_service/utxo_scanner_task.rs (2)
270-274: Refactored wallet scanning to use birthday parameterThe code now properly passes the optional birthday from
ProvidedKeyswallet type to the scanning method, while passingNonefor other wallet types. This creates a more flexible and consistent approach to determining the scanning start point.
748-753: Improved UTXO scanning with wallet birthday supportThe method now accepts an optional birthday parameter and implements a fallback mechanism to get the birthday from the database if not provided. This allows for a more consistent scanning approach across wallet types while improving performance by avoiding unnecessary scanning from genesis for recently created wallets.
applications/minotari_console_wallet/src/init/mod.rs (7)
28-28: Appropriate import added for birthday input handling.The new import
dialoguer::Input as InputPromptis correctly added to support the interactive prompt for wallet birthday.
105-105: Correctly added optional birthday field to ViewAndSpendKey variant.The
WalletBoot::ViewAndSpendKeyenum variant has been properly updated to include an optionalbirthdayfield of typeOption<u16>.
755-755: Birthday correctly passed from CLI arguments.The
bootfunction now properly returns the birthday value from CLI arguments when creating a wallet from view and spend keys.
845-845: Pattern matching correctly updated for struct variant.The pattern matching in
boot_with_passwordhas been properly updated to match the new struct variant with the birthday field.
861-861: Pattern matching in conditional properly updated.The condition in
prompt_wallet_typehas been correctly updated to use thematches!macro with the new struct variant pattern.
866-866: Birthday field correctly extracted in pattern matching.The pattern matching in
prompt_wallet_typenow properly extracts the birthday field from theWalletBoot::ViewAndSpendKeyvariant.
895-895: Birthday correctly propagated to wallet type.The birthday value is properly passed from the
WalletBootenum to theWalletType::ProvidedKeysstruct, ensuring it's available for downstream components.
Works along with the tari-project/tari#6975 Description --- Use wallet birthday argument so it won't be necessary to scan utxos from the genesis block * For fresh wallets, scans blocks only from last 2 weeks(birthday - 2 weeks) Additional improvements --- * When wallet is up to date, it might scan before grpc service started - in this case it will return `scanned_height: 0`. Require 3 connections and 10 retries(10 wallet state updates) instead of 2 * Break progress emitter(condition was never true) * Log out initial wallet scan progress for easier debugging in future <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Added ability to retrieve and display the wallet's birthday (the block height from which the wallet starts scanning the blockchain). - Introduced new methods to access wallet keys and seed words. - **Improvements** - Enhanced wallet startup by allowing the blockchain scan to begin from a specified birthday, improving performance for existing wallets. - Centralized and streamlined wallet seed retrieval for better reliability and maintainability. - Improved wallet scan progress monitoring with more informative logging and refined completion detection. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Description
Allows users to specify the wallet birthday
Summary by CodeRabbit