Skip to content

Prevent address generation on startup#82

Open
ekulkisnek wants to merge 2 commits into
LayerTwo-Labs:masterfrom
ekulkisnek:fix-address-generation-startup
Open

Prevent address generation on startup#82
ekulkisnek wants to merge 2 commits into
LayerTwo-Labs:masterfrom
ekulkisnek:fix-address-generation-startup

Conversation

@ekulkisnek
Copy link
Copy Markdown

@ekulkisnek ekulkisnek commented May 19, 2026

Description

This PR resolves the issue where the Thunder GUI window size was too small on startup and caused layout squishing (vertical letters) in the Mempool Explorer and Transaction Builder tabs.

Changes Made

  1. Initial Window Size: Configured eframe::NativeOptions in app/main.rs to set the default viewport inner size to 1280x720 pixels.
  2. Transaction Builder Tab: Replaced nested SidePanel containers inside ScrollArea with ui.horizontal and ui.vertical columns using fixed widths. This resolves layout breaking and enables correct horizontal scrolling behavior. Also updated the spent UTXOs grid ID to "spent_utxos" to prevent ID collisions.
  3. Mempool Explorer Tab: Wrapped the columns in a horizontal ScrollArea and replaced nested SidePanels with ui.horizontal and ui.vertical columns. Renamed the outputs grid from "inputs" to "outputs" to fix a duplicate ID warning.
  4. Formatting: Formatted all changes using cargo fmt.

Verification

  • Verified compilation with cargo check.
  • Verified that the full workspace test suite passes successfully with cargo test.
  • Verified that no Clippy warnings or formatting errors are present.

This pull request was made by Antigravity Gemini 3.5 Flash High.

Avoid generating and writing a new wallet address to LMDB every time the GUI application starts up, which could lead to performance degradation. Instead, reuse the last generated address on initialization, and only generate a new address on user demand (via explicit 'generate' button).
@fumin
Copy link
Copy Markdown
Contributor

fumin commented May 20, 2026

Thanks, I think this commit c4fe7d6 in this PR solves the issue #80 where a new wallet address was generated every time the Thunder app starts up.

Comment thread app/app.rs
}

pub fn get_new_main_address(
pub async fn get_new_main_address_async(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd prefer to explicitly name get_new_main_address as blocking - I think names like

pub async fn get_new_main_address(..)

pub fn get_new_main_address_blocking(..)

would be better

Comment thread app/app.rs
}

pub fn deposit(
pub async fn deposit_async(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd prefer to explicitly name deposit as blocking - I think names like

pub async fn deposit(..)

pub fn deposit_blocking(..)

would be better

Comment thread app/main.rs
});

if !config.headless {
let fallback_rt;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to do deferred initialization if possible - something like

let rt_handle = match &app {
    Ok(app) => Some(app.runtime.handle().clone()),
    Err(_) =>
        // fallback runtime
        tokio::runtime::Builder::new_multi_thread()
                    .enable_all()
                    .build()
                    .ok(),
};
let _rt_guard = rt_handle.as_ref().map(|rt| rt.enter());

would be cleaner

Comment thread lib/wallet.rs
Ok(address)
}

pub fn get_last_address(&self) -> Result<Option<Address>, Error> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better naming convention here would be

/// Gets the latest generated address
pub fn try_get_last_address(&self) -> Result<Option<Address>, Error> {...}

/// Gets the latest generated address, or generates a new one if no addresses have already been generated
pub fn get_or_generate_last_address -> Result<Address, Error> {...}

Comment thread lib/wallet.rs
use super::*;

#[test]
fn test_get_address_or_new() -> Result<(), Error> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to return a Result<(), Error> here, because the error will not be formatted with sources if encountered during the test. Use anyhow::Result<()> here instead

Comment thread lib/wallet.rs
.unwrap()
.as_nanos()
));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: a lot of useless line breaks here, this test could be a lot more compact without compromising readablility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants