Commit Graph
267 Commits
Author SHA1 Message Date
Antoine Poinsot 421c1af6cd bitcoind: fix the detection of unconfirmed RBF spending txs
As we walk through the spend transactions in the wallet, we may return
the txid of the transaction that was replaced instead of the new one.
2023-08-22 16:49:13 +02:00
Antoine Poinsot 77e46d5495 daemon: remove 'help' detection in command line arguments
This is superfluous and prevents using config files with "-h" in their
path.
2023-08-22 16:42:57 +02:00
Antoine Poinsot 05c9b580db Merge #625: bitcoin: looper: avoid large sleeps when bitcoind is syncing
0d5041ca4a bitcoin: looper: avoid large sleeps when bitcoind is syncing (Antoine Poinsot)

Pull request description:

  Sleeping for 30 whole seconds impedes the shutdown check. Sleep only .5s but still only do poll bitcoind one every 30s when it's syncing.

  It was reported to make the GUI hang when closing it while syncing.

ACKs for top commit:
  edouardparis:
    utACK 0d5041ca4a

Tree-SHA512: 48c9121a02abaf8311d7b646ea64cbde4e14fda737c6f78521739bc185e6081642d05b3ca8088d3ce6782ffa00d6e5879e6a6e09da7f05c85f8476ac83b6860b
2023-08-22 16:16:22 +02:00
Antoine Poinsot 0d5041ca4a bitcoin: looper: avoid large sleeps when bitcoind is syncing
Sleeping for 30 whole seconds impedes the shutdown check. Sleep only .5s
but still only do poll bitcoind one every 30s when it's syncing.
2023-08-22 15:41:26 +02:00
Antoine Poinsot 2a6b775f60 lib: non-blocking daemon shutdown
This makes it possible to trigger the shutdown of the daemon through the
DaemonHandle, without having to block while waiting for the poller
thread to join.

Incidently, this allows to avoid having to move `self` which in turns
allows to fix a GUI bug (see
https://github.com/wizardsardine/liana/issues/622).

Only available as an optional feature since `is_finished` needs rustc
1.61.
2023-08-22 14:55:14 +02:00
jp1ac4 3372a8d461 bitcoind: add stop method
This is required by the GUI for stopping an internal bitcoind when closing Liana.
2023-08-16 09:26:40 +01:00
jp1ac4 60ee667f6c bitcoind: make BitcoinD public
This is so that it can be used by the GUI for checking connectivity to bitcoind.
2023-08-16 09:24:10 +01:00
Antoine Poinsot 0591243abe Merge #601: lianad: print a more helpful error message on startup failure
d4da2bf6b4 daemon bin: try to detect '--help' or '-h' (Antoine Poinsot)
01ce0f179d daemon bin: more helpful error message on config file parsing error (Antoine Poinsot)
222c8bba81 daemon bin: a more helpful error message on unknown arguments. (Antoine Poinsot)

Pull request description:

  Specifically, link to a sample configuration file. How are users supposed to know how to write the config file otherwise?

  Fixes #559.

ACKs for top commit:
  darosior:
    self-ACK d4da2bf6b4 -- trivial.

Tree-SHA512: 7ca05aa0e351c390b67051ad36c2e767b019cf6339d8207e1fdbd1ead47a3d79ab6cd9584c412d98ae876aa7e8ea906885c52261565917a7cd1126798806b5d2
2023-08-14 10:04:57 +02:00
Antoine Poinsot 0785bb7f9f poller: don't filter out coins with already a spend txid when checking for spends
What if the spending transaction gets RBF'd?
2023-08-11 11:52:51 +02:00
Antoine Poinsot e549510e21 Merge #602: bitcoind: set load_on_startup to true when loading watchonly wallet
23a63f35e1 bitcoind: override watchonly wallet as to be loaded on startup (Antoine Poinsot)

Pull request description:

  we used to not set 'load_on_startup' when creating a watchonly wallet. This could create some complications when people are using agressive pruning configurations.

  Fix this by overwriting this parameter when loading watchonly wallets. We can always revert this in the future if for some reason a user wants to have it set to false and no be overwritten everytime Liana loads it.

  Fixes #594.

ACKs for top commit:
  darosior:
    self-ACK 23a63f35e1 -- tested locally

Tree-SHA512: 8310918286a8a0102bfc76e9d5b2ba4a8b50cac3e4ce2fd26bdfae7c153eeba3bf516d70ed6ef6256c5f4bcc3955559c011a7035cbc293cc594b829ea9038a5c
2023-08-11 10:30:30 +02:00
Antoine Poinsot d4da2bf6b4 daemon bin: try to detect '--help' or '-h'
It should fall into the "number of args isn't equal to 3" category
anyways, but it's a cheap way of trying to be more helpful.
2023-08-11 10:13:47 +02:00
Antoine Poinsot 23a63f35e1 bitcoind: override watchonly wallet as to be loaded on startup
we used to not set 'load_on_startup' when creating a watchonly wallet.
This could create some complications when people are using agressive
pruning configurations.

Fix this by overwriting this parameter when loading watchonly wallets.
We can always revert this in the future if for some reason a user wants
to have it set to false and no be overwritten everytime Liana loads it.
2023-08-10 13:04:40 +02:00
Antoine Poinsot 01ce0f179d daemon bin: more helpful error message on config file parsing error 2023-08-10 11:46:41 +02:00
Antoine Poinsot 222c8bba81 daemon bin: a more helpful error message on unknown arguments. 2023-08-10 11:43:47 +02:00
Antoine Poinsot 605c3f657e descriptors: allow the multipath step to be different than '<0;1>'
Ledger and wallet policies disallow having more than 2 depth after the
placeholder, therefore we can't do `@1/0/<0;1>/*`, `@1/1/<0;1>/*`, ..
Instead we have to do `@1/<0;1>/*`, `@1/<2;3>/*`, ..

Why not? Salvatore also says the cost of deriving another depth is
non-trivial on a signing device.

Don't pick a fight with Salvatore, instead just let the GUI (or whatever
creates the desc) use different multipath steps for keys derived from
the same xpubs.
2023-08-10 08:51:17 +02:00
Antoine Poinsot 10acc482e1 descriptors: fix the signatures count analysis
Since https://github.com/wizardsardine/liana/pull/575 we started using
xpubs with an appended derivation path, and the analysis was assuming
there wasn't any.
2023-08-10 08:50:06 +02:00
Antoine Poinsot 7a33040b83 descriptors: make signed_pubkeys a mapping from fingerprint
It's supposed to represent the number of signature per "master" key, i
guess. At the moment it would always be 1 because the origin changes
when we queried more keys from the signing device (because we increased
the account).
2023-08-09 18:49:49 +02:00
Antoine Poinsot 64df2a15a2 db: keep NOT NULL constraint on is_immature in migration
This adds an extraneous DEFAULT compared to the schema in freshly
created databases, but anything else (altering the column in an
SQLite-friendly way after setting all NULL values to 0) would be way too
involved.
2023-08-07 13:24:30 +02:00
Antoine Poinsot 39d576fe83 Merge #578: Fix the tracking of immature coinbase deposits
097d5e71c1 qa: adapt the migration functional test to also support 1.0 (Antoine Poinsot)
289f6581cc qa: functional test createspend refuses immature outpoints (Antoine Poinsot)
95dd3e5293 qa: fix and improve the coinbase deposit functional test (Antoine Poinsot)
6b82894614 bitcoin: track maturity of coinbase deposits (Antoine Poinsot)
6ab6161078 commands: expose whether a coin is immature in listcoins (Antoine Poinsot)
fd717123be commands: don't create spends with immature coins (Antoine Poinsot)
26add29b19 database: record whether a coin comes from an immature coinbase (Antoine Poinsot)

Pull request description:

  #567 uncovered that we were actually not tracking coinbase deposits correctly. In fact we would most likely miss them all in any real situation. This is because we would filter out immature coinbase deposits from the result of `listsinceblock` and not consider them newly received coins. But they would be confirmed, and as the chain moves forward we'd not scan this range anymore even once they've become mature.

  This PR fixes it by the simplest possible manner: record immature coinbase deposits as unconfirmed and only mark them as confirmed once they've become mature. This is a bit clumsy, but should be fine for the number of users that would receive payouts from coinbase transactions (ie most likely 0). Also, we don't accurately update coinbase coins on reorg. This is unnecessary as it'd be very unlikely that a mature coinbase would become immature and if there is a 100 blocks reorg that would invalidate it altogether we'd have bigger problems.

  Fixes #567.
  ~~Still as draft as i want to go over this one more time before asking for review, as this if pretty intricate and touches core parts of our codebase.~~

ACKs for top commit:
  darosior:
    self-ACK 097d5e71c1. Didn't have the chance to re-review it but getting it in is best at this time. Edouard will still have a look post-merge.

Tree-SHA512: 4a5f0fb7561af1d4c51dcba26bc20ef5e7a8b2c730547f762782f75c1f28c26e2a577573aa514db8927c1eeb601685071e9eb85c11537621de58c75824435b05
2023-08-01 14:49:00 +02:00
Antoine Poinsot 8ae597fec1 bitcoind: create watchonly wallet with load_on_startup = true 2023-07-31 12:40:59 +02:00
Antoine Poinsot adf9bf8dd8 Merge #575: descriptor: make it possible to reuse xpubs at different derivation paths
28049d4f7c descriptor: make it possible to use the same xpub at different paths (Antoine Poinsot)

Pull request description:

  This is unnecessary to bump a hardened step to get another xpub for the same participant:
  - It's more hurdle when sharing it
  - It's more hurdle when verifying it on the device's screen
  - It's for the same person within the same script anyways

  Fix this by allowing to use the same xpub multiple times in a descriptor as long as the derivation path is different. Then the GUI will be able to use a new unhardened derivation step instead of bumping the BIP48 "accounts". A unit test is introduced that showcases this.

  See also https://github.com/wizardsardine/liana/issues/542.

ACKs for top commit:
  edouardparis:
    ACK 28049d4f7c

Tree-SHA512: e864a8193998667d36b34d96e6e32bfff1c507b3c31faa324b7f264604c41b5d2d4aefeec3b71a1d3edf5b0242966861887baf97d7a410e43e7449f22c3453f4
2023-07-24 18:32:59 +02:00
Antoine Poinsot 6b82894614 bitcoin: track maturity of coinbase deposits
We detect and store immature deposits (cause otherwise we won't go
through them again with listsinceblock), but mark them as such and
unconfirmed.
We only mark them as confirmed once they've matured. It's a bit clumsy
but it's not as if most of our users had coinbase deposits.
2023-07-20 13:42:35 +02:00
Antoine Poinsot 6ab6161078 commands: expose whether a coin is immature in listcoins 2023-07-20 13:42:35 +02:00
Antoine Poinsot fd717123be commands: don't create spends with immature coins 2023-07-20 13:42:34 +02:00
Antoine Poinsot 26add29b19 database: record whether a coin comes from an immature coinbase
We need to keep track of such coins to:
	- Track their maturation
	- Avoid using them (for instance in coin selection)

Reorg handling for coinbase deposits that become immature is not
implemented (yet). That's reasonable because:
1. It would be very unlikely that we'd move back, so it's most likely
   gonna be mature again immediately.
2. If there's a reorg of more than 100 blocks we've got bigger problems.
2023-07-20 13:42:30 +02:00
Antoine Poinsot f4d184f6f7 descriptor: refuse non-normalized xpubs
We wouldn't be able to derive them.
2023-07-19 18:52:08 +02:00
Antoine Poinsot 28049d4f7c descriptor: make it possible to use the same xpub at different paths
It's a much better UX to be able to share and verify one xpub and just
use different unhardened paths for the various public keys used in the
same script that originate from the same master key.
2023-07-19 17:28:33 +02:00
Antoine Poinsot 9007947e4e bitcoind: use minreq as HTTP transport for JSONRPC
Instead of the hand-written HTTP implementation in the rust-jsonrpc
library, use the minreq crate. It's a small, maintained, low dependency
library actually focused on writing an HTTP client.

This also reworks and better document the request retry logic.
2023-07-13 10:18:07 +02:00
Antoine Poinsot e3ee50b7af Update rust-jsonrpc dependency to latest version 2023-07-13 10:07:00 +02:00
Antoine Poinsot b9753b48d0 descriptors: update the satisfaction size estimation
The latest rust-miniscript version deprecated the helper we were using,
in favour of one that gives the maximum size difference of a transaction
input before and after satisfaction. The new helper differs in that it
does not account for the empty ScriptSig byte (which uncovered we were
actually double-counting it), and assumes the non-satisfied transaction
input is already part of a Segwit transaction (which we rectified).

This uncovered a mistake in the computation of the witness script size
in the unit test. We also get rid of the needless wu_to_vb() standalone
function.
2023-07-13 09:56:10 +02:00
Antoine Poinsot 0ac4d80ddb commands: fix two clippy lints
For some reason it started warning about them after the upgrade of
rust-miniscript.
2023-07-13 09:56:10 +02:00
Antoine Poinsot e28010915f lianad: update rust-miniscript (and rust-bitcoin) dependencies
Rust-bitcoin, that we use through rust-miniscript, has seen plenty of
breaking changes in the latest version. I've tried to keep the necessary
changes here minimal, still it had to be a single commit to keep it
hygienic. But i'll try to summarize the main things here. Tobin also
wrote a guide about the release at
https://rust-bitcoin.org/blog/release-0.30.0/.

The most verbose change in this commit is probably due to the `Address`
type overhaul. It's overengineered if you ask me but hey here we are. I
tried to keep network validation in commands, and otherwise passing
around unchecked addresses (to avoid having to pass around a global
state between our various components).

Another non-obvious change was changes in hash types upstream and the
removal of `ToHex`, forcing us to get the hex representation of a txid
through its `Display` implementation. It is however displayed backward
in this case ("little-endian" if you will), and we need a regular hex
encoding for some queries to the database. We needed to make sure we
didn't implement any silent bug here.

The rest (Script type changes, PSBT serialization updates, ..) is
probably self-explanatory.
2023-07-13 09:56:09 +02:00
Antoine Poinsot c20c05cee7 ci: upgrade lianad clippy to 1.70 2023-06-28 10:23:15 +02:00
Antoine Poinsot b2f95ada58 commands: take advantage of 1.48 compat riddance 2023-06-27 17:26:44 +02:00
raphjaph 700f6e1d6f make compilable on aarch64 (M1) 2023-05-24 00:08:54 +02:00
Antoine Poinsot ec55348693 Merge #499: sqlite: prevent races when updating the next derivation index
039b82d9b3 sqlite: prevent races when updating the next derivation index (Antoine Poinsot)

Pull request description:

  You can check the unit test triggering the race fails on master. I'm pretty sure it's the reason for the address generation bug i experienced yesterday when testing.

ACKs for top commit:
  edouardparis:
    utACK 039b82d9b3

Tree-SHA512: e245d8732346731c5a98223363c9d2e77f3a568e046055007162167f7a7209cc0e9d0f57c7219e469788ff73c570962396c4da0e056c790ffffbd953c75ab3ee
2023-05-12 13:03:26 +02:00
Antoine Poinsot 039b82d9b3 sqlite: prevent races when updating the next derivation index 2023-05-12 12:08:55 +02:00
Antoine Poinsot 0f07361d9b bitcoind: adapt the warning detection with interface breakage in v25 2023-05-12 11:27:46 +02:00
Antoine Poinsot 3a82c3a81d bitcoind: do not assert presence of 'warning' field in unloadwallet response 2023-05-12 10:57:23 +02:00
Antoine Poinsot 8debaf8e83 Merge #490: Release 1.0 preparation
fe906da612 Bump version to 1.0.0 (Antoine Poinsot)
73902627d6 Add a SECURITY.md (Antoine Poinsot)
664a9b6cf5 Documentation updates for v1.0 (Antoine Poinsot)
1f9b78383a CHANGELOG: add v1.0 release notes (Antoine Poinsot)
e685f3b55c contrib: fix guix build to use lianad's master (Antoine Poinsot)

Pull request description:

ACKs for top commit:
  darosior:
    self-ACK fe906da612

Tree-SHA512: 3412855d292c00de5b40171f555f661f64927f1bc635fa36fad70fe9bec93551bf9421e6c75d6d26fd9cdc8f6536979b8417db50617c484ae80ef2289b07ddb5
2023-05-11 17:05:06 +02:00
Antoine Poinsot 17d1f847bc lib: on Windows unload the watchonly wallet before deleting it 2023-05-11 12:22:48 +02:00
Antoine Poinsot fe906da612 Bump version to 1.0.0 2023-05-11 11:44:57 +02:00
Antoine Poinsot c6c312a011 commands: allow to create send-to-self transactions with 'createspend' 2023-05-04 16:15:09 +02:00
Antoine Poinsot a076a83cba Reset the daemon and GUI versions post 0.4 branch-off 2023-04-13 08:54:18 +02:00
Antoine Poinsot baf68e8224 lianad: bump version 2023-04-10 11:23:55 +02:00
Antoine Poinsot 104c6e1a09 commands: add an 'updated_at' field to listspendtxs entries 2023-04-05 12:41:03 +02:00
Antoine Poinsot 6b666e75c0 db: unit test the migration from v0 to v1 2023-04-05 12:41:03 +02:00
Antoine Poinsot 29ae0a4a5e db: add a new 'updated_at' column to Spend transactions
Since this is our first modification to the database schema since the
first release of the software this also introduces migration logic for
existing databases.
2023-04-05 12:41:02 +02:00
Antoine Poinsot d68d0e1134 commands: adapt 'createrecovery' to multiple recovery paths 2023-04-04 11:53:22 +02:00
Antoine Poinsot cfbb02c7c8 descriptors: multi-recovery-path Liana descriptor
This makes it possible to have more than one recovery path in a Liana
descriptor. The descriptor and partial spend analysis are adapted to
report information about all recovery paths.
2023-04-04 11:53:21 +02:00