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
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
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
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
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.
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
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.
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.
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).
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.