]> Untitled Git - bdk/log
bdk
3 years agoBump version to 0.20.1-dev github/release/0.20.0
Steve Myers [Wed, 13 Jul 2022 18:41:57 +0000 (11:41 -0700)]
Bump version to 0.20.1-dev

3 years agoBump version to 0.20.0 0.20.0 v0.20.0
Steve Myers [Wed, 13 Jul 2022 17:55:57 +0000 (10:55 -0700)]
Bump version to 0.20.0

3 years agoMerge bitcoindevkit/bdk#667: Rename `set_current_height` to `current_height`
Alekos Filini [Wed, 13 Jul 2022 12:43:17 +0000 (14:43 +0200)]
Merge bitcoindevkit/bdk#667: Rename `set_current_height` to `current_height`

92b9597f8b8dc3694508062b5e7c5f23acbc3a4f Rename `set_current_height` to `current_height` (Alekos Filini)

Pull request description:

  ### Description

  Usually we don't have any prefix except for methods that can *add* to a list or replace the list entirely (e.g. `add_recipients` vs `set_recipients`)

  I missed this during review of #611

  ### 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:
    utACK 92b9597f8b8dc3694508062b5e7c5f23acbc3a4f - I'm sorry I didn't notice it!

Tree-SHA512: 3391068b2761bcd04d740ef41f9e772039fca7bc0e0736afcbc582ec74b6c91eb155d9e09dd7a07462eec29e32ac86e41ba339d9a550af3f754164cab6bdbf61

3 years agoMissing newlines
Alekos Filini [Wed, 13 Jul 2022 09:13:05 +0000 (11:13 +0200)]
Missing newlines

3 years agoRename `set_current_height` to `current_height`
Alekos Filini [Wed, 13 Jul 2022 08:27:38 +0000 (10:27 +0200)]
Rename `set_current_height` to `current_height`

Usually we don't have any prefix except for methods that can *add* to a
list or replace the list entirely (e.g. `add_recipients` vs
`set_recipients`)

3 years agoMerge bitcoindevkit/bdk#653: Fix: Wallet sync may decrement address index
Alekos Filini [Mon, 11 Jul 2022 14:58:00 +0000 (16:58 +0200)]
Merge bitcoindevkit/bdk#653: Fix: Wallet sync may decrement address index

af6bde3997ac2fe4cfdbb691f2af2e802f0ab7c6 Fix: Wallet sync may decrement address index (志宇)

Pull request description:

  ### Description

  Fixes #649

  It is critical to ensure `Wallet::get_address` with `AddressIndex::new` always returns a new and unused address.

  This bug seems to be Electrum-specific. The fix is to check address index updates to  ensure that newly suggested indexes are not smaller than indexes already in database.

  ### Notes to the reviewers

  I have written new tests in `/testutils/blockchain_tests.rs` that tests all `Blockchain` implementations.

  ### 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:
  afilini:
    ACK af6bde3997ac2fe4cfdbb691f2af2e802f0ab7c6

Tree-SHA512: d714bebcf7c2836f8b98129b39b4939b0e36726acf0208e52d501f433be6cdb12f1abebc28bd7da0be8b780ccce6e1e42c8fdc6633dd486bf329bc6f88e1ce67

3 years agoFix: Wallet sync may decrement address index
志宇 [Sun, 3 Jul 2022 06:32:05 +0000 (14:32 +0800)]
Fix: Wallet sync may decrement address index

This bug seems to be Electrum-specific. The fix is to check the
proposed changes against the current state of the database. Ensure
newly suggested indexes are not smaller than indexes already in
database.

Changes:
* Check index updates before they are applied to database during
  Electrum Blockchain sync (Thank you @rajarshimaitra for providing
  an elegant solution).

Tests added:
* bdk_blockchain_tests!::test_sync_address_index_should_not_decrement
* bdk_blockchain_tests!::test_sync_address_index_should_increment

These tests ensure there will be no unexpected address reuse when
grabbing a new address via `Wallet::get_address` with `AddressIndex::New`.

Other changes:
* Tweak `rpc.rs` so that clippy is happy.

3 years agoMerge bitcoindevkit/bdk#664: Deprecate `AddressValidator`
Alekos Filini [Mon, 11 Jul 2022 09:48:54 +0000 (11:48 +0200)]
Merge bitcoindevkit/bdk#664: Deprecate `AddressValidator`

45db468c9be0c8bb2dc5fac52fbd52b6b41b4d53 Deprecate `AddressValidator` (志宇)

Pull request description:

  ### Description

  `AddressValidator` should be deprecated as noted by @afilini [on Discord](https://discord.com/channels/753336465005608961/753367451319926827/994899488957272064):

  > address validators are supposed to be used for a slightly different thing, which is when you ask the hardware wallet to independently generate the address for a derivation index and then you compare what you see on your computer/phone with what the hardware wallet is displaying
  > in the case of change addresses i agree that it's not as important (because as you said the device can just refuse to sign) but for consistency we implemented it for both external and internal addresses
  > more broadly, they can be thought of as a way to get a callback every time an address is generated, which may also be useful for other things (for example when i was working on a green-compatible client written in bdk i used that feature to ping the server every time a new address was generated, because that's required in their protocol)
  > that said, i think currently pretty much nobody uses them and i am myself moving away from the concept that "everything needs to happen inside bdk": currently my mindset is targeted more towards reducing complexity by breaking down individual parts and wrapping them or making them "extensible" in some way
  > that is to say: if you want to verify addresses in your hardware wallet you don't necessarily need bdk to do it for you (actually, you would still have to implement the callback manually), you can just call bdk to get a new addr and then ping the device yourself. and this would allow us to reduce complexity and delete some code
  > actually, here's an idea: unless somebody here is opposed to this, i can make a pr to deprecate address validators in the next (0.20) release. if after that again nobody complains we can completely remove them and point users towards different strategies to achieve the same goal

  ### Checklists

  * [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
  * [x] I've updated `CHANGELOG.md`

ACKs for top commit:
  afilini:
    ACK 45db468c9be0c8bb2dc5fac52fbd52b6b41b4d53

Tree-SHA512: 71071f4494537ece9153f5308cb4f576189016afa8ac87bc57bfdcda03ee94d5f7a3477d04f6dd37eeeea2fada6aaad42ad29c964df0971beeda7418ada65f6d

3 years agoDeprecate `AddressValidator`
志宇 [Mon, 11 Jul 2022 08:37:41 +0000 (16:37 +0800)]
Deprecate `AddressValidator`

3 years agoUpdate CHANGELOG and lib.rs docs version
Steve Myers [Wed, 6 Jul 2022 20:19:01 +0000 (13:19 -0700)]
Update CHANGELOG and lib.rs docs version

3 years agoBump version to 0.20.0-rc.1
Steve Myers [Wed, 6 Jul 2022 19:52:00 +0000 (12:52 -0700)]
Bump version to 0.20.0-rc.1

3 years agoMerge bitcoindevkit/bdk#621: Add remove_partial_sigs and try_finalize to SignOptions
Steve Myers [Wed, 6 Jul 2022 17:45:54 +0000 (10:45 -0700)]
Merge bitcoindevkit/bdk#621: Add remove_partial_sigs and try_finalize to SignOptions

e3a17f67d90f11d1d1a27a98ec97674c8cd3d2f7 add try_finalize to SignOptions (KaFai Choi)
c2e4ba8cbd77f1a41d269b621b0001d042c1ea57 add remove_partial_sigs to SignOptions (KaFai Choi)

Pull request description:

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

  ### Description

  This PR is to add 2 keys(`try_finalize` and `remove_partial_sigs`) in `SignOptions`. See this issue for detail https://github.com/bitcoindevkit/bdk/issues/612

  ### Notes to the reviewers

  ~I found the negative naming of these 2 new keys `do_not_finalize` and `do_not_remove_partial_sigs` are a bit confusing(like most negative named paremeter/variable). Should we actually change it back to positive naming(`do_finalize` and `do_remove_partial_sigs`)?~

  ### 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
  * [x] I've updated `CHANGELOG.md`

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

Tree-SHA512: 781b31d3ecf0bcd605206c0481fd5de3125f1c8ff18a463dbf4c821e5557847f7d70a3fe8618e100fb89f4f6899655ac0efa3593f77f915ad5bcb7e558bb2a7a

3 years agoMerge bitcoindevkit/bdk#634: Get block hash by its height
Steve Myers [Wed, 6 Jul 2022 17:17:08 +0000 (10:17 -0700)]
Merge bitcoindevkit/bdk#634: Get block hash by its height

2af678aa846a82657d13bcda2ac0b4a9db4e2b80 Get block hash by its height (Vladimir Fomene)

Pull request description:

  ### Description
  This PR create a new trait `blockchain::GetBlockHash` with a `get_block_hash` method which returns a block hash given the block height. This has been implemented for all blockchain backends.
  Fixes #603

  ### Notes to the reviewers

  I haven't updated the `CHANGELOG.md` and docs. Am I suppose to update it for this change?

  ### 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
  * [ ] I've added docs for the new feature
  * [ ] I've updated `CHANGELOG.md`

ACKs for top commit:
  notmandatory:
    ACK 2af678aa846a82657d13bcda2ac0b4a9db4e2b80

Tree-SHA512: 9c084a6665ecbf27ee8170fdb06e0dc8373d6a901ce29e5f5a1bec111d1507cb3bee6b03a653a55fd20e0fabe7a5eada3353e24a1e21f3a11f01bb9881ae99e5

3 years agoGet block hash by its height
Vladimir Fomene [Thu, 16 Jun 2022 19:42:02 +0000 (20:42 +0100)]
Get block hash by its height

Create blockchain::GetBlockHash trait
with a method to get block hash given
a block height. Then, implement this
trait for all backends (Electrum, RPC
, Esplora, CBF). Referenced in issue 603.

3 years agoMerge bitcoindevkit/bdk#648: test: BDK won't add unconf inputs when fee bumping
Alekos Filini [Wed, 6 Jul 2022 14:41:58 +0000 (16:41 +0200)]
Merge bitcoindevkit/bdk#648: test: BDK won't add unconf inputs when fee bumping

5d00f8238886a993ef21056e5b3e216a4aae6951 test that BDK won't add unconf inputs when fee bumping (Daniela Brozzoni)
98748906f6799041341227de33bec20e8c6ef4b0 test: fix populate_test_db conf calculation (Daniela Brozzoni)
1d9fdd01faf3a0f17c57381a7c54d136e9d69ffe Remove wrong TODO comment in build_fee_bump (Daniela Brozzoni)

Pull request description:

  ### Description

  Closes #144

  ### Notes to reviewers

  #144 is describing a bug that doesn't seem to happen in BDK master anymore (BDK not respecting BIP125 rule 2). This PR just adds a test to check that the bug is fixed.

  ### 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:
  afilini:
    ACK 5d00f8238886a993ef21056e5b3e216a4aae6951

Tree-SHA512: 95833f3566f9716762884d65f3f656346482e45525a3e92efa86710b9f574fdd9af7d235f1f425e4298d6ff380db9af60d1d2008ccde2588d971757db2d136b8

3 years agotest that BDK won't add unconf inputs when fee bumping
Daniela Brozzoni [Fri, 1 Jul 2022 09:11:11 +0000 (11:11 +0200)]
test that BDK won't add unconf inputs when fee bumping

Fixes #144

Also removes a leftover dbg!() in a test

3 years agotest: fix populate_test_db conf calculation
Daniela Brozzoni [Fri, 1 Jul 2022 08:56:48 +0000 (10:56 +0200)]
test: fix populate_test_db conf calculation

populate_test_db would previously give back a transaction with N + 1
confirmations when you asked for N.

This commit also fixes test_spend_coinbase, which would improperly
ask for a transaction with 0 confirmations instead of 1.

3 years agoMerge bitcoindevkit/bdk#585: set coin type based on network
Alekos Filini [Wed, 6 Jul 2022 10:22:54 +0000 (12:22 +0200)]
Merge bitcoindevkit/bdk#585: set coin type based on network

db9d43ed2f4146dbfdc28a72d0c9ae420f831fc3 use network to set coin type (Esraa Jbara)

Pull request description:

  resolves #578

  * [x] 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:
    re-ACK db9d43ed2f4146dbfdc28a72d0c9ae420f831fc3
  afilini:
    re-ACK db9d43ed2f4146dbfdc28a72d0c9ae420f831fc3

Tree-SHA512: 0310a09ef21c6fc792688a9ccc19221b1cffaeceefd34f4c83f206e965abe963a78f9e4ca53db046b39e7bf1be118a101afe5c08c43f06ecf35ed9536102cd9b

3 years agoadd try_finalize to SignOptions
KaFai Choi [Sat, 4 Jun 2022 05:42:52 +0000 (12:42 +0700)]
add try_finalize to SignOptions

3 years agoadd remove_partial_sigs to SignOptions
KaFai Choi [Sun, 29 May 2022 03:53:37 +0000 (10:53 +0700)]
add remove_partial_sigs to SignOptions

3 years agoRemove wrong TODO comment in build_fee_bump
Daniela Brozzoni [Thu, 30 Jun 2022 18:31:38 +0000 (20:31 +0200)]
Remove wrong TODO comment in build_fee_bump

The proposed solution is bad for privacy as well.
Let's call the initial change output, which is normally shrink when you
fee bump, change#1, and the extra output aforementioned change#2 (as,
in this case, it's going to be a change output as well). If you add change#2
you might not revel change#1, but you're still revealing change#2.
You're not improving your privacy, and you're wasting money in fees.

3 years agouse network to set coin type
Esraa Jbara [Fri, 15 Apr 2022 17:08:30 +0000 (20:08 +0300)]
use network to set coin type

Signed-off-by: Esraa Jbara <jbesraa@gmail.com>
3 years agoMerge bitcoindevkit/bdk#614: Avoid using immature coinbase inputs
Alekos Filini [Tue, 5 Jul 2022 20:25:28 +0000 (22:25 +0200)]
Merge bitcoindevkit/bdk#614: Avoid using immature coinbase inputs

e85aa247cb85601e96f4d82b7a996f709559223f Avoid using immature coinbase inputs (Daniela Brozzoni)
0e0d5a0e957fbf602023011d9114d8bcb8effb67 populate_test_db accepts a `coinbase` param (Daniela Brozzoni)

Pull request description:

  ### Description

  With this PR we start considering how many confirmations a coinbase has. If it's not mature yet, we don't use it for building transactions.
  Fixes #413

  ### Notes to the reviewers

  This PR is based on #611, review that one before reviewing this 😄

  007c5a78335a3e9f6c9c28a077793c2ba34bbb4e adds a coinbase parameter to `populate_test_db`, to specify if you want the db to be populated with immature coins. This is useful for `test_spend_coinbase`, but that's probably going to be the only use case.
  I don't think it's a big deal to have a test function take an almost_always_useless parameter - it's not an exposed API, anyways. But, if you can come up with a different way of implementing `test_spend_coinbase` that doesn't require 007c5a78335a3e9f6c9c28a077793c2ba34bbb4e, even better! I looked for it for a while, but other than duplicating the whole `populate_test_db` code, which made the test way harder to comprehend, I didn't find any other way.

  ### 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:
  afilini:
    ACK e85aa24

Tree-SHA512: 30f470c33f9ffe928500a58f821f8ce445c653766459465eb005031ac523c6f143856fc9ca68a8e1f23a485c6543a9565bd889f9557c92bf5322e81291212a5f

3 years agoMerge bitcoindevkit/bdk#652: Fix: Hang when `ElectrumBlockchainConfig::stop_gap ...
Alekos Filini [Tue, 5 Jul 2022 10:30:15 +0000 (12:30 +0200)]
Merge bitcoindevkit/bdk#652: Fix: Hang when `ElectrumBlockchainConfig::stop_gap == 0`

612da165f8cfbc2b0aee0a37b2cdc44d6da017c8 `Blockchain` stop_gap testing improvements (志宇)
8a5f89e129d421a41af02ea85383d5b82f5ff665 Fix hang when `ElectrumBlockchainConfig::stop_gap == 0` (志宇)

Pull request description:

  * Ensure `chunk_size` is > 0 during wallet sync.

  * Slight refactoring for better readability.

  * Add test: `test_electrum_blockchain_factory_sync_with_stop_gaps`

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

  ### Description

  `Wallet::sync` hangs indefinitely when syncing with Electrum with `stop_gap` set as 0.

  The culprit is having `chunk_size` set as `stop_gap`. A zero value results in syncing not being able to progress.

  Fixes #651

  ### 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:
  afilini:
    ACK 612da165f8cfbc2b0aee0a37b2cdc44d6da017c8

Tree-SHA512: 56f1bff788855facc21856209922594cff9f639c5c58ecd180a0493322a75a564b72ded330ab0b6d6c90007ce859d2b8a5d2870d619bae5ddf9a3d64837f3753

3 years agoAvoid using immature coinbase inputs
Daniela Brozzoni [Wed, 25 May 2022 17:56:50 +0000 (18:56 +0100)]
Avoid using immature coinbase inputs

Fixes #413

3 years ago`Blockchain` stop_gap testing improvements
志宇 [Mon, 4 Jul 2022 12:37:21 +0000 (20:37 +0800)]
`Blockchain` stop_gap testing improvements

This is a continuation of the #651 fix. We should also check whether the
same bug affects esplora as noted by @afilini. To achieve this, I've
introduced a `ConfigurableBlockchainTester` trait that can test multiple
blockchain implementations.

* Introduce `ConfigurableBlockchainTester` trait.
* Use the aforementioned trait to also test esplora.
* Change the electrum test to also use the new trait.
* Fix some complaints by clippy in ureq.rs file (why is CI not seeing
  this?).
* Refactor some code.

3 years agoMerge bitcoindevkit/bdk#575: Remove database flush
Steve Myers [Mon, 4 Jul 2022 20:40:12 +0000 (13:40 -0700)]
Merge bitcoindevkit/bdk#575: Remove database flush

5ff8320e3b1cb4e3971549a3e3c168f20762d04b add private function ivcec_to_u32 in keyvalue (KaFai Choi)
e68d3b9e63914c1008e1a4bb20a847428659d52e remove Database::flush (KaFai Choi)

Pull request description:

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

  ### Description

  This PR is to remove Database::flush. See this issue for detail https://github.com/bitcoindevkit/bdk/issues/567

  ### Notes to the reviewers
  The 2nd commit is a small refactoring of adding a new private ivec_to_u32 to avoid too much code duplication. Please let me know if it's ok to include this in this PR or I should make it into a separate PR

  Currently existing test cases are shared across for all Databaes implementation so I am not sure if we should add  specific test cases for keyvalue(Tree) for this auto-flush behaviour?(and I feel like it's more a implementation detail). Please let me know how should I proceed for test case in this PR

  ### 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
  * [x] I've updated `CHANGELOG.md`

  #### 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:
    re-ACK 5ff8320e3b1cb4e3971549a3e3c168f20762d04b

Tree-SHA512: eb37de8217efeb89d3ae346da36d0fb55aa67554d591b4759500f793bcf6aa7601c3d717fd473136c88e76aa72dbb6008ecf62b1d4ccf5ba3cbd1598f758522a

3 years agoFix hang when `ElectrumBlockchainConfig::stop_gap == 0`
志宇 [Sun, 3 Jul 2022 04:47:54 +0000 (12:47 +0800)]
Fix hang when `ElectrumBlockchainConfig::stop_gap == 0`

* Ensure chunk_size is > 0 during wallet sync.
* Slight refactoring for better readability.
* Add test: test_electrum_blockchain_factory_sync_with_stop_gaps

3 years agoMerge bitcoindevkit/bdk#625: Restrict `drain_to` usage
Alekos Filini [Thu, 30 Jun 2022 10:28:11 +0000 (12:28 +0200)]
Merge bitcoindevkit/bdk#625: Restrict `drain_to` usage

6a150368674046f796f5c37755896f16d8345fbc Restrict `drain_to` usage (Daniela Brozzoni)

Pull request description:

  ### Description
  Before this commit, you could create a transaction with `drain_to` set
  without specifying recipients, nor `drain_wallet`, nor `utxos`. What would
  happen is that BDK would pick one input from the wallet and send
  that one to `drain_to`, which is quite weird.
  This PR restricts the usage of `drain_to`: if you want to use it as a
  change output, you need to set recipients as well. If you want to send
  a specific utxo to the `drain_to` address, you specify it through
  `add_utxos`. If you want to drain the whole wallet, you set
  `drain_wallet`. In any other case, if `drain_to` is set, we return a
  `NoRecipients` error.

  Fixes #620

  ### 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 - kinda?
  * [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:
  afilini:
    ACK 6a150368674046f796f5c37755896f16d8345fbc

Tree-SHA512: 69076977df37fcaac92dd99d2f2c9c37098971817d5b0629fc7e3069390eb5789331199b3b7c5d0569d70473f4f37e683a5a0b30e2c6b4e2ec22a5ef1d0f2d77

3 years agopopulate_test_db accepts a `coinbase` param
Daniela Brozzoni [Wed, 25 May 2022 17:54:40 +0000 (18:54 +0100)]
populate_test_db accepts a `coinbase` param

Allows user to ask for a test db populated with clean coins
from coinbases. This is useful for testing the wallet behaviour
when some inputs are coinbases.

3 years agoMerge bitcoindevkit/bdk#611: Discourage fee sniping with nLockTime
Alekos Filini [Wed, 29 Jun 2022 13:57:57 +0000 (15:57 +0200)]
Merge bitcoindevkit/bdk#611: Discourage fee sniping with nLockTime

97bc9dc7170c336e97cd756b1f07ac3c23a39626 Discourage fee sniping with nLockTime (Daniela Brozzoni)

Pull request description:

  ### Description
  By default bdk sets the transaction's nLockTime to current_height
  to prevent fee sniping.
  current_height can be provided by the user through TxParams; if the user
  didn't provide it, we use the last sync height, or 0 if we never synced.

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

  ### Notes to the reviewers:

  If you want to know more about fee sniping: https://bitcoinops.org/en/topics/fee-sniping/

  ### 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
  * [x] I've updated `CHANGELOG.md`

ACKs for top commit:
  afilini:
    ACK 97bc9dc7170c336e97cd756b1f07ac3c23a39626

Tree-SHA512: e92d1ae907687d9fee44d120d790f1ebdf14b698194979e1be8433310fd5636afa63808effed12fce6091f968ec6b76b727cfee6fed54068af0a7450239fdd26

3 years agoMerge bitcoindevkit/bdk#633: Additional comments for `TransactionDetails`.
Alekos Filini [Wed, 29 Jun 2022 13:52:37 +0000 (15:52 +0200)]
Merge bitcoindevkit/bdk#633: Additional comments for `TransactionDetails`.

77c7d0aae944dbd5a44ca9b8f239db0c9edcd4f8 Additional comments for `TransactionDetails`. (志宇)

Pull request description:

  ### Description

  I'm not sure if this is needed or helpful, but this PR adds comments to describe how the `sent` and `received` fields of `TransactionDetails` are calculated.

  I wasn't sure how it was done until I looked deeper into the codebase (but maybe I am too much of a beginner and this is common sense for most).

  ### 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:
    re-ACK 77c7d0aae944dbd5a44ca9b8f239db0c9edcd4f8

Tree-SHA512: 8d29d249a70bc2d0631078b6772c5543bdc61ee43df3810ab666f5e97ca59b0d4cfc8acad14bbaf8674baba319f24fa2781a42740ca42bccd9688831aaedea72

3 years agoAdditional comments for `TransactionDetails`.
志宇 [Wed, 15 Jun 2022 14:13:41 +0000 (22:13 +0800)]
Additional comments for `TransactionDetails`.

Describe how fields `received` and `sent` are calculated for
`TransactionDetails`.

3 years agoadd private function ivcec_to_u32 in keyvalue
KaFai Choi [Wed, 23 Mar 2022 06:46:16 +0000 (13:46 +0700)]
add private function ivcec_to_u32 in keyvalue

3 years agoremove Database::flush
KaFai Choi [Wed, 23 Mar 2022 03:58:05 +0000 (10:58 +0700)]
remove Database::flush

3 years agoDiscourage fee sniping with nLockTime
Daniela Brozzoni [Wed, 30 Mar 2022 14:29:31 +0000 (16:29 +0200)]
Discourage fee sniping with nLockTime

By default bdk sets the transaction's nLockTime to current_height
to discourage fee sniping.
current_height can be provided by the user through TxParams; if the user
didn't provide it, we use the last sync height, or 0 if we never synced.

Fixes #533

3 years agoRestrict `drain_to` usage
Daniela Brozzoni [Mon, 6 Jun 2022 19:45:13 +0000 (21:45 +0200)]
Restrict `drain_to` usage

Before this commit, you could create a transaction with `drain_to` set
without specifying recipients, nor `drain_wallet`, nor `utxos`. What would
happen is that BDK would pick one input from the wallet and send
that one to `drain_to`, which is quite weird.
This PR restricts the usage of `drain_to`: if you want to use it as a
change output, you need to set recipients as well. If you want to send
a specific utxo to the `drain_to` address, you specify it through
`add_utxos`. If you want to drain the whole wallet, you set
`drain_wallet`. In any other case, if `drain_to` is set, we return a
`NoRecipients` error.

Fixes #620

3 years agoMerge bitcoindevkit/bdk#643: Fix README.md link to rust 1.56.1 blog post
Alekos Filini [Tue, 28 Jun 2022 06:43:03 +0000 (08:43 +0200)]
Merge bitcoindevkit/bdk#643: Fix README.md link to rust 1.56.1 blog post

d020dede3785f351c0a58a0787c20c396437ff87 Fix README.md link to rust 1.56.1 blog post (Steve Myers)

Pull request description:

  ### Description

  Fix link to rust blog for 1.56.1 as pointed out by ulrichard: https://github.com/weareseba/bdk-reserves/pull/5#issuecomment-1159212838

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits

Top commit has no ACKs.

Tree-SHA512: a5bd76fca97dd64c12617b43230dbc36b1178e47224ce324b67cd13999e5f92d2a05d6a9e909841e6d5c6904f2fa426b6bee1001e757d53cc91fb4fd3803f56b

3 years agoFix README.md link to rust 1.56.1 blog post
Steve Myers [Tue, 28 Jun 2022 05:04:54 +0000 (22:04 -0700)]
Fix README.md link to rust 1.56.1 blog post

3 years agoMerge bitcoindevkit/bdk#638: Fix CI, bump MSRV to 1.56.1
Alekos Filini [Mon, 27 Jun 2022 21:25:16 +0000 (23:25 +0200)]
Merge bitcoindevkit/bdk#638: Fix CI, bump MSRV to 1.56.1

b289c4ec2d4e19cd231e65f6e71e2b7422a81be1 Bump MSRV from 1.56.0 to 1.56.1 (Daniela Brozzoni)

Pull request description:

  ### Description
  This PR fixes the CI, which is currently failing after a Github Actions update.
  The MSRV is bumped to 1.56.1 (from 1.56.0), since that's `reqwest`'s current MSRV.

  ### 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:
  afilini:
    ACK b289c4ec2d4e19cd231e65f6e71e2b7422a81be1

Tree-SHA512: e3aa8638ffd374371037e71d1c9790dd4fb3aa29f0ade5655b47ef5184b26120ee5281cd1745612af2572beb8a6bb43f84da3d60a73b455f9652853fcf31b62d

3 years agoBump MSRV from 1.56.0 to 1.56.1
Daniela Brozzoni [Tue, 21 Jun 2022 14:20:28 +0000 (16:20 +0200)]
Bump MSRV from 1.56.0 to 1.56.1

In this way we can continue using reqwest v0.11, whose MSRV is now
1.56.1
The only difference between v1.56.0 and v1.56.1 is a bug fix for
CVE-2021-42574.

3 years agoMerge bitcoindevkit/bdk#622: fix typo
Alekos Filini [Mon, 13 Jun 2022 09:44:35 +0000 (11:44 +0200)]
Merge bitcoindevkit/bdk#622: fix typo

a85ef62698eae748242f31db80fa3aabd3b2b64e fix typo (Buck Perley)

Pull request description:

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

  ### Description

  <!-- Describe the purpose of this PR, what's being adding and/or fixed -->
  just a small typo fix

  ### Notes to the reviewers

  <!-- In this section you can include notes directed to the reviewers, like explaining why some parts
  of the PR were done in a specific way -->

  ### 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:
  rajarshimaitra:
    ACK a85ef62698eae748242f31db80fa3aabd3b2b64e
  afilini:
    ACK a85ef62698eae748242f31db80fa3aabd3b2b64e

Tree-SHA512: 089de23adae62492a0b39a27c9cb8cb8afc99e5634194118681b8a9a46ff0b073558f9cd515cd4db4c9c6e6f9c813bfa4b193d4e3f9558b34ad29cbd46cf028c

3 years agoMerge commit 'refs/pull/629/head' of github.com:bitcoindevkit/bdk
Steve Myers [Fri, 10 Jun 2022 17:46:27 +0000 (10:46 -0700)]
Merge commit 'refs/pull/629/head' of github.com:bitcoindevkit/bdk

3 years agoBump version to 0.19.1-dev github/release/0.19.0
Steve Myers [Fri, 10 Jun 2022 17:13:43 +0000 (10:13 -0700)]
Bump version to 0.19.1-dev

3 years agoBump version to 0.19.0 v0.19.0
Steve Myers [Fri, 10 Jun 2022 16:08:43 +0000 (09:08 -0700)]
Bump version to 0.19.0

3 years agoUpdate CHANGELOG.md to 0.19.0
Steve Myers [Wed, 8 Jun 2022 22:18:54 +0000 (15:18 -0700)]
Update CHANGELOG.md to 0.19.0

3 years agoMerge bitcoindevkit/bdk#623: Bump versions
Alekos Filini [Wed, 8 Jun 2022 10:59:15 +0000 (12:59 +0200)]
Merge bitcoindevkit/bdk#623: Bump versions

3283a200bc5fef4bca38954abad669130125f70c Bump rusqlite (Philipp Hoenisch)
3f9b4cdca9dc05d3e8f63df7235287e192a1838a Bump ahash (Philipp Hoenisch)

Pull request description:

  ### Description

  Not much to say besides that I bumped some version which helps us to resolve some dependency hell :)

  ### Notes to the reviewers

  `ahash` was previously fixed because of an incompatibility with the defined MSRV. The MSRV has been bumped to 1.56 so we can update the dependency.

  ### 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
  * [ ] I've updated `CHANGELOG.md`

  #### 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:
  rajarshimaitra:
    ACK 3283a200bc5fef4bca38954abad669130125f70c

Tree-SHA512: 4760890529bb4dd87fafdda04188fd06e707398abfa7d36d26077233525e76cc8c7d8888ad996c1cc4ac31ab708ea9a56a602b1d1578b97f9e44b610df3d969b

3 years agoBump version to 0.19.0-rc.1
Steve Myers [Tue, 7 Jun 2022 20:13:23 +0000 (13:13 -0700)]
Bump version to 0.19.0-rc.1

3 years agoMerge bitcoindevkit/bdk#628: rpc: use `importdescriptors` with Core >= 0.21
Steve Myers [Tue, 7 Jun 2022 20:00:46 +0000 (13:00 -0700)]
Merge bitcoindevkit/bdk#628: rpc: use `importdescriptors` with Core >= 0.21

e1a1372baec86da784af697e025615b8e0bccf4e rpc: use `importdescriptors` with Core >= 0.21 (Alekos Filini)

Pull request description:

  ### Description

  Only use the old `importmulti` with Core versions that don't support descriptor-based (sqlite) wallets.

  Add an extra feature to test against Core 0.20 called `test-rpc-legacy`.

  This also makes us compatible with Core 23.0 and is thus a replacement for #613, which actually looking back at it was adding support for 23.0 but probably breaking older wallets by adding the extra argument to `createwallet`.

  I believe #613 should now only focus on getting the tests to work against 23.0, which is still important but not such a high priority as being compatible with the latest version of Core.

  Also fixes #598

  ### 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
  * [x] I've updated `CHANGELOG.md`

ACKs for top commit:
  notmandatory:
    ACK e1a1372baec86da784af697e025615b8e0bccf4e

Tree-SHA512: 7891b8ab2fc900ea2a186f64a32aea970f28a50339063ed0e1a8d13248e5c038b8fff3d9e26b93cb7daafd0c873379e64a28836dbe4e4b82f1983577a88971ff

3 years agorpc: use `importdescriptors` with Core >= 0.21
Alekos Filini [Tue, 7 Jun 2022 11:14:52 +0000 (13:14 +0200)]
rpc: use `importdescriptors` with Core >= 0.21

Only use the old `importmulti` with Core versions that don't support
descriptor-based (sqlite) wallets.

Add an extra feature to test against Core 0.20 called `test-rpc-legacy`

3 years agoBump rusqlite
Philipp Hoenisch [Mon, 6 Jun 2022 00:57:50 +0000 (10:57 +1000)]
Bump rusqlite

Signed-off-by: Philipp Hoenisch <philipp@hoenisch.at>
3 years agoBump ahash
Philipp Hoenisch [Mon, 6 Jun 2022 00:57:09 +0000 (10:57 +1000)]
Bump ahash

We can upgrade this now as MSRV was bumped to 1.56

Signed-off-by: Philipp Hoenisch <philipp@hoenisch.at>
3 years agofix typo
Buck Perley [Sun, 5 Jun 2022 17:06:13 +0000 (12:06 -0500)]
fix typo

3 years agoMerge bitcoindevkit/bdk#619: Fix index out of bound error
Steve Myers [Sun, 5 Jun 2022 17:12:47 +0000 (10:12 -0700)]
Merge bitcoindevkit/bdk#619: Fix index out of bound error

d9b9b3dc464d6a9cd4157cc4135a2e7b88ce4ab3 Fix InvalidColumnIndex error (Philipp Hoenisch)

Pull request description:

  This query returns 7 rows, so last row is index 6

  ### 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] I've added tests to reproduce the issue which are now passing

ACKs for top commit:
  danielabrozzoni:
    tACK d9b9b3dc464d6a9cd4157cc4135a2e7b88ce4ab3
  rajarshimaitra:
    tACK d9b9b3dc464d6a9cd4157cc4135a2e7b88ce4ab3

Tree-SHA512: 8a3d8a291daa4af86a2a2eacc31f002972dd9cdb9bf300a4b09e2e015c4a967dc4fa7e925afbcce8b104a01e1d7f7c8cb0badda8e1ac5ade511681f490c719d5

3 years agoMerge bitcoindevkit/bdk#593: Add support for Taproot and `tr()` descriptors
Alekos Filini [Fri, 3 Jun 2022 14:42:51 +0000 (16:42 +0200)]
Merge bitcoindevkit/bdk#593: Add support for Taproot and `tr()` descriptors

20d36c71d470ea5ece98dd218f4dbdb0ba872d11 Update CHANGELOG.md for Taproot (Alekos Filini)
ef08fbd3c7f424cb77e231c2daaed2039b28b938 Update to the newest release of rust-bitcoin (Alekos Filini)
5320c8353e05adecf0d18336d48934567257e64d taproot-tests: validate `tap_tree` in psbt outputs (Alekos Filini)
c1bfaf9b1ebd92ac8952afd0d5867897672acfb4 Add blockchain tests for parsing, signing, finalizing taproot core psbts (Steve Myers)
0643f76c1fac5ee25f8a9de4c3a2cd57a3974b5e taproot-tests: Add tests for the policy module (Alekos Filini)
89cb425e69303fe62fe7332d8528011b7a98b4df taproot-tests: Add test coverage for tx signing (Alekos Filini)
461397e590471a8d10590b7d754e206310bceef5 taproot-tests: Test taproot key and script spend in the blockchain tests (Alekos Filini)
c67116fb55de525a9045527eefcb5cdb6f4d34a9 policy: Consider `tap_key_origins` when looking for sigs in PSBTs (Alekos Filini)
572c3ee70d6d335af0e2e541d2497f8bdcfb63c9 policy: Build `SatisfiableItem::*Signature` based on the context (Alekos Filini)
ff1abc63e03e5c24d375eb2c4f20302c9187d24d policy: Refactor `PkOrF` into an enum (Alekos Filini)
308708952b598f8f0f1f6cb5f3743e443485cb1e Fix type inference for the `tr()` descriptor, add basic tests (Alekos Filini)
fe1877fb185af7a235ceb1a9696d1edd66f957d8 Support `tr()` descriptors in dsl (Alekos Filini)
cdc7057813a4a2acba5224c966da2c3473efa669 Add `tr()` descriptors to the `descriptor!()` macro (Alekos Filini)
c121dd0252f392ac4bd5e787c9cb570dedcec478 Use `tap_key_origins` in PSBTs to derive descriptors (Alekos Filini)
855382113380612ca4f4c7da0a4a93c7a4f9aab9 Populate more taproot fields in PSBTs (Alekos Filini)
8a5a87b0752e0bdaa003ff7c3f1d153a447dbe85 Populate `tap_key_origin` in PSBT inputs and outputs (Alekos Filini)
1312184ed7a9c5c7a6f99cf8bb08d43775ba5083 Attach a context to our software signers (Alekos Filini)
906598ad9254643a204df7711693dcc0a73a0332 Refactor signer traits, add support for taproot signatures (Alekos Filini)

Pull request description:

  ### Description

  This is a work-in-progress PR to update BDK to rust-bitcoin `0.28` which introduces taproot support and a few other improvements. While updating we also introduce taproot support in BDK.

  High level list of subtasks for this PR:
  - [x] Update rust-bitcoin and rust-miniscript
  - [x] Stop using deprecated structs
  - [x] Add taproot metadata to psbts
  - [x] Produce schnorr signatures
  - [x] Finalize taproot txs
  - [x] Support `tr()` descriptors in the `descriptor!()` macro
  - [x] Write a lot of tests
    - [x] Interoperability with other wallets (Core + ?)
       - [x] Signing/finalizing a psbt made by core
       - [x] Producing a psbt that core can sign and finalize
    - [x] Creating psbts
      - [x] Verify the metadata are correct
      - [x] Verify sighashes are applied correctly
      - [x] Create a tx with a foreign taproot and non-taproot utxo
    - [x] Signing psbts
      - [x] Signing for a key spend
      - [x] Signing for a script spend
      - [x] Signing with a single (wif) key
      - [x] Signing with an xprv (with and without knowing the utxo being spent in the db)
      - [x] Signing with weird sighashes
    - [x] Policy module
      - [x] Simple key spend
      - [x] More complex tap tree with a few keys
      - [x] Verify both `contribution` and `satisfaction` of a PSBT input
    - [x] Wallet module
      - [x] Generate addresses

  Fixes #63

  ### Notes to the reviewers

  #### Milestone

  I'm adding this to the `0.19` milestone because now that rust-bitcoin and rust-miniscript have been released we should not waiting too long to release a version of BDK that supports the new libraries.

  #### API Breaks

  Since this is an API-break because of the new version of rust-bitcoin and rust-miniscript, I'm also taking the chance to update a few things in our lib that I had been thinking about for a while.

  One example is the signer interface, which had that weird `sign_whole_tx()` method. This has now been removed, and the `Signer` trait replaced with `TransactionSigner` and `InputSigner`. I'm also starting to think that the signer should not only look at the psbt to figure out what to do, but ideally it should also receive some information about the descriptor (for example, the type) to simplify the code.

  One option is to add an extra parameter, but that would probably only be used by our internal signers and not much else (for example, if you ask an hardware wallet to sign, it will probably already know what kind of wallet you have).

  Another option is to wrap `PrivateKey` and `DescriptorXKey<ExtendedPrivKey>` which are the two internal signers we support with a struct that contains metadata about the descriptor, and then implement the signer traits on that struct. We could construct this in `Wallet::new()`, after miniscript parses the descriptor.

  #### MSRV Bump

  Due to the update of `rust-electrum-client`, which in turn depends on an updated `webpki`, we will have to bump our MSRV beacuse 1.46 is not supported by the new `webpki` version.

  ### 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 docs for the new feature
  * [ ] I've updated `CHANGELOG.md`

Top commit has no ACKs.

Tree-SHA512: 44ec6c4e7fe0bc87862bb76581ddae7905c8796a4a130c90b48b73b4b7d01ea1a20043b8a0ff449fc2db2f7aecc490def8daee2d420809ded1ece7f085a48f55

3 years agoFix InvalidColumnIndex error
Philipp Hoenisch [Fri, 3 Jun 2022 05:28:43 +0000 (15:28 +1000)]
Fix InvalidColumnIndex error

This query returns 7 columns, so last columns is index 6

3 years agoUpdate CHANGELOG.md for Taproot
Alekos Filini [Wed, 1 Jun 2022 12:55:43 +0000 (14:55 +0200)]
Update CHANGELOG.md for Taproot

3 years agoUpdate to the newest release of rust-bitcoin
Alekos Filini [Wed, 1 Jun 2022 12:50:08 +0000 (14:50 +0200)]
Update to the newest release of rust-bitcoin

3 years agotaproot-tests: validate `tap_tree` in psbt outputs
Alekos Filini [Tue, 31 May 2022 15:47:26 +0000 (17:47 +0200)]
taproot-tests: validate `tap_tree` in psbt outputs

Co-authored-by: Daniela Brozzoni <danielabrozzoni@protonmail.com>
3 years agoAdd blockchain tests for parsing, signing, finalizing taproot core psbts
Steve Myers [Wed, 25 May 2022 02:26:41 +0000 (19:26 -0700)]
Add blockchain tests for parsing, signing, finalizing taproot core psbts

3 years agotaproot-tests: Add tests for the policy module
Alekos Filini [Tue, 24 May 2022 09:49:31 +0000 (11:49 +0200)]
taproot-tests: Add tests for the policy module

3 years agotaproot-tests: Add test coverage for tx signing
Alekos Filini [Wed, 18 May 2022 17:55:21 +0000 (19:55 +0200)]
taproot-tests: Add test coverage for tx signing

3 years agotaproot-tests: Test taproot key and script spend in the blockchain tests
Alekos Filini [Wed, 18 May 2022 09:36:15 +0000 (11:36 +0200)]
taproot-tests: Test taproot key and script spend in the blockchain tests

This is to ensure a Bitcoin node accepts our transactions

3 years agopolicy: Consider `tap_key_origins` when looking for sigs in PSBTs
Alekos Filini [Tue, 24 May 2022 13:50:49 +0000 (15:50 +0200)]
policy: Consider `tap_key_origins` when looking for sigs in PSBTs

We used to only look at `bip32_derivations` which is only used for ECDSA
keys.

3 years agopolicy: Build `SatisfiableItem::*Signature` based on the context
Alekos Filini [Tue, 24 May 2022 09:24:48 +0000 (11:24 +0200)]
policy: Build `SatisfiableItem::*Signature` based on the context

Also refactor our code to lookup signatures in PSBTs to use the context

3 years agopolicy: Refactor `PkOrF` into an enum
Alekos Filini [Tue, 24 May 2022 08:39:17 +0000 (10:39 +0200)]
policy: Refactor `PkOrF` into an enum

For whatever reason we were using a struct as an enum, so we might as
well fix it in this PR since we are already breaking the API quite
badly.

3 years agoFix type inference for the `tr()` descriptor, add basic tests
Alekos Filini [Fri, 29 Apr 2022 14:08:03 +0000 (16:08 +0200)]
Fix type inference for the `tr()` descriptor, add basic tests

3 years agoSupport `tr()` descriptors in dsl
Alekos Filini [Fri, 29 Apr 2022 13:38:45 +0000 (15:38 +0200)]
Support `tr()` descriptors in dsl

3 years agoAdd `tr()` descriptors to the `descriptor!()` macro
Alekos Filini [Sat, 13 Nov 2021 14:39:34 +0000 (15:39 +0100)]
Add `tr()` descriptors to the `descriptor!()` macro

3 years agoUse `tap_key_origins` in PSBTs to derive descriptors
Alekos Filini [Fri, 29 Apr 2022 10:59:09 +0000 (12:59 +0200)]
Use `tap_key_origins` in PSBTs to derive descriptors

3 years agoPopulate more taproot fields in PSBTs
Alekos Filini [Thu, 28 Apr 2022 13:39:31 +0000 (15:39 +0200)]
Populate more taproot fields in PSBTs

3 years agoPopulate `tap_key_origin` in PSBT inputs and outputs
Alekos Filini [Wed, 27 Apr 2022 14:29:02 +0000 (16:29 +0200)]
Populate `tap_key_origin` in PSBT inputs and outputs

3 years agoAttach a context to our software signers
Alekos Filini [Thu, 12 May 2022 15:28:41 +0000 (17:28 +0200)]
Attach a context to our software signers

This allows the signer to know the signing context precisely without
relying on heuristics on the psbt fields.

Due to the context being static, we still have to look at the PSBT when
producing taproot signatures to determine the set of leaf hashes that
the key can sign for.

3 years agoRefactor signer traits, add support for taproot signatures
Alekos Filini [Tue, 26 Apr 2022 14:54:10 +0000 (16:54 +0200)]
Refactor signer traits, add support for taproot signatures

3 years agoMerge bitcoindevkit/bdk#605: Fix sqlite database set_utxo to insert or update utxos
Steve Myers [Tue, 24 May 2022 15:18:55 +0000 (08:18 -0700)]
Merge bitcoindevkit/bdk#605: Fix sqlite database set_utxo to insert or update utxos

35feb107ed5969720ce54a6aa76b7b2176f6c7c1 [CI] Fix cont_integration test-blockchains to run all tests (Steve Myers)
24719081511969299459d01566b0d669a7b51f7b Update CHANGELOG with warning about sqlite-db deleted wallet data (Steve Myers)
0b1a399f4e556a981bb992cc9b1d34318e260a7c Update sqlite schema with unique index for utxos, change insert_utxo to upsert (Steve Myers)
cea79872d717b395560a344cc4dd0e022c3bd9a9 Update database tests to verify set_utxo upserts (Steve Myers)

Pull request description:

  ### Description

  This PR fixes #591 by:
  1. Add sqlite `MIGRATIONS` statements to remove duplicate utxos and add unique utxos index on txid and vout.
  2. Do an upsert (if insert fails update) instead of an insert in `set_utxo()`.
  3. Update database::test::test_utxo to also verify `set_utxo()` doesn't insert duplicate utxos.

  ### Notes to the reviewers

  I verified the updated `test_utxo` fails as expected before my fix and passes after the fix. I tested the new migrations using the below `bdk-cli` command and a manually updated sqlite db with duplicate utxos.
  ```shell
  cargo run --no-default-features --features cli,sqlite-db,esplora-ureq -- wallet -w test1 --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
  ```

  ### 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
  * [ ] I've updated `CHANGELOG.md`

  #### 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:
    utACK 35feb107ed5969720ce54a6aa76b7b2176f6c7c1 - Code looks good, but I didn't do any local test to see if the db gets wiped

Tree-SHA512: 753c7a0cfd0e803b5e12f39181d9a718791c4ce229d5072e6498db75a7008e94d447b3d0b4b0c205e7a8f127f60102e12bac2d271b8bad3a3038856bfd54e99c

3 years agoMerge bitcoindevkit/bdk#610: Populate the redeemScript for `sh(wsh(sortedmulti()))`
Alekos Filini [Tue, 24 May 2022 08:14:36 +0000 (10:14 +0200)]
Merge bitcoindevkit/bdk#610: Populate the redeemScript for `sh(wsh(sortedmulti()))`

82de8b50da6e8b9752332b80da395c792c371def Populate the redeemScript for `sh(wsh(sortedmulti()))` (Alekos Filini)

Pull request description:

  ### Description

  Also explicitly match all the individual variants to ensure a similar problem
  doesn't happen again.

  Fixes #609

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

Tree-SHA512: 7cccae44679089b70e8d9df466a165debe17c4cf30ae11cb27357fbda830d3d7ce53161e414b354b1f2be46efe413b8e44132f5e6d625298b740d44112ca286a

3 years agoPopulate the redeemScript for `sh(wsh(sortedmulti()))`
Alekos Filini [Mon, 23 May 2022 19:01:28 +0000 (21:01 +0200)]
Populate the redeemScript for `sh(wsh(sortedmulti()))`

Also explicitly match all the individual variants to ensure a similar problem
doesn't happen again.

Fixes #609

3 years ago[CI] Fix cont_integration test-blockchains to run all tests
Steve Myers [Thu, 19 May 2022 21:00:40 +0000 (14:00 -0700)]
[CI] Fix cont_integration test-blockchains to run all tests

3 years agoUpdate CHANGELOG with warning about sqlite-db deleted wallet data
Steve Myers [Wed, 18 May 2022 20:44:57 +0000 (13:44 -0700)]
Update CHANGELOG with warning about sqlite-db deleted wallet data

3 years agoUpdate sqlite schema with unique index for utxos, change insert_utxo to upsert
Steve Myers [Thu, 12 May 2022 00:33:32 +0000 (17:33 -0700)]
Update sqlite schema with unique index for utxos, change insert_utxo to upsert

3 years agoUpdate database tests to verify set_utxo upserts
Steve Myers [Thu, 12 May 2022 01:04:18 +0000 (18:04 -0700)]
Update database tests to verify set_utxo upserts

3 years agoMerge bitcoindevkit/bdk#604: unpinning dependency tokio to just 1
Steve Myers [Tue, 17 May 2022 18:13:19 +0000 (11:13 -0700)]
Merge bitcoindevkit/bdk#604: unpinning dependency tokio to just 1

939a1156c65d0f347cb4397e0883573737d39761 unpinning dependency tokio to 1 (Richard Ulrich)

Pull request description:

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

  ### Description

  unpinning dependency tokio to just 1

  ### 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
  * [x] I've updated `CHANGELOG.md`

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

Tree-SHA512: 7b33522411f6b63d844d12cc86c8992aa4105c29e91dbef67362a6c600f3ef39e802ff5893054bf8feeb7fa5bf383765025096cbc2ccb9a6b83bc5c919a5a43d

3 years agounpinning dependency tokio to 1
Richard Ulrich [Mon, 9 May 2022 14:28:50 +0000 (16:28 +0200)]
unpinning dependency tokio to 1

3 years agoMerge bitcoindevkit/bdk#606: Upgrade to rust-bitcoin 0.28
Alekos Filini [Thu, 12 May 2022 18:29:41 +0000 (20:29 +0200)]
Merge bitcoindevkit/bdk#606: Upgrade to rust-bitcoin 0.28

00164588f2ddab91bb4468ec010dc1bbca277eb5 Stop using deprecated structs (Alekos Filini)
a16c18255ceb3e13ff92ee41b2b6f6510491eeb8 Upgrade to rust-bitcoin 0.28 and miniscript 7.0 (Alekos Filini)

Pull request description:

  ### Description

  Upgrade all our dependencies to work with the new release of rust-bitcoin

  ### Notes to the reviewers

  The commits in this pr were originally part of #593

  ### 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 updated `CHANGELOG.md`

ACKs for top commit:
  rajarshimaitra:
    ACK 00164588f2ddab91bb4468ec010dc1bbca277eb5

Tree-SHA512: eef7e94246e619686b4dfffd6e4cb685630fe2eaf9447f2f0b49ed2643d67f81c50e0d89b66267db4552a05e58f638d885eb7056270648403f716803fce9e275

3 years agoStop using deprecated structs
Alekos Filini [Tue, 26 Apr 2022 13:11:22 +0000 (15:11 +0200)]
Stop using deprecated structs

3 years agoUpgrade to rust-bitcoin 0.28 and miniscript 7.0
Alekos Filini [Thu, 14 Apr 2022 15:20:46 +0000 (17:20 +0200)]
Upgrade to rust-bitcoin 0.28 and miniscript 7.0

3 years agoMerge bitcoindevkit/bdk#569: [blockchain] Add traits to reuse `Blockchain`s across...
Steve Myers [Wed, 11 May 2022 04:31:50 +0000 (21:31 -0700)]
Merge bitcoindevkit/bdk#569: [blockchain] Add traits to reuse `Blockchain`s across multiple wallets

8795da48397800effeffae8417c6e749ec488212 wallet: Move `wallet_name_from_descriptor` above the tests (Alekos Filini)
9c405e9c70e417dea0e610f9d44e99911d6b4e44 [blockchain] Add traits to reuse `Blockchain`s across multiple wallets (Alekos Filini)
2d83af49051f5d33105315164f3edf7f72f3741f Move testutils macro module before the others (Alekos Filini)

Pull request description:

  ### Description

  Add three new traits:
  - `StatelessBlockchain` is used to tag `Blockchain`s that don't have any wallet-specic state, i.e. they can be used as-is to sync multiple wallets.
  - `StatefulBlockchain` is the opposite of `StatelessBlockchain`: it provides a method to "clone" a `Blockchain` with an updated internal state (a new wallet checksum and, optionally, a different number of blocks to skip from genesis). Potentially this also allows reusing the underlying connection on `Blockchain` types that support it.
  - `MultiBlockchain` is a generalization of this concept: it's implemented automatically for every type that implements `StatefulBlockchain` and for every `Arc<T>` where `T` is a `StatelessBlockchain`. This allows a piece of code that deals with multiple sub-wallets to just get a `&B: MultiBlockchain` without having to deal with stateful and statless blockchains individually.

  These new traits have been implemented for Electrum, Esplora and RPC (the first two being stateless and the latter stateful). It hasn't been implemented on the CBF blockchain, because I don't think it would work in its current form (it throws away old block filters, so it's hard to go back and rescan).

  This is the first step for #549, as BIP47 needs to sync many different descriptors internally.

  It's also very useful for #486.

  ### Notes to the reviewers

  This is still a draft because:
  - I'm still wondering if these traits should "inherit" from `Blockchain` instead of the less-restrictive `WalletSync` + `GetHeight` which is the bare minimum to sync a wallet
  - I need to write tests, at least for rpc which is stateful
  - I need to add 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
  * [x] I've updated `CHANGELOG.md`

ACKs for top commit:
  rajarshimaitra:
    tACK 8795da48397800effeffae8417c6e749ec488212

Tree-SHA512: 03f3b63d51199b26a20d58cf64929fd690e2530f873120291a7ffea14a6237334845ceb37bff20d6c5466fca961699460af42134d561935d77b830e2e131df9d

3 years agoMerge bitcoindevkit/bdk#602: wrong Network path fixed
Alekos Filini [Tue, 10 May 2022 15:25:50 +0000 (17:25 +0200)]
Merge bitcoindevkit/bdk#602: wrong Network path fixed

b4100a71896cdbd7cf2c38cdce9f846ea74b6d44 wrong Network path fixed (Pedro Felix)

Pull request description:

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

  ### Description
  This change needs to be made for this example to compile correctly.
  <!-- Describe the purpose of this PR, what's being adding and/or fixed -->

  ### Notes to the reviewers

  <!-- In this section you can include notes directed to the reviewers, like explaining why some parts
  of the PR were done in a specific way -->

  ### 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
  * [ ] I've updated `CHANGELOG.md`

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

Tree-SHA512: b4b7d186cabc7b3ed2d5b6411414d56eeee09c4e8d9d704a26f8817d6573b6b182d7ef1ff8139b6f4f6fb3e4ec99c2c09758804a6bb25051e45b0885c0def5e3

3 years agowallet: Move `wallet_name_from_descriptor` above the tests
Alekos Filini [Fri, 15 Apr 2022 20:12:34 +0000 (22:12 +0200)]
wallet: Move `wallet_name_from_descriptor` above the tests

3 years ago[blockchain] Add traits to reuse `Blockchain`s across multiple wallets
Alekos Filini [Tue, 15 Mar 2022 09:48:00 +0000 (10:48 +0100)]
[blockchain] Add traits to reuse `Blockchain`s across multiple wallets

Add two new traits:
- `StatelessBlockchain` is used to tag `Blockchain`s that don't have any
  wallet-specic state, i.e. they can be used as-is to sync multiple wallets.
- `BlockchainFactory` is a trait for objects that can build multiple
  blockchains for different descriptors. It's implemented automatically
  for every `Arc<T>` where `T` is a `StatelessBlockchain`. This allows a
  piece of code that deals with multiple sub-wallets to just get a
  `&B: BlockchainFactory` to sync all of them.

These new traits have been implemented for Electrum, Esplora and RPC
(the first two being stateless and the latter having a dedicated
`RpcBlockchainFactory` struct). It hasn't been implemented on the CBF
blockchain, because I don't think it would work in its current form
(it throws away old block filters, so it's hard to go back and rescan).

This is the first step for #549, as BIP47 needs to sync many different
descriptors internally.

It's also very useful for #486.

3 years agoMove testutils macro module before the others
Alekos Filini [Wed, 23 Mar 2022 11:00:24 +0000 (12:00 +0100)]
Move testutils macro module before the others

This allows using the `testuitils` macro in their tests as well

3 years agowrong Network path fixed
Pedro Felix [Fri, 6 May 2022 16:03:35 +0000 (09:03 -0700)]
wrong Network path fixed

Signed-off-by: Pedro Felix <NEWAGAIN@Pedros-MacBook-Pro.local>
Signed-off-by: Pedro Felix <p.felixgarcia@gmail.com>
3 years agoMerge bitcoindevkit/bdk#600: Change wallet::get_funded_wallet to return Wallet<AnyDat...
Alekos Filini [Fri, 6 May 2022 08:28:37 +0000 (10:28 +0200)]
Merge bitcoindevkit/bdk#600: Change wallet::get_funded_wallet to return Wallet<AnyDatabase>

e7a56a92685ce1948d2ec7232fccd7e072d4abb3 Change wallet::get_funded_wallet to return Wallet<AnyDatabase> (Steve Myers)

Pull request description:

  ### Description

  Change testing function `wallet::get_funded_wallet` to return `Wallet<AnyDatabase>` instead of `Wallet<MemoryDatabase>`. This will allow us to use this function for testing `bdk-ffi` which only works with `Wallet<AnyDatabase>`.

  ### Notes to the reviewers

  This is required to complete https://github.com/bitcoindevkit/bdk-ffi/pull/148.

  ### 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
  * [ ] I've updated `CHANGELOG.md`

  #### 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:
  afilini:
    ACK e7a56a92685ce1948d2ec7232fccd7e072d4abb3

Tree-SHA512: 47b53ab6dcee63fc7b24666d3cf9a0ad832782081dd2fe92961c8c9b4c302df90db96b0b518af71d6cbc85319434971219100f8cedb35ce7212d944db29a4295

3 years agoMerge bitcoindevkit/bdk#599: Fix typo in docs for TxBuilder allow_shrinking method
Alekos Filini [Fri, 6 May 2022 08:26:49 +0000 (10:26 +0200)]
Merge bitcoindevkit/bdk#599: Fix typo in docs for TxBuilder allow_shrinking method

4628a10191f451a7b0ade674e9f8568bf695e49c Fix typo in docs for TxBuilder allow_shrinking method (thunderbiscuit)

Pull request description:

  ### Description
  This PR fixes a small typo in the documentation for the `allow_shrinking()` method on the `TxBuilder`.

  ### Notes to the reviewers
  The sentence
  ```txt
  Explicitly tells the wallet that it is allowed to reduce the fee of the output matching this `script_pubkey` in order to bump the transaction fee. Without specifying this the wallet will attempt to find a change output to shrink instead.
  ```
  was changed for
  ```txt
  Explicitly tells the wallet that it is allowed to reduce the amount of the output matching this `script_pubkey` in order to bump the transaction fee. Without specifying this the wallet will attempt to find a change output to shrink instead.
  ```

  To reflect the fact that it's the _amount_ of the output that is being reduced in order to leave more for the fees.

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

Tree-SHA512: ca135764d78144295fdbdb4673ca6dec153c6f83ee7fb5d7d3051e0d46b04d23b2f3c3fd66e44491da842c778e72b52f8996d00e4c20986d7ccb11587f0d7d27

3 years agoChange wallet::get_funded_wallet to return Wallet<AnyDatabase>
Steve Myers [Thu, 5 May 2022 23:42:56 +0000 (16:42 -0700)]
Change wallet::get_funded_wallet to return Wallet<AnyDatabase>

3 years agoFix typo in docs for TxBuilder allow_shrinking method
thunderbiscuit [Thu, 5 May 2022 19:15:04 +0000 (15:15 -0400)]
Fix typo in docs for TxBuilder allow_shrinking method

3 years agoMerge bitcoindevkit/bdk#596: Bump MSRV to 1.56
Steve Myers [Wed, 4 May 2022 16:55:19 +0000 (09:55 -0700)]
Merge bitcoindevkit/bdk#596: Bump MSRV to 1.56

cca69481eb7edb28532a4ed78185248d410050ac Bump MSRV to 1.56 (Alekos Filini)

Pull request description:

  ### Description

  Following the discussion in #331, bump the MSRV to `1.56`. We already have other PRs bumping it to at least `1.51` (#593), but I'm felling like we are always lagging behind and our CI breaks regularly. As @LLFourn suggested, this PR makes a relatively large bump, hoping this buys us enough time to finish splitting up BDK, which will allow us to have a lower MSRV for the "core" crate.

  ### 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 updated `CHANGELOG.md`

ACKs for top commit:
  notmandatory:
    ACK cca69481eb7edb28532a4ed78185248d410050ac

Tree-SHA512: bc6572dc94e1c4cbb6d21f6e06a9730af5763fb4811311a61a6a6ec850b5a65664a21e4a7070a3ebcd702529fbba97b2e9a43c1277b9b9f092e194f16a39bc1a

3 years agoBump MSRV to 1.56
Alekos Filini [Tue, 3 May 2022 10:41:22 +0000 (12:41 +0200)]
Bump MSRV to 1.56

3 years agoMerge bitcoindevkit/bdk#557: add OldestFirstCoinSelection
Alekos Filini [Mon, 25 Apr 2022 14:45:43 +0000 (16:45 +0200)]
Merge bitcoindevkit/bdk#557: add OldestFirstCoinSelection

6931d0bd1f044bf73c0cb760c0eb0be19aea8de1 add private function select_sorted_utxso to be resued by multiple CoinSelection impl (KaFai Choi)
545beec743412717895d0ba5d32ccd9aac68f4a6 add OldestFirstCoinSelection (KaFai Choi)

Pull request description:

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

  ### Description
  This PR is to add `OldestFirstCoinSelection`. See this issue for detail https://github.com/bitcoindevkit/bdk/issues/120
  <!-- Describe the purpose of this PR, what's being adding and/or fixed -->

  ### Notes to the reviewers
  Apologize in advance if the quality of this PR is too low.(I am newbie in both bitcoin wallet and rust).

  While this PR seemed very straight-forward to me in the first glance, it's actually a bit more complicated than I thought as it involves calling DB get the blockheight before sorting it.

  The current implementation should be pretty naive but I would like to get some opinion to see if I am heading to a right direction first before working on optimizations like

  ~~1. Avoiding calling DB for optional_utxos if  if the amount from required_utxos are already enough.~~ Probably not worth to do such optimization to keep code simpler?

  ### 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
  * [x] I've updated `CHANGELOG.md`

  #### 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:
  afilini:
    ACK 6931d0bd1f044bf73c0cb760c0eb0be19aea8de1

Tree-SHA512: d297bbad847d99cfdd8c6b1450c3777c5d55bc51c7934f287975c4d114a21840d428a75a172bfb7eacbac95413535452b644cab971efb8c0b5caf0d06d6d8356

3 years agoMerge bitcoindevkit/bdk#582: Expose bip39::Error
Alekos Filini [Mon, 25 Apr 2022 14:14:38 +0000 (16:14 +0200)]
Merge bitcoindevkit/bdk#582: Expose bip39::Error

c752ccbddeaa5ae441cc74a1386c1e412a447104 Expose bip39::Error (志宇)

Pull request description:

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

  ### Description

  Expose `bip39::Error` (fixes #581 )

  ### Notes to the reviewers

  I am aware that the `bip39` module plans to be rewritten (as per #561 ), however this seems like a rather straightforward and quick change that may be useful in the short/mid term.

  ### Checklists

  #### Bugfixes:

  * [x] Expose `bip39::Error`

ACKs for top commit:
  afilini:
    ACK c752ccbddeaa5ae441cc74a1386c1e412a447104

Tree-SHA512: 98b7ac1ba88aed07d9160830ee80496c32d531c15ada0e9b50a97f0883fbfced22fa83a7c7f8366aadb7e7a667d8a63dde869d31cc375206d277e55b2ec3089d