Commit Graph
202 Commits
Author SHA1 Message Date
Antoine Poinsot 9b866300be descriptors: merge the semantic analysis in one place
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.
2023-03-23 19:15:51 +01:00
Antoine Poinsot cd566b91af descriptors: rename LianaDescInfo into LianaPolicy
What this really represents is a spending policy. We'll extend it to be
able to infer it from a descriptor and to create a descriptor from it.
2023-03-23 16:25:01 +01:00
Antoine Poinsot 757009536b descriptors: make sure there is at least one timelocked path when parsing 2023-03-23 16:10:21 +01:00
Antoine Poinsot eebfa47559 descriptors: move descriptor policy analysis into its own submodule 2023-03-23 16:09:55 +01:00
Antoine Poinsot c0dd63dfb2 descriptors: move the LianaDescKey to the keys submodules 2023-03-23 14:43:18 +01:00
Antoine Poinsot 7772ae8d8a descriptors: move derived keys into their own submodule 2023-03-23 14:37:43 +01:00
Antoine Poinsot 9e78ac7e8d descriptors: make the module a folder. 2023-03-23 14:25:13 +01:00
Antoine Poinsot eebd061981 bitcoin: remove a confusing TODO
We don't assume that and in fact now use multiple descriptors
2023-03-22 14:58:30 +01:00
Antoine Poinsot 2dea4b1a6c Merge #355: Clippification: a little bit of housekeeping
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
2023-03-21 18:51:02 +01:00
Antoine Poinsot b8cd0d0e27 Bump version to 0.3 2023-02-27 14:46:28 +01:00
Antoine Poinsot 8965758421 bitcoind: fix a clippy warning about lifetime ellision 2023-02-17 10:22:08 +01:00
Antoine Poinsot 518eb91064 commands: print the PSBT in base64 on sanity checks failure
To make it readable..
2023-02-17 09:54:43 +01:00
Antoine Poinsot 6e1c41238f commands: have a detailed error for the insane fee sanity check 2023-02-17 09:54:43 +01:00
Antoine Poinsot c711c5b696 commands: don't overestimate the feerate in tx creation sanity checks
It was accounting for the transaction size without witnesses!
2023-02-16 16:09:54 +01:00
edouard 200d3777e0 Merge #293: Hot wallet support
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
2023-02-16 09:26:11 +01:00
Antoine Poinsot 20f394a452 random: add a commented-out test i used to run ENT
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).
2023-02-14 17:41:30 +01:00
Antoine Poinsot 157eea9893 lib: re-export the bip39 dependency 2023-02-14 17:41:30 +01:00
Antoine Poinsot 50f13d3e2e signer: allow to the set the network for extended keys encoding 2023-02-14 17:41:29 +01:00
Antoine Poinsot f10c35e964 daemonize: switch the pid and log file arguments
The caller and the definition had them swapped.. So it was logging to
the PID file and writing the PID to the log file..
2023-02-13 10:56:22 +01:00
Antoine Poinsot f5e7632c73 signer: expose a method for signing a PSBT 2023-02-10 12:21:23 +01:00
Antoine Poinsot b88874107e signer: add a method to get the xpub at a given path 2023-02-10 12:21:22 +01:00
Antoine Poinsot 59e55ae9f2 signer: implement mnemonics storage, and initialization from storage 2023-02-10 12:21:22 +01:00
Antoine Poinsot d341b6dea9 signer: cache the master xpriv 2023-02-10 12:21:21 +01:00
Antoine Poinsot 6e3b951e54 signer: a new module with a BIP39-based hot signer 2023-02-10 12:21:21 +01:00
Antoine Poinsot f8e5bb22ac bitcoind: don't crash on existing watchonly wallet, return an error. 2023-02-09 17:03:53 +01:00
Antoine Poinsot b43a90d52a lib: on Windows, delete leftover watchonly wallet in bitcoind datadir 2023-02-09 17:03:52 +01:00
edouard 0f71cbd7c5 Add wallet path in bitcoind errors related to wallet 2023-02-08 14:24:36 +01:00
Antoine Poinsot 9996483112 Merge #321: Descriptor spending policy inference fixes
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
2023-02-06 11:43:12 +01:00
Antoine Poinsot fcc1c21dbb descriptors: use the origin as xpub UID in partial spend info, not the fingerprint
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).
2023-02-05 14:31:24 +01:00
Antoine Poinsot 4af1a12a2a descriptors: fix the spending policy inference
This also cleans it up as well as merging the checks in the parser with
the analysis in the info() helper to be more confident they are
consistent.
2023-02-05 13:43:40 +01:00
Antoine Poinsot af058d59e3 bitcoind: detect deposits from (mature) coinbase transactions 2023-02-04 13:21:20 +01:00
Antoine Poinsot 72fc42bc38 descriptors: mention origin requirement in invalid key error 2023-02-03 18:32:05 +01:00
Antoine Poinsot d0de88bc01 daemon: release 0.2 2023-02-03 16:10:20 +01:00
Antoine Poinsot 83314edd7f Merge #308: Handle unconfirmed deposits that were replaced
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
2023-02-03 14:59:49 +01:00
Antoine Poinsot bd6f84421a Merge #299: Perform the bitcoind version sanity check before loading the watchonly wallet
9c7613fc14 lib: perform node-related bitcoind sanity checks before loading the wallet (Antoine Poinsot)

Pull request description:

  Fixes #284.

ACKs for top commit:
  edouardparis:
    ACK 9c7613fc14

Tree-SHA512: 3f2ec8ae7b1e426d214dbd693af90bebea305572a5c1dc903eff8c93de74cd964a7e463bfe65c7447bf9537f79c6b6d24354c93dd71374c9a8d8141adfce30a2
2023-02-03 13:25:45 +01:00
Antoine Poinsot f1532f8afc bitcoin: track expired unconfirmed deposits, remove them from DB 2023-02-03 13:17:26 +01:00
Antoine Poinsot ed156543c9 database: permit to remove coins from DB 2023-02-03 12:57:44 +01:00
Antoine Poinsot 62c4b9a01c bitcoind: cleanup gettx cache and conflict detection in spent_coins
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.
2023-02-03 12:57:43 +01:00
Antoine Poinsot 201c9f21b6 bitcoin: cache calls to 'gettransaction' when checking for coins confirmation 2023-02-03 12:57:42 +01:00
edouard 5e79c05c54 Add patch to liana version
The struct will be imported by the gui which
may need one day to increase the patch version number.
2023-02-02 14:43:04 +01:00
Antoine Poinsot 1cd61c9236 descriptors: require that an origin be set for the keys.
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.
2023-02-01 13:54:18 +01:00
Antoine Poinsot 9c7613fc14 lib: perform node-related bitcoind sanity checks before loading the wallet
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.
2023-02-01 11:57:09 +01:00
Antoine Poinsot 3ea85fa950 descriptor: introduce a helper to analyze a PSBT spending Liana coins 2023-01-26 21:26:29 +01:00
Antoine Poinsot aac330ca65 descriptors: rename DescCreationError in a general desc-related error 2023-01-24 19:38:35 +01:00
Antoine Poinsot e22e30dc8d descriptors: support Multisig in both the primary and recovery paths
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.
2023-01-24 19:38:34 +01:00
Antoine Poinsot ed6ff9c67b commands: check addresses' network when creating transactions 2022-12-20 18:04:54 +01:00
edouard 103c1950ba Remove change_index from listspendtxs response
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.
2022-12-20 14:00:16 +01:00
Antoine Poinsot d3b89add9a daemon: apply clippy 1.66.0 fixes 2022-12-16 11:01:23 +01:00
Antoine Poinsot 3ac9f39aa1 Merge #224: Windows watchonly wallet path workaround
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
2022-12-15 19:16:37 +01:00
Antoine Poinsot 48e4909e7a daemon: store the watchonly wallet file in bitcoind's datadir on Windows 2022-12-14 18:32:37 +01:00