34 Commits

Author SHA1 Message Date
Wei Chen
f6dc6890c3
docs(esplora): fixed full_scan and sync documentation 2024-05-06 16:51:19 +08:00
志宇
0f94f24aaf
feat(esplora)!: update to use new sync/full-scan structures 2024-04-26 15:09:21 +08:00
志宇
77d35954c1
feat(chain)!: rm local_chain::Update
The intention is to remove the `Update::introduce_older_blocks`
parameter and update the local chain directly with `CheckPoint`.

This simplifies the API and there is a way to do this efficiently.
2024-04-17 10:57:50 +08:00
志宇
72fe65b65f
feat(esplora)!: simplify chain update logic
Co-authored-by: LLFourn <lloyd.fourn@gmail.com>
2024-04-16 19:40:28 +08:00
志宇
519cd75d23
test(esplora): move esplora tests into src files
Since we want to keep these methods private.
2024-04-16 19:28:38 +08:00
志宇
bd62aa0fe1
feat(esplora)!: remove EsploraExt::update_local_chain
Previously, we would update the `TxGraph` and `KeychainTxOutIndex`
first, then create a second update for `LocalChain`. This required
locking the receiving structures 3 times (instead of twice, which
is optimal).

This PR eliminates this requirement by making use of the new `query`
method of `CheckPoint`.

Examples are also updated to use the new API.
2024-04-16 18:01:47 +08:00
Tobin C. Harding
984c758f96
Upgrade miniscript/bitcoin dependency
Upgrade:

- bitcoin to v0.31.0
- miniscript to v11.0.0

Note: The bitcoin upgrade includes improvements to the
`Transaction::weight()` function, it appears those guys did good, we
no longer need to add the 2 additional weight units "just in case".
2024-04-08 15:16:02 +10:00
Jose Storopoli
7c1861aab9
fix: define and document stop_gap
- changes the code implementation to "the maximum number of consecutive unused addresses"
  in esplora async and blocking extjensions.
- treat `stop_gap = 0` as `stop_gap = 1` for all purposes.
- renames `past_gap_limit` to `gap_limit_reached` to indicate we want to break once the gap
  limit is reached and not go further in `full_scan`, as suggested in
  https://github.com/bitcoindevkit/bdk/issues/1227#issuecomment-1859040463
- change the tests according to the new implementation.
- add notes on what `stop_gap` means and links to convergent definition in other
  Bitcoin-related software.

Closes #1227
2024-03-26 12:44:03 -03:00
Daniela Brozzoni
7aca88474a
Merge bitcoindevkit/bdk#1308: feat(esplora): include previous TxOuts for fee calculation
552f11cb5f66a9366dbc05c801fcae043ebe5b82 feat(esplora): include previous `TxOut`s for fee calculation The previous `TxOut` for transactions received from an external wallet are added as floating `TxOut`s to `TxGraph` to allow for fee calculation. (Wei Chen)

Pull request description:

  ### Description

  Partially implements #1265.

  The previous `TxOut` for transactions received from an external wallet are added as floating `TxOut`s to `TxGraph` to allow for fee calculation.

  ### Notes to the reviewers

  Currently only the `esplora` portion of #1265 has been implemented.
  The `electrum` portion will potentially be done in a new PR, as discussed on the 1/30/24 Lib call.

  ### Checklists

  #### To Do:
  * [ ] Implement `electrum` portion of #1265.

  #### 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:
  evanlinjin:
    re-ACK 552f11cb5f66a9366dbc05c801fcae043ebe5b82
  danielabrozzoni:
    ACK 552f11cb5f66a9366dbc05c801fcae043ebe5b82

Tree-SHA512: 752a24ebd0b9ad7952c1b093ecb251473e346c77b860c1a80c73418130189227405a0f0d7652967cf8c7b89994e8c37df96cd52b52b6daff9cc8c88b5194069a
2024-02-05 12:44:58 +01:00
Wei Chen
552f11cb5f
feat(esplora): include previous TxOuts for fee calculation
The previous `TxOut` for transactions received from an external
wallet are added as floating `TxOut`s to `TxGraph` to allow for
fee calculation.
2024-02-05 17:01:11 +08:00
vmammal
89a7ddca7f
ref(esplora): Box a large esplora_client::Error
to address `clippy::result_large_err`. Clippy's default large-error-
threshold is 128. `esplora_client::Error` currently has size 272.
2024-01-31 11:50:41 -05:00
Steve Myers
8ad52f720f
Merge bitcoindevkit/bdk#1267: Simplify Esplora::update_local_chain and add tests
c5afbaa95d7bc699981d6fe7f9964a41b7587d5c ci: update zstd-sys version to work with MSRV 1.63 (Steve Myers)
929b5ddb0c2e0dc7c346c08888201ac54efab84d refactor(esplora): better variable naming and docs (志宇)
216648bcfd2c622890bf7f50fb2eaa4396c42ed1 chore(esplora): Clarify consistency guarantees (LLFourn)
63fa710319f231f7f28d92cb49b0399f3250c9da fix(esplora): reuse returned height instead of zipping (志宇)
6f824cf325c6c882b00742d814be1d72602f05a6 test(esplora): introduce test cases for `update_local_chain` (志宇)
f05e8502e69a051af9869be6ba5ad9a376b25fc2 feat(esplora): greatly simplify `update_local_chain` (志宇)

Pull request description:

  Fixes #1199

  ### Description

  After a second look at the `update_local_chain` implementations, it was clear that they were over complicated. This PR simplifies the `EsploraExt::update_local_chain` method(s) of the `bdk_esplora` crate and adds a whole bunch of tests.

  ### Notes to the reviewers

  The description of #1199 is very brief, however @danielabrozzoni mentioned about potentially-problematic logic with `ASSUME_FINAL_DEPTH`. The logic was indeed convoluted and it did not need to be that way. This PR removes the need for `ASSUME_FINAL_DEPTH`.

  ### Changelog notice

  Fixed
  - Simplified `EsploraExt::update_local_chain` logic.

  ### 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

  #### Bugfixes:

  ~* [ ] This pull request breaks the existing API~
  ~* [ ] I've added tests to reproduce the issue which are now passing~ (there are now lots of tests though)
  * [x] I'm linking the issue being fixed by this PR

ACKs for top commit:
  evanlinjin:
    ACK c5afbaa95d7bc699981d6fe7f9964a41b7587d5c
  notmandatory:
    utACK c5afbaa95d7bc699981d6fe7f9964a41b7587d5c

Tree-SHA512: f588493a4643f0f68d3181f27adf91793d4e336be6e853a26289e0916ed83169e1067260b75e627f190842f691ec095e668c0b799ca80e7da2849dd28de32754
2024-01-31 08:37:15 -06:00
志宇
929b5ddb0c
refactor(esplora): better variable naming and docs 2024-01-31 21:35:22 +08:00
LLFourn
216648bcfd
chore(esplora): Clarify consistency guarantees 2024-01-30 13:57:06 +11:00
志宇
63fa710319
fix(esplora): reuse returned height instead of zipping 2024-01-29 17:51:03 +08:00
志宇
f05e8502e6
feat(esplora): greatly simplify update_local_chain 2024-01-19 23:17:54 +08:00
vmammal
b6a58d4f9b
doc(chain,esplora): minor documentation improvements
* Corrects an awkward use of the word 'an'
* Adds missing backticks, brackets in a few places
2024-01-17 14:07:14 -05:00
Steve Myers
de54e710ed
refactor(esplora_ext): rename scan_txs to sync and scan_txs_with_keychains to full_scan
removed txids and outpoints params from full_scan
2024-01-05 15:32:20 -06:00
Antoine Poinsot
cb713e5b8c
esplora: also fix the gap limit check in the async client 2023-11-24 12:21:14 +01:00
志宇
5998a22819
feat!: LocalChain with hardwired genesis checkpoint
This ensures that `LocalChain` will always have a tip. The `ChainOracle`
trait's `get_chain_tip` method no longer needs to return an option.
2023-11-16 06:41:18 +08:00
Wei Chen
0112c67b60
chore: rename ConfirmationTimeAnchor to ConfirmationTimeHeightAnchor
An `Anchor` implementation that records both height and time should have
both attributes included in the name.
2023-11-12 21:31:47 +08:00
Steve Myers
6a5c9d7a00
fix(esplora): use saturating_add in update_tx_graph()
This fixes overflow error when calling update_tx_graph() from update_tx_graph_without_keychain().
2023-09-25 21:09:42 -05:00
Steve Myers
4d1a9fd47a
test(esplora): add async_ext and blocking_ext integration tests 2023-09-25 21:09:40 -05:00
Steve Myers
94f8fa530b
docs: fix spelling errors 2023-09-16 10:43:26 -05:00
Vladimir Fomene
20900218ce
refactor: rename methods in EsploraExt and EsploraExtAsync 2023-09-12 16:38:49 +03:00
Daniela Brozzoni
6eb079576f
Update crates/esplora to rust-bitcoin 0.30.0 2023-08-03 10:59:05 +02:00
志宇
db15e03bdc
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`.
2023-07-28 11:37:17 +08:00
志宇
eabeb6ccb1
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>
2023-07-28 11:30:16 +08:00
志宇
1c3cbefa4d
[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.
2023-06-04 03:32:18 +08:00
志宇
5860704b2d
Implement redesigned versions of EsploraExt and EsploraAsyncExt
All associated examples are also updated.
2023-06-04 03:32:18 +08:00
志宇
877b658787
Add docs for EsploraAsyncExt and make doctests runnable 2023-03-16 13:08:42 +08:00
rajarshimaitra
24df03afd6
Add documentation fixes 2023-03-15 13:00:45 +08:00
LLFourn
2fcf9c4adb
Make async esplora futures Send 2023-03-10 12:19:54 +11:00
志宇
def0c9ed39
Add wallet_esplora_async example and various fixes
Fixes include:
* Allow `bdk_esplora` to use async with tls
* Reorganize `bdk_esplora` crate to have separate files for
  async vs blocking
* Use optional dependencies for `bdk_esplora` async
2023-03-09 11:07:45 +13:00