Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wallet examples #1442

Conversation

storopoli
Copy link
Contributor

@storopoli storopoli commented May 14, 2024

Description

Fix wallet examples.

Closes #1434

Notes to the reviewers

  • Print balances only in BTC
  • Uses Signet instead of Testnet
  • Fix wallet_esplora_async printing the KeychainKind twice, and forgets to print spk0
  • Change wallet examples to use mempool.space (Electrum) or BDK's signet (Esplora) to fix rate limiting issues, along with more conservative PARALLEL_REQUESTS
  • Standardize code for wallet_esplora_*
  • Uses the new BDK rustsqlite feature (in memory) instead of BDK's file store.

Changelog notice

  • fix BDK wallet example crates

Checklists

All Submissions:

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

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@storopoli storopoli changed the title Storopoli/fix-wallet-examples fix: wallet examples May 14, 2024
Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

ACK 214fa09

I'm just wondering if we should add a new dependency, but I don't see much problem as it's only on the example-crates

@storopoli
Copy link
Contributor Author

ACK 214fa09

I'm just wondering if we should add a new dependency, but I don't see much problem as it's only on the example-crates

But then it adds extra compile time and further surface for conflicts and other errors in all CI tests and Clippy checks...

That's the overhead that I referred to.

@ValuedMammal
Copy link
Contributor

I'm just wondering if we should add a new dependency, but I don't see much problem as it's only on the example-crates

But then it adds extra compile time and further surface for conflicts and other errors in all CI tests and Clippy checks...

That's the overhead that I referred to.

We could use Wallet::new_no_persist and forget about bringing in tempfile, but that would make the examples somewhat less illustrative. I recommended tempfile because otherwise the db file is left lingering in your system's tempdir which is kind of a nuisance #1045

Copy link
Contributor

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

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

I left a few comments. Additionally we should fix printing balances for wallet_rpc like you have in 96c0129, but besides that I think the rpc example is mostly fine. Also, what do you think about switching the examples to use Signet?

example-crates/wallet_esplora_blocking/src/main.rs Outdated Show resolved Hide resolved
example-crates/wallet_esplora_blocking/src/main.rs Outdated Show resolved Hide resolved
@notmandatory notmandatory added the documentation Improvements or additions to documentation label May 16, 2024
@notmandatory notmandatory added this to the 1.0.0-beta milestone May 16, 2024
@storopoli storopoli requested a review from ValuedMammal May 16, 2024 12:11
Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

utACK eeb3b7c

Copy link
Contributor

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

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

ACK eeb3b7c

Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

ACK cf22595

@storopoli
Copy link
Contributor Author

We might need to revisit this after #1128 was merged.
I only changed the async esplora wallet example,
so we might need to change the explora blocking and elecrum wallet examples.

Since we are using the bdk_sqlite crate now, we don't need tempdir.

@storopoli storopoli force-pushed the storopoli/fix-wallet-examples branch 2 times, most recently from c2802fe to 982756f Compare May 27, 2024 07:35
@storopoli
Copy link
Contributor Author

We might need to revisit this after #1128 was merged. I only changed the async esplora wallet example, so we might need to change the explora blocking and elecrum wallet examples.

Since we are using the bdk_sqlite crate now, we don't need tempdir.

Done! We are using bdk_sqlite now instead of tempdir in all wallet_* examples.

Ready for a new quick round of reviews @ValuedMammal and @oleonardolima

Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

ACK 982756f

Copy link
Contributor

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

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

ACK 982756f

This is beautiful. I'm wondering if we should change the faucet address to one that we know will be able to recycle the sats, probably doesn't need to be done now though, and to be honest I usually don't broadcast when running the example code anyway.

@oleonardolima
Copy link
Contributor

This is beautiful. I'm wondering if we should change the faucet address to one that we know will be able to recycle the sats, probably doesn't need to be done now though, and to be honest I usually don't broadcast when running the example code anyway.

That's a good point, maybe we could use one that's been used by @thunderbiscuit for the tests on the CI ? 🤔

@storopoli storopoli force-pushed the storopoli/fix-wallet-examples branch 2 times, most recently from 0e8124e to 3a0a1e2 Compare July 1, 2024 14:29
@storopoli
Copy link
Contributor Author

rebased

@thunderbiscuit
Copy link
Member

FYI I'm in the process of securing signet satoshis for the foundation. Once I have them I'll let everyone know in the chat and I can send the to whatever wallets we need.

README.md Outdated Show resolved Hide resolved
example-crates/wallet_rpc/src/main.rs Show resolved Hide resolved
@storopoli storopoli force-pushed the storopoli/fix-wallet-examples branch from bd8daef to 1c9d131 Compare July 3, 2024 16:05
@storopoli
Copy link
Contributor Author

Thanks @ValuedMammal. I've incorporated all of your suggestions, rebased and squashed everything into a single fix: wallet examples commit.

Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

tACK
besides the minor comment about the wallet_rpc README, it looks good to me.

example-crates/wallet_rpc/README.md Outdated Show resolved Hide resolved
@storopoli storopoli force-pushed the storopoli/fix-wallet-examples branch from 1c9d131 to 3d08c0d Compare July 4, 2024 16:06
Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

ACK 3d08c0d

@ValuedMammal
Copy link
Contributor

Just to recap I think there's a few things missing. Not sure if maybe something went wrong during a rebase. If we can fix these then I'd like to merge it soon to avoid more review churn.

  • Bring back the calls to wallet.take_staged() and db.write()
  • For electrum remember to use the new populate_tx_cache method
  • Fix typo in README, fix: wallet examples #1442 (comment)
  • For wallet_rpc I don't mind hardcoding the descriptors, just make sure the wallet_rpc/README matches the output of the help command cargo run --bin wallet_rpc -- --help

@storopoli storopoli force-pushed the storopoli/fix-wallet-examples branch 4 times, most recently from 00a7d32 to 0f4ab48 Compare July 9, 2024 16:02
@storopoli
Copy link
Contributor Author

Just to recap I think there's a few things missing. Not sure if maybe something went wrong during a rebase. If we can fix these then I'd like to merge it soon to avoid more review churn.

* Bring back the calls to `wallet.take_staged()` and `db.write()`

* For electrum remember to use the new `populate_tx_cache` method

* Fix typo in README, [fix: wallet examples #1442 (comment)](https://github.com/bitcoindevkit/bdk/pull/1442#discussion_r1663126729)

* For wallet_rpc I don't mind hardcoding the descriptors, just make sure the wallet_rpc/README matches the output of the help command `cargo run --bin wallet_rpc -- --help`

@ValuedMammal Thank you so much for going through this.
I made a mess in a rebase and all of these things were reverted back somehow.
They are properly fixed now.

@ValuedMammal
Copy link
Contributor

self-ACK 31f8b95

@notmandatory This looks good to me

Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

tACK 31f8b95

@storopoli storopoli force-pushed the storopoli/fix-wallet-examples branch from 31f8b95 to e282641 Compare July 28, 2024 20:11
@storopoli
Copy link
Contributor Author

rebased

- Print balances only in BTC
- Uses Signet instead of Testnet
- Fix wallet_esplora_async printing the KeychainKind twice, and forgets
  to print spk0
- Change wallet examples to use mempool.space (Electrum) or BDK's signet
  (Esplora) to fix rate limiting issues, along with more conservative
  PARALLEL_REQUESTS
- Standardize code for wallet_esplora_*
- Uses the new BDK rustsqlite (in-memory) instead of BDK's file store.
- Electrum: use the new populate_tx_cache method

Co-authored-by: ValuedMammal <[email protected]>
@storopoli storopoli force-pushed the storopoli/fix-wallet-examples branch from e282641 to dbd4f44 Compare July 28, 2024 20:13
Copy link
Contributor

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

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

Seeing that #1514 made significant improvements to the wallet examples, my feeling on this PR as of now is that most of the changes can be dropped except to fix these

  • remove "sats" from displayed balance
  • swap faucet address for BDK's address
  • electrum: fix inspect-spks

@ValuedMammal
Copy link
Contributor

Remember to include the "rusqlite" feature in Cargo.toml for any example crates that use it

@evanlinjin
Copy link
Member

Concept ACK, although changes in #1478 are going to somewhat conflict with this (expect a rebase). I would appreciate it if we merge #1478 before this one (since that one is a larger PR).

@notmandatory
Copy link
Member

@storopoli we can close this one now right?

@storopoli storopoli closed this Sep 19, 2024
@storopoli storopoli deleted the storopoli/fix-wallet-examples branch September 19, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

example: Fix wallet examples
6 participants