Repository navigation
Description
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
- Build bdk-cli with the
dns_paymentfeature enabled:cargo build --features dns_payment,repl
- Start REPL mode:
bdk-cli --network regtest repl --wallet test_wallet
- Try to create a DNS transaction:
wallet create_dns_tx --to_dns bcrt1qp...0j84c7d7:10000
- 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:10000Build 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
CreateDnsTxCommandimplementsAsyncAppCommand(insrc/handlers/dns/mod.rslines 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.rslines 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
Markadrian6399 commentedon Nov 13, 2026
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
emma31-dev commentedon Nov 13, 2026
It was just a reference.
Sure, you can work on it.
fix(repl): run create_dns_tx through AsyncAppCommand
fix(repl): make offline wallet commands async
fix(repl): make offline wallet commands async
fix(repl): make offline wallet commands async