187 Commits

Author SHA1 Message Date
Antoine Poinsot
925df283a6
bitcoin: check for ongoing rescans in the poller
Once the backend is done rescanning, we rollback our state down to the
rescan depth in order to scan for transactions from there.
2022-11-14 09:20:28 +01:00
Antoine Poinsot
073cdd0a89
commands: add a 'rescan_progress' field to 'getinfo'
We make sure to return a value as long as it was not wiped from
database, that's useful in functional tests.
2022-11-14 09:20:27 +01:00
Antoine Poinsot
7866ff46cf
commands: add a new 'startrescan' command 2022-11-14 09:20:27 +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
bd4de0b87a
bitcoin: interface for rescanning the chain on the Bitcoin backend
For now we are given a timestamp and use 'importdescriptors'. It might be
better to be passed a height and use 'rescanblockchain' instead.
2022-11-14 09:20:26 +01:00
Antoine Poinsot
c32f714a2e
bitcoind: add a 'noreply' client
The query we are going to use to rescan, 'importdescriptors' will block
until the rescan is finished. Stopping the connection through a timeout
immediately after triggering the rescan is a workaround to make it
asynchronous.

Eventually we should probably use 'rescanblockchain' but then it
wouldn't update the timestamps of the descriptors in the watchonly
wallet...
2022-11-14 09:20:25 +01:00
Antoine Poinsot
45d601282f
bitcoind: only sleep on error if there is >0 retries
Don't sleep if we won't retry.
2022-11-14 09:20:20 +01:00
Antoine Poinsot
51ff7d6734
bitcoind: a utility to find a block height by block timestamp
We are passed a timestamp and we want to know down to what height we
should rescan / roll back. That's helpful for it. It was a bit tricky
although it's a simple binary search.. So to make sure i got it right i
made it a standalone function in a utils/ module to be able to unit test
it.

See the TODO, it's theoretically not precisely entirely correct. But
it's good enough for now.
2022-11-09 15:42:55 +01:00
Antoine Poinsot
6323ae0d0f
bitcoind: add time and MTP to BlockStats 2022-11-09 10:48:09 +01:00
Antoine Poinsot
80803c78a4
bitcoind: handle missing previousblockhash from getblockheader
It seems that internally bitcoind might temporarily not have a pprev
pointer for a block. This will result in the optional
"previousblockhash" field to be null and would previously make us crash.

Handle that gracefully.
2022-11-09 10:22:33 +01:00
Antoine Poinsot
9fa4b95847
Merge #79: commands: actually use the change descriptor when creating a Spend
08505b25452e61a92d5b7eb4a02c893f0d585a91 commands: actually use the change descriptor when creating a Spend (Antoine Poinsot)

Pull request description:

  Fixes #78

ACKs for top commit:
  darosior:
    ACK 08505b25452e61a92d5b7eb4a02c893f0d585a91

Tree-SHA512: 4cccb6636f4e95831a9b3555f6a35cff85d855758b4c26c83b3db8086ea3012af6552ab0db485e982757b68c5c40d6b6696a95bca28c5b5b2f78339bfd800636
2022-11-05 12:09:41 +01:00
Antoine Poinsot
1ef45b7806
Merge #80: Clippy fixes
3b2c9109dd2c16e3812feb06f322ff0e6b6a61a0 Clippy fixes (Antoine Poinsot)

Pull request description:

  Clippy just broke under our feets by enabling more checks and making CI fail...

ACKs for top commit:
  darosior:
    ACK 3b2c9109dd2c16e3812feb06f322ff0e6b6a61a0

Tree-SHA512: 973f7ae94609209038626a3b6f9ff940d9e488c8588865b439a37a46eec1a5df995013ac98be0fc63e50009339e78238b3a317c568c89677fcb0facf08736874
2022-11-05 12:02:11 +01:00
Antoine Poinsot
08505b2545
commands: actually use the change descriptor when creating a Spend 2022-11-05 11:53:38 +01:00
Antoine Poinsot
3b2c9109dd
Clippy fixes
Clippy just broke under our feets by enabling more checks and making CI
fail...
2022-11-05 11:51:45 +01:00
edouard
76bd319d88
Merge #75: Add spend panel
6f75515f9b572d6fa77facdba9ddd2cd1bf94a64 Add coins and recipients view (edouard)
a043f024e2e6fd2355b8bff3e27c7e8e58886c92 fix clippy errors (edouard)
063786fe5485e4f5a857ed9c45f3fbec3fc5f69a Create spend transaction (edouard)
7fda64f4adae04e2f95439975e6e82a66c0a6035 Add select inputs step (edouard)
0b2f64279b92bf0502f4edc1d9bee3c231e933e8 Add choose feerate step (edouard)
5b9414260b34c37e9cddc7d79eb0a16d8d42767e Add choose recipient step (edouard)
e1209d2cff01a11053263c2e4934e80c088a83bd Add spend panel (edouard)
95aa8a152993a43dc2451c45efcfe73d68f4c45b Add spend txs to app cache (edouard)

Pull request description:

  based on #71

ACKs for top commit:
  edouardparis:
    Self-ACK 6f75515f9b572d6fa77facdba9ddd2cd1bf94a64

Tree-SHA512: 7edeb66b21af61f610d492576aac56b2dc1bfe1eb12a665787e5db03f54b55970c607d6ff29d6227360c7544bae4168f8d22ade648a0e13bc2f9050af0d95d06
2022-11-04 18:30:04 +01:00
edouard
6f75515f9b Add coins and recipients view 2022-11-04 18:07:49 +01:00
edouard
a043f024e2 fix clippy errors 2022-11-04 16:22:32 +01:00
edouard
063786fe54 Create spend transaction 2022-11-03 18:11:28 +01:00
edouard
7fda64f4ad Add select inputs step 2022-11-03 16:33:05 +01:00
edouard
0b2f64279b Add choose feerate step 2022-11-03 16:33:05 +01:00
edouard
5b9414260b Add choose recipient step 2022-11-03 16:33:05 +01:00
edouard
e1209d2cff Add spend panel 2022-11-03 16:33:05 +01:00
edouard
95aa8a1529 Add spend txs to app cache 2022-11-03 16:33:05 +01:00
edouard
ecd5962831
Merge #71: gui: import xpubs from hws
1d8527ed95e8e8454ffb989aded266224ec753e3 minisafe: bump miniscript (edouard)
258aeb57feba3b84e09d5bf3e863209cea06113a hw: load wallet from config (edouard)
6500381059c232023c29eb251e66cdb68bbe8148 installer: add clipboard (edouard)
c2ed30961c4c49826e97f6ab59eb0952ef1a9d2c installer: register wallet (edouard)
a2021ca326d614d7a604e3e6cad9f568e29a2d20 installer: refac context (edouard)
56be997d6bdbecc4d8c5ae7cded322c6c6936ed5 gui: fix ci add missing deps (edouard)
8ad37f18a88a57748a7c3f53f1ecb6bb8347194a gui: import xpubs from hws (wip) (edouard)

Pull request description:

ACKs for top commit:
  edouardparis:
    self-ACK 1d8527ed95e8e8454ffb989aded266224ec753e3

Tree-SHA512: 21b669915388ec60ff37dbb5be3a5f635571c60387ebb696689eddcc7f41cd3d900aff8aa3c5f11fd60860dc19e87dac7fd39e7cbbe6a8eae0ea8baba643354a
2022-11-03 16:10:54 +01:00
edouard
1d8527ed95 minisafe: bump miniscript 2022-11-03 15:00:41 +01:00
edouard
258aeb57fe hw: load wallet from config 2022-11-02 16:21:55 +01:00
edouard
6500381059 installer: add clipboard 2022-10-31 14:56:54 +01:00
edouard
c2ed30961c installer: register wallet 2022-10-31 14:54:26 +01:00
edouard
a2021ca326 installer: refac context 2022-10-31 14:54:26 +01:00
edouard
56be997d6b gui: fix ci add missing deps 2022-10-31 14:54:26 +01:00
edouard
8ad37f18a8 gui: import xpubs from hws (wip) 2022-10-31 14:54:26 +01:00
Antoine Poinsot
8b129fe3e5
Merge #74: Decent change management (using multipath descriptors)
117171f24ff5bd6731d9e5e50e4515a03013a9eb commands: use a separate key chain for change addresses (Antoine Poinsot)
d9f905a19a5c6076683bbe7714ecb86fbafe0555 db: track the next unused derivation index for change, too (Antoine Poinsot)
58a0e57c59bf7b4f451580917f701e95e45d1af6 db: record whether a coin was received on a change address (Antoine Poinsot)
9b04a551474b2cd5ed793e42832454635d964495 db: store derivation index also for addresses from the change desc (Antoine Poinsot)
4f3daa7741b6996c17133dacedb4e70c66f5bac8 descriptors: cache the receive and change descriptors (Antoine Poinsot)
ca3d7c1f3360daa53fbec723fb960051a926d687 descriptors: introduce a newtype for the multipath descriptor (Antoine Poinsot)
1320ee30bacdedd449dfa89a3008e01995917c9f daemon: use multipath descriptors (Antoine Poinsot)
d4db804e4bad928466fa1db4a84a474ff4c33d7b qa: add a missing 'wait_for' in spend creation test (Antoine Poinsot)
7a18c583cbfcd958db9c79e8b13a0a68c1d20d41 bitcoind: filter received coins based on parent descriptors (Antoine Poinsot)
ba4c1e0383e302d2a822176d93b3b9fadc174b4b bitcoind: include change outputs in listsinceblock (Antoine Poinsot)
caaca1fd1a721acae150b8bd9212e51b8e378c99 descriptors: rename derive into derive_received (Antoine Poinsot)
f985fd787917e344b17ae90edd7b99bc1c9f3a7c descriptors: remove as_inner method (Antoine Poinsot)
846d924792089e41e530e414b26f0823afc151eb qa: upgrade python-bip380 to latest master (Antoine Poinsot)
3105b86a28444097e20e14261ffbfd5448b2854b Use my own fork of rust-miniscript (Antoine Poinsot)

Pull request description:

  This fixes #18 by implementing the de-facto standard of using a `/0/*` keychain for receiving addresses and a `/1/*` keychain for change addresses. Note that once we'll have multisig, reusing addresses will still be possible since wallet don't share the same "next derivation index".

  In order to avoid forcing the user to configure and backup two almost identical descriptors, we make use of the recently proposed BIP389 (https://github.com/bitcoin/bips/pull/1354). In order to prevent as much as possible introducing a backward incompatibility in the configuration file after the first release, we restrict the usage of multipath descriptors to `<0;1>` here.
  We now derive public keys from `xpub/0/*` and `xpub/1/*` while we were previously deriving them from `xpub/*`.

  This triggered a pretty invasive refactoring, as most parts of the codebase had to be updated to support the new change/receive separation (even the functional test miniscript dependency had to be updated, see https://github.com/darosior/python-bip380/pull/21).
  Broadly, this:
  1. Update our Miniscript dependency to my upstream PR (https://github.com/rust-bitcoin/rust-miniscript/pull/470) rebased on top of the 8.0.0 release.
  2. Updates the descriptors module to handle somewhat safely the multipath descriptors (to avoid mixing up the single, multi, and derived descriptors).
  3. Makes a multipath descriptor mandatory in the configuration file.
  4. Updates the Bitcoin backend poller aware of descriptors for which to track coins.
     - Necessarily this updates the bitcoind implementation to import two descriptors
  5. Record in database whether a coin was for the change or receive descriptor, in addition to its derivation index

ACKs for top commit:
  edouardparis:
    ACK 117171f24ff5bd6731d9e5e50e4515a03013a9eb

Tree-SHA512: efcb7267f1ba6a5a3072e96fd1c70272f81092e86ee1178833f83d0aa88f271f42c269b71ca9992e76bb3e103baf1a189a609cc20f14f29b7388ab133da99044
2022-10-28 13:44:29 +02:00
Antoine Poinsot
117171f24f
commands: use a separate key chain for change addresses 2022-10-24 15:00:17 +02: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
4f3daa7741
descriptors: cache the receive and change descriptors 2022-10-24 15:00:15 +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
d4db804e4b
qa: add a missing 'wait_for' in spend creation test 2022-10-24 15:00:14 +02:00
Antoine Poinsot
7a18c583cb
bitcoind: filter received coins based on parent descriptors
Our bitcoind watchonly wallet could, maybe, have other descriptors that
were imported. Sounds pretty unlikely since we use a dedicated wallet
but hey.

More importantly, we'll need to know the parent descriptor of the coin
in order to recognize it as newly received or change.
2022-10-24 15:00:13 +02:00
Antoine Poinsot
ba4c1e0383
bitcoind: include change outputs in listsinceblock 2022-10-24 15:00:13 +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
f985fd7879
descriptors: remove as_inner method
We'll change the semantic of the descriptor, so we need to make sure
nothing accesses it with the old semantic.
2022-10-24 15:00:12 +02:00
Antoine Poinsot
846d924792
qa: upgrade python-bip380 to latest master
For multipath descriptors support
2022-10-24 15:00:11 +02:00
Antoine Poinsot
3105b86a28
Use my own fork of rust-miniscript
It supports multipath descriptors. We'll need to find a solution for the release
2022-10-24 09:01:03 +02:00
edouard
a623bd0f7a
Merge #70: bump minisafe#790d28
813b9684a90b2cf9b39d6e96c9d383d8d32ba5b8 bump minisafe#790d28 (edouard)

Pull request description:

ACKs for top commit:
  edouardparis:
    ACK 813b9684a90b2cf9b39d6e96c9d383d8d32ba5b8

Tree-SHA512: 8af937fdeac2e6d7df77cfd57eb5ab047d7babdedfbe9db67304b066c3779bb61806da24b0b5cba7c18fd8ee1df51a6258ea8df72f8ad608ddad9711c07d10be
2022-10-21 11:39:41 +02:00
edouard
813b9684a9 bump minisafe#790d28 2022-10-21 10:43:08 +02:00
Antoine Poinsot
790d283e77
Merge #67: Update rust-miniscript to 8.0.0
49ccc28ca7b0ee6e266d79ace67ff35c3d50905c Cargo: update most dependencies to the latest version (Antoine Poinsot)
a4bdb1efb79b8b87ba6131dea96798766e1fbcf5 tree wide: upgrade to Miniscript 8.0.0 (Antoine Poinsot)
d432745da583e2c38e67cae540b9417d76867bfa Cargo: don't require the 'compiler' feature from miniscript (Antoine Poinsot)
f7ca86191a6972bb6a8e3d78261159648db4ca23 ci: temporary disable 1.48 build on macOS (Antoine Poinsot)
f3e93df80c5f400e0b8f83c4862f0ff4b9f0f367 qa: add missing sighash type to dummy signatures in test_update_spend (Antoine Poinsot)

Pull request description:

  Took the opportunity to update some dependencies, too.

ACKs for top commit:
  darosior:
    ACK 49ccc28ca7b0ee6e266d79ace67ff35c3d50905c

Tree-SHA512: babd0ac6af752e4671b1221f63bcc85cf9f1029162893c71ba991b2da0c16bf02e70bf061969b1a058d7c22d57061d99a82d4ed8564787a38f8a35a784d21812
2022-10-20 18:17:04 +02:00
Antoine Poinsot
49ccc28ca7
Cargo: update most dependencies to the latest version 2022-10-20 17:53:27 +02:00