Skip to content

fix(repl): run create_dns_tx through AsyncAppCommand - #390

Open
Markadrian6399 wants to merge 1 commit into
bitcoindevkit:masterfrom
Markadrian6399:fix/repl-create-dns-tx
Open

Markadrian6399 wants to merge 1 commit into
bitcoindevkit:masterfrom
Markadrian6399:fix/repl-create-dns-tx

Conversation

@Markadrian6399

Copy link
Copy Markdown

Description

Running wallet create_dns_tx in REPL mode failed with:

Error: Generic error: CreateDnsTx is dispatched asynchronously through main

The same command works fine outside the REPL. The REPL handler sent all offline wallet commands through the sync AppCommand::execute, so CreateDnsTx hit the stub in offline.rs and errored out.

This change matches on the offline subcommand in respond and awaits CreateDnsTx through AsyncAppCommand, like main.rs already does.

Fixes #385

Notes to the reviewers

I kept the CreateDnsTx arm in offline.rs since that match has to be exhaustive. I only updated its error message so it points to the async path.

The new imports in repl.rs are behind dns_payment, so building with just repl doesn't warn about unused imports.

Added a regression test in tests/integration/offline.rs.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

Bugfixes:

  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@emma31-dev emma31-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for picking this up!

I was thinking, Rather than adding a second CreateDnsTx dispatch here and keeping the error stub in offline.rs, consider making OfflineWalletSubCommand::execute async instead. Both call sites (main::run and repl::respond) are already async, so each collapses to cmd.execute(&mut ctx).await?, the main.rs special case can go away, and the CreateDnsTx arm in offline.rs can await AsyncAppCommand directly. That removes the need for two entry points to know which offline command is async, and avoids this dispatch logic being duplicated again if another async offline command is added. The regression test is useful.

@vadim-anfv @tvpeter What do you think of this approach instead?

@emma31-dev

Copy link
Copy Markdown
Contributor

@Markadrian6399 Another thing, It seems the signature used hasn't been added to to your github so it is showing unverified

create_dns_tx failed in REPL mode with "CreateDnsTx is dispatched
asynchronously through main". The REPL ran every offline command
through the sync execute, so CreateDnsTx hit the error stub.

OfflineWalletSubCommand::execute is now async, and the CreateDnsTx arm
awaits the DNS command directly. main and the REPL both just await
cmd.execute, so the special case in main.rs and the stub are gone.
Adds a REPL regression test.

Fixes bitcoindevkit#385
@Markadrian6399

Copy link
Copy Markdown
Author

Thanks for the suggestion, that’s much cleaner.
I’ve made OfflineWalletSubCommand::execute async, so main and the REPL now both just call cmd.execute(&mut ctx).await.

@emma31-dev emma31-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for switching to the async aggregator! The change looks good and is much cleaner than the duplicated dispatch.

However, the regression test doesn’t look updated from the first revision, and it will fail in the --all-features CI job. That build enables an online backend, which makes wallet config require --client-type and --url; the test’s setup only passes the descriptors and --database-type sqlite, so it exits with code 2 before the REPL even starts:

error: the following required arguments were not provided:
  --client-type <CLIENT_TYPE>
  --url <URL>

I reproduced this with --features electrum,dns_payment. It passes with only repl,dns_payment,sqlite, but that isn’t what --all-features runs. This is the same class of issue as repl_persist_tests. Could you either: gate repl_dns_tests like multipath_tests so it only runs in offline-only builds, or pass --client-type/--url conditionally based on which backend feature is enabled.

Please run cargo test --all-features --test cli before pushing.

Minor: the "Insufficient funds" assertion is a bit brittle. Asserting that the stub message is absent plus that some non-stub error occurred would be more durable.

@tvpeter tvpeter added this to the CLI 4.1.0 milestone Nov 18, 2026
@tvpeter tvpeter moved this from Todo to Ready to Review in BDK-CLI Nov 18, 2026

This branch has not been deployed

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

Labels

None yet

Projects

Status: Ready to Review

Development

Successfully merging this pull request may close these issues.

wallet create_dns_tx fails in REPL mode with async dispatch error

3 participants