Skip to content

wallet create_dns_tx fails in REPL mode with async dispatch error #385

Open

Description

@emma31-dev

Describe the bug
When using the wallet create_dns_tx command in REPL mode, it fails with the error message:

Error: Generic error: CreateDnsTx is dispatched asynchronously through main

This is inconsistent with normal CLI mode where wallet create_dns_tx works correctly. The command should function identically in both modes.

To Reproduce

  1. Build bdk-cli with the dns_payment feature enabled:
    cargo build --features dns_payment,repl
  2. Start REPL mode:
    bdk-cli --network regtest repl --wallet test_wallet
  3. Try to create a DNS transaction:
    wallet create_dns_tx --to_dns bcrt1qp...0j84c7d7:10000
  4. Observe the error

Expected behavior
The command should successfully create a PSBT from DNS payment instructions, just like it does when run directly via CLI:

bdk-cli --network testnet wallet --wallet test_wallet create_dns_tx --to_dns bcrt1qp...0j84c7d7:10000

Build environment

  • BDK-CLI tag/commit: 9ba7801
  • OS+version: macOS
  • Rust/Cargo version: 1.97.1
  • Rust/Cargo target: x86_64-apple-darwin
  • Features: dns_payment, repl

Additional context

Root Cause

The issue stems from how async commands are handled in REPL mode vs normal CLI mode:

In Normal CLI Mode (works correctly) - src/main.rs lines 97-105:

WalletSubCommand::OfflineWalletSubCommand(cmd) => {
    let runtime = WalletRuntime::load(&home_dir, &wallet_name)?;
    let mut wallet = runtime.build_wallet(command_requires_db(&cmd))?;

    {
        let mut ctx = AppContext::new_offline_wallet(
            runtime.network,
            runtime.home_dir.clone(),
            &mut wallet,
        );

        match cmd {
            #[cfg(feature = "dns_payment")]
            commands::OfflineWalletSubCommand::CreateDnsTx(dns_cmd) => {
                dns_cmd
                    .execute(&mut ctx)
                    .await?
                    .write_out(std::io::stdout())?;
            }
            other => other.execute(&mut ctx)?,
        }
    }
    wallet.persist()?;
}

In REPL Mode (fails) - src/handlers/offline.rs lines 92-94:

#[cfg(feature = "dns_payment")]
Self::CreateDnsTx(_) => Err(Error::Generic(
    "CreateDnsTx is dispatched asynchronously through main".to_string(),
)),

And in src/handlers/repl.rs lines 58-62, offline commands are dispatched synchronously:

WalletSubCommand::OfflineWalletSubCommand(cmd) => {
    let mut ctx = AppContext::new_offline_wallet(network, datadir, wallet);
    cmd.execute(&mut ctx).map_err(|e| e.to_string())?;
    Some(())
}

Technical Details

  • CreateDnsTxCommand implements AsyncAppCommand (in src/handlers/dns/mod.rs lines 84-164)
  • The command requires async because it performs DNS resolution operations (BIP-353)
  • The REPL respond function is already async, but doesn't have special handling for async offline commands
  • Online wallet commands in REPL already handle async correctly (see src/handlers/repl.rs lines 71-81)

Proposed Solution

The REPL handler in src/handlers/repl.rs should replicate the same pattern used in main.rs for handling CreateDnsTx.

Update the OfflineWalletSubCommand handling (currently at lines 58-62) to match with async execution:

WalletSubCommand::OfflineWalletSubCommand(cmd) => {
    let mut ctx = AppContext::new_offline_wallet(network, datadir, wallet);
    match cmd {
        #[cfg(feature = "dns_payment")]
        OfflineWalletSubCommand::CreateDnsTx(dns_cmd) => {
            dns_cmd
                .execute(&mut ctx)
                .await?
                .write_out(std::io::stdout())
                .map_err(|e| e.to_string())?;
        }
        other => {
            other.execute(&mut ctx).map_err(|e| e.to_string())?;
        }
    }
    Some(())
}

Once this is implemented in REPL mode, the error-returning stub in src/handlers/offline.rs (lines 92-94) can be removed since the command will be handled directly in the REPL dispatcher, just like it is in main.

Activity

  1. added
    bug
    on Nov 12, 2026
  2. Markadrian6399 commented on Nov 13, 2026

    @Markadrian6399

    I hit this on 9ba7801 too. One thing I noticed: the snippet in the proposed solution won’t compile as is. OfflineWalletSubCommand and AsyncAppCommand need importing. And since respond returns a String error, the ? after .await needs a .map_err(|e| e.to_string()) first. I’d like to work on this

  3. emma31-dev commented on Nov 13, 2026

    @emma31-dev
    ContributorAuthor

    I hit this on 9ba7801 too. One thing I noticed: the snippet in the proposed solution won’t compile as is. OfflineWalletSubCommand and AsyncAppCommand need importing. And since respond returns a String error, the ? after .await needs a .map_err(|e| e.to_string()) first. I’d like to work on this

    It was just a reference.

    Sure, you can work on it.

  4. added a commit that references this issue on Nov 14, 2026
    363fbd1
  5. moved this from Todo to In Progress in BDK-CLIon Nov 14, 2026
  6. added a commit that references this issue on Nov 15, 2026
    fe50271
  7. added 2 commits that reference this issue on Nov 24, 2026
    992bd06
    c5e5442
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    • Status
      In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions