]> Untitled Git - bdk/log
bdk
2 years agoesplora: also test the gap limit bounds in the async client
Antoine Poinsot [Mon, 20 Nov 2023 11:00:50 +0000 (12:00 +0100)]
esplora: also test the gap limit bounds in the async client

2 years agoesplora: also fix the gap limit check in the async client
Antoine Poinsot [Mon, 20 Nov 2023 11:00:31 +0000 (12:00 +0100)]
esplora: also fix the gap limit check in the async client

2 years agoesplora: scan gap limit bounds testing
Antoine Poinsot [Mon, 20 Nov 2023 10:52:30 +0000 (11:52 +0100)]
esplora: scan gap limit bounds testing

2 years agoesplora: fix incorrect gap limit check in blocking client
Antoine Poinsot [Mon, 20 Nov 2023 09:34:10 +0000 (10:34 +0100)]
esplora: fix incorrect gap limit check in blocking client

The gap limit was checked such as if the last_index was not None but the
last_active_index was, we'd consider having reached it. But the
last_index is never None for this check. This effectively made it so the
gap limit was always 1: if the first address isn't used
last_active_index will be None and we'd return immediately.

Fix this by avoiding error-prone Option comparisons and correctly
checking we've reached the gap limit before breaking out of the loop.

2 years agoMerge bitcoindevkit/bdk#1190: Add `Wallet::list_output` method
Daniela Brozzoni [Tue, 21 Nov 2023 15:53:50 +0000 (16:53 +0100)]
Merge bitcoindevkit/bdk#1190: Add `Wallet::list_output` method

278210bb8918923005e80968df3dfcc3372c0a5c docs(bdk): clarify `insert_txout` docs (志宇)
6fb45d8a735ec8db9142489d86107de192e0fa9c test(bdk): add `test_list_output` (志宇)
e803ee901002cae4db5ebf3544eb42c6cf81e5e2 feat(bdk): add `Wallet::list_output` method (志宇)
82632897aaa4ea0ac24803f58fbd13d6dc9c4357 refactor(bdk)!: rename `LocalUtxo` to `LocalOutput` (志宇)

Pull request description:

  Fixes #1184

  ### Description

  Introduce `Wallet::list_output` method that lists all outputs (both spent and unspent) in a consistent history.

  ### Changelog notice

  - Rename `LocalUtxo` to `LocalOutput`.
  - Add `Wallet::list_output` 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

  #### New Features:

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

ACKs for top commit:
  notmandatory:
    re-ACK 278210bb8918923005e80968df3dfcc3372c0a5c
  danielabrozzoni:
    ACK 278210bb8918923005e80968df3dfcc3372c0a5c

Tree-SHA512: 151af0e05e55d9c682271ef0c7a82e189531db963f65aa62c2ba0507f203dde39ab7561521c56e72c26830828e94ff96b7bd7e3f46082b23f79c5e0f89470136

2 years agoMerge bitcoindevkit/bdk#1204: chore: remove bdk dependency on log and dev dependency...
Steve Myers [Mon, 20 Nov 2023 23:33:48 +0000 (15:33 -0800)]
Merge bitcoindevkit/bdk#1204: chore: remove bdk dependency on log and dev dependency on env_logger

02fa34089623ea43e9c62003e3b829d10dec5a14 chore: remove bdk dependency on log and dev dependency on env_logger (Steve Myers)

Pull request description:

  ### Description

  As suggested by @TheBlueMatt we shouldn't use the `log` crate because even though it is a rust-lang project is may depend on some other crates that aren't as well maintained. Since we were only use `log` in a few places and not it any other bdk workspace projects except the `bdk` package I removed it.

  ### Notes to the reviewers

  For consistency I also removed the `env_logger` from the dev dependencies since it was only being used in a few places in a couple examples and println! is adequate for examples.

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

Top commit has no ACKs.

Tree-SHA512: beb9e4d465112090093590c45e3e5e2286a99a819312512eb3e5b40d0eade9740314bb8e45a2ad3fa0a4c86e32711d2ef8f966842815874b9315fd0b63bc7283

2 years agochore: remove bdk dependency on log and dev dependency on env_logger
Steve Myers [Sat, 11 Nov 2023 19:02:02 +0000 (13:02 -0600)]
chore: remove bdk dependency on log and dev dependency on env_logger

2 years agodocs(bdk): clarify `insert_txout` docs
志宇 [Mon, 20 Nov 2023 21:06:53 +0000 (05:06 +0800)]
docs(bdk): clarify `insert_txout` docs

Inserted txouts will not be shown in `list_unspent` or `list_output`.

2 years agotest(bdk): add `test_list_output`
志宇 [Wed, 1 Nov 2023 20:24:25 +0000 (04:24 +0800)]
test(bdk): add `test_list_output`

2 years agofeat(bdk): add `Wallet::list_output` method
志宇 [Wed, 1 Nov 2023 05:25:28 +0000 (13:25 +0800)]
feat(bdk): add `Wallet::list_output` method

2 years agorefactor(bdk)!: rename `LocalUtxo` to `LocalOutput`
志宇 [Wed, 1 Nov 2023 04:33:57 +0000 (12:33 +0800)]
refactor(bdk)!: rename `LocalUtxo` to `LocalOutput`

2 years agoMerge bitcoindevkit/bdk#1028: Add CreateTxError and use as error type for TxBuilder...
Steve Myers [Thu, 16 Nov 2023 18:30:16 +0000 (12:30 -0600)]
Merge bitcoindevkit/bdk#1028: Add CreateTxError and use as error type for TxBuilder::finish()

00ec19ef2d59b6268424105f3d1947ab637b8c0c ci: fix MSRV pinning for rustls 0.21.9 (Steve Myers)
77f9977c02683071748f5fd6d07bde4b2d1f4a12 feat(wallet): Add infallible Wallet get_address(), get_internal_address functions (Steve Myers)
9e7d99e3bf9687251930c9a6bc5f1fe6a7c78bcb refactor(bdk)!: add context specific error types, remove top level error mod (Steve Myers)

Pull request description:

  ### Description

  To remove some places where there were `.expect("TODO")` I added a new `CreateTxError` type which is returned from `TxBuilder::finish()`. I also updated related tests and doc tests.

  Fixes https://github.com/bitcoindevkit/bdk/issues/996#issuecomment-1621036206

  Also added fallible `Wallet::try_get_address()` and `try_get_internal_address()`  to return `Result` with a possible `D:WriteError` when a PersistBackend is used. This should fix #996.

  I removed catch-all bdk::Error and replaced usages with new types and updated related functions, fixes #994.

  ### Notes to the reviewers

  ~~I didn't add all possible bdk::Error types that `Wallet::create_tx()` and `TxBuilder::finish()` functions might throw. It's probably not too much more work but will take a bit more research so I want to make sure this is the right general approach first.~~

  I added `anyhow` to the dev-dependencies so I could remove some `.expect()` lines from the docs tests and make the examples closer to what an end user should do.  I also used the `anyhow!()` macro to replace a few places that were using the `bdk::Error::Generic` in example code.

  I also moved the module level error.rs file to wallet/error.rs so no one would be tempted to make any new catch all errors and to make it clear that all the errors in it are wallet module related.

  ### Changelog notice

  Changed

  - Updated bdk module to use new context specific error types
    - wallet: MiniscriptPsbtError, CreateTxError, BuildFeeBumpError error enums
    - coin_selection: module Error enum
  - Renamed fallible Wallet address functions to try_get_address() and try_get_internal_address()

  Removed

  - Removed catch-all top level bdk::Error enum
  - Removed impl_error macro

  Added

  -  Added infallible Wallet get_address(), get_internal_address functions

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

  * [x] 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

Top commit has no ACKs.

Tree-SHA512: a87c0856d71f9c945d12b6de6d368f49bd62d73886ac46ac83d00ddb81f2c38c5233ba053e40c76dea73ee7bfc19dac510eec5d7c9026ae50a2dc7308ac4786f

2 years agoci: fix MSRV pinning for rustls 0.21.9
Steve Myers [Thu, 16 Nov 2023 17:56:09 +0000 (11:56 -0600)]
ci: fix MSRV pinning for rustls 0.21.9

2 years agofeat(wallet): Add infallible Wallet get_address(), get_internal_address functions
Steve Myers [Thu, 16 Nov 2023 17:18:11 +0000 (11:18 -0600)]
feat(wallet): Add infallible Wallet get_address(), get_internal_address functions

refactor!(wallet)!: rename fallible Wallet try_get_address(), try_get_internal_address functions

2 years agorefactor(bdk)!: add context specific error types, remove top level error mod
Steve Myers [Thu, 16 Nov 2023 16:22:37 +0000 (10:22 -0600)]
refactor(bdk)!: add context specific error types, remove top level error mod

refactor(bdk)!: remove impl_error macro
refactor(wallet)!: add MiniscriptPsbtError, CreateTxError, BuildFeeBumpError error enums
refactor(coin_selection)!: add module Error enum
test(bdk): use anyhow dev-dependency for all tests

2 years agoMerge bitcoindevkit/bdk#1220: chore: fix typos and remove unused speculos dockerfiles
Daniela Brozzoni [Thu, 16 Nov 2023 13:31:52 +0000 (14:31 +0100)]
Merge bitcoindevkit/bdk#1220: chore: fix typos and remove unused speculos dockerfiles

27a63abd1e7c87aaf3e07f8023370887a270c61a chore: typos fixed (Einherjar)

Pull request description:

  ### Description

  Fixes the typos and remove unused speculos dockerfiles that was done in #1165.
  Moving these changes into this PR to be merged first.
  Then, we can rebase #1165 and make it only related to CI and Nix.
  (Maybe do a big squash 😄)

  ## Note to Reviewers

  About the speculos stuff, we are not using them, removed in #793,
  more specifically in 3f5a78ae3b1e6c3f0a6acc98bb2445c895cfd743.

  ### Changelog notice

  - Fix typos in codebase and docs
  - Remove unused CI tests with hardware signer Dockerfiles

  ### 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
  * [ ] 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:
  danielabrozzoni:
    ACK 27a63abd1e7c87aaf3e07f8023370887a270c61a

Tree-SHA512: a01101d0741e2b0e1d1254b5cae670c5a936bb0b89332c102feb57d58d2b9ae995ed4436068b0dc5fae73dbe22431c3143d6e04cdc12eab991bd726cfd2fbe25

2 years agochore: typos fixed
Einherjar [Fri, 20 Oct 2023 20:37:28 +0000 (17:37 -0300)]
chore: typos fixed

2 years agoMerge bitcoindevkit/bdk#1178: `LocalChain` with hardwired genesis block
Steve Myers [Thu, 16 Nov 2023 00:04:08 +0000 (18:04 -0600)]
Merge bitcoindevkit/bdk#1178: `LocalChain` with hardwired genesis block

f1b112e8f9563c2afb9097911ee5e1afbbc55d22 docs(bitcoind_rpc): update docs for `Emitter::new` (志宇)
9a250baf6203a077fcfc03c3f6b386d5fba03d60 chore: make clippy happy (志宇)
79b84bed0ec399a375490c2c0f16c6ea3f5969b6 feat(bdk): changeset's `Append` impl checks that network is consistent (志宇)
06a956ad20ca5f1dcd108e45a1a1fed924128cdb feat!: change `load_from_persistence` to return an option (志宇)
c3265e2514070bd4da92ca343fe884e13e831360 test(bdk): add tests for wallet constructor methods (志宇)
96f1d94e2c8378d820a59e5ceafe686477243bf8 test(file_store): add construction method tests (志宇)
1886dc4fe743408132c3257afc1cacbb4d964105 chore(examples): use `Wallet::new_or_load` method where appropriate (志宇)
24994a3ed47aacf203ca0b456eb22f4b93ec58a8 feat(file_store)!: have separate methods for creating and opening Store (志宇)
d294e2e3189dc14efe5b9916cf83f5e7f8592c64 feat(wallet)!: add `new_or_load` methods (志宇)
7c6cbc4d9f7349e769594151936b3e2947b79d00 chore(file_store): rm empty test file (志宇)
6cf3963c6cfeacc8cd9d59bdb0bafded5022baaf feat(bdk)!: have separate methods for creating and loading `Wallet` (志宇)
7d5f31f6cc323241e866c136656f9674e0bf7c53 feat(chain, file_store): add `is_empty` method to `PersistBackend` trait (志宇)
5998a228191caccfaeac2b38ed4f319994b944c1 feat!: `LocalChain` with hardwired genesis checkpoint (志宇)

Pull request description:

  closes #1079
  closes #1107

  ### Description

  Many methods of `TxGraph` require a `chain_tip: BlockId` input to use against a `ChainOracle` implementation. This is used to ask the `ChainOracle` implementation whether a certain block exists in the chain identified by the `chain_tip`. This guarantees that the `TxGraph` methods will return a consistent history of transactions.

  However, the `ChainOracle` trait's `get_chain_tip` method returns an option of `BlockId`. It becomes unclear what to do when `get_chain_tip` returns `None`.

  This PR changes the `ChainOracle::get_chain_tip` method to always return a `BlockId` (no `Option`). `LocalChain` now hardwires the genesis block in order to implement `ChainOracle`.

  `bdk::Wallet` and `bdk_file_store::Store` are changed to have separate constructor methods for initializing a fresh instance and recovering a previous instance from persistence.

  ### Notes to the reviewers

  ### Changelog notice

  - Changed `ChainOracle::get_chain_tip` method to return a `BlockId` instead of an `Option` of a `BlockId`.
  - Refactored `LocalChain` so that the genesis `BlockId` is hardwired. This way, the `ChainOracle::get_chain_tip` implementation can always return a tip.
  - Add `is_empty` method to `PersistBackend`. This returns true when there is no data in the persistence.
  - Changed `Wallet::new` to initialize a fresh wallet only.
  - Added `Wallet::load` to restore an instance of a wallet.
  - Replaced `Store::new` with separate methods to create/open the database file.

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

2 years agodocs(bitcoind_rpc): update docs for `Emitter::new`
志宇 [Wed, 15 Nov 2023 23:23:56 +0000 (07:23 +0800)]
docs(bitcoind_rpc): update docs for `Emitter::new`

2 years agochore: make clippy happy
志宇 [Wed, 15 Nov 2023 23:17:16 +0000 (07:17 +0800)]
chore: make clippy happy

2 years agofeat(bdk): changeset's `Append` impl checks that network is consistent
志宇 [Mon, 6 Nov 2023 03:52:03 +0000 (11:52 +0800)]
feat(bdk): changeset's `Append` impl checks that network is consistent

2 years agofeat!: change `load_from_persistence` to return an option
志宇 [Wed, 1 Nov 2023 01:21:24 +0000 (09:21 +0800)]
feat!: change `load_from_persistence` to return an option

`PersistBackend::is_empty` is removed. Instead, `load_from_persistence`
returns an option of the changeset. `None` means persistence is empty.
This is a better API than a separate method. We can now differentiate
between a persisted single changeset and nothing persisted.

`Store::aggregate_changeset` is refactored to return a `Result` instead
of a tuple. A new error type (`AggregateChangesetsError`) is introduced
to include the partially-aggregated changeset in the error. This is a
more idiomatic API.

2 years agotest(bdk): add tests for wallet constructor methods
志宇 [Mon, 30 Oct 2023 22:46:27 +0000 (06:46 +0800)]
test(bdk): add tests for wallet constructor methods

2 years agotest(file_store): add construction method tests
志宇 [Mon, 30 Oct 2023 10:02:44 +0000 (18:02 +0800)]
test(file_store): add construction method tests

2 years agochore(examples): use `Wallet::new_or_load` method where appropriate
志宇 [Mon, 30 Oct 2023 03:38:20 +0000 (11:38 +0800)]
chore(examples): use `Wallet::new_or_load` method where appropriate

2 years agofeat(file_store)!: have separate methods for creating and opening Store
志宇 [Mon, 30 Oct 2023 03:02:50 +0000 (11:02 +0800)]
feat(file_store)!: have separate methods for creating and opening Store

2 years agofeat(wallet)!: add `new_or_load` methods
志宇 [Fri, 27 Oct 2023 06:14:25 +0000 (14:14 +0800)]
feat(wallet)!: add `new_or_load` methods

These methods try to load wallet from persistence and initializes the
wallet instead if non-existant.

An internal helper method `create_signers` is added to reuse code.
Documentation is also improved.

2 years agochore(file_store): rm empty test file
志宇 [Thu, 26 Oct 2023 00:12:09 +0000 (08:12 +0800)]
chore(file_store): rm empty test file

2 years agofeat(bdk)!: have separate methods for creating and loading `Wallet`
志宇 [Wed, 25 Oct 2023 22:20:37 +0000 (06:20 +0800)]
feat(bdk)!: have separate methods for creating and loading `Wallet`

`Wallet::new` now creates a new wallet. `Wallet::load` loads an existing
wallet. The network type is now recoverable from persistence. Error
types have been simplified.

2 years agofeat(chain, file_store): add `is_empty` method to `PersistBackend` trait
志宇 [Wed, 25 Oct 2023 23:47:29 +0000 (07:47 +0800)]
feat(chain, file_store): add `is_empty` method to `PersistBackend` trait

2 years agofeat!: `LocalChain` with hardwired genesis checkpoint
志宇 [Thu, 12 Oct 2023 08:55:32 +0000 (16:55 +0800)]
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.

2 years agoMerge commit 'refs/pull/1121/head' of github.com:bitcoindevkit/bdk
Steve Myers [Tue, 14 Nov 2023 17:51:48 +0000 (11:51 -0600)]
Merge commit 'refs/pull/1121/head' of github.com:bitcoindevkit/bdk

2 years agofeat: add dependabot
Einherjar [Tue, 12 Sep 2023 15:28:37 +0000 (12:28 -0300)]
feat: add dependabot

Fixes #1118.
Adds `dependabot.yml` to `.github/` to check for `"github-action"`
updates on a `"weekly"` basis.
This does not touch Rust code or Cargo workflows.

It will  create PRs and we would need to approve them
(they would be subject to the same merge policy)
to instantiate the proposed dependabots into `master`.

2 years agoMerge bitcoindevkit/bdk#1202: fix(chain): filter coinbase tx not in best chain
Daniela Brozzoni [Tue, 14 Nov 2023 13:56:56 +0000 (14:56 +0100)]
Merge bitcoindevkit/bdk#1202: fix(chain): filter coinbase tx not in best chain

991cb77b6fbeedbf52d1bd9aa6b3d680f8269969 fix(chain): filter coinbase tx not in best chain (Wei Chen)

Pull request description:

  ### Description

  Fixes #1144.
  Coinbase transactions cannot exist in the mempool and be unconfirmed. `TxGraph::try_get_chain_position` should always return `None` for coinbase transactions not anchored in best chain.

  ### 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
  * [x] 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 991cb77b6fbeedbf52d1bd9aa6b3d680f8269969
  danielabrozzoni:
    ACK 991cb77b6fbeedbf52d1bd9aa6b3d680f8269969

Tree-SHA512: 9e06d8404708eee050c96807a876a470303f4983666c82c56c17d97c2d4b72784e75271279fd393c53a6a967a352aea1ef2762da71ac4bb58f7a0c2f05354948

2 years agoMerge bitcoindevkit/bdk#1206: chore: rename `ConfirmationTimeAnchor` to `Confirmation...
Daniela Brozzoni [Tue, 14 Nov 2023 13:48:24 +0000 (14:48 +0100)]
Merge bitcoindevkit/bdk#1206: chore: rename `ConfirmationTimeAnchor` to `ConfirmationTimeHeightAnchor`

0112c67b6031b55a6c73f797db52d64a1b4ee38a chore: rename `ConfirmationTimeAnchor` to `ConfirmationTimeHeightAnchor` (Wei Chen)

Pull request description:

  ### Description

  Closes #1187.
  An `Anchor` implementation that records both height and time should have both attributes included in the name.

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

Tree-SHA512: 024cbc83c8aca36baeaf2ce36979d62f235ffea7702e7ac8d4e7669cbc1730f7e1469ba78bf3da6c5a14abedbf1a9e832bdd66fdaa154ad2bef29cb187e1c504

2 years agoci: Pin jobserver after cc
Daniela Brozzoni [Mon, 13 Nov 2023 09:15:34 +0000 (10:15 +0100)]
ci: Pin jobserver after cc

Since now only cc depends on jobserver, it should be pinned after we pin cc

2 years agoMerge bitcoindevkit/bdk#1200: fix(bdk): Check if we're using the correct internal...
Daniela Brozzoni [Mon, 13 Nov 2023 09:08:48 +0000 (10:08 +0100)]
Merge bitcoindevkit/bdk#1200: fix(bdk): Check if we're using the correct internal key before signing

e553231eae45dc6d263a1fce2a3a9c46f6af2510 fix(bdk): Check if we're using the correct... ...internal key before signing (Daniela Brozzoni)

Pull request description:

  ### Description

  Fixes #1142

  We would previously sign with whatever x_only_pubkey we had in hand, without first checking if it was the right key or not. This effectively meant that adding multiple taproot PrivateKey signers would produce unbroadcastable transactions.

  ### Changelog notice

  - Fix a bug related to taproot signing with internal keys. We would previously sign with the first private key we had, without checking if it was the correct internal key or not.

  ### 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
  * [x] 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 e553231eae45dc6d263a1fce2a3a9c46f6af2510

Tree-SHA512: c4abbcd27935b8ce80a70b6e0843507866e3d075939f0b01504c090929ed96b4b9c6fee599f701e69960a6c86175682cc6d7f8cc4c3fb1d08a74b7563f8ca145

2 years agoMerge bitcoindevkit/bdk#1145: fix(electrum): fixed chain sync issue
Daniela Brozzoni [Mon, 13 Nov 2023 08:35:45 +0000 (09:35 +0100)]
Merge bitcoindevkit/bdk#1145: fix(electrum): fixed chain sync issue

1010efd8d68e886cc46f0ac2f016630b670ea73c fix(electrum): fixed chain sync issue (Wei Chen)

Pull request description:

  ### Description

  This may or may not fix #1125.
  Fixed what appeared to be a logic error in `construct_update_tip` in `electrum_ext.rs` that caused the local chain tip to always be a block behind the newest confirmed block.

  ### 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
  * [x] 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:
  danielabrozzoni:
    ACK 1010efd8d68e886cc46f0ac2f016630b670ea73c - although I've been able to reproduce the issue in #1125, I'm convinced that this PR fixes at least a bug, as demonstrated in #1171 (yet to be reviewed and merged).

Tree-SHA512: 92790e9072d17be74d2cd24bec3503e1ad5d97f728ee81490eeb09ac3f8d4a3a7e8d9628e943bc801246d5bfd345152c11d5dbe25246f5a57b3118727d3ae315

2 years agochore: rename `ConfirmationTimeAnchor` to `ConfirmationTimeHeightAnchor`
Wei Chen [Sun, 12 Nov 2023 13:31:44 +0000 (21:31 +0800)]
chore: rename `ConfirmationTimeAnchor` to `ConfirmationTimeHeightAnchor`

An `Anchor` implementation that records both height and time should have
both attributes included in the name.

2 years agofix(electrum): fixed chain sync issue
Wei Chen [Tue, 3 Oct 2023 10:06:53 +0000 (18:06 +0800)]
fix(electrum): fixed chain sync issue

Fixed a logic error in `construct_update_tip` in `electrum_ext.rs` that caused
the local chain tip to always be a block behind the newest confirmed block.

2 years agofix(chain): filter coinbase tx not in best chain
Wei Chen [Thu, 9 Nov 2023 21:34:08 +0000 (05:34 +0800)]
fix(chain): filter coinbase tx not in best chain

Coinbase transactions cannot exist in the mempool and be unconfirmed.
`TxGraph::try_get_chain_position` should always return `None` for coinbase
transactions not anchored in best chain.

2 years agofix(bdk): Check if we're using the correct...
Daniela Brozzoni [Wed, 8 Nov 2023 17:16:21 +0000 (18:16 +0100)]
fix(bdk): Check if we're using the correct...
...internal key before signing

Fixes #1142

We would previously sign with whatever x_only_pubkey we had in hand,
without first checking if it was the right key or not. This effectively
meant that adding multiple taproot PrivateKey signers would produce
unbroadcastable transactions.

2 years agoMerge bitcoindevkit/bdk#1109: Further improve unconfirmed tx conflict resolution
Daniela Brozzoni [Thu, 9 Nov 2023 09:06:59 +0000 (10:06 +0100)]
Merge bitcoindevkit/bdk#1109: Further improve unconfirmed tx conflict resolution

afbf83c8b0d5c97495e6ceaa39963415edef6911 chain(fix): conflict resolution for txs with same last_seen (Wei Chen)

Pull request description:

  ### Description

  Fixes #1102. If a conflicting tx has the same `last_seen`, then we check lexicographical sorting of txids.

  ### Notes to the reviewers

  The tests for this fix exist in the `TxTemplate` structure in #1064 which may need to be merged first.

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

Tree-SHA512: 91b8fbff305b715247501b861ab7ea9e9d9ef99248b05d14e01aacf7e64ad7826f35773e8998cf421dbd04f663714026084c6e817ac5365bce4844c8ea3b7e3f

2 years agochain(fix): conflict resolution for txs with same last_seen
Wei Chen [Fri, 1 Sep 2023 09:58:47 +0000 (17:58 +0800)]
chain(fix): conflict resolution for txs with same last_seen

The tx conflict `Scenario` test for unconfirmed txs with the same
last_seen has been amended for its corresponding conflict
resolution bug fix.

2 years agoMerge bitcoindevkit/bdk#1182: chore: fix MSRV for flate2
志宇 [Mon, 6 Nov 2023 03:14:47 +0000 (11:14 +0800)]
Merge bitcoindevkit/bdk#1182: chore: fix MSRV for flate2

95250fc44ed1372e77995d04ac2b380e0cb126a0 ci(chain): downgrade hashbrown dependency to 0.9.1 to fix ahash related MSRV issue (Steve Myers)
f17df1e1338c63cb79b5f9b2223dba347244c432 ci: more fixed dependencies for MSRV 1.57.0 (Vladimir Fomene)

Pull request description:

ACKs for top commit:
  notmandatory:
    ACK 95250fc44ed1372e77995d04ac2b380e0cb126a0
  realeinherjar:
    ACK 95250fc44ed1372e77995d04ac2b380e0cb126a0
  evanlinjin:
    ACK 95250fc44ed1372e77995d04ac2b380e0cb126a0

Tree-SHA512: ad090713d97cf778598bb4acee200d7acbc987fe74964f171cc9939149251bddce9474b750371df26d3f6548780f4db2c17b3fe2cf5f6d627c808d682c929918

2 years agoci(chain): downgrade hashbrown dependency to 0.9.1 to fix ahash related MSRV issue
Steve Myers [Sat, 4 Nov 2023 02:46:25 +0000 (21:46 -0500)]
ci(chain): downgrade hashbrown dependency to 0.9.1 to fix ahash related MSRV issue

2 years agoci: more fixed dependencies for MSRV 1.57.0
Vladimir Fomene [Fri, 13 Oct 2023 17:45:40 +0000 (20:45 +0300)]
ci: more fixed dependencies for MSRV 1.57.0

2 years agochore: add meta data to bitcoind_rpc crate
Steve Myers [Thu, 12 Oct 2023 14:33:34 +0000 (09:33 -0500)]
chore: add meta data to bitcoind_rpc crate

2 years agoBump bdk version to 1.0.0-alpha.2 v1.0.0-alpha.2
Steve Myers [Wed, 11 Oct 2023 22:30:36 +0000 (17:30 -0500)]
Bump bdk version to 1.0.0-alpha.2

Bump bdk_chain to 0.6.0
Bump bdk_electrum to 0.4.0
Bump bdk_esplora to 0.4.0

2 years agoMerge bitcoindevkit/bdk#1164: ref(chain): Rename direct_conflicts_of_tx to direct_con...
Daniela Brozzoni [Tue, 10 Oct 2023 15:16:37 +0000 (17:16 +0200)]
Merge bitcoindevkit/bdk#1164: ref(chain): Rename direct_conflicts_of_tx to direct_conflitcs

d5c87c49a82c5cd3a4558e61fe9984f0ae8c6cb7 ref(chain): Rename direct_conflicts_of_tx to... ...direct_conflitcs (Daniela Brozzoni)
009408d24361235c1d85b7d147983cff7b0fc191 ci: Pin jobserver to 0.1.26 to keep MSRV (Daniela Brozzoni)

Pull request description:

  Fixes #1138

  ### Changelog notice

  - rename `TxGraph::direct_conflicts_of_tx` to `TxGraph::direct_conflicts`

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

Tree-SHA512: 10072c65025d5fcc5d90c61ecba1dad53bcd10929326ab18ddadb21322841203aa5861adc9c5f200bbc57b0fe59dd4859dc3672870a0ad343fd8a660fd8aa40e

2 years agoref(chain): Rename direct_conflicts_of_tx to...
Daniela Brozzoni [Tue, 10 Oct 2023 14:30:48 +0000 (16:30 +0200)]
ref(chain): Rename direct_conflicts_of_tx to...
...direct_conflitcs

Fixes #1138

2 years agoci: Pin jobserver to 0.1.26 to keep MSRV
Daniela Brozzoni [Tue, 10 Oct 2023 14:44:28 +0000 (16:44 +0200)]
ci: Pin jobserver to 0.1.26 to keep MSRV

2 years agoMerge bitcoindevkit/bdk#1041: Add `bitcoind_rpc` chain source module.
Steve Myers [Mon, 9 Oct 2023 20:46:48 +0000 (15:46 -0500)]
Merge bitcoindevkit/bdk#1041: Add `bitcoind_rpc` chain source module.

85c62532a55cfc94eade4d20ca3075dc4cd4882e docs(bitcoind_rpc): better `Emitter::mempool` explanation (志宇)
b69c13ddf6aa7cfb9be8c841b255e7f5f13ad328 example_bitcoind_rpc: tweaks (志宇)
5f34df8489fedae2aa3fd001036cc9ef6abe9a7a bitcoind_rpc!: bring back `CheckPoint`s to `Emitter` (志宇)
57590e0a1f2dad09a63fadb11f01e9f704cdcffb bitcoind_rpc: rm `BlockHash` from `Emitter::last_mempool_tip` (志宇)
6d4b33ef91a6c3e3443f6321cf3e3d186f77c595 chain: split `IndexedTxGraph::insert_tx` into 3 methods (志宇)
4f5695d43add3eab37ab12e897ac7c49f0d0787e chain: improvements to `IndexedTxGraph` and `TxGraph` APIs (志宇)
150d6f8ab6cd1eb1c9448d61e7bd71db0dd32a01 feat(example_bitcoind_rpc_polling): add example for RPC polling (志宇)
4f10463d9eaad9365b87dd99d49f0ddb8be673ee test(bitcoind_rpc): add no_agreement_point test (志宇)
a73dac2d91b29c4ba05f606f81e511fbf1f9ec7f test(bitcoind_rpc): initial tests for `Emitter` (志宇)
bb7424d11d3a4bd837ddde0f42f9abd93d56aee1 feat(bitcoind_rpc): introduce `bitcoind_rpc` crate (志宇)
240657b1674ad901c77090ee1fa96dc0d71e91d7 chain: add batch-insert methods for `IndexedTxGraph` (志宇)
43bc813c6498b5b021d70a6127ff7e57d7337813 chain: add helper methods on `CheckPoint` (志宇)
b3db5ca9df4302fddcd5474569849371f2be7e2d feat(chain): add `AnchorFromBlockPosition` trait (志宇)
f795a43cc72fdb4ef26ca349c4cb4f4bfd3b90b5 feat(example_cli): allow chain specific args in examples (志宇)

Pull request description:

  ### Description

  This PR builds on top of #1034 and adds the `bitcoind_rpc` chain-src module and example.

  ### Notes to the reviewers

  Don't merge this until #1034 is in!

  ### Changelog notice

  * Add `bitcoind_rpc` chain-source module.
  * Add `example_bitcoind_rpc` example module.
  * Add `AnchorFromBlockPosition` trait which are for anchors that can be constructed from a given block, height and position in block.
  * Add helper methods to `IndexedTxGraph` and `TxGraph` for batch operations and applying blocks directly.
  * Add helper methods to `CheckPoint` for easier construction from a block `Header`.

  ### Checklists

  * [x] Add test: we should detect when an initially-confirmed transaction is "unconfirmed" during a reorg.
  * [x] Improve `example_bitcoind_rpc`: add `live` command.
  * [x] Improve docs.
  * [x] Reintroduce `CheckPoint`.

  #### 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:
  notmandatory:
    Re ACK 85c62532a55cfc94eade4d20ca3075dc4cd4882e

Tree-SHA512: 88dbafbebaf227b18c69f2ea884e3e586bf9c11e5e450eb4872ade1d1ccd5cf1e33ce9930a6f5aa918baa3e92add7503858b039b8c9d553a281ad6d833f08a49

2 years agoMerge bitcoindevkit/bdk#1152: fix(wallet_esplora): missing_heights uses the graph...
志宇 [Mon, 9 Oct 2023 17:14:57 +0000 (01:14 +0800)]
Merge bitcoindevkit/bdk#1152: fix(wallet_esplora): missing_heights uses the graph update

b1461f05d05a0b9cf056a9604032468064ca1a05 fix(wallet_esplora): missing_heights uses the... ...graph update (Daniela Brozzoni)

Pull request description:

  Fixes #1151.

  When wallet_esplora_* was used to sync a wallet containing a transaction confirmed some time ago (more than 10-15 blocks ago), the transaction would be stuck in an "unconfirmed" state forever.

  At the first scan time, `update_local_chain` would just fetch the last 10 to 15 blocks (depending on the server used), and `tx_graph.missing_heights` wouldn't return the tx's confirmation block as it was called on the original, non-updated tx_graph.
  So, after the first scan, we would have a transaction in memory with an anchor that doesn't exist in our local_chain, and try_get_chain_position would return unconfirmed.

  When scanning again, missing_heights would find the missing anchor, but `update_local_chain` wouldn't include it as it's older than ASSUME_FINAL_DEPTH.

  The missing block would be downloaded every time, but never included in the local_chain, and the transaction would remain unconfirmed forever.

  Here we call missing_heights on the updated graph, so that it can correctly return the anchor height, and `update_local_chain` can fetch it and include it in the chain.

  ### Notes to the reviewers

  I'm not sure if this is the right approach, so I'm opening this PR to gather feedback. I still need to add tests, I'll do so once we decide if this is the right way to go or not.

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

  * [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 b1461f05d05a0b9cf056a9604032468064ca1a05

Tree-SHA512: ba0cf85929644ee737dbc77e6afec662845532de0f120917aa6000ca8f5db79d0cb3971bd92285b5c5b5d26042b60b6c8536f50c9bd49615e31f5da28e80a509

2 years agodocs(bitcoind_rpc): better `Emitter::mempool` explanation
志宇 [Sat, 7 Oct 2023 19:04:13 +0000 (03:04 +0800)]
docs(bitcoind_rpc): better `Emitter::mempool` explanation

Also better docs for `Emitter` fields.

2 years agoexample_bitcoind_rpc: tweaks
志宇 [Sat, 7 Oct 2023 18:29:04 +0000 (02:29 +0800)]
example_bitcoind_rpc: tweaks

* avoid holding mutex lock over io
* document `CHANNEL_BOUND` const
* use the `relevant` variant of `batch_insert_unconfirmed`
* print elapsed time in stdout for various updates

2 years agobitcoind_rpc!: bring back `CheckPoint`s to `Emitter`
志宇 [Fri, 6 Oct 2023 16:56:01 +0000 (00:56 +0800)]
bitcoind_rpc!: bring back `CheckPoint`s to `Emitter`

* `bdk_chain` dependency is added. In the future, we will introduce a
  separate `bdk_core` crate to contain shared types.
* replace `Emitter::new` with `from_height` and `from_checkpoint`
  * `from_height` emits from the given start height
  * `from_checkpoint` uses the provided cp to find agreement point
* introduce logic that ensures emitted blocks can connect with
  receiver's `LocalChain`
* in our rpc example, we can now `expect()` chain updates to always
  since we are using checkpoints and receiving blocks in order

2 years agobitcoind_rpc: rm `BlockHash` from `Emitter::last_mempool_tip`
志宇 [Fri, 6 Oct 2023 09:39:22 +0000 (17:39 +0800)]
bitcoind_rpc: rm `BlockHash` from `Emitter::last_mempool_tip`

Instead of comparing the blockhash against the emitted_blocks map
to see whether the block is part of the emitter's best chain, we
reduce the `last_mempool_tip` height to the last agreement height
during the polling logic.

The benefits of this is we have tighter bounds for avoiding re-
emission. Also, it will be easier to replace `emitted_blocks` to
a `CheckPoint` (since we no longer rely on map lookup).

2 years agochain: split `IndexedTxGraph::insert_tx` into 3 methods
志宇 [Fri, 6 Oct 2023 03:07:00 +0000 (11:07 +0800)]
chain: split `IndexedTxGraph::insert_tx` into 3 methods

Instead of inserting anchors and seen_at timestamp in the same method,
we have three separate methods. This makes the API easier to understand
and makes `IndexedTxGraph` more consistent with the `TxGraph` API.

2 years agochain: improvements to `IndexedTxGraph` and `TxGraph` APIs
志宇 [Thu, 5 Oct 2023 18:05:31 +0000 (02:05 +0800)]
chain: improvements to `IndexedTxGraph` and `TxGraph` APIs

For `IndexedTxGraph`:
- Remove `InsertTxItem` type (this is too complex).
    - `batch_insert_relevant` now uses a simple tuple `(&tx, anchors)`.
    - `batch_insert` is now also removed, as the same functionality can be
      done elsewhere.
- Add internal helper method `index_tx_graph_changeset` so we don't need
  to create a seprate `TxGraph` update in each method.
- `batch_insert_<relevant>_unconfirmed` no longer takes in an option of
  last_seen.
- `batch_insert_unconfirmed` no longer takes a reference of a
  transaction (since we apply all transactions anyway, so there is no
  need to clone).

For `TxGraph`:
- Add `batch_insert_unconfirmed` method.

2 years agofeat(example_bitcoind_rpc_polling): add example for RPC polling
志宇 [Wed, 4 Oct 2023 10:22:03 +0000 (18:22 +0800)]
feat(example_bitcoind_rpc_polling): add example for RPC polling

2 years agotest(bitcoind_rpc): add no_agreement_point test
志宇 [Wed, 4 Oct 2023 10:20:10 +0000 (18:20 +0800)]
test(bitcoind_rpc): add no_agreement_point test

Co-authored-by: Steve Myers <steve@notmandatory.org>
2 years agotest(bitcoind_rpc): initial tests for `Emitter`
志宇 [Wed, 4 Oct 2023 10:19:29 +0000 (18:19 +0800)]
test(bitcoind_rpc): initial tests for `Emitter`

2 years agofeat(bitcoind_rpc): introduce `bitcoind_rpc` crate
志宇 [Wed, 4 Oct 2023 10:11:17 +0000 (18:11 +0800)]
feat(bitcoind_rpc): introduce `bitcoind_rpc` crate

2 years agochain: add batch-insert methods for `IndexedTxGraph`
志宇 [Wed, 4 Oct 2023 09:10:46 +0000 (17:10 +0800)]
chain: add batch-insert methods for `IndexedTxGraph`

2 years agochain: add helper methods on `CheckPoint`
志宇 [Wed, 4 Oct 2023 08:57:19 +0000 (16:57 +0800)]
chain: add helper methods on `CheckPoint`

* `CheckPoint::from_header` allows us to construct a checkpoint from
  block header.
* `CheckPoint::into_update` transforms the cp into a
  `local_chain::Update`.

2 years agofeat(chain): add `AnchorFromBlockPosition` trait
志宇 [Wed, 4 Oct 2023 08:54:28 +0000 (16:54 +0800)]
feat(chain): add `AnchorFromBlockPosition` trait

This is useful for block-by-block chain sources. We can determine the
tx's anchor based on the block, block height and tx position in the
block.

2 years agofeat(example_cli): allow chain specific args in examples
志宇 [Wed, 4 Oct 2023 08:45:57 +0000 (16:45 +0800)]
feat(example_cli): allow chain specific args in examples

So you can pass in the esplora/electrum/bitcoind_rpc server details in
the example.

Co-authored-by: LLFourn <lloyd.fourn@gmail.com>
2 years agofix(wallet_esplora): missing_heights uses the...
Daniela Brozzoni [Fri, 6 Oct 2023 14:29:21 +0000 (16:29 +0200)]
fix(wallet_esplora): missing_heights uses the...
...graph update

Fixes #1151.
When wallet_esplora_* was used to sync a wallet containing a transaction
confirmed some time ago (more than 10-15 blocks ago), the transaction would
be stuck in an "unconfirmed" state forever.

At the first scan time, `update_local_chain` would just fetch the last 10 to
15 blocks (depending on the server used), and `tx_graph.missing_heights`
wouldn't return the tx's confirmation block as it was called on the
original, non-updated tx_graph.
So, after the first scan, we would have a transaction in memory with an
anchor that doesn't exist in our local_chain, and try_get_chain_position
would return unconfirmed.

When scanning again, missing_heights would find the missing anchor, but
`update_local_chain` wouldn't include it as it's older than
ASSUME_FINAL_DEPTH.

The missing block would be downloaded every time, but never included in
the local_chain, and the transaction would remain unconfirmed forever.

Here we call missing_heights on the updated graph, so that it can
correctly return the anchor height, and `update_local_chain` can
fetch it and include it in the chain.

2 years agoMerge bitcoindevkit/bdk#1157: chore: pin `byteorder` and `webpki` to fix MSRV
Daniela Brozzoni [Mon, 9 Oct 2023 13:03:27 +0000 (15:03 +0200)]
Merge bitcoindevkit/bdk#1157: chore: pin `byteorder` and `webpki` to fix MSRV

1db3f87a4850c11b010ceafeba8a64ee0e54e022 chore: pin `byteorder` and `webpki` to fix MSRV (志宇)

Pull request description:

  * pin `byteorder` to 1.4.3
  * pin `webpki` to 0.22.2
  * it's tokio:1.33.0 that needs to be pinned to 1.29.1
  * fix README MSRV comments

ACKs for top commit:
  danielabrozzoni:
    utACK 1db3f87a4850c11b010ceafeba8a64ee0e54e022

Tree-SHA512: 4c2dc009ea117dd7ca18c7a836eb2b169c68d6ccaf84f85bcc2d4a3bcb7b008ad99f1dadf933b20c9d6ca6cc761e89dbafa99f99e31776e291f480cd6a112b1d

2 years agochore: pin `byteorder` and `webpki` to fix MSRV
志宇 [Fri, 6 Oct 2023 03:19:22 +0000 (11:19 +0800)]
chore: pin `byteorder` and `webpki` to fix MSRV

* pin `byteorder` to 1.4.3
* pin `webpki` to 0.22.2
* it's tokio:1.33.0 that needs to be pinned to 1.29.1
* fix README MSRV comments

2 years agoMerge bitcoindevkit/bdk#1104: refactor: use set_lookahead in set_lookahead_for_all
志宇 [Sat, 7 Oct 2023 19:49:01 +0000 (03:49 +0800)]
Merge bitcoindevkit/bdk#1104: refactor: use set_lookahead in set_lookahead_for_all

e89cf5a16a239d51ae9eb1857b55e7178e588b74 refactor: use set_lookahead in set_lookahead_for_all (Vladimir Fomene)

Pull request description:

  ### Description

  Use set_lookahead in set_lookahead_for_all.

  ### 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:
  realeinherjar:
    ACK: e89cf5a16a239d51ae9eb1857b55e7178e588b74
  evanlinjin:
    ACK e89cf5a16a239d51ae9eb1857b55e7178e588b74

Tree-SHA512: 02d226be7adcfd5e23ecb9d17539b0e089cb55ddf9c6de980155960f8181f2d3ea3ac9a93b2c1b7e0a8d4e4c821d92f65405852c696c9a367193a42d60c1aac6

2 years agoMerge bitcoindevkit/bdk#1064: Better tests for transaction conflict handling
志宇 [Thu, 5 Oct 2023 16:19:17 +0000 (00:19 +0800)]
Merge bitcoindevkit/bdk#1064: Better tests for transaction conflict handling

6d601a7e885bfc627594b794b1a460be47799eea test(chain): Add test for conflicting transactions (Daniela Brozzoni)
48ca95b5412fd3719b749d33c85572941817e967 test(chain): Add test for walk_ancestors (Daniela Brozzoni)
59a2403e2802d27c51f2d30b5f8e1ed9f813dfcc test(chain): Introduce TxTemplate (Daniela Brozzoni)
6e511473a5e5730d5cad237c651c83dc4c5d8756 test(chain): add block_id! utility macro (Daniela Brozzoni)
62de55f12d910ac35180cbb3f0e4c4b353c44d11 fix(chain): Consider conflicting ancestors in... ...try_get_chain_pos (Daniela Brozzoni)
a3e8480ad9d41190da8de732dc8d00d636a0c911 doc(chain): Clarify direct_conflicts_of_tx's docs (Daniela Brozzoni)
4742d88ea322e43120fa96f6421a149294d26e3b feat(chain): Introduce TxAncestors, walk_ancestors (Daniela Brozzoni)
2f26eca607dc5de83a9bb12c33fa5336026ab3dd fix(chain): TxDescendants performs a BFS (Daniela Brozzoni)
486e0e143741a8c1312e7cb5258b3d43256dc9ec doc(chain): Fix typos (Daniela Brozzoni)

Pull request description:

  <!-- You can erase any parts of this template not applicable to your Pull Request. -->

  ### Description

  Fixes #1063.

  This PR introduces a new `TxTemplate` struct to test different transaction conflict scenarios in `TxGraph`.
  The following transaction conflict scenarios are tested:
  - 2 unconfirmed txs with different last_seens conflict. The most recent tx should be the only tx that appears in the list methods.
  - 3 unconfirmed txs with different last_seens conflict. The most recent tx should be the only tx that appears in the list methods.
  - An unconfirmed tx U conflicts with a tx anchored in orphaned block O. O has higher last_seen. O should be the only tx that appears in the list methods.
  - An unconfirmed tx U conflicts with a tx anchored in orphaned block O. U has higher last_seen. U should be the only tx that appears in the list methods.
  - Multiple unconfirmed txs conflict with a confirmed tx. None of the unconfirmed txs should appear in the list methods.
  - B and B' conflict. C spends B. B' is anchored in best chain. B and C should not appear in the list methods.
  - B and B' conflict. C spends B. B is anchored in best chain. B' should not appear in the list methods.
  - B and B' conflict. C spends both B and B'. C is impossible.
  - B and B' conflict. C spends both B and B'. C is impossible. B' is confirmed.
  - B and B' conflict. C spends both B and B'. C is impossible. D spends C.

  These tests revealed that `TxGraph::walk_conflicts` was not checking ancestors of the root tx for conflicts. `TxGraph::walk_conflicts` has been refactored to check for conflicting ancestor transactions by using a new `TxAncestors` iterator in `TxGraph`.

  ### Changelog notice

  - Introduced `tx_template` module
  - Introduced `TxGraph::TxAncestors` iterator
  - Refactored `TxGraph::walk_conflicts` to use `TxGraph::TxAncestors`
  - Added `walk_ancestors` to `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

  #### 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:
    ACK 6d601a7e885bfc627594b794b1a460be47799eea

Tree-SHA512: ea151392874c4312233e4e10299579f4eee4a7100ae344b4d7f19994284b49c1e43f37338bed931d16e77326021166ea0b94d6de3ccf50a8fabb25139a8e69b4

2 years agoMerge bitcoindevkit/bdk#1146: fix: Remove dependency on unnecessary bdk_chain features
Daniela Brozzoni [Wed, 4 Oct 2023 14:53:47 +0000 (16:53 +0200)]
Merge bitcoindevkit/bdk#1146: fix: Remove dependency on unnecessary bdk_chain features

5e79b81a6a3f7012153fea469720fab153266479 fix: Remove dependency on unnecessary bdk_chain features (LLFourn)

Pull request description:

ACKs for top commit:
  danielabrozzoni:
    utACK 5e79b81a6a3f7012153fea469720fab153266479

Tree-SHA512: 02259c2c87b46a3b16a89648ce87b36fc88a2816074de7e4dd012231c07bb5e1c2f833b6c8cab7f469c84ed0a0bc254276a6c145763daf187b2e589493892cd8

2 years agotest(chain): Add test for conflicting transactions
Daniela Brozzoni [Fri, 29 Sep 2023 13:43:58 +0000 (15:43 +0200)]
test(chain): Add test for conflicting transactions

Co-authored-by: Wei Chen <wzc110@gmail.com>
2 years agotest(chain): Add test for walk_ancestors
Daniela Brozzoni [Fri, 29 Sep 2023 13:54:38 +0000 (15:54 +0200)]
test(chain): Add test for walk_ancestors

Co-authored-by: Wei Chen <wzc110@gmail.com>
2 years agotest(chain): Introduce TxTemplate
Daniela Brozzoni [Fri, 29 Sep 2023 13:43:48 +0000 (15:43 +0200)]
test(chain): Introduce TxTemplate

Co-authored-by: Wei Chen <wzc110@gmail.com>
2 years agotest(chain): add block_id! utility macro
Daniela Brozzoni [Fri, 29 Sep 2023 14:02:48 +0000 (16:02 +0200)]
test(chain): add block_id! utility macro

Co-authored-by: Wei Chen <wzc110@gmail.com>
2 years agofix(chain): Consider conflicting ancestors in...
Daniela Brozzoni [Fri, 29 Sep 2023 14:51:50 +0000 (16:51 +0200)]
fix(chain): Consider conflicting ancestors in...
...try_get_chain_pos

In try_get_chain_pos, when we notice that a transaction is not included
in the best chain, we check the transactions in mempool to find
conflicting ones, and decide based on that if our transaction is still
in mempool or has been dropped.
This commit adds a check for transactions conflicting with the
unconfirmed ancestors of our tx.

Co-authored-by: Wei Chen <wzc110@gmail.com>
2 years agofix: Remove dependency on unnecessary bdk_chain features
LLFourn [Tue, 3 Oct 2023 23:52:12 +0000 (10:52 +1100)]
fix: Remove dependency on unnecessary bdk_chain features

2 years agodoc(chain): Clarify direct_conflicts_of_tx's docs
Daniela Brozzoni [Fri, 29 Sep 2023 14:51:15 +0000 (16:51 +0200)]
doc(chain): Clarify direct_conflicts_of_tx's docs

Co-authored-by: Wei Chen <wzc110@gmail.com>
2 years agofeat(chain): Introduce TxAncestors, walk_ancestors
Daniela Brozzoni [Fri, 29 Sep 2023 13:47:43 +0000 (15:47 +0200)]
feat(chain): Introduce TxAncestors, walk_ancestors

Co-authored-by: Wei Chen <wzc110@gmail.com>
2 years agofix(chain): TxDescendants performs a BFS
Daniela Brozzoni [Fri, 29 Sep 2023 16:42:49 +0000 (18:42 +0200)]
fix(chain): TxDescendants performs a BFS

This commit also changes test_descendants_no_repeat to check
the order of the transactions returned

2 years agodoc(chain): Fix typos
Daniela Brozzoni [Fri, 29 Sep 2023 13:48:42 +0000 (15:48 +0200)]
doc(chain): Fix typos

Co-authored-by: Wei Chen <wzc110@gmail.com>
2 years agoMerge bitcoindevkit/bdk#1137: fix: Add the pinning of time/cc in README
Steve Myers [Tue, 3 Oct 2023 00:20:52 +0000 (19:20 -0500)]
Merge bitcoindevkit/bdk#1137: fix: Add the pinning of time/cc in README

f28e665c7dd1d929f0b4f80a79caecafaf4b385e ci: update code_coverage workflow to use rust stable version (Steve Myers)
edfd4c236d76c91b3599c333ae8456ed4f577064 fix: Add the pinning of time/cc in README (Daniela Brozzoni)

Pull request description:

  Should have been in #1135, sorry.

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

Tree-SHA512: e1c2c05f436da1fd59b9988628318c0563b2dbe85a5f4fb8aef4c35d7601c441a542e8a2c3591c02f3a05ad9456cfc2d3f5e8605064498a56a39766f5bcbc2e1

2 years agoci: update code_coverage workflow to use rust stable version
Steve Myers [Sat, 30 Sep 2023 22:56:34 +0000 (17:56 -0500)]
ci: update code_coverage workflow to use rust stable version

2 years agoMerge bitcoindevkit/bdk#1132: fix: bump electrum version to 0.18
Daniela Brozzoni [Fri, 29 Sep 2023 13:27:40 +0000 (15:27 +0200)]
Merge bitcoindevkit/bdk#1132: fix: bump electrum version to 0.18

fe654310d7e46a0e05c8282bd7804ac0d5203816 fix: bump electrum version to 0.18 (sjeohp)

Pull request description:

  Fixes https://github.com/bitcoindevkit/bdk/issues/1123

ACKs for top commit:
  danielabrozzoni:
    ACK fe654310d7e46a0e05c8282bd7804ac0d5203816

Tree-SHA512: 184b82ba13c76c7e4fe14dcf1f30ee19345618ecf7f8eeb859963067eafa6c21dd79d90b36a44cd2cb50d4002623c4811789f8dbed9445272114b72b35461f8c

2 years agofix: Add the pinning of time/cc in README
Daniela Brozzoni [Fri, 29 Sep 2023 13:20:45 +0000 (15:20 +0200)]
fix: Add the pinning of time/cc in README

Should have been in #1135, sorry.

2 years agofix: bump electrum version to 0.18
sjeohp [Thu, 28 Sep 2023 16:49:19 +0000 (10:49 -0600)]
fix: bump electrum version to 0.18

2 years agoMerge bitcoindevkit/bdk#1135: ci: Pin time, cc in order to keep MSRV
Steve Myers [Thu, 28 Sep 2023 14:40:22 +0000 (09:40 -0500)]
Merge bitcoindevkit/bdk#1135: ci: Pin time, cc in order to keep MSRV

ea6411c6850eef4f6c171b3035b3d70a8b2a9dc5 ci: Pin time, cc in order to keep MSRV (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 ea6411c6850eef4f6c171b3035b3d70a8b2a9dc5

Tree-SHA512: e2400bd4a1583db8503efa05279f1d97b136dfbe63ae92bc33817fa6763f7f3b8789acf9aef0f36bb8a0486539637eaa101f638d223354d3c6193f2ab2ebdfdb

2 years agoci: Pin time, cc in order to keep MSRV
Daniela Brozzoni [Thu, 28 Sep 2023 11:03:47 +0000 (13:03 +0200)]
ci: Pin time, cc in order to keep MSRV

2 years agoMerge bitcoindevkit/bdk#1110: fix(esplora): use saturating_add in update_tx_graph()
Steve Myers [Tue, 26 Sep 2023 14:56:56 +0000 (09:56 -0500)]
Merge bitcoindevkit/bdk#1110: fix(esplora): use saturating_add in update_tx_graph()

bf9a4258496ef91bec4d15126d6e98a2450533ea ci: fix MSRV build by pinning tokio-util to 0.7.8 (Steve Myers)
d35668e76aa3ba429041305e54106c10429a8b1b ci(esplora): fix wasm cargo check by setting workspace resolver to version 2 (Steve Myers)
31d52e12c93469dc6af9a88eba42ad87315dd63b ci: fix msrv dependency versions for rustls-webpki and zip (Steve Myers)
6a5c9d7a00bfddbdf6bd279d003fefe3958dccc1 fix(esplora): use saturating_add in update_tx_graph() (Steve Myers)
4d1a9fd47ab61e1cba2d01fe1191df8c0064c767 test(esplora): add async_ext and blocking_ext integration tests (Steve Myers)

Pull request description:

  ### Description

  This fixes overflow error when calling update_tx_graph() from update_tx_graph_without_keychain().

  ### Notes to the reviewers

  You can reproduce the error by reverting 66a2bf5ef2a70f8de41941d2f07bec776d152b96.

  The tests could use some cleanup but get the job done for this PR.

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

  #### Bugfixes:

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

Top commit has no ACKs.

Tree-SHA512: eace00e0c289a7ac161985c4b8e46ad660ec0d6777cd74027ef1f0ab245daea87e34258233281796efb60473cf4f18d2647c090a14c0f05f3dc8a1950ebe9dab

2 years agoci: fix MSRV build by pinning tokio-util to 0.7.8
Steve Myers [Tue, 26 Sep 2023 02:08:52 +0000 (21:08 -0500)]
ci: fix MSRV build by pinning tokio-util to 0.7.8

2 years agoci(esplora): fix wasm cargo check by setting workspace resolver to version 2
Steve Myers [Thu, 14 Sep 2023 19:39:20 +0000 (14:39 -0500)]
ci(esplora): fix wasm cargo check by setting workspace resolver to version 2

The resolver version must be set at the workspace level.
See: https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#cargos-new-feature-resolver

2 years agoci: fix msrv dependency versions for rustls-webpki and zip
Steve Myers [Mon, 4 Sep 2023 06:01:04 +0000 (01:01 -0500)]
ci: fix msrv dependency versions for rustls-webpki and zip

2 years agofix(esplora): use saturating_add in update_tx_graph()
Steve Myers [Mon, 4 Sep 2023 05:25:38 +0000 (00:25 -0500)]
fix(esplora): use saturating_add in update_tx_graph()

This fixes overflow error when calling update_tx_graph() from update_tx_graph_without_keychain().

2 years agotest(esplora): add async_ext and blocking_ext integration tests
Steve Myers [Mon, 4 Sep 2023 05:20:45 +0000 (00:20 -0500)]
test(esplora): add async_ext and blocking_ext integration tests

2 years agoMerge bitcoindevkit/bdk#969: Update documentation for fee_rate and fee_absolute metho...
Daniela Brozzoni [Tue, 19 Sep 2023 13:04:57 +0000 (15:04 +0200)]
Merge bitcoindevkit/bdk#969: Update documentation for fee_rate and fee_absolute methods in tx_builder.rs

e6519e3a52a1ab8023b5fdf423d8f748a3b0260d Enhance the documentation for the fee_rate and fee_absolute methods. (Jon Marrs)

Pull request description:

  ### Description

  This pr helps solve this issue: https://github.com/bitcoindevkit/bdk/issues/856

  I added documentation to the fee_rate() method to describe the units as either satoshis/vbyte (sats/vbyte) or satoshis/kwu (sats/kwu), depending on the FeeRate type.

  I also added documentation to the fee_absolute() method to clarify that the fee is determined by whichever method (fee_rate or fee_absolute) was called last, as the FeePolicy is an enum, and FeeRate/FeeAmount are mutually exclusive.

  ### Notes to the reviewers

  I thought it would be helpful to provide documentation to alleviate confusion over the fee_rate method and the fee_absolute 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)

  #### Bugfixes:

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

ACKs for top commit:
  danielabrozzoni:
    ACK e6519e3a52a1ab8023b5fdf423d8f748a3b0260d

Tree-SHA512: 59f62d1d1f8355e6353c6a2550e464732975c86c767648adc9143f2b3a9b894a90536a30a33e9de7efbe53f16392ec2e19008d884fb65ef037edae64a3cb6970

2 years agoEnhance the documentation for the fee_rate and fee_absolute methods.
Jon Marrs [Sat, 16 Sep 2023 16:39:49 +0000 (09:39 -0700)]
Enhance the documentation for the fee_rate and fee_absolute methods.

Signed-off-by: Jon Marrs <jdmarrs@gmail.com>
2 years agoMerge bitcoindevkit/bdk#1086: docs: fix spelling errors
Daniela Brozzoni [Mon, 18 Sep 2023 08:12:50 +0000 (10:12 +0200)]
Merge bitcoindevkit/bdk#1086: docs: fix spelling errors

94f8fa530b34ae1c099db3df070000121e8283cf docs: fix spelling errors (Steve Myers)

Pull request description:

  ### Description

  I did a global spell check and found and fixed a few spelling errors.

  ### Notes to the reviewers

  This is low priority but want to make sure it's done before we do a beta release.

  ### 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:
  realeinherjar:
    ACK 94f8fa5
  evanlinjin:
    ACK 94f8fa530b34ae1c099db3df070000121e8283cf

Tree-SHA512: eed0be31264c45d8ef4d6b77e30927591014a76d71696f324440989e77b488d6bf018002d6df2354575b25e5a50d49bca6592976a310e6de7009e44d6b35518d