417 Commits

Author SHA1 Message Date
志宇
c0374a0eeb
feat(chain): SyncRequest now uses ExactSizeIterators
This allows the caller to track sync progress.
2024-04-27 20:40:08 +08:00
志宇
0f94f24aaf
feat(esplora)!: update to use new sync/full-scan structures 2024-04-26 15:09:21 +08:00
志宇
4c52f3e08e
feat(wallet): make wallet compatible with sync/full-scan structures
* Changed `Wallet::apply_update` to also take in anything that
  implements `Into<Update>`. This allows us to directly apply a
  `FullScanResult` or `SyncResult`.
* Added `start_full_scan` and `start_sync_with_revealed_spks` methods to
  `Wallet`.

Co-authored-by: Steve Myers <steve@notmandatory.org>
2024-04-26 12:55:48 +08:00
志宇
cdfec5f907
feat(chain): add sync/full-scan structures for spk-based syncing
These structures allows spk-based chain-sources to have a universal API.

Co-authored-by: Steve Myers <steve@notmandatory.org>
2024-04-26 12:55:47 +08:00
志宇
8e73998cfa
Merge bitcoindevkit/bdk#1380: Simplified EsploraExt API
96a9aa6e63474dbd93a2ef969eef5b07c79e6491 feat(chain): refactor `merge_chains` (志宇)
2f22987c9e924800f8682b2dcbdde60fd26b069a chore(chain): fix comment (志宇)
daf588f016ec3118c875db8ed6b55fa03683f0f6 feat(chain): optimize `merge_chains` (志宇)
77d35954c1f3a18f767267e9097f63ca11c709ec feat(chain)!: rm `local_chain::Update` (志宇)
1269b0610efb7bd86d92a909800f9330568c797a test(chain): fix incorrect test case (志宇)
72fe65b65f297ebb7160eee6859c46e29c2d9528 feat(esplora)!: simplify chain update logic (志宇)
eded1a7ea0c6a4b9664826df4f77b714cbad0bcc feat(chain): introduce `CheckPoint::insert` (志宇)
519cd75d23fbb72321b0b189dca12afbfd78c0c7 test(esplora): move esplora tests into src files (志宇)
a6e613e6b978b995abf6c92a16df0300b113aa2c test(esplora): add `test_finalize_chain_update` (志宇)
494d253493f1bc914adba16a28ccf1bc0a0f4ec8 feat(testenv): add `genesis_hash` method (志宇)
886d72e3d541d088320bbdad6804057f32aca684 chore(chain)!: rm `missing_heights` and `missing_heights_from` methods (志宇)
bd62aa0fe199d676710c9909617198d62f4897c0 feat(esplora)!: remove `EsploraExt::update_local_chain` (志宇)
1e997939837e9c1f0c087d6d28ac12e373c8c05f feat(testenv): add `make_checkpoint_tip` (志宇)

Pull request description:

  Fixes #1354

  ### Description

  Built on top of both #1369 and #1373, we simplify the `EsploraExt` API by removing the `update_local_chain` method and having `full_scan` and `sync` update the local chain in the same call. The `full_scan` and `sync` methods now takes in an additional input (`local_tip`) which provides us with the view of the `LocalChain` before the update. These methods now return structs `FullScanUpdate` and `SyncUpdate`.

  The examples are updated to use this new API. `TxGraph::missing_heights` and `tx_graph::ChangeSet::missing_heights_from` are no longer needed, therefore they are removed.

  Additionally, we used this opportunity to simplify the logic which updates `LocalChain`. We got rid of the `local_chain::Update` struct (which contained the update `CheckPoint` tip and a `bool` which signaled whether we want to introduce blocks below point of agreement). It turns out we can use something like `CheckPoint::insert` so the chain source can craft an update based on the old tip. This way, we can make better use of `merge_chains`' optimization that compares the `Arc` pointers of the local and update chain (before we were crafting the update chain NOT based on top of the previous local chain). With this, we no longer need the `Update::introduce_older_block` field since the logic will naturally break when we reach a matching `Arc` pointer.

  ### Notes to the reviewers

  * Obtaining the `LocalChain`'s update now happens within `EsploraExt::full_scan` and `EsploraExt::sync`. Creating the `LocalChain` update is now split into two methods (`fetch_latest_blocks` and `chain_update`) that are called before and after fetching transactions and anchors.
  * We need to duplicate code for `bdk_esplora`. One for blocking and one for async.

  ### Changelog notice

  * Changed `EsploraExt` API so that sync only requires one round of fetching data. The `local_chain_update` method is removed and the `local_tip` parameter is added to the `full_scan` and `sync` methods.
  * Removed `TxGraph::missing_heights` and `tx_graph::ChangeSet::missing_heights_from` methods.
  * Introduced `CheckPoint::insert` which allows convenient checkpoint-insertion. This is intended for use by chain-sources when crafting an update.
  * Refactored `merge_chains` to also return the resultant `CheckPoint` tip.
  * Optimized the update `LocalChain` logic - use the update `CheckPoint` as the new `CheckPoint` tip when possible.

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

Tree-SHA512: 3d4f2eab08a1fe94eb578c594126e99679f72e231680b2edd4bfb018ba1d998ca123b07acb2d19c644d5887fc36b8e42badba91cd09853df421ded04de45bf69
2024-04-22 17:45:01 +08:00
志宇
96a9aa6e63
feat(chain): refactor merge_chains
`merge_chains` now returns a tuple of the resultant checkpoint AND
changeset. This is arguably a more readable/understandable setup.

To do this, we had to create `CheckPoint::apply_changeset` which is kept
as a private method.

Thank you @ValuedMammal for the suggestion.

Co-authored-by: valuedvalued mammal <valuedmammal@protonmail.com>
2024-04-22 17:39:06 +08:00
志宇
2f22987c9e
chore(chain): fix comment 2024-04-22 10:39:37 +08:00
志宇
9800f8d88e
Merge bitcoindevkit/bdk#1408: Fix: enable blocking-https-rustls feature on esplora client
d3a14d411d2a1a37f07e42c28eae3a1836aec14d fix: enable blocking-https-rustls feature on esplora client (thunderbiscuit)

Pull request description:

  The [`blocking` feature on the rust-esplora-client library](https://github.com/bitcoindevkit/rust-esplora-client/blame/master/Cargo.toml#L35) changed from ureq to minreq, which does not come with https enabled by default, breaking previously working code that simply enabled the `blocking` feature on the `bdk_esplora` crate.

  This change will enable what is currently the "default https" [flag for the minreq library](https://docs.rs/minreq/latest/minreq/#https-or-https-rustls) when using the `blocking` feature on bdk_esplora, reverting that breaking change.

  ### Notes to the reviewers

  Another way we could do this (let me know if this is preferable) is to add a new feature called `blocking-https-rustls`:
  ```rust
  blocking = ["esplora-client/blocking"]
  blocking-https-rustls = ["esplora-client/blocking-https-rustls"]
  ```

  ### Changelog notice
  <!-- Notice the release manager should include in the release tag message changelog -->
  <!-- See https://keepachangelog.com/en/1.0.0/ for examples -->

  ### 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
  * [ ] I'm linking the issue being fixed by this PR

ACKs for top commit:
  storopoli:
    ACK d3a14d411d2a1a37f07e42c28eae3a1836aec14d
  evanlinjin:
    ACK d3a14d411d2a1a37f07e42c28eae3a1836aec14d

Tree-SHA512: d25495186ceba2fcd04bc9ff0aebfb32ac5db6885ef8e4df1e304c5ee5264f6161821e06d29367d2837afcc64a53f1553e7c0bb065e6a2e46dc08b8e04c2ad8e
2024-04-20 16:01:20 +08:00
valued mammal
d39b319ddf
test(wallet): Test wallet addresses
Adds test coverage for Wallet methods `reveal_addresses_to`,
`mark_used`, and `unmark_used`
2024-04-20 15:12:41 +08:00
valued mammal
a266b4718f
chore(wallet)!: Remove enum AddressIndex 2024-04-20 15:12:39 +08:00
valued mammal
d87874780b
refactor(wallet)!: Remove method get_address
As this is now made redundant by the newly added
wallet address methods.
2024-04-20 15:10:36 +08:00
valued mammal
d3763e5e37
feat(wallet): Add new address methods
Introduce a new API for getting addresses from the Wallet that
reflects a similiar interface as the underlying indexer
`KeychainTxOutIndex` in preparation for removing `AddressIndex` enum.

Before this change, the only way to get an address was via the methods
`try_get{_internal}_address` which required a `&mut` reference to the
wallet, matching on the desired AddressIndex variant. This is too
restrictive since for example peeking or listing unused addresses
shouldn't change the state of the wallet. Hence we provide separate
methods for each use case which makes for a more efficient API.
2024-04-20 15:02:55 +08:00
志宇
f00de9e0c1
Merge bitcoindevkit/bdk#1387: fix(wallet): remove the generic from wallet
e51af49ffa951e14203ac2b465ade351dd90f6cd fix(wallet): remove generic from wallet (Rob N)

Pull request description:

  ### Description

  The `PersistenceBackend` uses generics to describe errors returned while applying the change set to the persistence layer. This change removes generics wherever possible and introduces a new public error enum. Removing the generics from `PersistenceBackend` errors is the first step towards #1363

  *Update*: I proceeded with removing the generics from `Wallet` by introducing a `Box<dyn PersistenceBackend>` .

  ### Notes to the reviewers

  This one sort of blew up in the number of changes due to the use of generics for most of the `Wallet` error variants. The generics were only used for the persistence errors, so I removed the generics from higher level errors whenever possible. The error variants of `PersistenceBackend` may also be more expressive, but I will level that up for discussion and make any changes required.

  ### Changelog notice

  - Changed `PersistenceBackend` errors to depend on the `anyhow` crate.
  - Remove the generic `T` from `Wallet`

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

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

  #### Bugfixes:

  * [x] 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:
  evanlinjin:
    ACK e51af49ffa951e14203ac2b465ade351dd90f6cd

Tree-SHA512: 8ce4f1c495310e16145555f4a6a29a0f42cf8944eda68004595c3532580767f64f779185022147a00d75001c40d69fdf8f8de2d348eb68484b170d2a181117ff
2024-04-20 14:54:33 +08:00
thunderbiscuit
d3a14d411d
fix: enable blocking-https-rustls feature on esplora client 2024-04-19 11:45:39 -04:00
LLFourn
fac228337c
feat(chain)!: make KeychainTxOutIndex more range based
`KeychainTxOutIndex` should try and avoid "all" kind of queries.
There may be subranges of interest. If the user wants "all" they can
just query "..".
2024-04-18 15:31:14 +08:00
志宇
daf588f016
feat(chain): optimize merge_chains 2024-04-17 14:06:44 +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
志宇
1269b0610e
test(chain): fix incorrect test case 2024-04-17 10:45:19 +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
志宇
eded1a7ea0
feat(chain): introduce CheckPoint::insert
Co-authored-by: LLFourn <lloyd.fourn@gmail.com>
2024-04-16 19:28:41 +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
志宇
a6e613e6b9
test(esplora): add test_finalize_chain_update
We ensure that calling `finalize_chain_update` does not result in a
chain which removed previous heights and all anchor heights are
included.
2024-04-16 18:01:51 +08:00
志宇
494d253493
feat(testenv): add genesis_hash method
This gets the genesis hash of the env blockchain.
2024-04-16 18:01:51 +08:00
志宇
886d72e3d5
chore(chain)!: rm missing_heights and missing_heights_from methods
These methods are no longer needed as we can determine missing heights
directly from the `CheckPoint` tip.
2024-04-16 18:01:50 +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
志宇
1e99793983
feat(testenv): add make_checkpoint_tip
This creates a checkpoint linked list which contains all blocks.
2024-04-16 17:51:02 +08:00
Rob N
e51af49ffa
fix(wallet): remove generic from wallet 2024-04-15 10:33:34 -10:00
Steve Myers
5f238d8e67
Bump bdk version to 1.0.0-alpha.9
bdk_chain to 0.12.0
bdk_bitcoind_rpc to 0.8.0
bdk_electrum to 0.11.0
bdk_esplora to 0.11.0
bdk_file_store to 0.9.0
bdk_testenv to 0.2.0
2024-04-12 11:43:25 -05:00
Steve Myers
358e842dcd
Merge bitcoindevkit/bdk#1177: Upgrade bitcoin/miniscript dependencies
984c758f964f8fee687d21885b43b0b4705f318c Upgrade miniscript/bitcoin dependency (Tobin C. Harding)

Pull request description:

  Upgrade:

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

  Fix: #1196

ACKs for top commit:
  ValuedMammal:
    ACK 984c758f964f8fee687d21885b43b0b4705f318c
  notmandatory:
    ACK 984c758f964f8fee687d21885b43b0b4705f318c
  oleonardolima:
    ACK 984c758f964f8fee687d21885b43b0b4705f318c
  storopoli:
    ACK 984c758f964f8fee687d21885b43b0b4705f318c

Tree-SHA512: d64d530e93cc36688ba07d3677d5c1689b61f246f05d08092bbf86ddbba8a5ec49648e6825b950ef17729dc064da50d50b793475a288862a0461976876807170
2024-04-12 10:58:19 -05:00
志宇
446b045161
test(chain): introduce proptest for CheckPoint::range
Ensure that `CheckPoint::range` returns expected values by comparing
against values returned from a primitive approach.

I think it is a good idea to start writing proptests for this crate.
2024-04-11 21:43:21 +08:00
志宇
62619d3a4a
Merge bitcoindevkit/bdk#1385: Fix last seen unconfirmed
a2a64ffb6e92baf46a912f36294f3f4f521a528a fix(electrum)!: Remove `seen_at` param from `into_tx_graph` (valued mammal)
37fca35ddede6cbc9d9428a2722eff82a405b1b2 feat(tx_graph): Add method update_last_seen_unconfirmed (valued mammal)

Pull request description:

  A method `update_last_seen_unconfirmed` is added for `TxGraph` that allows inserting a `seen_at` time for all unanchored transactions.

  fixes #1336

  ### Changelog notice

  Changed:
  - Methods `into_tx_graph` and `into_confirmation_time_tx_graph`for `RelevantTxids` are changed to no longer accept a `seen_at` parameter.

  Added:
  - Added method `update_last_seen_unconfirmed` for `TxGraph`.

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

Tree-SHA512: 9011e63314b0e3ffcd50dbf5024f82b365bab1cc834c0455d7410b682338339ed5284caa721ffc267c65fa26d35ff6ee86cde6052e82a6a79768547fbb7a45eb
2024-04-11 21:33:14 +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
valued mammal
a2a64ffb6e
fix(electrum)!: Remove seen_at param from into_tx_graph
and `into_confirmation_time_tx_graph`, since now it makes
sense to use `TxGraph::update_last_seen_unconfirmed`.

Also, use `update_last_seen_unconfirmed` in examples for
electrum/esplora. We show how to update the last seen
time for transactions by calling `update_last_seen_unconfirmed`
on the graph update returned from a blockchain source, passing
in the current time, before applying it to another `TxGraph`.
2024-04-06 12:04:27 -04:00
valued mammal
37fca35dde
feat(tx_graph): Add method update_last_seen_unconfirmed
That accepts a `u64` as param representing the latest timestamp
and internally calls `insert_seen_at` for all transactions in
graph that aren't yet anchored in a confirmed block.
2024-04-06 11:50:37 -04:00
志宇
53942cced4
chore(chain)!: rm From<LocalChain> for BTreeMap<u32, BlockHash>
I don't think this was ever used. The only possible usecase I can think
of is for tests, but I don't think that is a strong enough incentive for
us to keep this.
2024-04-05 16:36:00 +08:00
志宇
2d1d95a685
feat(chain): impl PartialEq on CheckPoint
We impl `PartialEq` on `CheckPoint` instead of directly on `LocalChain`.
We also made the implementation more efficient.
2024-04-05 16:36:00 +08:00
志宇
9a62d56900
feat(chain): add get and range methods to CheckPoint
These methods allow us to query for checkpoints contained within the
linked list by height and height range. This is useful to determine
checkpoints to fetch for chain sources without having to refer back to
the `LocalChain`.

Currently this is not implemented efficiently, but in the future, we
will change `CheckPoint` to use a skip list structure.
2024-04-05 16:36:00 +08:00
志宇
2bb654077d
Merge bitcoindevkit/bdk#1345: fix: remove deprecated max_satisfaction_weight
798ed8ced25156049126645435127a22245e916f fix: remove deprecated `max_satisfaction_weight (Jose Storopoli)

Pull request description:

  ### Description
  Continuation of #1115.
  Closes #1036.

  * Change deprecated `max_satisfaction_weight` to `max_weight_to_satisfy`
  * Remove `#[allow(deprecated)]` flags

  ### Notes to the reviewers

  I've changed all `max_satisfaction_weight()` to `max_weight_to_satisfy()` in `Wallet.get_available_utxo()` and `Wallet.build_fee_bump()`. Checking the docs on the `miniscript` crate for `max_weight_to_satisfy` has the following note:

  We are testing if the underlying descriptor `is.segwit()` or `.is_taproot`,
  then adding 4WU if true or leaving as it is otherwise.

  Another thing, we are not testing in BDK tests for legacy (pre-segwit) descriptors.
  Should I also add them to this PR?

  ### Changelog notice
  ### Fixed
  Replace the deprecated `max_satisfaction_weight` from `rust-miniscript` to `max_weight_to_satisfy`.

  ### 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
  * [x]  I'm linking the issue being fixed by this PR

ACKs for top commit:
  evanlinjin:
    ACK 798ed8ced25156049126645435127a22245e916f

Tree-SHA512: 60babecee13c24915348ddb64894127a76a59d9421d52ea37acc714913685d57cc2be1904f9d0508078dd1db1f7d7dad83a734af5ee981801ca87de2e9984429
2024-04-02 19:21:51 +08:00
志宇
19304c13ec
Merge bitcoindevkit/bdk#1373: Wrap transactions as Arc<Transaction> in TxGraph
8ab58af093ff295b86c3f8189aa96dea313092c4 feat(chain)!: wrap `TxGraph` txs with `Arc` (志宇)

Pull request description:

  ### Description

  This PR makes `TxGraph` store transactions as `Arc<Transaction>`.

  `Arc<Transaction>` can be shared between the chain-source and receiving structures. This allows the chain-source to keep the already-fetched transactions (save bandwith) and have a shared pointer to the transaction (save memory).

  Our current logic to avoid re-fetching transactions is to refer back to the receiving structures. However, this means an additional round of locking our receiving structures.

  ### Notes to the reviewers

  This will make more sense once I update the esplora/electrum chain sources to make use of both #1369 and this PR. The result would be chain sources which would only require locking the receiving structures twice (once for initiating the update, and once for applying the update).

  ### Changelog notice

  * Changed `TxGraph` to store transactions as `Arc<Transaction>`. This allows chain-sources to cheaply keep a copy of already-fetched transactions.

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

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

ACKs for top commit:
  LLFourn:
    ACK 8ab58af093ff295b86c3f8189aa96dea313092c4
  notmandatory:
    ACK 8ab58af093ff295b86c3f8189aa96dea313092c4

Tree-SHA512: 81d7ad35fed7f253a3b902f09a41aaef2877f6201d4f6e78318741bf00e4b898a8000d878ffcbfe75701094ce3e9021bd718b190a655331a9e11f0ad66bdb02f
2024-03-31 17:50:31 +08:00
Jose Storopoli
798ed8ced2
fix: remove deprecated `max_satisfaction_weight
- Change deprecated `max_satisfaction_weight` to `max_weight_to_satisfy`
- Remove `#[allow(deprecated)]` flags
- updates the calculations in TXIN_BASE_WEIGHT and P2WPKH_SATISFACTION_SIZE

Update crates/bdk/src/wallet/coin_selection.rs

Co-authored-by: ValuedMammal <valuedmammal@protonmail.com>
2024-03-29 06:27:39 -03:00
Steve Myers
7b97c956c7
Bump bdk version to 1.0.0-alpha.8
bdk_bitcoind_rpc to 0.7.0
bdk_electrum to 0.10.0
bdk_esplora to 0.10.0
bdk_file_store to 0.8.0
bdk_hwi to 0.2.0
2024-03-27 15:13:57 +08:00
志宇
2580013912
chore(testenv): fix cargo manifest 2024-03-27 14:58:46 +08: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
志宇
8ab58af093
feat(chain)!: wrap TxGraph txs with Arc
Wrapping transactions as `Arc<Transaction>` allows us to share
transactions cheaply between the chain-source and receiving structures.
Therefore the chain-source can keep already-fetched transactions (save
bandwidth) and have a shared pointer to the transactions (save memory).

This is better than the current way we do things, which is to refer back
to the receiving structures mid-sync.

Documentation for `TxGraph` is also updated.
2024-03-25 12:57:26 +08:00
志宇
80e190b3e7
Merge bitcoindevkit/bdk#1171: chore: extract TestEnv into separate crate
7c9ba3cfc855dc0845476fe923dac4e47cb5c06a chore(electrum,testenv): move `test_reorg_is_detected_in_electrsd` (志宇)
2462e9041599f395673f9b14f0b618877832f099 chore(esplora): rm custom WASM target spec test dependency (志宇)
04d0ab5a978fbfd45a5c795f9142ff4a9ba29ee3 test(electrum): added scan and reorg tests Added scan and reorg tests to check electrum functionality using `TestEnv`. (Wei Chen)
4edf533b678cb21f4c29ded22692e607ff75e2cd chore: extract `TestEnv` into separate crate `TestEnv` is extracted into its own crate to serve as a framework for testing other block explorer APIs. (Wei Chen)
6e648fd5afa188290b05f8e050ba69fe5f8b80e4 chore: update MSRV dependency for nightly docs (Wei Chen)

Pull request description:

  ### Description

  `TestEnv` is extracted into its own crate with `electrsd` support added so that `TestEnv` can also serve `esplora` and `electrum`.
  The tests in the `esplora` crate have also been updated to use `TestEnv`.

  The `tx_can_become_unconfirmed_after_reorg()` test in `test_electrum` suggests that the electrum issue where a reorged tx would be stuck at confirmed does not exist anymore.

  ### Notes to the reviewers

  The code for `tx_can_become_unconfirmed_after_reorg()` was adapted from the same test in `bitcoind_rpc/test_emitter`. This electrum version of the test requires extra review, as I am uncertain if I used the API efficiently.

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

Tree-SHA512: 36c6501e477abb7ae68073b6f4776f1f69f8964010ab758aa3677aae96df10f2cb632421872cacd73b37123d6db8a9dbefb5b6416e0dd524b712bf3fc56b7139
2024-03-23 18:37:38 +08:00
志宇
7c9ba3cfc8
chore(electrum,testenv): move test_reorg_is_detected_in_electrsd 2024-03-23 18:28:49 +08:00
志宇
2462e90415
chore(esplora): rm custom WASM target spec test dependency
None of the `bdk_esplora` tests can run under WASM anyway since we
depend on `electrsd`.
2024-03-23 17:57:27 +08:00
Wei Chen
04d0ab5a97
test(electrum): added scan and reorg tests
Added scan and reorg tests to check electrum functionality using
`TestEnv`.
2024-03-22 17:59:35 +08:00
Wei Chen
4edf533b67
chore: extract TestEnv into separate crate
`TestEnv` is extracted into its own crate to serve as a framework
for testing other block explorer APIs.
2024-03-22 17:59:35 +08:00
志宇
a837cd349b
Merge bitcoindevkit/bdk#1378: Update bdk README
06d7dc5c3a890f0a141de4cf6f421fe766d99ec3 doc(bdk): Update bdk README (vmammal)

Pull request description:

  fixes #1044

  ### Notes

  The code snippet is a compile fail because variables `txout` and `outpoint` are not initialized. Any other suggestions are welcome.

  There is still some old commented code in the file that's probably not needed unless we want to provide another example snippet, say for getting new address info.

  * [x] Fix broken links
  * [x] Use a new unused tprv
  * [ ] Try to make persistence example make sense, or maybe just do away with it

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

Tree-SHA512: 09a671bc6bea574d7a4b42b64718380ee71a0c5d36c6b7ca1dc19a2c567de510b27ccc91fe05e7178bf31c562db66bc64f660415de5bb2f32f369b13c44ad3d2
2024-03-22 15:10:21 +08:00