34 Commits

Author SHA1 Message Date
Antoine Poinsot
1f06c4d4dc db: fix the list_txids query
We need to limit the number of *distinct* txids. Limiting the number of
results in the inner queries at all could lead to incorrect results
with regard to ordering too.

See https://github.com/revault/liana/pull/99#discussion_r1029619579.
2022-11-22 19:31:02 +01:00
edouard
3cd709697b Add listconfirmed command 2022-11-22 19:31:02 +01:00
Antoine Poinsot
968a7d17a0
daemon: rename Minisafe to Liana 2022-11-17 17:10:22 +01:00
Antoine Poinsot
42d2ffeec1
db: more flexible interface for updating our next derivation indexes.
Instead of only incrementing it, allow to be able to set it to any
value. This will be useful for instance to set the derivation to the
latest used onchain, if another wallet is much further down the
derivation tree than we are (or after a rescan).
2022-11-16 15:19:50 +01:00
Antoine Poinsot
7e83bfad55
db: the interface to store the state of an ongoing rescan
We'll need to store in persistent storage if a rescan was requested by a
user, and if so from what date.

For the SQLite implementation we introduce a rescan_timestamp to the
wallet table.
2022-11-14 09:20:26 +01:00
Antoine Poinsot
d9f905a19a
db: track the next unused derivation index for change, too 2022-10-24 15:00:17 +02:00
Antoine Poinsot
58a0e57c59
db: record whether a coin was received on a change address
So we know what descriptor to use when spending it.
2022-10-24 15:00:16 +02:00
Antoine Poinsot
9b04a55147
db: store derivation index also for addresses from the change desc
This doubles the storage required but there is no way around it if we
want the poller to detect those coins without grinding.
2022-10-24 15:00:16 +02:00
Antoine Poinsot
ca3d7c1f33
descriptors: introduce a newtype for the multipath descriptor
The multipath descriptor has very different properties than the receive
and change ones. Use a newtype to assist us in differentiating those.
2022-10-24 15:00:15 +02:00
Antoine Poinsot
1320ee30ba
daemon: use multipath descriptors
In config, expect to be given a multipath descriptor that contains a
derivation path for both receive and change addresses, but only for
those.

Instead of 'xpub/*', start using 'xpub/0/*' and 'xpub/1/*'.

When creating the watchonly wallet on bitcoind import both the receive
and change descriptors.

When polling, check for coins on both descriptors.
2022-10-24 15:00:14 +02:00
Antoine Poinsot
caaca1fd1a
descriptors: rename derive into derive_received
We'll be able to derive change addresses too
2022-10-24 15:00:12 +02:00
Antoine Poinsot
a4bdb1efb7
tree wide: upgrade to Miniscript 8.0.0
This also updates the indirect rust-bitcoin dependency to 0.29.

Major changes are in the descriptors management:
	- The rust-miniscript descriptors don't support raw hashes
	  within the pk_h() fragments, so we don't need all the boutique
	  management for this.
	- The key translator API changed.
	- We now take a u16 for the timelock instead of our previous
	  checks. This was inspired by the new rust-bitcoin Sequence
	  type.
	- We now take a path instead of just a derivation index in
	  DerivedKey. We might use paths after all...

As for rust-bitcoin it's just a few nits:
	- No more 'global' field on PSBTs (yay)
	- Couple more trait derivation on types
	- Some APIs were renamed.
2022-10-20 17:53:26 +02:00
Antoine Poinsot
92f7ef1225
commands: make listcoins return all coins by default
We'll add some parameters to filter by status and/or outpoints later on.
But for now also list coins that were spent or are being spent.
2022-10-17 11:47:41 +02:00
Antoine Poinsot
e9e4acd69d
db: database interface to rollback to a previous best block 2022-10-17 11:47:40 +02:00
Antoine Poinsot
972c8dac86
db: require the spend block height from the DB interface
Hence add a 'spend_block_height' field to the 'coin' column in the
SQLite implementation. This also contains a couple cleanups, as well as
a fix (we were still checking if the blockheight was > 1).
2022-10-17 10:44:38 +02:00
Antoine Poinsot
6038843d33
database: rename coins' spent_at in spend_block_time 2022-10-17 10:27:03 +02:00
Antoine Poinsot
8b4866158b
daemon: clippification
That's a minimal API break because of some error variants that were
Box'd.
2022-10-13 14:24:24 +02:00
Antoine Poinsot
c9b6c6dedb
db: re-rename list_unspent_coins into unspent_coins 2022-10-12 17:19:27 +02:00
edouard
3cf6bcbb98 add spent_coins to bitcoind poller 2022-10-05 17:41:16 +02:00
edouard
94ee94edbd Add blocktime and spent_at to coins table
Spent coins are coins where spent_txid and spent_at
are both not null.
2022-10-05 17:41:16 +02:00
Antoine Poinsot
c73e8a42dd
commands: add a new 'delspendtx' command 2022-10-01 14:05:27 +02:00
Antoine Poinsot
c6e004806a
commands: add a 'list_spend' command (and 'listspendtxs' RPC) 2022-10-01 13:33:08 +02:00
Antoine Poinsot
bafcadf398
db: interface to upsert a Spend PSBT and query it by txid
I initially wanted to have a bridge table between the 'coins' and
'spend_transactions' table as we do in revaultd. But let's not optimize
to early, we'll see if/when we need it.
2022-09-15 11:41:33 +02:00
Antoine Poinsot
46320d5fc0
db: an interface to query coins by their outpoints 2022-09-15 11:41:29 +02:00
Antoine Poinsot
0fd57db8a8
Use the descriptor newtype instead of the raw miniscript Descriptor type 2022-08-18 12:02:27 +02:00
Antoine Poinsot
99a9cbf0f8
poller: query derivation index by address from DB 2022-08-18 12:01:26 +02:00
Antoine Poinsot
3f17e9f0c3
database: change interface from update_der_index to increment_der_index
And take care of updating the (addr->index) mapping in the SQLite implementation.
2022-08-18 12:01:26 +02:00
Antoine Poinsot
e74ea4c2d3
sqlite: a table for a mapping from address to derivation index. 2022-08-18 12:01:25 +02:00
Antoine Poinsot
05b3af1b5a
database: interface and implementation for coins storage and update 2022-08-18 12:01:24 +02:00
Antoine Poinsot
726209cc0a
jsonrpc: add a 'stop' command
This also implements a simple JSONRPC server sanity check

And introduces a new tmp_dir() test utility, that i didn't have the courage to split from this commit
2022-08-17 19:39:57 +02:00
Antoine Poinsot
ea3595349d
Accept a custom database interface when starting the daemon 2022-08-17 19:39:55 +02:00
Antoine Poinsot
2609061a69
commands: implement getnewaddress 2022-08-06 10:53:47 +02:00
Antoine Poinsot
dd37255d7b
bitcoin: update our tip in the poller
This introduces the DB connection in the poller thread
2022-07-27 12:30:53 +02:00
Antoine Poinsot
b0196ab529
daemon: introduce an SQLite database
With a schema similar to revaultd, but a different interface.
2022-07-23 12:49:17 +02:00