403 Commits

Author SHA1 Message Date
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
jp1ac4
c0d432057d
spend: add warning about fee for ancestor 2024-01-26 07:43:19 +00:00
jp1ac4
a38c1739b6
spend: return additional fee paid for ancestors 2024-01-25 14:57:58 +00:00
jp1ac4
62bb4aded4
commands: include unconfirmed change as candidates 2024-01-25 14:57:56 +00:00
jp1ac4
b05b0f14e5
commands: add ancestor info for user-selected unconfirmed coins 2024-01-25 14:55:07 +00:00
jp1ac4
94ef66c03a
spend: increase candidate weight to pay for ancestor 2024-01-25 14:55:06 +00:00
jp1ac4
5f0022083d
bitcoin: add mempool_entry to interface 2024-01-25 14:55:06 +00:00
jp1ac4
edbf00f17c
bitcoin: add ancestor size and fees to mempool entry 2024-01-25 14:55:06 +00:00
Antoine Poinsot
3aa9550a89
Merge #922: descriptors: add a method to get a PSBT's change outputs
39299263954b4d29f6bdcb177e9b2377d1ea92ed descriptors: add a method to get a PSBT's change outputs (Antoine Poinsot)
c6b554da93bdc90b0c2a6cb70d962fcaaf718aff descriptors: unit test we do take into account derivation steps before wildcard and multipath (Antoine Poinsot)

Pull request description:

  Fixes #857.

ACKs for top commit:
  darosior:
    ACK 39299263954b4d29f6bdcb177e9b2377d1ea92ed -- re-applying Edouard's ACK. Only change is the addition of an `index()` method on the `ChangeOutput` enum.

Tree-SHA512: fceaa4e492684be08d45ab09d74345d5825b73d930f5caa4162862e5ff94f32cd5e9ab23b0730bc7ef44569c8e10cfed0f343b4843590a2163122d3402fc3734
2024-01-24 11:28:51 +01:00
Antoine Poinsot
3929926395
descriptors: add a method to get a PSBT's change outputs 2024-01-24 11:26:00 +01:00
Antoine Poinsot
79141e2042
Merge #927: commands: include missing amount in spend response
13398982534d56a5723dfa86723c5917483c8653 commands: include missing amount in response (jp1ac4)

Pull request description:

  This PR follows a discussion around https://github.com/wizardsardine/liana/pull/873#issuecomment-1886715468.

  The GUI uses the `InsufficientFunds` error to get the missing amount when the user is creating a new spend, but it is not straightforward to extract this information in a general way from the RPC error (see https://github.com/wizardsardine/liana/issues/822#issuecomment-1836482355) and instead the spend module's `create_spend` is currently used (see https://github.com/wizardsardine/liana/pull/863).

  With this PR, the missing amount will be included in the `createspend` response rather than as an error.

  These changes are based on suggestions from @darosior and @edouardparis.

  In a follow-up PR, the GUI should revert to using the `createspend` command to calculate the amount left to select.

ACKs for top commit:
  darosior:
    re-ACK 1339898

Tree-SHA512: bf702d6b355339e96e719c1d95824e7941ac4fbaece4ec4cccd00b56ea4683ce7fb0cefc43faa5731b57e7935ef99da3a2c73b84aaeb9fa5f67703c799be2196
2024-01-23 17:33:48 +01:00
jp1ac4
1339898253
commands: include missing amount in response
The GUI uses the InsufficientFunds error to get the missing
amount when the user is creating a new spend.

It is not straightforward to extract this information in a
general way from the RPC error. Instead, this missing amount
will be included in the command response.

These changes are based on suggestions from darosior
and edouardparis.
2024-01-23 15:01:34 +00:00
pythcoiner
79177945ad add timestamp field to getinfo 2024-01-19 13:06:32 +01:00
Antoine Poinsot
c6b554da93
descriptors: unit test we do take into account derivation steps before wildcard and multipath 2024-01-15 18:57:39 +01:00
jp1ac4
5a15c744e7
commands: return warnings from spend creation 2024-01-11 20:06:00 +00:00
jp1ac4
da474ad6ce
spend: add warning when adding change to fee 2024-01-11 20:05:59 +00:00
jp1ac4
8d84f0de86
spend: return max possible change from coin selection 2024-01-11 20:05:59 +00:00
jp1ac4
e4d8330f34
spend: use debug log level in coin selection
This function is now called many times from the GUI via
`create_spend` and we expect this log message to be generated
multiple times.
2024-01-11 20:04:55 +00:00
Antoine Poinsot
d8a5e1d780
Merge #906: Bump MSRV, upgrade dependencies and clippification
0e99136404fcbbdee09eef4b116f17222cb2dee0 Clippification (Antoine Poinsot)
4949632fe6510151df9281b55a049169842ee5ef bitcoin: remove unused import (Antoine Poinsot)
ce026a62e6bf064cea249f391e4ab870f1cbcb61 Update rust-bitcoin and rust-miniscript (Antoine Poinsot)
2bce4c525d51b8ecbc923a43632ef8a724426453 Cargo: bump jsonrpc version to 0.17 (Antoine Poinsot)
65c9e389bb89197c2e9066b82789cec63b18d2d1 Cargo: bump rusqlite to 0.30 (Antoine Poinsot)
84e8a2ae8630789f5b8cc3796e0f1e4ff87614f2 Cargo.lock: update minor dependencies after MSRV bump (Antoine Poinsot)
92328fb8f6e34a383e876a79fad3fee4110c09a5 Bump MSRV for lianad to 1.63 (Antoine Poinsot)

Pull request description:

  New years' cleanup!

  Our MSRV was becoming too restrictive to keep being able to benefit from the latest releases of our dependencies. Strike a better balance between not requiring a recklessly new compiler and still being able to get upstream bug fixes.

  From this update most of our dependencies to their latest point releases. Then upgrade rusqlite, jsonrpc and rust-[bitcoin, miniscript] to their latest major version. Note their is a ton of updates. I've done a minimal due diligence to check what was updated, to what version, what changed, but i can't realistically audit all the code changes this is effectively pulling. I think we need to look into `cargo-crev`.

  Take the opportunity to apply some clippy cleanups, and bump the version we're using in CI.

  See commit messages for details.

ACKs for top commit:
  darosior:
    reACK 0e99136404fcbbdee09eef4b116f17222cb2dee0 -- re-applying jp1ac4's ACK after addressing review

Tree-SHA512: f7940a90065fdf2e9c2013a882955f8f8febe537f8268224a321ae2df2e380c5a34c8c99891b25aa3ee14efe9c5eaaa7ee3ffa6ea163a749cec044db351dd408
2024-01-11 10:48:27 +01:00
Antoine Poinsot
0e99136404
Clippification
Bump clippy in CI to latest stable.
2024-01-11 10:45:41 +01:00
Antoine Poinsot
4949632fe6
bitcoin: remove unused import 2024-01-11 10:45:40 +01:00
Antoine Poinsot
ce026a62e6
Update rust-bitcoin and rust-miniscript
The most notable change is rust-bitcoin's change in the serialization of
transaction with no input. It now accounts for the segwit marker even
for those. The base tx weight in coin selection had to be adapted to
handle this.

See https://gnusha.org/bitcoin-rust/2024-01-04.log for details.
2024-01-11 10:45:36 +01:00
Antoine Poinsot
2bce4c525d
Cargo: bump jsonrpc version to 0.17
It now finally accepts an option as argument.
2024-01-04 14:32:58 +01:00
Antoine Poinsot
a3731fa004
bitcoind: error when trying to rescan past prune height 2024-01-03 11:30:29 +01:00
Antoine Poinsot
5c3763526d
config: redact RPC credentials in Config Debug impl. 2023-12-21 14:27:36 +01:00
jp1ac4
552a49edb2
config: add user:password option for RPC authentication 2023-12-20 15:56:06 +00:00
Antoine Poinsot
6d2833fc18
Drop watchonly wallet migration for old Windows datadir
It was introduced in v2 (released in August 2023) for migrating datadir created using Liana v1 (May 2023).
2023-12-20 11:21:51 +01:00