Commit Graph
191 Commits
Author SHA1 Message Date
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
Antoine Poinsot 030bfadaf7 bitcoind: decrease the sync progress roundup threshold 2022-12-14 16:51:17 +01:00
Antoine Poinsot 4560bc9ed2 bitcoind: move roundup_progress() to utils and unit test it 2022-12-14 16:51:16 +01:00
Antoine Poinsot ad1f0e20b1 Merge #182: Recovery command to sweep "expired" coins
ba994ff8ff commands: do not underestimate the size of created transactions (Antoine Poinsot)
46a94d6c8e qa: test recovery 'sweep' transaction creation (Antoine Poinsot)
3b5cbd5122 qa: introduce a sign_and_broadcast utility (Antoine Poinsot)
d362885b85 qa: record the recovery xpub too (Antoine Poinsot)
a69fb625ea qa: use a CSV of 10 for recovery (Antoine Poinsot)
a78f46fa2f [refactoring] jsonrpc: sort command names alphabetically (Antoine Poinsot)
c09ae3f87b commands, jsonrpc: add a new 'createrecovery' command (Antoine Poinsot)
3d5d0134b4 commands: fix the capacity of input vectors in create_spend (Antoine Poinsot)
f2312593da commands: check for dust outputs in the PSBT sanity checks (Antoine Poinsot)
9f23161a53 commands: correct the max feerate value (Antoine Poinsot)
54410cd9c4 database: allow to query coins by their spending status (Antoine Poinsot)

Pull request description:

  A new command that provides a simple way for a user to sweep all the coins whose timelocked recovery path is available.

  The first part of #180. Note this also contains a number of drive-by fixes that i noticed while coding this up.

ACKs for top commit:
  darosior:
    self-ACK ba994ff8ff -- tested by Edouard on the GUI

Tree-SHA512: 002cb8602370fe3bec0692fe7bbe9e7af494b43756d3092da99b37e4ce2837bcdfcfb3afe7043900eb41c70de12e2129e19363b9efe41cee91c7f1f7c2824fb0
2022-12-13 18:17:14 +01:00
Antoine Poinsot 05bbb3eef2 Merge #215: update bitcoind connection and be more robust at startup
acd6929831 doc: update for bitcoind 24.0.1 release (Antoine Poinsot)
650101525d bitcoind: set minimum required version to 24.0 (Antoine Poinsot)
9211d849c1 bitcoind: be less stupid when loading the watchonly wallet (Antoine Poinsot)

Pull request description:

  Fixes #210
  Fixes #209
  Fixes #213

ACKs for top commit:
  darosior:
    self-ACK acd6929831

Tree-SHA512: 8cacf41b0e00faed877462dc57b595265ff2936937d45535d1be2b42fd1bf80df2928ccacbefd43f82d88a728aca898a8549899380e341de8b8e74d34ec74642
2022-12-13 18:00:17 +01:00
Antoine Poinsot f6db9c6677 descriptors: rule out null timelocks
They are valid by consensus, not by Miniscript.
2022-12-13 16:59:56 +01:00
Antoine Poinsot 650101525d bitcoind: set minimum required version to 24.0 2022-12-13 16:37:52 +01:00
Antoine Poinsot 9211d849c1 bitcoind: be less stupid when loading the watchonly wallet
Only load it if isn't there already.
2022-12-13 16:14:20 +01:00
Antoine Poinsot ba994ff8ff commands: do not underestimate the size of created transactions
We were truncating when computing the virtual size of satisfactions.
2022-12-13 15:37:58 +01:00
Antoine Poinsot a78f46fa2f [refactoring] jsonrpc: sort command names alphabetically 2022-12-09 12:27:48 +01:00
Antoine Poinsot c09ae3f87b commands, jsonrpc: add a new 'createrecovery' command
This is a new command dedicated to the recovery usecase. For now it's
dead simple: sweep all coins that are available through the recovery
path to a given address.
2022-12-09 12:27:47 +01:00
Antoine Poinsot 3d5d0134b4 commands: fix the capacity of input vectors in create_spend
They were based on the expected size of the outputs vector...
2022-12-09 12:20:39 +01:00