429 Commits

Author SHA1 Message Date
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
Antoine Poinsot
85fdc40366
descriptor: encapsulate PSBT in/out information update
It'll make it easier to switch to update Taproot info.
2024-03-13 16:49:45 +01:00
Antoine Poinsot
f7924fb9dc
descriptors: lifting *can* fail
Not sure what i was thinking when writing this.
2024-03-13 12:02:50 +01:00
Antoine Poinsot
8d33f49935
Merge #965: poller: unspend expired before new spend
cc1de1d6d6710f1426a957806661e7f3461a7cb5 poller: unspend coins before spending new (jp1ac4)
1e7653e08a3778446ff677bb147df68b734a31fd tests: add function to wait while condition holds (jp1ac4)

Pull request description:

  This change ensures that the spend txid of a coin is updated directly to another value in case a conflicting spend is detected.

  The previous order caused the spend txid to first be cleared, which would misleadingly make the coin appear as confirmed
  rather than spending.

  I've added a new utils function for the functional tests that is a slight generalisation of `wait_for` with an additional condition that must always be met while waiting.

  `wait_for` now calls this new function with the condition being one that is always true.

ACKs for top commit:
  darosior:
    ACK cc1de1d6d6710f1426a957806661e7f3461a7cb5

Tree-SHA512: e3f00804a63b0e94bc1b2cbee03cac63dd6e2555ca6d301589b356b2baf8e0cf27362e1dda44018d1d8282e300b187079fcf61f5d2754263b9e8b08cd34be06e
2024-03-12 08:47:41 +01:00
jp1ac4
cc1de1d6d6
poller: unspend coins before spending new
This change ensures that the spend txid of a coin is updated
directly to another value in case a conflicting spend is
detected.

The previous order caused the spend txid to first be cleared,
which would misleadingly make the coin appear as confirmed
rather than spending.
2024-03-11 15:41:17 +00:00
Antoine Poinsot
16afa3e992
Merge #987: lib: expose random module
daf60264d16a554f8877f28e11b5df6eab33d324 lib: expose random module (jp1ac4)

Pull request description:

  This is motivated by #929. The GUI will need to generate a salt and password for RPC user/password authentication to the managed bitcoind, and can use this module to get random bytes.

ACKs for top commit:
  darosior:
    utACK daf60264d16a554f8877f28e11b5df6eab33d324

Tree-SHA512: a6ba822bffc6f3d2e5c96be986cb5f1024640b5e71b3bb8a611080e5bcc734b25281fbc52cc1eb15f89d7c72cac8495c163a630758f66ac7e72410ecb7be34cb
2024-03-09 20:00:40 +01:00
jp1ac4
bfd6ca517b
commands: increment receive index on each use
This is a similar fix as for the change index.
2024-03-09 19:15:30 +01:00
jp1ac4
cc5e396ace
commands: increment change index on each use
This is a fix to ensure the change index in the database is
incremented if a new spend is created with a change
address derived from the current index, regardless of whether
this new spend is broadcast or not.
2024-03-09 19:15:28 +01:00
jp1ac4
c88224ca71
testutils: fix change_index 2024-03-09 19:08:58 +01:00
Antoine Poinsot
f19e872814
Merge #958: database: convert CoinStatus to listcoins argument string
fa39e2ced460918d6c6c94c0e2b7dae19b612fa9 database: convert `CoinStatus` to `listcoins` argument string (jp1ac4)

Pull request description:

  This is a preliminary PR towards https://github.com/wizardsardine/liana/issues/677 and is the counterpart to the existing `CoinStatus::from_arg()` method.

  This is needed so that the GUI can pass the required string arguments to the `listcoins` RPC command when using an external Liana daemon.

ACKs for top commit:
  edouardparis:
    ACK fa39e2ced460918d6c6c94c0e2b7dae19b612fa9

Tree-SHA512: e555739e641e4be66ce4942e8294606ab001572395ed73a6c40fa2af38f076357a7c3acba4e4d756fb6d334a11107827a95c53d3f3aecfe32ceca80fc85af83a
2024-03-09 19:06:01 +01:00
Antoine Poinsot
cf299b997b
Merge #957: Get genesis timestamp from bitcoind
f2c418f79a6fe8f1d6138b12af9fdc7303b4725d get genesis timestamp from bitcoind (pythcoiner)

Pull request description:

  fixes #904

ACKs for top commit:
  jp1ac4:
    ACK f2c418f79a.

Tree-SHA512: 7b1b7c13c21b657109ab0aab0d89deb47f5f6693f95687b86c219fc109ee304c38e3ebe865d071ebbbfa890a6a754c615f5dd70f2fe8c492bdea35d0394f36eb
2024-03-09 19:04:00 +01:00
Antoine Poinsot
1819988b3f
Merge #921: Add optional txids param to listspendtxs
da1ebce5b6328f8f5636192e7434d1ba598d5516 add txids param to listspendtxs (pythcoiner)

Pull request description:

  fix #862
  - [x] daemon
  - [x] tests
  - [x] doc

ACKs for top commit:
  jp1ac4:
    ACK da1ebce5b6.

Tree-SHA512: 9696a8077bce2ba8f2abc9eda6a4cdc8654c83ffd61bc5b8419ca50e5ecc447dc78d2059e608c16e94306c27f2aaf21a77c879d21a54f24a049337545750cef7
2024-03-09 18:55:01 +01:00
Antoine Poinsot
1fe5acb673
Merge #873: commands: include unconfirmed change as coin selection candidates
c0d432057df6b2f0bc879f718489c761867fa88c spend: add warning about fee for ancestor (jp1ac4)
a38c1739b6d6bdc5944e2300f1cdf9121babf7d1 spend: return additional fee paid for ancestors (jp1ac4)
62bb4aded43a379bcf5607fd48c492fcfb84bfd5 commands: include unconfirmed change as candidates (jp1ac4)
b05b0f14e5e08ab32e78ea263531d8a587c5b184 commands: add ancestor info for user-selected unconfirmed coins (jp1ac4)
94ef66c03a17221cc9cddb8d1d463a46f0b489c9 spend: increase candidate weight to pay for ancestor (jp1ac4)
5f0022083df8354ceb03d79311317e378296629d bitcoin: add mempool_entry to interface (jp1ac4)
edbf00f17c3796dc326bfbe6ae8833c201bdc045 bitcoin: add ancestor size and fees to mempool entry (jp1ac4)
04503225bcd066dd7d4099997c56b836c29d5b31 func test: use utils function (jp1ac4)

Pull request description:

  This is a first PR towards resolving #826 that adds unconfirmed change as coin selection candidates when creating a spend.

  As per https://github.com/wizardsardine/liana/issues/826#issuecomment-1853058734, I haven't made any changes to the `rbfpsbt` command.

  We will also need to apply the same change in the GUI when selecting candidates for coin selection there (see https://github.com/wizardsardine/liana/pull/863#discussion_r1422823362).

ACKs for top commit:
  darosior:
    ACK c0d4320

Tree-SHA512: 8c17f5f8c32913f1ffae3a93ca3e8ee52ac40ee86790e41d73def5ed0c057e110e101797f778715fcd5f6bded1cd170618209323b5114a4f69c02d0ce066a2f2
2024-03-09 18:48:54 +01:00
jp1ac4
fa39e2ced4
database: convert CoinStatus to listcoins argument string 2024-03-08 08:16:04 +00:00
jp1ac4
daf60264d1
lib: expose random module
This is motivated by the GUI needing to generate a salt and
password for RPC user/password authentication to the
managed bitcoind.
2024-02-28 19:18:45 +00:00
Antoine Poinsot
e9bd8805e5
descriptors: fix derived key parsing and formatting 2024-02-27 13:03:11 +01:00
pythcoiner
da1ebce5b6 add txids param to listspendtxs 2024-02-24 21:56:48 +01:00
pythcoiner
f2c418f79a get genesis timestamp from bitcoind 2024-02-11 01:59:49 +01:00