277 Commits

Author SHA1 Message Date
志宇
83e7b7ec40
docs(chain): improve KeychainTxOutIndex docs
More clarity for revealed/lookahead spks and give usecases.
2024-01-17 13:30:28 +08:00
志宇
9294e30943
docs(wallet): improve docs for unbounded spk iterator methods 2024-01-17 13:29:16 +08:00
志宇
b74c2e2622
fix(wallet): use efficient peek address logic
Changes the peek address logic to use the optimized `Iterator::nth`
implementation of `SpkIterator`.

Additionally, docs are added for panics that will occur when the caller
requests for addresses with out-of-bound derivation indices (BIP32).
2024-01-17 11:17:25 +08:00
志宇
81aeaba48a
feat(chain): add SpkIterator::descriptor method
Otherwise there will be no way to view the descriptor of the
`SpkIterator`.
2024-01-17 11:17:25 +08:00
志宇
c7b47af72f
refactor(chain)!: revamp KeychainTxOutIndex API
Previously `SpkTxOutIndex` methods can be called from
`KeychainTxOutIndex` due to the `DeRef` implementation. However, the
internal `SpkTxOut` will also contain lookahead spks resulting in an
error-prone API.

`SpkTxOutIndex` methods are now not directly callable from
`KeychainTxOutIndex`. Methods of `KeychainTxOutIndex` are renamed for
clarity. I.e. methods that return an unbounded spk iter are prefixed
with `unbounded`.
2024-01-17 11:17:25 +08:00
志宇
705690ee8f
feat(chain): make output of SpkTxOutIndex::unused_spks cloneable
This allows us to pass this to chain sources without calling
`Iterator::collect` first.
2024-01-13 20:07:02 +08:00
志宇
264bb85efc
Merge bitcoindevkit/bdk#1261: Refactor reveal_to_target and next_store_index
761189ab2b679fbfee45b33435d66ed98a135e2a feat(chain): debug_assert non-wildcard desc. to only cache index 0 (志宇)
887e112e8f4ee5300bf09a0f3590861bff7fd053 ref(chain): Refactor reveal_to_target (Daniela Brozzoni)
21d88758262bfbc3d9d2109aac9883f23ab651c4 ref(chain): Refactor next_store_index (Daniela Brozzoni)

Pull request description:

  ### Description

  As a part of #1203, I found myself having to modify `reveal_to_target`, but had some troubles understanding exactly what the method was doing.

  This PR refactors `reveal_to_target` to be, in my opinion, a bit clearer. We now exist prematurely if `next_reveal_index` < `target_index`; this way, we don't need to keep track of `next_reveal_index`, as it would always be equal to `Some(target_index)`.
  As a part of trying to understand `reveal_to_target` I had to read through `next_store_index`, I slightly improved it for clarity reasons as well.

  ### Changelog notice

  ### Checklists

  #### All Submissions:

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

ACKs for top commit:
  evanlinjin:
    ACK 761189ab2b679fbfee45b33435d66ed98a135e2a

Tree-SHA512: 17f70bccbfa1cccf718ece0eeb61f4944c9108776cf1d606ef823ae9ff58bf52114750927ac99561644ece598f8131ee7f7605071d42c91e5e88e05035e74836
2024-01-11 11:00:50 +08:00
志宇
761189ab2b
feat(chain): debug_assert non-wildcard desc. to only cache index 0 2024-01-10 22:47:53 +01:00
Steve Myers
8f6dad76ef
Bump bdk_esplora and bdk_file_store versions for 1.0.0-alpha.3 release
These crates need to have their versions bumped because the version of bdk_chain was bumped to 0.7.0 with the 1.0.0-alpha.3 release.

bdk_esplora to 0.5.0
bdk_file_store to 0.3.0
2024-01-09 15:06:08 -06:00
Daniela Brozzoni
887e112e8f
ref(chain): Refactor reveal_to_target
Simplify the `reveal_to_target` algorithm by exiting prematurely if
the `target_index` is already revealed.
Since the `reveal_to_index` variable was different from
`Some(target_index)` only if the target was already revealed, we can
getrid of the variable altogether.
2024-01-09 14:13:43 +01:00
Daniela Brozzoni
21d8875826
ref(chain): Refactor next_store_index
Rename `v` to `index` for better clarity, and add a comment explaining
the `range`
2024-01-09 14:13:42 +01:00
Daniela Brozzoni
105d70e974
ref(hwi): Move hwi out of bdk
Fixes #872
2024-01-08 13:33:56 +01:00
Steve Myers
9efaead8f1
Merge bitcoindevkit/bdk#1255: Bump bdk version to 1.0.0-alpha.3
003271117cb347556cc82455558da40ef50a1156 Bump bdk version to 1.0.0-alpha.3 (Steve Myers)

Pull request description:

  ### Description

  - Bump bdk version to 1.0.0-alpha.3
  - Bump bdk_chain to 0.7.0
  - Bump bdk_bitcoin_rpc to 0.2.0
  - Bump bdk_electrum to 0.5.0

  ### Notes to the reviewers

  ### Changelog notice

  See #1254

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

Tree-SHA512: ac0756f52436880fe633e9ecb83f3d53f485ccfa89a3a89aa51ee4ba5da5cee87f507da69a9e1271f8aaf4425f65d04fb201ea9a4f64bce18f96039ea3548d61
2024-01-07 11:02:12 -06:00
Elias Rohrer
8694624bd5
Bump bip39 to v2.0
We previously bumped the `bip39` version to 2.0 in the 0.2X release
branch. Back then, bumping it in `master` was erroneously considered unnecessary.

Here, we therefore bump the crate version in `master` after all.
2024-01-07 17:09:02 +01:00
Steve Myers
003271117c
Bump bdk version to 1.0.0-alpha.3
Bump bdk_chain to 0.7.0
Bump bdk_bitcoin_rpc to 0.2.0
Bump bdk_electrum to 0.5.0
2024-01-06 15:08:40 -06:00
Steve Myers
f6418ba911
Merge bitcoindevkit/bdk#1258: fix(typos): existant -> existent
028caa9f8cd51afba0fdc81748fc8cf536c75cd0 fix(typos): existant -> existent (Jose Storopoli)

Pull request description:

  ### Description

  These typos are blocking the Nix typo CI in #1257

  ### Notes to the reviewers

  Blocking #1257

  ### Changelog notice

  - fix: typos in documentation
  -
  ### 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:
  notmandatory:
    ACK 028caa9f8cd51afba0fdc81748fc8cf536c75cd0

Tree-SHA512: 0bd91efd0eec55fdc537824435552c968858a5b827179b3f9f3f37785db3fa92d3e6f0c73023de0c506224c81217c402d5afa8a2f768fecaf6a3c8378226d184
2024-01-06 14:29:10 -06:00
Jose Storopoli
028caa9f8c
fix(typos): existant -> existent
These typos are blocking the Nix typo CI in #1257
2024-01-06 14:13:56 -03:00
志宇
a1d34afa24
feat(wallet)!: add NonEmptyDatabase variant to NewError
`NewError` is the error type when constructing a wallet with
`Wallet::new`. We want this to return an error when the database already
contains data (in which case, the caller should use `load` or
`new_or_load`).
2024-01-06 13:19:03 +08: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
Steve Myers
95d34854f4
refactor(electrum_ext): rename scan_without_keychain to sync and scan to full_scan
removed txids and outpoints params from full_scan
2024-01-05 15:31:12 -06:00
志宇
1def76f1f1
chore: make clippy happy and bump clippy msrv 2023-12-29 19:57:48 +08:00
LLFourn
c9467dcbb2
chore: improve documentation of lookahead 2023-12-29 16:40:48 +11:00
Antoine Poinsot
4fd539b647
feat(chain)!: KeychainTxOutIndex uses a universal lookahead
The wallet is currently created without setting any lookahead value for
the keychain. This implicitly makes it a lookahead of 0. As this is a
high-level interface we should avoid footguns and aim for a reasonable
default.

Instead of simply patching it for wallet, we alter `KeychainTxOutIndex`
to have a default lookahead value. Additionally, instead of a
per-keychain lookahead, the constructor asks for a `lookahead` value.
This avoids the footguns of having methods which allows the caller the
decrease the `lookahead` (and therefore panicing). This also simplifies
the API.

Co-authored-by: Antoine Poisot <darosior@protonmail.com>
Co-authored-by: 志宇 <hello@evanlinjin.me>
2023-12-28 12:51:11 +08:00
thunderbiscuit
f4863c6314
fix(wallet): apply loaded changeset to indexed_graph 2023-12-20 21:55:22 -05:00
Daniela Brozzoni
0adff9c35f
doc: Improve TxGraph & co docs 2023-12-13 10:12:12 +01:00
Steve Myers
169385bb5b
ci: change MSRV to 1.63.0 2023-12-08 15:18:49 -06:00
Steve Myers
f741122ffb
Merge bitcoindevkit/bdk#1158: doc(bdk): Clarify the absolute_fee docs
0ecc0280c032301dc638e75e54a8691d66d50274 doc(bdk): Clarify the absolute_fee, fee_rate docs (Daniela Brozzoni)

Pull request description:

  Fixes #1066

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

Tree-SHA512: 152e48b86c21d4fad711abf76dd8fdc0e8955030331005c1ba6ff0c866c52870161f91ec740838f8238c5ad1c620e06212099308a55d130699cb18e4666e3f3f
2023-12-05 07:35:01 -06:00
Steve Myers
959b4f8172
Merge bitcoindevkit/bdk#1179: build(esplora): Add async-https-rustls flag to esplora client
6817ca9bcbff957efb58f96886a30b6bd87c0cde ci: pin hyper-rustls version to 0.24.0 for 1.57 MSRV (thunderbiscuit)
4ee41dbc402121d14ffa099863bf35329851c1e4 build(esplora): Add async-https-rustls flag to esplora client (thunderbiscuit)

Pull request description:

  ### Description
  The bdk_esplora crate currently doesn't expose the [`async-https-rustls` flag offered by the rust-esplora-client](ef1925e1ee/Cargo.toml (L44)) crate and instead requires users to build using the `default-tls` flag on reqwest, which uses the platform-specific openssl library when compiling. This creates complications for cross-compilation, notably for our Android builds that currently support 3 architectures (`arm64-v8a`, `armeabi-v7a`, and `x86_64`). In order to solve this we can either compile the openssl libraries for each of the platforms we want to support, or use the rustls-tls version of reqwest. The second options is much easier and requires less fiddling with the internals of the Android native development kit and cross-compilation rabbit holes.

  Before we merge this I want to make sure I understand the tradeoffs between the `native-tls` and the `rustls-tls` and confirm that there are not potential issues there, but from what I understand they should provide the same functionality/security, and because these are already available/exposed in reqwest and rust-esplora-client, I think this should be a fairly straightforward additional feature we offer.

  ### Changelog notice
  ```txt
  Added:
    - New async-https-rustls feature flag for the bdk_esplora crate, allowing to compile rust-esplora-client using rustls-tls instead of the default native-tls.
  ```

  ### 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 6817ca9bcbff957efb58f96886a30b6bd87c0cde
  realeinherjar:
    ACK 6817ca9bcb
  danielabrozzoni:
    ACK 6817ca9bcbff957efb58f96886a30b6bd87c0cde

Tree-SHA512: 1d417da7cf85e157d71f56442a06e817e8741822d7bff9089f7fbb70ff8b4854f1f52befbc348b849e9c98cae848b792d426cd5bf551e7a9089b15467d28efdd
2023-12-04 22:30:12 -06:00
Antoine Poinsot
43aed386bc
esplora: also test the gap limit bounds in the async client 2023-11-24 12:21:16 +01:00
Antoine Poinsot
cb713e5b8c
esplora: also fix the gap limit check in the async client 2023-11-24 12:21:14 +01:00
Antoine Poinsot
2c4e90a76f
esplora: scan gap limit bounds testing 2023-11-24 12:21:13 +01:00
Antoine Poinsot
18bd329617
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.
2023-11-24 12:21:12 +01:00
Daniela Brozzoni
9e681b39fb
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
2023-11-21 16:54:21 +01:00
Steve Myers
02fa340896
chore: remove bdk dependency on log and dev dependency on env_logger 2023-11-20 15:18:29 -08:00
thunderbiscuit
4ee41dbc40
build(esplora): Add async-https-rustls flag to esplora client 2023-11-20 16:16:27 -05:00
志宇
278210bb89
docs(bdk): clarify insert_txout docs
Inserted txouts will not be shown in `list_unspent` or `list_output`.
2023-11-21 05:06:53 +08:00
志宇
6fb45d8a73
test(bdk): add test_list_output 2023-11-21 04:38:04 +08:00
志宇
e803ee9010
feat(bdk): add Wallet::list_output method 2023-11-21 04:38:03 +08:00
志宇
82632897aa
refactor(bdk)!: rename LocalUtxo to LocalOutput 2023-11-21 04:35:00 +08:00
Steve Myers
77f9977c02
feat(wallet): Add infallible Wallet get_address(), get_internal_address functions
refactor!(wallet)!: rename fallible Wallet try_get_address(), try_get_internal_address functions
2023-11-16 11:18:11 -06:00
Steve Myers
9e7d99e3bf
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
2023-11-16 10:24:35 -06:00
Einherjar
27a63abd1e
chore: typos fixed 2023-11-16 07:25:20 -06:00
志宇
f1b112e8f9
docs(bitcoind_rpc): update docs for Emitter::new 2023-11-16 07:23:56 +08:00
志宇
9a250baf62
chore: make clippy happy 2023-11-16 07:17:16 +08:00
志宇
79b84bed0e
feat(bdk): changeset's Append impl checks that network is consistent 2023-11-16 07:07:49 +08:00
志宇
06a956ad20
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.
2023-11-16 07:07:49 +08:00
志宇
c3265e2514
test(bdk): add tests for wallet constructor methods 2023-11-16 07:07:49 +08:00
志宇
96f1d94e2c
test(file_store): add construction method tests 2023-11-16 07:07:48 +08:00
志宇
24994a3ed4
feat(file_store)!: have separate methods for creating and opening Store 2023-11-16 07:07:48 +08:00
志宇
d294e2e318
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.
2023-11-16 07:07:48 +08:00