446 Commits

Author SHA1 Message Date
Antoine Poinsot
1f8d17e414
Merge #1212: DesKeyChecker.check() => check the change multipath is not hardened
8d495579e1f0b2bd329d3d299e707491c02a31bd lianad: DesKeyChecker.check() => check the change multipath is not hardened (pythcoiner)

Pull request description:

  This PR add a check to verify that the change descriptor is not hardened.
  without this check it allow import of invalid (not  derivable change) multipath like <0;1'> into a LianaDescriptor.

  closes #1183

ACKs for top commit:
  jp1ac4:
    ACK 8d495579e1f0b2bd329d3d299e707491c02a31bd.
  darosior:
    ACK 8d495579e1f0b2bd329d3d299e707491c02a31bd

Tree-SHA512: f003fa7b819fa03f84126794b30371419208f1ab4f9e36df2f640dd1c1d20564db7bf1abb9897942e5c43f12e7547f01f07dabf2e8ad1df2e1a3218616883444
2024-08-05 11:54:31 +02:00
Antoine Poinsot
90df14ce57
Merge #1180: Save transactions in database
bf1e90e0fa7f357dc5fb20c12e454f58433dd898 sqlite: merge two migration tests (jp1ac4)
e8836757c70b67ea08a3091b960ff6164422d2b9 sqlite: add a unit test for migration between v4 and v5 (Antoine Poinsot)
af5fddfc4953eb49cf1cb0e56bbb4c947cc95364 commands: use database for TxGetter (jp1ac4)
a86d12d629c0197b9611b36a1b133cf3f7d41dc8 commands: get wallet transactions from db (jp1ac4)
afa6a5160160e265ae5dd427e9ffe6daea14885b poller: save transactions in database (jp1ac4)
ba4c819918ef218d2732e6614a62500f53b8b000 sqlite: separate DB migration from constructor (Antoine Poinsot)
50e7ffafa4b2ad008e0949e940d00a020b7fa4fa lib: setup the connection to bitcoind before the connection to SQLite. (Antoine Poinsot)

Pull request description:

  This is the first step of https://github.com/wizardsardine/liana/issues/56#issuecomment-2183063784.

  The poller will now save transactions in our own database. These transactions are selected based on the deposit and spend transactions of coins. Only the txid and transaction itself are saved, with the corresponding block height and time taken from the coins table.

  In a couple of follow-up commits, I've replaced some RPC calls to bitcoind with DB queries.

ACKs for top commit:
  darosior:
    re-ACK bf1e90e0fa7f357dc5fb20c12e454f58433dd898

Tree-SHA512: a1d0a6381efe307655b94a3ff257c58e4d921e98a7fa79e5c9f80016c19df761b10266d4122cb290b78424c5e2acefc163683fcfc948950e3c838e39ba31ba57
2024-08-02 12:01:19 +02:00
jp1ac4
bf1e90e0fa
sqlite: merge two migration tests 2024-08-02 10:49:33 +01:00
Antoine Poinsot
e8836757c7
sqlite: add a unit test for migration between v4 and v5 2024-08-02 10:49:32 +01:00
jp1ac4
af5fddfc49
commands: use database for TxGetter 2024-08-02 10:49:32 +01:00
jp1ac4
a86d12d629
commands: get wallet transactions from db 2024-08-02 10:49:31 +01:00
jp1ac4
afa6a51601
poller: save transactions in database
This includes changes from darosior's commits:
3e7d968508a71ffa740576d6bf9432611e78f4a5
e2225a5110ca981c340eef329182e702b375b55f
2024-08-02 09:41:16 +01:00
Antoine Poinsot
ba4c819918
sqlite: separate DB migration from constructor
This is a slightly modified version of darosior's commit:
d826f9fa6336de6eb293a85af044c2c95550cfb5
2024-08-02 09:39:31 +01:00
pythcoiner
8d495579e1 lianad: DesKeyChecker.check() => check the change multipath is not hardened 2024-08-02 07:08:38 +02:00
Antoine Poinsot
50e7ffafa4
lib: setup the connection to bitcoind before the connection to SQLite. 2024-07-30 13:18:11 +01:00
Antoine Poinsot
b2aeafab56
Merge #1186: Add minimum feerate to TooLowFeerate error message
8be0d9856b29eb30593ae7614fe74430ffd206d4 commands: add minimum feerate to TooLowFeerate error message (Aaron Carlucci)

Pull request description:

  This PR adds the minimum feerate value into the `TooLowFeerate` error message for additional context. Addresses the second bullet point in #853.

ACKs for top commit:
  jp1ac4:
    ACK 8be0d9856b29eb30593ae7614fe74430ffd206d4. Thanks!

Tree-SHA512: 3a0e9c69ddb40433faf1e58c16dfee0212641b34478eddeda99388ebf82e2fb466633ab8f79c9bb0bb784f4a46807aa0a5abd65b9d92506144b84addb01dfdd8
2024-07-29 13:53:27 +02:00
Antoine Poinsot
bb68fb5ec1
Merge #1092: spend: randomized anti-fee sniping
f2791744d8ad3068d12a39bb07f3745012785a5f spend: set locktime for anti-fee sniping (jp1ac4)

Pull request description:

  This is to resolve #44.

  In the first commit, I combine the destinations and change parameters in `spend::create_spend` in order to avoid "too many arguments" error when adding a new parameter. I think these two parameters combine naturally so that `destinations` includes both recipients and change address.

  The second commit sets locktime following the same approach as Bitcoin Core:
  - locktime is set to current tip height, but randomly (about 10% of cases) value is set up to 100 blocks earlier
  - if tip is more than 8 hours old, locktime is set to 0

  For randomness, I'm currently using the current time's milliseconds in order not to add another dependency, which I think is good enough for this use case.

  For consistency, I decided to use "locktime" everywhere instead of "lock time" or "lock-time".

ACKs for top commit:
  darosior:
    ACK f2791744d8ad3068d12a39bb07f3745012785a5f

Tree-SHA512: 69a57cf664e24b32a835c35eaf9016961b2d0f396891a826582044e6302b2ca04dcf5bf2617b5e18dcbfa25cc254a6e8025262718984095677c829ce051a66cc
2024-07-29 12:32:29 +02:00
Aaron Carlucci
8be0d9856b commands: add minimum feerate to TooLowFeerate error message 2024-07-10 14:47:10 +02:00
Antoine Poinsot
168112de10
Bump version to 6.0 2024-06-27 15:53:30 +02:00
pythcoiner
a8e256eb6b clippyfy 2024-06-25 03:01:29 +02:00
jp1ac4
0eda557fdf
descriptors: improve satisfaction size estimate for primary path
Thanks to darosior for providing the changes to `max_sat_weight`
and the Taproot sanity checks test.
2024-06-20 17:09:38 +01:00
jp1ac4
f2791744d8
spend: set locktime for anti-fee sniping 2024-05-28 07:50:48 +01:00
Antoine Poinsot
bf2e8b5699
Merge #953: [Daemon] Add -v/--version/-h/--help args
cd0e69ab237b7fb33aebebb4ca9bad12f06239fe add -v/--version and -h/--help args (pythcoiner)

Pull request description:

  ![image](https://github.com/wizardsardine/liana/assets/124568858/5822e3de-f7f8-4943-8c13-3aff05dca3b5)

ACKs for top commit:
  darosior:
    ACK cd0e69ab237b7fb33aebebb4ca9bad12f06239fe

Tree-SHA512: 408e3f4397c43bbe6347f817e9145c8d6f1ff56aec26310b9f3605f181add581ffb34dce6b353507e6d1877a4a6d169fb0887b1ba5797d7f930eb69d4a706f30
2024-04-19 08:28:47 +02:00
jp1ac4
43ecd94a46
spend: change parameter type for rbf
The parameter has been renamed and changed to `Option` as it is
only required when creating a replacement transaction using RBF.
2024-04-05 21:56:17 +01:00
jp1ac4
6376909ea1
commands: remove rbf rule 4 logic
RBF rule 4 is now enforced by coin selection.
2024-04-05 21:54:08 +01:00
jp1ac4
936d7e9585
spend: bump bdk_coin_select to 0.3.0
The `score` method of the `LowestFee` metric has been fixed
and so our temporary fix is no longer required.

The `min_fee` parameter of `select_coins_for_spend`,
if positive, now ensures that RBF rule 4 is satisfied.

`base_weight` is no longer stored in `CoinSelector` and
instead the output weights are stored in `Target`. This
means that the `output_weight` of `DrainWeights` no longer needs
to take into account a potential change in output count varint.
2024-04-05 21:46:06 +01:00
jp1ac4
5d6ca97e4c
spend: reword warning messages 2024-03-28 11:08:49 +00:00
jp1ac4
f14c3a7f75
spend: fix typo in enum variant 2024-03-27 17:59:16 +00:00
Antoine Poinsot
6d498db5e5
Merge #1034: Prepare v5 release
2dc8cb0d422d2f601c8662df71651c596d15ae36 README: add Coldcard as supported signing device (Antoine Poinsot)
abf15fea3c15ca5f0005417a1490e057d40e6c6b CHANGELOG: release notes for v5 (Antoine Poinsot)
b5c2375d0bb6bef6cd2f0d7534c303fe71118105 doc: update the signing devices compatibility documentation (Antoine Poinsot)
d9337121abe486389514c7b2336e39d2a1f0c8de Bump Liana version (Antoine Poinsot)
de05460ad01145df9bbf63ec58932a72dd1a14d3 doc/BUILD.md: correct MSRV (Antoine Poinsot)

Pull request description:

ACKs for top commit:
  darosior:
    self-ACK 2dc8cb0d422d2f601c8662df71651c596d15ae36 -- not code

Tree-SHA512: b84ea6dabf3ff41ac9b61c6ee8ef7cbbdb5942d13bff83b70e60c93e2f61a14db164b7987129cfde5fd59a667297e2832458f62f0e979d949667d0cc2c168f37
2024-03-25 16:33:51 +01:00
Antoine Poinsot
62efd33342
Merge #1001: commands: exclude immature coins from auto-selection
f9bae9cc0814d909a72a800d9f6d7ced2f99f06d database: add migration from db version 3 to 4 (jp1ac4)
2c96ef57bd606524223da037375ef351ea69e949 commands: exclude immature coins from coin selection (jp1ac4)
3a7c151674c487dd11f4f2d1db78d468f5f087a9 database: allow for coinbase transactions to change addresses (jp1ac4)

Pull request description:

  As a follow-up to #873, this ~~adds a comment to make clear that immature coins are not included as candidates for auto-selection~~ excludes immature coins from auto-selection.

  An unconfirmed coin could be both immature and marked as change, as the latter only depends on whether the address is derived from the wallet's change descriptor. I've also removed a corresponding assertion that may not always hold.

ACKs for top commit:
  darosior:
    ACK f9bae9cc0814d909a72a800d9f6d7ced2f99f06d -- this is very nice. Again, great catch. And thanks for adding a more extensive unit test.

Tree-SHA512: 12abe3dd18723db58ff701f664c6085e7fd29d39fefa7206e3e00fa5fb3e3b4320720c183a9719a3a0f3124896347ac74571b45a54bd504d674f779913466c16
2024-03-25 16:16:05 +01:00
jp1ac4
f9bae9cc08
database: add migration from db version 3 to 4 2024-03-25 11:49:48 +00:00
Antoine Poinsot
d9337121ab
Bump Liana version 2024-03-22 16:42:33 +01:00
Antoine Poinsot
58c71c794a
lib: gate the RPC server availability on the 'daemon' feature
This is a temporary hack. We should improve this API.
2024-03-21 12:50:04 +01:00
Antoine Poinsot
b7fde6a9e4
commands: update our state immediately after broadcasting a tx 2024-03-21 12:49:12 +01:00
Antoine Poinsot
1cf42d9aee
poller: introduce a communication channel with the poller thread
We'll need to ask the poller thread another thing besides to shut down,
so it's cleaner to start using proper messages.

The mpsc channel in the std lib was buggy for awhile but since they
merged crossbeam and are using this behind the hood now it should be
fine starting with Rust 1.67. That's (slightly) higher than our MSRV but
it's what we use for releases so that's reasonable. See
https://github.com/rust-lang/rust/issues/39364 for details.
2024-03-21 12:47:11 +01:00
Antoine Poinsot
f6ce85cfd3
lib: remove the panic hook.
We now provide a way for a user of the daemon to poll for errors in the
threads, so aborting the process on a thread panic shouldn't be
necessary anymore.
2024-03-20 20:22:42 +01:00
Antoine Poinsot
b4fe963a5b
lib: encapsulate the handling of both threads (poller and RPC server)
This is inspired from the work in
https://github.com/wizardsardine/liana/pull/909 (specifically
d8c59e30ed)
to externalize the management of the poller thread. However, there may
be only one poller thread. Starting more than one can lead to a crash or
potentially to data corruption. Therefore it feels safer to manage it
internally.

Instead of exposing the management of the poller to the user of the
library, we manage both threads inside the `DaemonHandle` data structure
and expose a way for a user to check for errors which may have occured
in any of the threads.

This makes it possible to:
1. Eventually propagate errors from the threads to the user of the
   daemon (https://github.com/wizardsardine/liana/pull/909);
2. Communicate internally with the poller thread, for instance to
   trigger a poll immediately (following commits).
2024-03-20 20:22:41 +01:00
Antoine Poinsot
fd5387f954
poller: use the same database connection across one update round 2024-03-20 20:22:32 +01:00
Antoine Poinsot
ea6923e2c0
poller: make the updating process into its own function. 2024-03-20 20:22:31 +01:00
jp1ac4
2c96ef57bd
commands: exclude immature coins from coin selection
An immature coin could in principle be marked as change
as this depends only on whether the address is derived from
the wallet's change descriptor.
2024-03-20 18:29:38 +00:00
jp1ac4
3a7c151674
database: allow for coinbase transactions to change addresses
`is_change` is `true` for a coin if its address is derived
from our change descriptor and could in principle be used for a
coinbase transaction.

The functional test was provided by darosior in a PR comment:
https://github.com/wizardsardine/liana/pull/1001#pullrequestreview-1948564150
2024-03-20 18:29:37 +00:00
Antoine Poinsot
52c3613568
descriptors: adapt 'change_indexes()' to Taproot
We match on both the legacy and the Taproot field in the PSBT output. It shouldn't matter since we already assume the PSBT is well-formed.
2024-03-20 10:44:50 +01:00
Antoine Poinsot
0c65d20569
descriptors: encapsulate change_indexes unit test 2024-03-20 10:41:56 +01:00
pythcoiner
cd0e69ab23 add -v/--version and -h/--help args 2024-03-19 19:31:14 +01:00
Antoine Poinsot
96d30db5b8
signer: taproot support in hot signer 2024-03-13 19:21:52 +01:00
Antoine Poinsot
80a7dc32aa
signer: move p2wsh signing into a dedicated function 2024-03-13 19:21:51 +01:00
Antoine Poinsot
d6222583be
command: also update Taproot sigs in 'updatespend' 2024-03-13 19:21:51 +01:00
Antoine Poinsot
714bd3c4ed
spend: check for either p2wsh or Taproot sigs in sanity checks 2024-03-13 19:21:50 +01:00
Antoine Poinsot
e05039f67b
spend: don't populate non_witness_utxo for Taproot 2024-03-13 19:21:50 +01:00
Antoine Poinsot
8596ca76f3
bitcoind: compare descriptors, not their string representation.
It's more robust and bitcoind serializes `wsh()` descriptors using `'`
as hardened marker and `tr()` descriptors using `h`..
2024-03-13 19:21:49 +01:00
Antoine Poinsot
602c862118
bitcoind: sanity check min supported version for Taproot descriptor
TapMiniscript support was only released in 26.0:
https://bitcoincore.org/en/releases/26.0
2024-03-13 19:21:48 +01:00
Antoine Poinsot
d3b7e4cc44
config: unit test a valid config with a Taproot descriptor 2024-03-13 19:21:48 +01:00
Antoine Poinsot
6cf8eaab3b
config: deser_from_str isn't descriptor specific. 2024-03-13 19:21:47 +01:00
Antoine Poinsot
04f4b8a744
descriptors: Taproot support
We introduce support for tr() descriptors alongside wsh() descriptors in
creating (compiling from policy, parsing from string) and working with
(analyizing its policy, getting spend information) a descriptor.

When compiling a Taproot descriptor, if no key from the policy could be
used as single internal key we deterministically generate an unspendable
internal key as per
https://delvingbitcoin.org/t/unspendable-keys-in-descriptors/304/21.
Similarly when lifting the policy of a Taproot descriptor, if the
internal key matches the deterministic unspendable key for this
descriptor we discard it from the analysis.

To fill information about an output for signers, we re-use
rust-miniscript PSBT input updated instead of re-inventing the wheel. It
does necessitate a hack however to use a type they would accept.

We don't change the "max size of a spending input" for now, even though
it means we would significantly overpay fees for descriptors with a
spendable internal key.
2024-03-13 19:21:47 +01:00
Antoine Poinsot
c897d41965
descriptors: encapsulate key matching logic
It will be useful when we introduce Taproot support in the next commit.
2024-03-13 19:21:46 +01:00