62 Commits

Author SHA1 Message Date
Alekos Filini
308708952b
Fix type inference for the tr() descriptor, add basic tests 2022-05-31 18:16:24 +02:00
Alekos Filini
c121dd0252
Use tap_key_origins in PSBTs to derive descriptors 2022-05-31 18:16:17 +02:00
Alekos Filini
1312184ed7
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.
2022-05-27 11:48:50 +02:00
Alekos Filini
906598ad92
Refactor signer traits, add support for taproot signatures 2022-05-27 11:48:41 +02:00
Alekos Filini
00164588f2
Stop using deprecated structs 2022-05-12 17:31:48 +02:00
Alekos Filini
a16c18255c
Upgrade to rust-bitcoin 0.28 and miniscript 7.0 2022-05-12 12:51:21 +02:00
Alekos Filini
cca69481eb
Bump MSRV to 1.56 2022-05-04 17:29:07 +02:00
LLFourn
326bfe82a8
Remove Blockchain from wallet
Although somewhat convenient to have, coupling the Wallet with
the blockchain trait causes development friction and complexity.
What if sometimes the wallet is "offline" (no access to the blockchain)
but sometimes its online?
The only thing the Wallet needs the blockchain for is to sync.
But not all applications will even use the sync method and the sync
method doesn't require the full blockchain functionality.
So we instead pass the blockchain in when we want to sync.

- To further reduce the coupling with blockchain I removed the get_height call from `new` and just use the height of the
last sync in the database.
- I split up the blockchain trait a bit into subtraits.
2022-02-24 20:39:00 +11:00
thunderbiscuit
7f8103dd76
Fix typos in comments 2021-11-23 14:09:54 -05:00
Tobin Harding
12de13b95c
Remove redundant borrows
Clippy emits:

  warning: this expression borrows a reference

As suggested remove the borrows from the front of vars that are already references.
2021-06-10 13:16:07 +10:00
Alekos Filini
881ca8d1e3
[signer] Add an option to explicitly allow using non-ALL sighashes
Instead of blindly using the `sighash_type` set in a psbt input, we
now only sign `SIGHASH_ALL` inputs by default, and require the user to
explicitly opt-in to using other sighashes if they desire to do so.

Fixes #350
2021-05-26 10:38:15 +02:00
Riccardo Casatta
f6631e35b8
continue signing when finding already finalized inputs 2021-05-07 13:52:20 +02:00
Riccardo Casatta
7961ae7f8e
Check index out of bound also for tx inputs not only for psbt inputs 2021-05-06 15:13:25 +02:00
Alekos Filini
b5e9589803
[signer] Adjust signing behavior with SignOptions 2021-05-06 08:58:38 +02:00
Alekos Filini
1d628d84b5
[signer] Fix error variant 2021-05-05 16:59:59 +02:00
Riccardo Casatta
192965413c
Convert upper-case acronyms as suggested by CamelCase convention
see https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
2021-04-07 22:14:54 +02:00
davemo88
dc83db273a
better derivation path building 2021-03-11 21:54:00 -05:00
davemo88
201bd6ee02
better derivation path building 2021-03-11 21:35:16 -05:00
davemo88
396ffb42f9
handle descriptor xkey origin 2021-03-11 17:39:02 -05:00
Steve Myers
12ae1c3479
Update license to Apache 2.0 or MIT, copyright to Bitcoin Dev Kit Developers 2021-03-03 13:23:25 -08:00
Tobin Harding
bda416df0a
Use mixed order insertions
Currently we have a unit test to test that signers are sorted by
ordering. We call `add_external` to add them but currently we add them
in the same order we expect them to be in. This means if the
implementation happens to insert them simply in the order they are
added (i.e. insert to end of list) then this test will still pass.

Insert in a mixed order, including one lower followed by one higher -
this ensures we are not inserting at the front or at the back but are
actually sorting based on the `SignerOrdering`.
2021-02-24 13:39:36 +11:00
Tobin Harding
a838c2bacc
Use id() for DummySigner comparison
If we give the `DummySigner` a valid identifier then we can use this to
do comparison.

Half the time we do comparison we only have a `dyn Signer` so we cannot
use `PartialEq`, add a helper function to check equality (this is in
test code so its not toooo ugly).

Thanks @afilini for the suggestion.
2021-02-24 13:37:41 +11:00
Tobin Harding
cb3b8cf21b
Do not compare vtable
Clippy emits error:

 comparing trait object pointers compares a non-unique vtable address

The vtable is an implementation detail, it may change in future. we
should not be comparing vtable addresses for equality. Instead we can
get a pointer to the data field of a fat pointer and compare on that.
2021-02-24 13:30:48 +11:00
Steve Myers
1c6864aee8
Rename ToDescriptorKey to IntoDescriptorKey 2021-02-12 23:23:20 -08:00
Steve Myers
d638da2f10
Rename ToWalletDescriptor to IntoWalletDescriptor 2021-02-12 23:23:20 -08:00
Steve Myers
04348d0090
Fix clippy warning 'wrong_self_convention' 2021-02-12 22:23:48 -08:00
Alekos Filini
3d9d6fee07
Update bitcoin, miniscript, electrum-client 2021-02-05 09:11:27 -05:00
Alekos Filini
c431a60171
[signer] Add Signer::id()
Closes #261
2021-01-27 11:43:28 -05:00
LLFourn
656c9c9da8
Use () to indicate a missing blockchain
So that:
1. There are no runtime errors
2. There less type annotations needed
3. Less traits and stuff to document
2020-12-23 14:52:29 +11:00
Alekos Filini
63aabe203f
Merge commit 'refs/pull/235/head' of github.com:bitcoindevkit/bdk 2020-12-18 10:41:37 +01:00
Alekos Filini
7e90657ee1
[descriptor] Make the syntax of descriptor!() more consistent
The syntax now is pretty much the same as the normal descriptor syntax,
with the only difference that modifiers cannot be grouped together (i.e.
`sdv:older(144)` must be turned into `s:d:v:older(144)`.
2020-12-16 19:00:55 +01:00
Alekos Filini
5f373180ff
Merge commit 'refs/pull/223/head' of github.com:bitcoindevkit/bdk 2020-12-16 11:11:38 +01:00
Alekos Filini
931a110e4e
Merge commit 'refs/pull/229/head' of github.com:bitcoindevkit/bdk 2020-12-16 10:48:10 +01:00
Steve Myers
148e8c6088
[docs] Add docs to the 'wallet' module 2020-12-15 15:12:32 -08:00
Evgenii P
09730c0898
Take ID into account in SignersContainerKey's PartialEq impl 2020-12-15 22:40:07 +07:00
Evgenii P
5315c3ef25
rustfmt 2020-12-15 11:36:26 +07:00
Evgenii P
c58236fcd7
Fix SignersContainer::find to filter out incorrect IDs 2020-12-15 11:36:26 +07:00
Evgenii P
2658a9b05a
Fix SignersContainerKey PartialOrd to respect the ID 2020-12-15 11:36:26 +07:00
Evgenii P
c075183a7b
Revert replacing BTreeMap to HashMap in SingersContainer 2020-12-15 11:35:34 +07:00
Alekos Filini
1713d621d4
Rename ScriptType to KeychainKind
This avoids confusion with the "type of script".
2020-12-14 17:14:24 +01:00
Evgenii P
351b656a82
Use unstable sort by key for performance 2020-12-14 16:27:54 +07:00
Evgenii P
95af38a01d
rustfmt 2020-12-14 01:03:14 +07:00
Evgenii P
3ceaa33de0
Add unit tests for SignersContainer 2020-12-14 01:03:14 +07:00
Evgenii P
5d190aa87d
Remove debug output 2020-12-14 01:02:48 +07:00
Evgenii P
20e0a4d421
Replace BTreeMap with a HashMap 2020-12-13 18:37:27 +07:00
Alekos Filini
7a42c5e095
Switch to "mainline" rust-miniscript 2020-11-17 23:57:28 +01:00
LLFourn
796f9f5a70
Make Signer and AddressValidator Send and Sync 2020-11-03 16:16:32 +11:00
LLFourn
3b3659fc0c
Remove redundant Box around signers 2020-11-03 16:06:43 +11:00
Alekos Filini
872d55cb4c
[wallet] Default to SIGHASH_ALL if not specified
Closes #133
2020-10-16 15:40:30 +02:00
Alekos Filini
100f0aaa0a
Bump rust-bitcoin to 0.25, fix Cargo dependencies
Closes #112, closes #113, closes #124
2020-10-13 10:39:48 +02:00