]> Untitled Git - bdk/log
bdk
2 years agoExplicitly deny multipath keys
Daniela Brozzoni [Wed, 19 Jul 2023 16:48:20 +0000 (18:48 +0200)]
Explicitly deny multipath keys

Although there is *some* code to handle multipath keys inside bdk,
it's all untested, and from a few quick tests it
seems that it's pretty easy to find buggy edge cases.
Better to deny multipath descs for now, and revisit the
decision once we work on supporting multidescriptor wallets.

2 years agoUpdate wallet_electrum to rust-bitcoin 0.30.0
Daniela Brozzoni [Wed, 28 Jun 2023 13:13:22 +0000 (15:13 +0200)]
Update wallet_electrum to rust-bitcoin 0.30.0

2 years agoUpdate example_electrum to rust-bitcoin 0.30.0
Daniela Brozzoni [Wed, 28 Jun 2023 13:12:56 +0000 (15:12 +0200)]
Update example_electrum to rust-bitcoin 0.30.0

2 years agoUpdate example_cli to rust-bitcoin 0.30.0
Daniela Brozzoni [Mon, 26 Jun 2023 10:18:43 +0000 (12:18 +0200)]
Update example_cli to rust-bitcoin 0.30.0

2 years agoUpdate tmp_plan to rust-bitcoin 0.30.0
Daniela Brozzoni [Mon, 26 Jun 2023 10:18:15 +0000 (12:18 +0200)]
Update tmp_plan to rust-bitcoin 0.30.0

2 years agoUpdate coin_select to rust-bitcoin 0.30.0
Daniela Brozzoni [Mon, 26 Jun 2023 10:18:15 +0000 (12:18 +0200)]
Update coin_select to rust-bitcoin 0.30.0

2 years agoUpdate wallet_esplora and wallet_esplora_async to...
Daniela Brozzoni [Mon, 26 Jun 2023 10:15:09 +0000 (12:15 +0200)]
Update wallet_esplora and wallet_esplora_async to...
...rust-bitcoin 0.30.0

2 years agoUpdate crates/esplora to rust-bitcoin 0.30.0
Daniela Brozzoni [Sat, 24 Jun 2023 16:06:23 +0000 (18:06 +0200)]
Update crates/esplora to rust-bitcoin 0.30.0

2 years agoUpdate crates/electrum to bitcoin 0.30.0
Daniela Brozzoni [Sat, 24 Jun 2023 16:06:23 +0000 (18:06 +0200)]
Update crates/electrum to bitcoin 0.30.0

2 years agoUpdate bdk to bitcoin 0.30.0
Daniela Brozzoni [Wed, 19 Jul 2023 13:27:48 +0000 (15:27 +0200)]
Update bdk to bitcoin 0.30.0

2 years agoUpdate bdk_chain to bitcoin 0.30.0
Daniela Brozzoni [Wed, 21 Jun 2023 15:59:34 +0000 (17:59 +0200)]
Update bdk_chain to bitcoin 0.30.0

2 years agoMerge bitcoindevkit/bdk#1034: Implement linked-list `LocalChain` and update chain...
志宇 [Thu, 3 Aug 2023 08:04:30 +0000 (16:04 +0800)]
Merge bitcoindevkit/bdk#1034: Implement linked-list `LocalChain` and update chain-src crates/examples

b206a985cffaa9b614841219371faa53ba23dfc3 fix: Even more refactoring to code and documentation (志宇)
bea8e5aff4f1e4d61db3970a6efaec86e686dbc3 fix: `TxGraph::missing_blocks` logic (志宇)
db15e03bdce78c6321f906f390b10b3d9e7501b2 fix: improve more docs and more refactoring (志宇)
95312d4d05618b4c464acc0fdff49fb17405ec88 fix: docs and some minor refactoring (志宇)
8bf7a997f70fdffd072fd37e12c385e731728c5a Refactor `debug_assertions` checks for `LocalChain` (志宇)
315e7e0b4b373d7175f21a48ff6480b6e919a2c6 fix: rm duplicate `bdk_tmp_plan` module (志宇)
af705da1a846214f104df8886201a23cfa4b6b74 Add exclusion of example cli `*.db` files in `.gitignore` (志宇)
eabeb6ccb169b32f7b7541c9dc6481693bdeeb8a Implement linked-list `LocalChain` and update chain-src crates/examples (志宇)

Pull request description:

  Fixes #997
  Replaces #1002

  ### Description

  This PR changes the `LocalChain` implementation to have blocks stored as a linked-list. This allows the data-src thread to hold a shared ref to a single checkpoint and have access to the whole history of checkpoints without cloning or keeping a lock on `LocalChain`.

  The APIs of `bdk::Wallet`, `esplora` and `electrum` are also updated to reflect these changes. Note that the `esplora` crate is rewritten to anchor txs in the confirmation block (using the esplora API's tx status block_hash). This guarantees 100% consistency between anchor blocks and their transactions (instead of anchoring txs to the latest tip). `ExploraExt` now has separate methods for updating the `TxGraph` and `LocalChain`.

  A new method `TxGraph::missing_blocks` is introduced for finding "floating anchors" of a `TxGraph` update (given a chain).

  Additional changes:

  * `test_local_chain.rs` is refactored to make test cases easier to write. Additional tests are also added.
  * Examples are updated.
  * Exclude example-cli `*.db` files in `.gitignore`.
  * Rm duplicate `bdk_tmp_plan` module.

  ### Notes to the reviewers

  This is the smallest possible division of #1002 without resulting in PRs that do not compile. Since we have changed the API of `LocalChain`, we also need to change `esplora`, `electrum` crates and examples alongside `bdk::Wallet`.

  ### Changelog notice

  * Implement linked-list `LocalChain`. This allows the data-src thread to hold a shared ref to a single checkpoint and have access to the whole history of checkpoints without cloning or keeping a lock on `LocalChain`.
  * Rewrote `esplora` chain-src crate to anchor txs to their confirmation blocks (using esplora API's tx-status `block_hash`).

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] I've added docs for the new feature

ACKs for top commit:
  LLFourn:
    ACK b206a985cffaa9b614841219371faa53ba23dfc3

Tree-SHA512: a513eecb4f1aae6a5c06a69854e4492961424312a75a42d74377d363b364e3d52415bc81b4aa3fbc3f369ded19bddd07ab895130ebba288e8a43e9d6186e9fcc

2 years agoMerge bitcoindevkit/bdk#1039: docs: add required style for commit messages
Steve Myers [Wed, 2 Aug 2023 21:35:32 +0000 (16:35 -0500)]
Merge bitcoindevkit/bdk#1039: docs: add required style for commit messages

e17f03e7555b7b6f5348b9854f3d4ef559e84d75 docs: add required style for commit messages (Steve Myers)

Pull request description:

  ### Description

  Update CONTRIBUTING.md to specify that new commits should use 'Conventional Commits 1.0' style messages. See https://www.conventionalcommits.org/en/v1.0.0/.  I also fixed our current MSRV in the doc and fixed a spelling error.

  ### Notes to the reviewers

  I'm open to suggestions if anyone has another well documented style for commit messages.

  ### Changelog notice

  None.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  thunderbiscuit:
    ACK e17f03e7555b7b6f5348b9854f3d4ef559e84d75. I've been using conventional commits for Padawan for over 2 years and think it's got good value, particularly on projects with bigger teams and number of contributors.
  danielabrozzoni:
    ACK e17f03e7555b7b6f5348b9854f3d4ef559e84d75 - I was hesitant at first, but I think this would make the commit messages cleaner (and in most cases even shorter). Going forward we should consider adding a CI check enforcing this.

Tree-SHA512: 5f4c42814e35e013ff7846110b2897a35720b8f4b8974f8c8004fc0f5161a10076cac62a7aa711c14295129999f93e238034972f28b77145c1917613f8856b03

2 years agofix: Even more refactoring to code and documentation
志宇 [Tue, 1 Aug 2023 10:27:24 +0000 (18:27 +0800)]
fix: Even more refactoring to code and documentation

Thank you to @LLFourn and @danielabrozzoni for these suggestions.

2 years agofix: `TxGraph::missing_blocks` logic
志宇 [Sat, 22 Jul 2023 14:41:33 +0000 (22:41 +0800)]
fix: `TxGraph::missing_blocks` logic

Added additional tests for unnecessary duplicate heights

2 years agofix: improve more docs and more refactoring
志宇 [Sat, 22 Jul 2023 11:42:12 +0000 (19:42 +0800)]
fix: improve more docs and more refactoring

Thank you @vladimirfomene for these suggestions.

* Rename `LocalUpdate::keychain` to `LocalUpdate::last_active_indices`.
* Change docs for `CheckPoint` to be more descriptive.
* Fix incorrect logic in `update_local_chain` for `EsploraExt` and
  `EsploraAsyncExt`.

2 years agofix: docs and some minor refactoring
志宇 [Sat, 22 Jul 2023 08:36:31 +0000 (16:36 +0800)]
fix: docs and some minor refactoring

Shout out to @LLFourn for these suggestions.

* Improve/fix `LocalChain` documentation
* Refactor `TxGraph::missing_blocks` to make it more explicit that
  `last_block` has state.
* `update_local_chain` method of `EsploraExt` and `EsploraAsyncExt` now
  returns a `local_chain::Update` instead of just a `CheckPoint`.

2 years agoRefactor `debug_assertions` checks for `LocalChain`
志宇 [Sat, 22 Jul 2023 06:43:19 +0000 (14:43 +0800)]
Refactor `debug_assertions` checks for `LocalChain`

2 years agofix: rm duplicate `bdk_tmp_plan` module
志宇 [Thu, 20 Jul 2023 00:17:27 +0000 (08:17 +0800)]
fix: rm duplicate `bdk_tmp_plan` module

2 years agoAdd exclusion of example cli `*.db` files in `.gitignore`
志宇 [Thu, 20 Jul 2023 00:16:20 +0000 (08:16 +0800)]
Add exclusion of example cli `*.db` files in `.gitignore`

2 years agoImplement linked-list `LocalChain` and update chain-src crates/examples
志宇 [Wed, 19 Jul 2023 09:42:52 +0000 (17:42 +0800)]
Implement linked-list `LocalChain` and update chain-src crates/examples

This commit changes the `LocalChain` implementation to have blocks
stored as a linked-list. This allows the data-src thread to hold a
shared ref to a single checkpoint and have access to the whole history
of checkpoints without cloning or keeping a lock on `LocalChain`.

The APIs of `bdk::Wallet`, `esplora` and `electrum` are also updated to
reflect these changes. Note that the `esplora` crate is rewritten to
anchor txs in the confirmation block (using the esplora API's tx status
block_hash). This guarantees 100% consistency between anchor blocks and
their transactions (instead of anchoring txs to the latest tip).
`ExploraExt` now has separate methods for updating the `TxGraph` and
`LocalChain`.

A new method `TxGraph::missing_blocks` is introduced for finding
"floating anchors" of a `TxGraph` update (given a chain).

Additional changes:

* `test_local_chain.rs` is refactored to make test cases easier to
  write. Additional tests are also added.
* Examples are updated.
* Fix `tempfile` dev dependency of `bdk_file_store` to work with MSRV

Co-authored-by: LLFourn <lloyd.fourn@gmail.com>
2 years agoMerge bitcoindevkit/bdk#1046: Avoid pinning dependencies, use --precise in ci
Daniela Brozzoni [Tue, 25 Jul 2023 15:05:53 +0000 (17:05 +0200)]
Merge bitcoindevkit/bdk#1046: Avoid pinning dependencies, use --precise in ci

ffb7c795e15d2d879f2d857e7607729ca4a53155 ci: Avoid pinning dependencies, use --precise (Daniela Brozzoni)
56b8eea64330044fd7761cb2439d7dcca05106f2 ci: No need to add the llvm repository for wasm (Daniela Brozzoni)

Pull request description:

  Fixes #1035

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  evanlinjin:
    ACK ffb7c795e15d2d879f2d857e7607729ca4a53155

Tree-SHA512: a2e5e0ffea87dc86e27c2f2f3550e6e6429e66f5fd8e0196e85915de5b0f14f0e4ee9d56c87b38b101eb28d86a65868054c20421f32ecd475ca73d00471e2f8d

2 years agoci: Avoid pinning dependencies, use --precise
Daniela Brozzoni [Mon, 24 Jul 2023 10:44:48 +0000 (12:44 +0200)]
ci: Avoid pinning dependencies, use --precise

Fixes #1035

2 years agoci: No need to add the llvm repository for wasm
Daniela Brozzoni [Tue, 25 Jul 2023 11:15:47 +0000 (13:15 +0200)]
ci: No need to add the llvm repository for wasm

Adding it fails with "The repository'http://apt.llvm.org/focal
llvm-toolchain-focal Release' does not have a Release file.", and for
some reason it's not needed anymore.

2 years agoMerge bitcoindevkit/bdk#1031: remove duplicate `is_empty`
Daniela Brozzoni [Mon, 24 Jul 2023 09:20:59 +0000 (11:20 +0200)]
Merge bitcoindevkit/bdk#1031: remove duplicate `is_empty`

f5074ee3aee319137db1ddfa1e99f7e111abcfd4 remove duplicate `is_empty` from DerivationAdditions (Vladimir Fomene)

Pull request description:

  Duplicate `is_empty` method

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  danielabrozzoni:
    ACK f5074ee3aee319137db1ddfa1e99f7e111abcfd4

Tree-SHA512: 1cb48d25c9e57dbe444646ebc33c838e3d58c2523d74b58a75f0d085f68d070ec6a644c46e0bccb8765af7167c8359f079a6222fc9d17ae28ce1e6dda820fc84

2 years agodocs: add required style for commit messages
Steve Myers [Wed, 19 Jul 2023 21:15:35 +0000 (16:15 -0500)]
docs: add required style for commit messages

Update CONTRIBUTING.md to specify that new commits should use 'Conventional Commits 1.0'
style messages. See https://www.conventionalcommits.org/en/v1.0.0/.

2 years agoremove duplicate `is_empty` from DerivationAdditions
Vladimir Fomene [Fri, 14 Jul 2023 14:52:08 +0000 (17:52 +0300)]
remove duplicate `is_empty` from DerivationAdditions

2 years agoBump version to 1.0.0-alpha.1 v1.0.0-alpha.1
Steve Myers [Tue, 4 Jul 2023 17:28:06 +0000 (12:28 -0500)]
Bump version to 1.0.0-alpha.1

2 years ago[ci] fix docsrs error for bdk crate
Steve Myers [Tue, 20 Jun 2023 17:33:05 +0000 (12:33 -0500)]
[ci] fix docsrs error for bdk crate

2 years agoFix cargo features
志宇 [Mon, 26 Jun 2023 00:22:26 +0000 (08:22 +0800)]
Fix cargo features

* `bdk_chain/std` should also enable `miniscript/std`
* use the version of `hashbrown` that `bitcoin` and `miniscript` is
  using

2 years agoMerge bitcoindevkit/bdk#894: Better no-std support
Steve Myers [Tue, 20 Jun 2023 21:35:41 +0000 (16:35 -0500)]
Merge bitcoindevkit/bdk#894: Better no-std support

7ab84be9c747fd73fc5d1bd0706e7027a66aadb5 Better no-std support (Steve Myers)

Pull request description:

  This replaces #893

  ### Description

  Carrying over relevant maintenance changes from release 0.27.2 to bdk `master`.

  - Use `default-features = false` for `miniscript` and `bitcoin`
  - Introduce `std`  features for `bdk`, `bdk_chain` and `bdk_esplora`

  ### Notes to the reviewers

  The `default-features = false`for `bitcoin` and `miniscript` is to let `bdk` be unbiased for things like no-std.

  ### Changelog notice

  - Set default-features = false for rust-bitcoin and rust-miniscript #894
  - Introduce `std`  features for `bdk`, `bdk_chain` and `bdk_esplora`

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  notmandatory:
    ACK 7ab84be9c747fd73fc5d1bd0706e7027a66aadb5

Tree-SHA512: 217e0ebc04cd59898d4de1c4f8cc6c87de2561659e277cc6e0d969c8bc61142ca62c8bda86643d55676dce39da25891b516a901005a03a31404dae118a5fce76

2 years agoBetter no-std support
Steve Myers [Wed, 15 Mar 2023 16:44:52 +0000 (11:44 -0500)]
Better no-std support

- Use `default-features = false` for `miniscript`,`bitcoin`,and `bdk_chain`
- Introduce `bdk_chain/std` feature
- Add GitHub workflow `check-no-std` (not yet completly working)
- Update GitHub workflow `check-wasm` to disable default `std` features

2 years agoMerge bitcoindevkit/bdk#840: create taproot descriptor template
Steve Myers [Mon, 19 Jun 2023 20:42:16 +0000 (15:42 -0500)]
Merge bitcoindevkit/bdk#840: create taproot descriptor template

e30919ba3a7941e6f54e2f95e94533c05415d831 Create taproot descriptor template (Vladimir Fomene)

Pull request description:

  ### Description

  This PR solves #836. This PR adds a P2TR
  descriptor template and a BIP86 taproot
  descriptor template. With this, users
  can now create a taproot descriptor with templates.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] 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
  * [x] I'm linking the issue being fixed by this PR

ACKs for top commit:
  notmandatory:
    ACK e30919ba3a7941e6f54e2f95e94533c05415d831

Tree-SHA512: ad171d29e1b22613a9fb5e6ed148d1d3002c76152df1b5aa94e24be134d08d7c90dda9560b7501a8df28e5a7076339745da627bbdde5ed6fa11eab3199c34a99

2 years agoMerge bitcoindevkit/bdk#1009: Pin log dependency to 0.4.18 to keep the MSRV to 1...
Daniela Brozzoni [Mon, 19 Jun 2023 12:11:53 +0000 (14:11 +0200)]
Merge bitcoindevkit/bdk#1009: Pin log dependency to 0.4.18 to keep the MSRV to 1.57.0

fa54a2e3a5096b263388b9f729ba1cb42574072e Pin log dependency to 0.4.18 to keep the MSRV to 1.57.0 (Daniela Brozzoni)

Pull request description:

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  evanlinjin:
    ACK fa54a2e3a5096b263388b9f729ba1cb42574072e

Tree-SHA512: 5fc19dd8485fcfe88c2720ff183dac7bfb6cacefa7be0c23aa1e7b345d81d1e41ac0903d84c5606b00adf2314911ee9d25972bfd4f0764e70456c8d8ffb3ab33

2 years agoPin log dependency to 0.4.18 to keep the MSRV to 1.57.0
Daniela Brozzoni [Mon, 19 Jun 2023 11:50:59 +0000 (13:50 +0200)]
Pin log dependency to 0.4.18 to keep the MSRV to 1.57.0

2 years agoMerge bitcoindevkit/bdk#976: Reimplement `Wallet`, `ElectrumExt` and `Esplora{Async...
Daniela Brozzoni [Mon, 19 Jun 2023 11:36:00 +0000 (13:36 +0200)]
Merge bitcoindevkit/bdk#976: Reimplement `Wallet`, `ElectrumExt` and `Esplora{Async}Ext` with redesigned structures.

75f8b81d58a985669ce7302fe235ad68eddc0d47 Update documentation (志宇)
cff92111d500fbcdd70015c03bf57b386d473fba [wallet_redesign] Clean up and document address methods (志宇)
a7668a2f3e98b8950a139b7c88fbebff56f49a5f [wallet_redesign] Modified `insert_tx` to use lowest checkpoint (志宇)
ac80829caa4bc94de0acdd0459917d095358559c Rename fields of `tx_graph::Additions` (Shourya742)
1c3cbefa4df7a4f93bc95203534da8ea0186fc5a [chain_redesign] Remove old structures (志宇)
5860704b2dfab5d3883fc89960ce4a69b92b65ef Implement redesigned versions of `EsploraExt` and `EsploraAsyncExt` (志宇)
2952341e5245acef14623b482095526d55b64bd6 Update the `wallet_electrum` example (志宇)
78a7920ba378bb57f0b61d93faf29ec813889a75 `bdk_electrum` API improvements and simplifications (志宇)
92709d03ce8ed979cda127c2c30811bb1c8c5f58 Various tweaks to code arrangement and documentation (志宇)
50425e979bdbe81621fcd54463cdc7c7aeed90f0 Introduce `keychain::LocalChangeSet` (志宇)
a78967e51ba1fa94f00a0f7a580dfc009428a947 [example-cli] simplify new address logic (LLFourn)
6a1ac7f80a7f97cd3c6264fb54f2d1e3b1f95130 [examples_redesign] Implemented `example_electrum` (志宇)
f55974a64bd0f5f2ef9e95831c2fb5d4f92f8282 [examples_redesign] Introduce `example_cli` package (志宇)
2e3cee4bd0568073e42e5670476febddd85a7b36 [electrum_redesign] Introduce redesigned `ElectrumExt` (志宇)
7261669c097791ee2ff8c7da6754868732d02eb3 Add `last_seen` to the the `ConfirmationTime::Unconfirmed` variant (志宇)
aba88130d91b329d8637c450c84fd10af508bdac [wallet_redesign] Move the majority of `Update` to `bdk_chain` (志宇)
e69fccb15fb17ba6eb86e24efad4b9bd96e3bf72 [wallet_redesign] Update `Wallet` with redesigned structures (志宇)

Pull request description:

  ### Description

  Closes #938

  * Update `Wallet` to use redesigned structures.
  * Update `bdk_electrum::ElectrumExt` to produce updates for redesigned structures.
  * Update `bdk_esplora::EsploraExt` and `bdk_esplora::EsploraAsyncExt` to produce updates for redesigned structures.
  * Added `example-crates/example_cli` library for implementing examples with redesigned structures.
  * Added `example-crate/example_electrum` which is an electrum CLI wallet using the redesigned structures.
  * Updated `example-crate/{wallet_electrum|wallet_esplora|wallet_esplora_async}` examples to use redesigned structures.
  * Remove all old structures.

  ### Notes to the reviewers

  ~These changes bump our `all-features` MSRV to `1.60.0` because of the introduction of `bdk_esplora`. As long as the `bdk_chain` and `bdk_wallet` crates hit a MSRV of `1.48.0`, it will be fine (this work is done in #987).~ No longer needed due to #993

  ~I had to comment out the examples that use `Wallet` with our chain sources. Once we update the helper-packages for those chain sources, we can also update the examples.~

  Possible future improvements for `ElectrumExt`:

  * Remove requirement to retry obtaining ALL data after reorg is detected. Transactions can be anchored to a lower block (not block tip), and an `assume_final_depth` value can be used.

  * The logic to finalize an update with confirmation time can be improved during reorgs to not require returning an error.

  * Use the subscription model of electrum, as intended by the API.

  ### Changelog notice

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] I've added docs for the new feature

ACKs for top commit:
  LLFourn:
    ACK 75f8b81d58a985669ce7302fe235ad68eddc0d47
  danielabrozzoni:
    Partial ACK 75f8b81d58a985669ce7302fe235ad68eddc0d47 - the Wallet code looks good to me, I don't have a good enough understanding of the esplora/electrum code to confidently ACK it.

Tree-SHA512: d1d2b79e3c28fbe826044a8b5ef9b122c2dcfc0d371f24cc4aac7f286500b587c2dc3b06ca6461c8721adbc29f56ca41e7566eace560b0a9c541604e6a225c61

2 years agoUpdate documentation
志宇 [Mon, 29 May 2023 13:54:53 +0000 (21:54 +0800)]
Update documentation

* Add `warn(missing_docs)` for `bdk_wallet` and `bdk_chain`.
* Add missing documentation.
* Remove `LocalChain::heights` method.
* Remove old TODOs.

2 years ago[wallet_redesign] Clean up and document address methods
志宇 [Mon, 29 May 2023 05:20:12 +0000 (13:20 +0800)]
[wallet_redesign] Clean up and document address methods

2 years ago[wallet_redesign] Modified `insert_tx` to use lowest checkpoint
志宇 [Sun, 28 May 2023 07:57:46 +0000 (15:57 +0800)]
[wallet_redesign] Modified `insert_tx` to use lowest checkpoint

Also updated the documentation.

2 years agoRename fields of `tx_graph::Additions`
Shourya742 [Sun, 30 Apr 2023 04:13:28 +0000 (09:43 +0530)]
Rename fields of `tx_graph::Additions`

* Changed `tx` to `txs`
* Changed `txout` to `txouts`

2 years ago[chain_redesign] Remove old structures
志宇 [Wed, 24 May 2023 03:37:26 +0000 (11:37 +0800)]
[chain_redesign] Remove old structures

Other changes:

* The `async-https` feature of `bdk_esplora` is no longer default.
* Rename `ObservedAs` to `ChainPosition`.
* Set temporary MSRV to 1.60.0 to compile all workspace members will all
  features.

2 years agoImplement redesigned versions of `EsploraExt` and `EsploraAsyncExt`
志宇 [Thu, 18 May 2023 06:04:48 +0000 (14:04 +0800)]
Implement redesigned versions of `EsploraExt` and `EsploraAsyncExt`

All associated examples are also updated.

2 years agoUpdate the `wallet_electrum` example
志宇 [Thu, 18 May 2023 02:14:47 +0000 (10:14 +0800)]
Update the `wallet_electrum` example

2 years ago`bdk_electrum` API improvements and simplifications
志宇 [Thu, 18 May 2023 02:02:23 +0000 (10:02 +0800)]
`bdk_electrum` API improvements and simplifications

* `ElectrumUpdate::missing_full_txs` now returns a `Vec<Txid>` so we
  don't keep a reference to the passed-in `graph`.

* `ElectrumUpdate::finalize*` methods now takes in `missing` txids
  instead of `full_txs`. `Client::batch_transaction_get` is called
within the methods.

Other changes:

* `wallet::ChangeSet` is now made public externally. This is required as
  a wallet db should implement `PersistBackend<wallet::ChangeSet>`.

2 years agoVarious tweaks to code arrangement and documentation
志宇 [Wed, 17 May 2023 03:48:35 +0000 (11:48 +0800)]
Various tweaks to code arrangement and documentation

As per reviews by @danielabrozzoni and @LLFourn

2 years agoIntroduce `keychain::LocalChangeSet`
志宇 [Sat, 13 May 2023 15:28:03 +0000 (23:28 +0800)]
Introduce `keychain::LocalChangeSet`

This corresponds to `keychain::KeychainChangeSet` but for the redesigned
structures with `LocalChain`.

This structure is now used in `Wallet` as well as the examples.

2 years ago[example-cli] simplify new address logic
LLFourn [Sat, 13 May 2023 03:03:03 +0000 (11:03 +0800)]
[example-cli] simplify new address logic

2 years ago[examples_redesign] Implemented `example_electrum`
志宇 [Fri, 12 May 2023 09:43:05 +0000 (17:43 +0800)]
[examples_redesign] Implemented `example_electrum`

This is a version of `keychain_tracker_electrum` that uses the
redesigned structures instead.

2 years ago[examples_redesign] Introduce `example_cli` package
志宇 [Fri, 12 May 2023 08:17:17 +0000 (16:17 +0800)]
[examples_redesign] Introduce `example_cli` package

This is the equivalent of `keychain_tracker_example_cli` that works with
the redesigned structures.

2 years ago[electrum_redesign] Introduce redesigned `ElectrumExt`
志宇 [Thu, 11 May 2023 16:08:16 +0000 (00:08 +0800)]
[electrum_redesign] Introduce redesigned `ElectrumExt`

There are a number of improvements that can be done, but it is in a
decent state to be usable.

Possible improvements:

* Remove requirement to retry obtaining ALL data after reorg is
  detected. Transactions can be anchored to a lower block (not block
  tip), and an `assume_final_depth` value can be used.

* The logic to finalize an update with confirmation time can be improved
  during reorgs to not require returning an error.

2 years agoAdd `last_seen` to the the `ConfirmationTime::Unconfirmed` variant
志宇 [Thu, 11 May 2023 14:56:26 +0000 (22:56 +0800)]
Add `last_seen` to the the `ConfirmationTime::Unconfirmed` variant

This allows us to skip adding an extra input to `Wallet::insert_tx`.

Also remove redundant logic.

2 years ago[wallet_redesign] Move the majority of `Update` to `bdk_chain`
志宇 [Thu, 11 May 2023 10:46:41 +0000 (18:46 +0800)]
[wallet_redesign] Move the majority of `Update` to `bdk_chain`

This is to make it easier for chain source crates to formulate updates.

2 years ago[wallet_redesign] Update `Wallet` with redesigned structures
志宇 [Tue, 9 May 2023 13:49:33 +0000 (21:49 +0800)]
[wallet_redesign] Update `Wallet` with redesigned structures

2 years agoMerge bitcoindevkit/bdk#1001: Rename "keychanins" to keychains
Daniela Brozzoni [Thu, 1 Jun 2023 22:42:30 +0000 (00:42 +0200)]
Merge bitcoindevkit/bdk#1001: Rename "keychanins" to keychains

22b8a4884245449fcf60877ca031e0e9e7495de9 Rename "keychanins" to keychains (Daniela Brozzoni)

Pull request description:

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  notmandatory:
    ACK 22b8a4884245449fcf60877ca031e0e9e7495de9

Tree-SHA512: 13ebbd597771a9d91c317fedc4dc506a275a641b764f24650cd13217cf8ac0d06c42a935a8c9e1e7f4761d2ade473c7f8381e90875e867b7a61381aa33cd8581

2 years agoRename "keychanins" to keychains
Daniela Brozzoni [Thu, 1 Jun 2023 17:24:52 +0000 (19:24 +0200)]
Rename "keychanins" to keychains

2 years agoMerge bitcoindevkit/bdk#957: Documentation regarding absolute_fee and fee_rate updated
Daniela Brozzoni [Sun, 28 May 2023 13:04:56 +0000 (15:04 +0200)]
Merge bitcoindevkit/bdk#957: Documentation regarding absolute_fee and fee_rate updated

10b4b6c665d58321436413d1d9c0486e7d74c5ec Documentations regarding absolute_fee and fee_rate updated (TATHAGATA ROY)

Pull request description:

  ### Description
  This pr solves this issue #856
  Updated the documentation for absolute fee and fee rate in BDK docs

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)

  #### Bugfixes:

  * [x] I'm linking the issue being fixed by this PR

ACKs for top commit:
  danielabrozzoni:
    ACK 10b4b6c665d58321436413d1d9c0486e7d74c5ec

Tree-SHA512: 5b5f360b742313443368dc0b75275c38888cb358545661f7d9c78f3290789c50ffa9830e18473055d8e3da544c7d9527b023a1acdb28eaf862b24c892b23e9c4

2 years agoDocumentations regarding absolute_fee and fee_rate updated
TATHAGATA ROY [Thu, 27 Apr 2023 21:34:16 +0000 (21:34 +0000)]
Documentations regarding absolute_fee and fee_rate updated

Update tx_builder.rs

2 years agoMerge bitcoindevkit/bdk#993: Unpin base64
Daniela Brozzoni [Thu, 25 May 2023 15:24:36 +0000 (17:24 +0200)]
Merge bitcoindevkit/bdk#993: Unpin base64

ac3759254a939b01830ac6963b1d5160da01b733 Unpin base64 (Daniela Brozzoni)

Pull request description:

  base64 lowered the MSRV to 1.57.0 in version 0.21.2

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  evanlinjin:
    ACK ac3759254a939b01830ac6963b1d5160da01b733

Tree-SHA512: de66f4be7c7fd608f5a74e51c5666f4fe6b962c5a8345c08c7b1da2551f81b9adfb28c58f0991ac6c985fa5c31f3eb7d17f99edf136b04945cefa24b28eaee19

2 years agoUnpin base64
Daniela Brozzoni [Thu, 25 May 2023 13:37:16 +0000 (15:37 +0200)]
Unpin base64

base64 lowered the MSRV to 1.57.0 in version 0.21.2

2 years agoCreate taproot descriptor template
Vladimir Fomene [Tue, 14 Feb 2023 22:16:02 +0000 (01:16 +0300)]
Create taproot descriptor template

This PR solves #836. This PR adds a P2TR
descriptor template and a BIP86 taproot
descriptor template. With this, users
can now create a taproot descriptor with templates.

2 years agoMerge bitcoindevkit/bdk#990: Pin base64 to 0.21.0 to keep the MSRV to 1.57.0
Daniela Brozzoni [Wed, 24 May 2023 15:49:51 +0000 (17:49 +0200)]
Merge bitcoindevkit/bdk#990: Pin base64 to 0.21.0 to keep the MSRV to 1.57.0

df74b23f315007cc36d3a12904380f861326fb32 Pin base64 to 0.21.0 to keep the MSRV to 1.57.0 (Daniela Brozzoni)

Pull request description:

  Fixes #986

  ### Changelog notice

  - Pin base64 to 0.21.0

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  notmandatory:
    ACK df74b23f315007cc36d3a12904380f861326fb32

Tree-SHA512: fb11db0771542b074b7605e4af9ec655c22106b1d3451e27103d2f81686270efb44d8687f8312b5b7ab724f03e8f24c349a9f4f3b6e0c89ed9550b121f526ce7

2 years agoPin base64 to 0.21.0 to keep the MSRV to 1.57.0
Daniela Brozzoni [Wed, 24 May 2023 14:12:34 +0000 (16:12 +0200)]
Pin base64 to 0.21.0 to keep the MSRV to 1.57.0

2 years agoMerge bitcoindevkit/bdk#981: Fixed typos in CONTRIBUTING.md
Daniela Brozzoni [Thu, 18 May 2023 10:36:16 +0000 (12:36 +0200)]
Merge bitcoindevkit/bdk#981: Fixed typos in CONTRIBUTING.md

c7a045fa54a8183899d90730249c06c3f538b027 Fixed typos in CONTRIBUTING.md (Jon Marrs)

Pull request description:

  ### Description

  Fixed typos in CONTRIBUTING.md

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)

ACKs for top commit:
  thunderbiscuit:
    ACK c7a045fa54a8183899d90730249c06c3f538b027.

Tree-SHA512: de66f4be7c7fd608f5a74e51c5666f4fe6b962c5a8345c08c7b1da2551f81b9adfb28c58f0991ac6c985fa5c31f3eb7d17f99edf136b04945cefa24b28eaee19

2 years agoFixed typos in CONTRIBUTING.md
Jon Marrs [Wed, 17 May 2023 04:39:18 +0000 (21:39 -0700)]
Fixed typos in CONTRIBUTING.md

2 years agoMerge bitcoindevkit/bdk#975: Improve `txout` listing and balance APIs for redesigned...
志宇 [Thu, 11 May 2023 13:00:23 +0000 (21:00 +0800)]
Merge bitcoindevkit/bdk#975: Improve `txout` listing and balance APIs for redesigned structures

ed89de752cf20cb80deefda3ddf65a137b669288 Improve txout filter/listing method docs for `TxGraph` (志宇)
fb75aa94a9f47d53ce7246c14d739fc53dc38197 Clarify `TxGraph::try_filter_chain_unspents` logic (志宇)
96b10751325dc1bced09f9e864438216400e4ba3 Fix and improve `Persist::commit` method (志宇)
e01d17d59bd6177bf5e457232219669782b727b7 Improve `txout` listing and balance APIs for redesigned structures (志宇)

Pull request description:

  ### Description

  As noted in https://github.com/bitcoindevkit/bdk/issues/971#issuecomment-1542408941.

  Instead of relying on a `OwnedIndexer` trait to filter for relevant txouts, we move the listing and balance methods from `IndexedTxGraph` to `TxGraph` and add an additional input (list of relevant outpoints) to these methods.

  This provides a simpler implementation and a more flexible API.

  #### Other Fixes

  The `Persist::commit` method is fixed in 96b10751325dc1bced09f9e864438216400e4ba3.

  Previously, regardless of whether writing to persistence backend is successful or not, the logic always cleared `self.staged`. This is changed to only clear `self.staged` after successful write.

  Additionally, the written changeset (if any) is returned, and `PersistBackend::write_changes` will not be called if `self.staged` is empty.

  ### Notes to the reviewers

  Yes, slightly more boilerplate to do the same things, but less code to maintain and a much more flexible API. Very worth it IMO.

  ### Changelog notice

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] I've added docs for the new feature

ACKs for top commit:
  LLFourn:
    ACK ed89de752cf20cb80deefda3ddf65a137b669288

Tree-SHA512: efae18c13ee74eff801febca61cb16bf4d8f3203ced96172b9ef555d8d2a749a382f87d024e8c92aacbab7eb4e50a8337de798e10524291ad80c6b35c4dc0161

2 years agoImprove txout filter/listing method docs for `TxGraph`
志宇 [Thu, 11 May 2023 04:43:49 +0000 (12:43 +0800)]
Improve txout filter/listing method docs for `TxGraph`

Rename the `S` trait bound to `OI` (outpoint index) to emphasize it's
not only for spk indexing.

2 years agoClarify `TxGraph::try_filter_chain_unspents` logic
志宇 [Thu, 11 May 2023 03:59:57 +0000 (11:59 +0800)]
Clarify `TxGraph::try_filter_chain_unspents` logic

2 years agoFix and improve `Persist::commit` method
志宇 [Thu, 11 May 2023 03:49:33 +0000 (11:49 +0800)]
Fix and improve `Persist::commit` method

Previously, regardless of whether writing to persistence backend is
successful or not, the logic always cleared `self.staged`. This is
changed to only clear `self.staged` after successful write.

Additionally, the written changeset (if any) is returned, and
`PersistBackend::write_changes` will not be called if `self.staged` is
empty.

2 years agoImprove `txout` listing and balance APIs for redesigned structures
志宇 [Wed, 10 May 2023 06:14:29 +0000 (14:14 +0800)]
Improve `txout` listing and balance APIs for redesigned structures

Instead of relying on a `OwnedIndexer` trait to filter for relevant
txouts, we move the listing and balance methods from `IndexedTxGraph` to
`TxGraph` and add an additional input (list of relevant outpoints) to
these methods.

This provides a simpler implementation and a more flexible API.

2 years agoMerge bitcoindevkit/bdk#965: Implement persistence with the new structures
志宇 [Wed, 10 May 2023 15:23:49 +0000 (23:23 +0800)]
Merge bitcoindevkit/bdk#965: Implement persistence with the new structures

4963240599364c6520d0a6ecae97db77cc7b8ba8 Add more `impl`s for `Append` and docs for file store `magic` (志宇)
2aa08a5898545f670df9ed9c4804231f321d811a [persist_redesign] Introduce redesigned `persist` types (志宇)

Pull request description:

  ### Description

  This is part of #895 and #971

  * Introduce a more generic version of the `keychain::persist::*` structures that only needs a single generic for the changeset type.

  Additional changes:

  * The `Append` trait has a new method `is_empty`.
  * Introduce `Store` structure for `bdk_file_store` (which implements `PersistBackend`).

  ### Changelog notice

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] I've added docs for the new feature

Top commit has no ACKs.

Tree-SHA512: 0211fbe7d7e27805d3ed3a80b42f184cdff1cebb32fd559aa9838e4a7f7c7e47b6c366b6ef68e299f876bafed549b8d1d8b8cc0366bf5b61db079504a565b9b4

2 years agoAdd more `impl`s for `Append` and docs for file store `magic`
志宇 [Wed, 10 May 2023 06:48:26 +0000 (14:48 +0800)]
Add more `impl`s for `Append` and docs for file store `magic`

2 years ago[persist_redesign] Introduce redesigned `persist` types
志宇 [Tue, 9 May 2023 01:59:42 +0000 (09:59 +0800)]
[persist_redesign] Introduce redesigned `persist` types

This is a more generic version of `keychain::persist::*` structures.

Additional changes:

* The `Append` trait has a new method `is_empty`.
* Introduce `Store` structure for `bdk_file_store`.

2 years agoMerge pull request #963 from evanlinjin/chain_redesign_tweaks
志宇 [Fri, 5 May 2023 12:11:11 +0000 (20:11 +0800)]
Merge pull request #963 from evanlinjin/chain_redesign_tweaks

Various tweaks to redesigned structures

2 years ago[chain_redesign] Rename `LocalChain::inner()` to `blocks()`
志宇 [Fri, 5 May 2023 11:49:30 +0000 (19:49 +0800)]
[chain_redesign] Rename `LocalChain::inner()` to `blocks()`

Also, we can get rid of `LocalChain::get_blockhash`, since we can
already expose the internal map.

Additionally, tests and docs are improved.

2 years ago[chain_redesign] Various `LocalChain` improvements
志宇 [Fri, 5 May 2023 08:55:21 +0000 (16:55 +0800)]
[chain_redesign] Various `LocalChain` improvements

* Introduce `LocalChain::inner` method to get the inner map of block
  height to hash.
* Replace `LocalChain::get_block` (which outputted `BlockId`, thus able
  to return invalid representation) with `get_blockhash` that just
returns a `BlockHash`.
* Remove `TODO` comments that should be github tickets.

2 years ago[chain_redesign] `BlockId` should not implement `Anchor`
志宇 [Wed, 3 May 2023 08:03:23 +0000 (16:03 +0800)]
[chain_redesign] `BlockId` should not implement `Anchor`

If `BlockId` implements `Anchor`, the meaning is ambiguous. We cannot
tell whether it means the tx is anchors at the block, or whether it also
means the tx is confirmed at that block.

Instead, `ConfirmationHeightAnchor` and `ConfirmationTimeAnchor` structs
are introduced as non-ambiguous `Anchor` implementations.

Additionally, `TxGraph::relevant_heights` is removed because it is also
ambiguous. What heights are deemed relevant? A simpler and more flexible
method `TxGraph::all_anchors` is introduced instead.

2 years ago[chain_redesign] Relax generic constraints
志宇 [Wed, 3 May 2023 07:20:49 +0000 (15:20 +0800)]
[chain_redesign] Relax generic constraints

2 years ago[chain_redesign] Add `LocalChain::insert_block`
志宇 [Wed, 3 May 2023 07:01:39 +0000 (15:01 +0800)]
[chain_redesign] Add `LocalChain::insert_block`

2 years ago[chain_redesign] Change behavior of `try_get_chain_position`
志宇 [Wed, 3 May 2023 03:43:16 +0000 (11:43 +0800)]
[chain_redesign] Change behavior of `try_get_chain_position`

`TxGraph::try_get_chain_position` used to always exclude unconfirmed
transactions with last_seen value of 0. However, what is the point of
including a transaction in the graph if it cannot be part of the chain
history? Additionally, maybe sometimes we don't wish to use the
last_seen field at all.

The new behavior will consider unconfirmed transactions with last_seen
of 0.

2 years agoMerge pull request #927 from LagginTimes/custom_spk_iterator
志宇 [Tue, 2 May 2023 09:36:51 +0000 (17:36 +0800)]
Merge pull request #927 from LagginTimes/custom_spk_iterator

Custom spk iterator

2 years agoImplement SpkIterator
Wei [Wed, 22 Mar 2023 09:00:08 +0000 (17:00 +0800)]
Implement SpkIterator

SpkIterator was created with its own nth() and next() implementations
and its own new() and new_with_range() constructors.

Co-authored-by: 志宇 <hello@evanlinjin.me>
2 years agoMerge commit 'refs/pull/960/head' of github.com:bitcoindevkit/bdk
Steve Myers [Mon, 1 May 2023 20:40:35 +0000 (15:40 -0500)]
Merge commit 'refs/pull/960/head' of github.com:bitcoindevkit/bdk

Reenable code coverage upload to Coveralls, only for /crates repos

2 years agoMerge pull request #959 from rajarshimaitra/test-graph-2
志宇 [Mon, 1 May 2023 06:53:30 +0000 (14:53 +0800)]
Merge pull request #959 from rajarshimaitra/test-graph-2

Cleanup IndexedTxGraph test.

2 years agoMerge pull request #953 from benthecarman/kwu
Lloyd Fournier [Mon, 1 May 2023 03:22:44 +0000 (13:22 +1000)]
Merge pull request #953 from benthecarman/kwu

Add sat_per_kwu to FeeRate

2 years agoFilter code coverage report results
Steve Myers [Sat, 29 Apr 2023 20:47:08 +0000 (15:47 -0500)]
Filter code coverage report results

2 years agoReenable code coverage upload to Coveralls, only for ./crates packages
Steve Myers [Sat, 29 Apr 2023 14:18:35 +0000 (09:18 -0500)]
Reenable code coverage upload to Coveralls, only for ./crates packages

2 years agoTest cleanup and added documentation.
rajarshimaitra [Sat, 29 Apr 2023 11:57:12 +0000 (17:27 +0530)]
Test cleanup and added documentation.

- Explainer doc added for the test.
- Test code simplified.
- One more edge cases added.

2 years agoMerge bitcoindevkit/bdk#926: Introduce redesigned `bdk_chain` structures
Daniela Brozzoni [Fri, 28 Apr 2023 16:47:13 +0000 (18:47 +0200)]
Merge bitcoindevkit/bdk#926: Introduce redesigned `bdk_chain` structures

b799a5728b7e08a18059ffee7fe7ee6078354977 [bdk_chain_redesign] Add tests for `IndexedTxGraph` with `LocalChain` (rajarshimaitra)
8cd0328eec0b55f10dd085597a435b689b37444a [bdk_chain_redesign] Implement `OwnedIndexer` for indexers (rajarshimaitra)
911af34f509ad0b4c86c0be819d79b202679e3e5 [bdk_chain_redesign] Fix calculation bugs. (rajarshimaitra)
e536307e5c5532fc0cac0657a26609cfd26115bf [bdk_chain_redesign] Fix `tx_graph::Additions::append` logic (志宇)
f101dde09b6067c17b0b64ea3e3efd358a32a820 [bdk_chain_redesign] Fix `tx_graph::Additions::append` logic (志宇)
1b152647c557d2ff492cd241999c5320f7c4f6c5 [bdk_chain_redesign] Change `insert_relevant_txs` method (志宇)
ecc74ce4cd1ab0c51c2e9bcaa4f7d53390dd4d9b [bdk_chain_redesign] Docs for `is_mature` and `is_confirmed_and_spendable` (志宇)
ac336aa32f485cb253ac7ea5cae3b4bcc78cf507 [bdk_chain_redesign] Make `insert_relevant_txs` topologically-agnostic (志宇)
165b874dfedb2e05a7ea5d56e6f80577ada48d73 [bdk_chain_redesign] Add test for `insert_relevant_txs` (志宇)
f3e7b67bf1195eadf48a8f26f960b3f39d6134f7 [bdk_chain_redesign] Various tweaks and fixes (志宇)
03c128311a687249238fb109f804cde25ffddad2 [bdk_chain_redesign] Revert changes to `SparseChain` (志宇)
34a7bf5afe2d78db47b149f4958f0a0365b017d0 [bdk_chain_redesign] Rm unnecessary code and premature optimisation (志宇)
6c495707423cc7ce26c3027893dc812281b73053 [bdk_chain_redesign] Rm `HashSet` from `TxGraph::relevant_heights` (志宇)
1003fe2ee6167e110b0195e2431560b5b222e2f1 [bdk_chain_redesign] Test `LocalChain` (志宇)
7175a82c04b0a3f0c5716f4a37e122da70b8ceac [bdk_chain_redesign] Add tests for `TxGraph::relevant_heights` (志宇)
8e36a2e5f6d0fe2813dca9a13005e0b1be7e94c3 [bdk_chain_redesign] Remove incomplete logic (志宇)
81436fcd72a3c45bb10a098be28de0116322d22d [bdk_chain_redesign] Fix `Anchor` definition + docs (志宇)
001efdd1cb658f3a2929ffcf9047e6b07e9bd15c Include tests for new updates of TxGraph (rajarshimaitra)
10ab77c549e597d0d8157d94ae6fa3b4d39fd5dc [bdk_chain_redesign] MOVE `TxIndex` into `indexed_chain_graph.rs` (志宇)
7d92337b932fdcfec7008da8ed81f2b4b6e7a069 [bdk_chain_redesign] Remove `IndexedTxGraph::last_height` (志宇)
a7fbe0ac672cde6c308737fc98020f6693071a5f [bdk_chain_redesign] Documentation improvements (志宇)
ee1060f2ff168e6aaffa41882be2b319729f7de8 [bdk_chain_redesign] Simplify `LocalChain` (志宇)
611d2e3ea2ed9249ddf04e0f9089642160e5c901 [bdk_chain_redesign] Consistent `ChainOracle` (志宇)
bff80ec378fab29556099f9830bcb42911658710 [bdk_chain_redesign] Improve `BlockAnchor` docs (志宇)
24cd8c5cc7f3a6bd0db2bd45642f08a28ea5337a [bdk_chain_redesign] More tweaks and renamings (志宇)
ddd5e951f5ec77070034c7390a635d8d5bd7cb85 [bdk_chain_redesign] Modify signature of `TxIndex` (志宇)
da4cef044d4a3ad0f44ff1e33936c93c38c2f774 [bdk_chain_redesign] Introduce `Append` trait for additions (志宇)
89cfa4d78e059f9fe2544b690bbbf90e92b3efee [bdk_chain_redesign] Better names, comments and generic bounds (志宇)
6e59dce10b66212d7180cadabba887cc4d20fc32 [bdk_chain_redesign] `chain_oracle::Cache` (志宇)
a7eaebbb77f8794c5ff3717aaf0cf73dd5a77480 [bdk_chain_redesign] Add serde support for `IndexedAdditions` (志宇)
c09cd2afce4e649caa2797628edaffae08a60628 [bdk_chain_redesign] Added methods to `LocalChain` (志宇)
7810059ed0f23cae7dee61fe587a1c8f3f49480a [bdk_chain_redesign] `TxGraph` tweaks (志宇)
a63ffe97397cd14bc0a13ea5e96ceddf8b63a4f0 [bdk_chain_redesign] Simplify `TxIndex` (志宇)
a1172def7df478c61076b0d99d5d0f5f9cd99da6 [bdk_chain_redesign] Revert some API changes (志宇)
8c906170c96919cd8c65e306b8351fe01e139fd4 [bdk_chain_redesign] Make default anchor for `TxGraph` as `()` (志宇)
468701a1295c90761749e1bb46cc201cc7f95613 [bdk_chain_redesign] Initial work on `LocalChain`. (志宇)
34d0277e44fd054c8d463dfa756d8531ccda3ca9 [bdk_chain_redesign] Rm anchor type param for structs that don't use it (志宇)
3440a057110fbbcc653f2f8c7d58175472299bae [bdk_chain_redesign] Add docs (志宇)
236c50fa7bace29a0373dd16416ecebbb6dc1ae8 [bdk_chain_redesign] `IndexedTxGraph` keeps track of the last synced height (志宇)
e902c10295ba430bf0522b92ffab68cd60bd1666 [bdk_chain_redesign] Fix `apply_additions` logic for `IndexedTxGraph`. (志宇)
313965d8c84f5de43cafa58c7bd9250aea93b22c [bdk_chain_redesign] `mut_index` should be `index_mut` (志宇)
db7883d813e97229340c32a8fa82a9a13bac7361 [bdk_chain_redesign] Add balance methods to `IndexedTxGraph` (志宇)
d0a2aa83befce5dda26f8b3ae05449f6967df25a [bdk_chain_redesign] Add `apply_additions` to `IndexedTxGraph` (志宇)
6cbb18d409d84ea0c399d9b3ecb0cdb49cc0b32e [bdk_chain_redesign] MOVE: `IndexedTxGraph` into submodule (志宇)
784cd34e3db727659dbb26c428ed9096927286c1 [bdk_chain_redesign] List chain data methods can be try/non-try (志宇)
43b648fee02291858dfcab9b639c55a0bc3fad81 [bdk_chain_redesign] Add `..in_chain` methods (志宇)
61a8606fbcaec933f915c4f0600cd6f5e35636e8 [bdk_chain_redesign] Introduce `ChainOracle` and `TxIndex` traits (志宇)
5ae5fe30ebd53d72fe567509506ae0cda7a3a244 [bdk_chain_redesign] Introduce `BlockAnchor` trait (志宇)

Pull request description:

  ### Description

  This is part of #895

  The initial `bdk_chain` structures allowed updating to be done without blocking IO (alongside many other benefits). However, the requirement to have transactions "perfectly positioned" in our `SparseChain` increased complexity of the syncing API. Updates needed to be meticulously crafted to properly connect with the original `SparseChain`. Additionally, it forced us to keep a local copy of the "best chain" data (which may not always be needed depending on the chain source).

  The redesigned structures, as introduced by this PR, fixes these shortcomings.

  1. Instead of `SparseChain`, we introduce the ability to `Anchor` a transaction to multiple blocks that may or may not be in the same chain history. We expand `TxGraph` to records these anchors (while still maintaining the *monotone* nature of `TxGraph`). When updating our new `TxGraph`, we don't need to complicated *are-we-connected* checks that we need for `SparseChain`.
  2. The chain source, in combination with our new`TxGraph` is all that we need to determine the "chain position" of a transaction. The chain source only needs to implement a single trait `ChainOracle`. This typically does not need to be updated (as it is remote), although we can have a special `ChainOracle` implementation that is stored locally. This only needs block height and hash information, reducing the scope of *non-monotine* structures that need to be updated.

  **What is done:**

  * `TxGraph` includes anchors (ids of blocks that the tx is seen in) and last-seem unix timestamp (for determining which non-confirmed tx we should consider as part of "best chain" if there are conflicts). This structure continues to be fully "monotone"; we can introduce data in any manner and not risk resulting in an inconsistent state.
  * `LocalChain` includes the "checkpoint" logic of `SparseChain` but removes the `txid` data. `LocalChain` implements the `ChainOracle` trait. Any blockchain-source can also implement the `ChainOracle` trait.
  * `IndexedTxGraph` is introduced and contains two fields; an internal `TxGraph` struct and a `TxIndex` implementation. These two fields will be updated atomically and can replace the functionality of `keychain::Tracker`.

  **What is in-progress:**

  * ~@evanlinjin: The `TxIndex` trait should not have `is_{}_relevant` methods as we cannot guarantee this across all transaction indexes. We should introduce extension traits for these (https://github.com/bitcoindevkit/bdk/pull/926#discussion_r1159286393).~
  * ~@evanlinjin: `BlockAnchor` should be defined as "if this block is in chain, then this tx must be in chain". Therefore, the anchor does not provide us with the exact confirmation height of the tx. We need to introduce an extension trait `ExactConfirmationHeightAnchor` for certain operations (https://github.com/bitcoindevkit/bdk/pull/926#discussion_r1155480352).~

  **What will be done external to this PR:**

  * @rajarshimaitra: Persisting `indexed_tx_graph::Additions` (#937).
  * @notmandatory: Update examples to use redesigned structures.
  * Update `bdk::Wallet` to use the redesigned structures.

  ### Changelog notice

  * Initial implementation of the `bdk_chain` redesign (as mentioned in #895). Currently, only the `bdk_chain` core structures are implemented. Persistence and updates to the current examples and `bdk::Wallet` will be done in separate PRs.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] I've added docs for the new feature

ACKs for top commit:
  rajarshimaitra:
    ACK https://github.com/bitcoindevkit/bdk/pull/926/commits/b799a5728b7e08a18059ffee7fe7ee6078354977
  danielabrozzoni:
    Partial ACK b799a5728b7e08a18059ffee7fe7ee6078354977 - good job! I haven't looked at the tests or at the methods implementations in depth, but I have reviewed the architecture and it looks good. I have a few non-blocking questions.

Tree-SHA512: 8c386354cbd02f0701b5134991b65d206a54d19a2e78ab204e6ff1fa78a18f16299051bc0bf4ff4d2f5a0adab9b15658fa53cd0de2ca16969f4bf6a485225082

2 years ago[bdk_chain_redesign] Add tests for `IndexedTxGraph` with `LocalChain`
rajarshimaitra [Thu, 27 Apr 2023 14:09:21 +0000 (19:39 +0530)]
[bdk_chain_redesign] Add tests for `IndexedTxGraph` with `LocalChain`

These tests cover list_txout, list_utxo and balance methods.

2 years ago[bdk_chain_redesign] Implement `OwnedIndexer` for indexers
rajarshimaitra [Thu, 27 Apr 2023 14:08:35 +0000 (19:38 +0530)]
[bdk_chain_redesign] Implement `OwnedIndexer` for indexers

`SpkTxOutIndex` and `KeychainTxOutIndex` now both implement
`OwnedIndexer`.

2 years ago[bdk_chain_redesign] Fix calculation bugs.
rajarshimaitra [Thu, 27 Apr 2023 14:08:25 +0000 (19:38 +0530)]
[bdk_chain_redesign] Fix calculation bugs.

* `IndexedTxGraph::try_balance` should include "confirmed and spendable"
  into `confirmed` balance.
* `TxGraph::try_list_chain_unspents` filter logic should be reversed.

2 years ago[bdk_chain_redesign] Fix `tx_graph::Additions::append` logic
志宇 [Fri, 28 Apr 2023 10:54:36 +0000 (18:54 +0800)]
[bdk_chain_redesign] Fix `tx_graph::Additions::append` logic

* `Additions` now implements `Append` and uses `Append` to implement
  `append()`.
* `append()` logic enforces that `last_seen` values should only
  increase.
* Test written for `append()` with `last_seen` behaviour.

2 years agoAdd sat_per_kwu to FeeRate
benthecarman [Thu, 27 Apr 2023 01:25:25 +0000 (20:25 -0500)]
Add sat_per_kwu to FeeRate

2 years ago[bdk_chain_redesign] Fix `tx_graph::Additions::append` logic
志宇 [Tue, 25 Apr 2023 17:09:19 +0000 (01:09 +0800)]
[bdk_chain_redesign] Fix `tx_graph::Additions::append` logic

2 years ago[bdk_chain_redesign] Change `insert_relevant_txs` method
志宇 [Sat, 22 Apr 2023 16:12:41 +0000 (00:12 +0800)]
[bdk_chain_redesign] Change `insert_relevant_txs` method

Instead of forcing all transactions inserted to use the same anchors, we
change the API to have unique anchors per transaction.

This allows for more flexibility in general. For example, use `Anchor`
implementations that contain the position in a block of a transaction.

2 years ago[bdk_chain_redesign] Docs for `is_mature` and `is_confirmed_and_spendable`
志宇 [Sat, 22 Apr 2023 15:39:49 +0000 (23:39 +0800)]
[bdk_chain_redesign] Docs for `is_mature` and `is_confirmed_and_spendable`

Docs are updated to explain why `is_mature` and
`is_confirmed_and_spendable` may return false-negatives.

2 years ago[bdk_chain_redesign] Make `insert_relevant_txs` topologically-agnostic
志宇 [Sat, 22 Apr 2023 14:56:51 +0000 (22:56 +0800)]
[bdk_chain_redesign] Make `insert_relevant_txs` topologically-agnostic

The `insert_relevant_txs` test has also been changed to used
`KeychainTxOutIndex` so that index additions can be checked
(`SpkTxOutIndex` has no additions).

Additionally, generic bounds of some `IndexedTxGraph` list methods have
been fixed.

2 years ago[bdk_chain_redesign] Add test for `insert_relevant_txs`
志宇 [Fri, 21 Apr 2023 06:39:13 +0000 (14:39 +0800)]
[bdk_chain_redesign] Add test for `insert_relevant_txs`

Ensure `insert_relevant_txs` does not require transactions to be in
topological order.

Other changes: Rm `try_list_owned_txs` as it is useless

2 years ago[bdk_chain_redesign] Various tweaks and fixes
志宇 [Fri, 21 Apr 2023 05:29:44 +0000 (13:29 +0800)]
[bdk_chain_redesign] Various tweaks and fixes

The `ConfirmationHeight` trait has been removed in favour of a second
method on the `Anchor` trait: `confirmation_height_upper_bound()`.

Methods `try_balance_at()` and `balance_at()` of `IndexedTxGraph` have
been removed as they do not provide additional functionality.

`IndexedTxGraph::insert_relevant_txs` now uses two loops, the first loop
indexes all transactions first. This is done as some indexes require
ancestor transactions to be indexed first and we cannot guarantee that
the input transactions are in topological order.

2 years ago[bdk_chain_redesign] Revert changes to `SparseChain`
志宇 [Fri, 21 Apr 2023 04:33:03 +0000 (12:33 +0800)]
[bdk_chain_redesign] Revert changes to `SparseChain`