This merges the Miniscript policy semantic analysis we perform both when
parsing a descriptor and when gathering information about a Liana
descriptor in one, right, place: the analysis submodule.
ebf5a294ad gui: fix some clippy warning (Antoine Poinsot)
cf3e9cafe0 ci: run clippy using Rust 1.67.1 (Antoine Poinsot)
8965758421 bitcoind: fix a clippy warning about lifetime ellision (Antoine Poinsot)
Pull request description:
FIx clippy lints and bump the clippy version for the daemon. Also fix some lints for the GUI (there are some false positives that couldn't be fixed though).
ACKs for top commit:
darosior:
self-ACK ebf5a294ad -- trivial
Tree-SHA512: 3fccbce67637d417da1758584f1d4f027e1536054b21c7abafc2e6b70e65901abb373a1ffc7fc7efbbbdf5c504ccde9df75e477d72ecd46a8b7798ce7985f64d
20f394a452 random: add a commented-out test i used to run ENT (Antoine Poinsot)
157eea9893 lib: re-export the bip39 dependency (Antoine Poinsot)
50f13d3e2e signer: allow to the set the network for extended keys encoding (Antoine Poinsot)
f5e7632c73 signer: expose a method for signing a PSBT (Antoine Poinsot)
b88874107e signer: add a method to get the xpub at a given path (Antoine Poinsot)
59e55ae9f2 signer: implement mnemonics storage, and initialization from storage (Antoine Poinsot)
d341b6dea9 signer: cache the master xpriv (Antoine Poinsot)
6e3b951e54 signer: a new module with a BIP39-based hot signer (Antoine Poinsot)
Pull request description:
This introduces a new `signer` module. Its purpose is to provide clients of the Liana daemon (such as the GUI) with tools to sign transactions.
For now, the only signer available is a hot signer based on BIP39. It allows to generate new mnemonics from OS-provided randomness (with added randomness from the CPU if available and mixed-in contextual data). Mnemonics are stored in plaintext in a `mnemonics` folder at the root of a provided data directory.
Fixes#49.
ACKs for top commit:
edouardparis:
ACK 20f394a452
Tree-SHA512: 299476fdec69139cab9428e8466b4d320798ecd91a08251cac9d1fb086e43cffdb296eca4061a022a7182b5df2101977bb8300ead0d31f3f75988792145bba7f
https://www.fourmilab.ch/random/
Entropy = 8.000000 bits per byte.
Optimum compression would reduce the size
of this 912444480 byte file by 0 percent.
Chi square distribution for 912444480 samples is 254.09, and randomly
would exceed this value 50.43 percent of the times.
Arithmetic mean value of data bytes is 127.4952 (127.5 = random).
Monte Carlo value for Pi is 3.141641048 (error 0.00 percent).
Serial correlation coefficient is 0.000022 (totally uncorrelated = 0.0).
fcc1c21dbb descriptors: use the origin as xpub UID in partial spend info, not the fingerprint (Antoine Poinsot)
4af1a12a2a descriptors: fix the spending policy inference (Antoine Poinsot)
Pull request description:
The analysis was assuming missing that a `thresh(2, older(x), thresh(k, key1, key2, ..)` policy could be normalized to `thresh(k + 1, older(x), key1, key2, ..)` when `k == the number of keys` (i.e. in case of a N-of-N multisig). This also merges the analysis logic with the parsing check to make sure we don't introduce any inconsistency.
ACKs for top commit:
edouardparis:
utACK fcc1c21dbb
Tree-SHA512: d12db2ccf43d20fc85ea6f9fdfe2869948d2c63a2af22287c9133cf6f732fe92c7c0c63ba70ea3dfb0c910a93753ebd42cb168b4cf6bd6ccbed4e1cc7028b614
We were using the fingerprint as a stable unique identifier for xpubs in
a descriptor. It's not. For instance, what if a single signer is used
both in the primary and recovery path? The same fingerprint would appear
in both paths and we would mix up the signatures for both paths (ie if a
signature for each was provided, we would count each path as having 2
signatures).
3a573b695e qa: test we discard RBF'd deposits (Antoine Poinsot)
f1532f8afc bitcoin: track expired unconfirmed deposits, remove them from DB (Antoine Poinsot)
ed156543c9 database: permit to remove coins from DB (Antoine Poinsot)
62c4b9a01c bitcoind: cleanup gettx cache and conflict detection in spent_coins (Antoine Poinsot)
201c9f21b6 bitcoin: cache calls to 'gettransaction' when checking for coins confirmation (Antoine Poinsot)
13214c887f qa: test we discard RBF'd deposits when replacement is confirmed (Antoine Poinsot)
Pull request description:
Previously we would not detect whether the transaction for an unconfirmed deposit was still in our mempool. For instance a deposit that was RBF'd would result in us storing two coins, the replaced and the replacement. Keeping the unconfirmed replaced coin forever.
Fix this by dropping unconfirmed coins from our database if their transaction isn't in our mempool (anymore).
Fixes#72.
ACKs for top commit:
edouardparis:
utACK 3a573b695e
Tree-SHA512: 677bedbf8024eb16e5f97264c2e01d733732673548772fc3a97868b9ca42a0429ad8c0d888b05d3bb2db9b85d309c418b916c9af578f54e499b5d0689376a1b0
This is the same logic as the (cleaner) one we introduced in
confirmed_coins. Merge the two in a single CachedTxGetter, unfortunaly
at the expense of having to clone() the GetTxRes for now because i don't
want to fight with the borrow checker.
It would be possible for users to create a descriptor with xpubs without
an origin set. In fact, not many are used to origins and it's a very
likely mistake. Signers need this information in order to be able to
sign. So they could potentially create a wallet and potentially never be
able to sign for one or multiple keys.
Fix this by requiring an origin for all keys in the descriptor.
We were checking the bitcoind version *after* trying to create a
watchonly wallet with a Miniscript descriptor, which defeats the purpose
of the check.
Fixes#284.
We only allow to create "legacy" multisigs for now (that is, what fits
in a CHECKMULTISIG, ie k-of-n with n<=20). See
https://github.com/wizardsardine/liana/issues/53 for discussions around
this.
We are a bit more laxist on parsing, where any miniscript that
corresponds to a multisig policy will be accepted.
Note this makes the helper inferring the CSV value from semantic policy
incorrect, but this is fix in a later commit as part of a complete
refactor of this logic.
Multiple change indexes may be present in a spend
draft transaction and can be detected instead
in the response psbt with the bip32_derivation
outputs fields.
48e4909e7a daemon: store the watchonly wallet file in bitcoind's datadir on Windows (Antoine Poinsot)
Pull request description:
Turns out that providing an absolute path to bitcoind when loading a wallet on Windows results in surprising behaviour.
ACKs for top commit:
edouardparis:
ACK 48e4909e7a
Tree-SHA512: b432460d529cf5b879361452af1e7947ec877c293f8a8a2e1740975a2957c0cdb288d1f9a1fa07e56193c7c65edf1f985d9e24dd3412f2bfc10922df239de766