208 Commits

Author SHA1 Message Date
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
ac80aa7721
Merge #84: Block chain rescanning for our descriptor(s)
32f3bdeb16b66878e23ba71a6f2c401c5d1f601a bitcoind: check the rescan was successful, retry at most 10 times (Antoine Poinsot)
337f422283e3392b6cea94df6211fd6c736772ef bitcoind: add the timestamp to the 'listdescriptors' entry (Antoine Poinsot)
3c75e2e944638fdfe7ae6986aee9af83e0e2a532 bitcoind: disable retry logic for noreply requests (Antoine Poinsot)
55cf21fa2aa7a66d998061684630a32cfb972a35 qa: unflake the getinfo RPC functional test (Antoine Poinsot)
96b634b69c3b059c0711a35bac580ffcbf34af57 bitcoind: make the rescan starting interface failible (Antoine Poinsot)
85cd261fcd50e87ad8c3b6a5443e7e38266ff655 bitcoin: remove the BitcoinError enum, use String as error instead (Antoine Poinsot)
9b253e7ea71e3da38922e35a9fdc182e85a15bcd bitcoind: rescan with a range, handle spurious error when rescanning (Antoine Poinsot)
ff753fecca5c1c77c44a4627a565e580aefc9446 bitcoind: get more info from 'listdescriptors' (Antoine Poinsot)
4a7fd1af2999622af7e6421c0bea611688150cae commands: check if the Bitcoin backend is already rescanning (Antoine Poinsot)
8a22f5e8c944447572bad60fa7e187058483ed47 qa: functional tests for block chain rescans (Antoine Poinsot)
925df283a62af32d816bcf2e0b2d20c7f08a3a31 bitcoin: check for ongoing rescans in the poller (Antoine Poinsot)
073cdd0a89c8688b2cdad73666b71a79d9f81ae1 commands: add a 'rescan_progress' field to 'getinfo' (Antoine Poinsot)
7866ff46cfcf02f75f0d5fd996434ef647940882 commands: add a new 'startrescan' command (Antoine Poinsot)
7e83bfad55504e758e2380ba76e48ce7f868b837 db: the interface to store the state of an ongoing rescan (Antoine Poinsot)
bd4de0b87a0db999ead08de335566df462251ca6 bitcoin: interface for rescanning the chain on the Bitcoin backend (Antoine Poinsot)
c32f714a2ed12135f07a2dd77951b15c3f0fcfe5 bitcoind: add a 'noreply' client (Antoine Poinsot)
45d601282fd4e722ad8558243c4b8c9c1ad11345 bitcoind: only sleep on error if there is >0 retries (Antoine Poinsot)
51ff7d6734db353e0aab65c45d322c45d7e3aa8b bitcoind: a utility to find a block height by block timestamp (Antoine Poinsot)
6323ae0d0fb2726e95a97ceda52b133027297719 bitcoind: add time and MTP to BlockStats (Antoine Poinsot)
80803c78a4579641b604c110e411556588ebdf24 bitcoind: handle missing previousblockhash from getblockheader (Antoine Poinsot)

Pull request description:

  This implements the ability for a user to rescan the block chain from an earlier timestamp to find transactions the wallet isn't currently aware of.

  The main difficulty arises with the fact there are two rescans to be performed:
  1. The block chain rescan on the Bitcoin backend. For the bitcoind implementation this means we need to rescan the bitcoind watchonly wallet down to the given timestamp (or height). We can imagine for an indexer backend such as an Electrum backend it could be almost instant.
  2. The update of our state with the new state of the Bitcoin backend. In the poller we scan blocks linearly, we will never scan a block that we already scanned and that includes blocks anterior to the first block we scanned. In order to implement this rescan of past blocks after a Bitcoin backend rescan was performed we reused our current chain reorganization logic: we rewind our state down to the first block that was rescanned by the backend. This is overkill (we don't need to erase existing information), but sufficient for now.

  The implementation is not as robust as it could be. Notably, in order to rescan the chain on the bitcoind implementation of the backend i use a trick to not make the connection block for the entire duration of the rescan when calling `importdescriptors`: i introduce a new client that has a timeout of 1 second and that ignores the response as well as timeout errors. Obviously this is problematic since it makes it more complicated to know whether the call actually succeeded.
  ~~A more robust solution would be to use `rescanblockchain` which starts the rescan without blocking but~~
  1. We should be storing a height in the database, not a timestamp
  2. The timestamp of the descriptors in the bitcoind watchonly wallet wouldn't be updated

  EDIT: i'm dumb, `rescanblockchain` does block too!

  I'm happy to have feedback on this. I think the current implementation is fine for now but eventually we should move to using `rescanblockchain` and get rid of the "noreply" client hack.

  Also, some  functional tests for edge cases we could encounter are included but happy to have some more suggestions.

  Fixes #28.

ACKs for top commit:
  darosior:
    ACK 32f3bdeb16b66878e23ba71a6f2c401c5d1f601a

Tree-SHA512: adca6345329f60d23ed85f0f6abc8f445b10d0c24b5a555a852d0507822598abc7de78742381b1a47b54820f97b037bb4d1ddd0e0b600921ef16c5128ba84950
2022-11-16 10:47:21 +01:00
edouard
04c85d6066
Merge #92: fix ci: wrong linter command for gui
635903118e07e9bc06b07c839e9fb2040ce36874 gui: fix clippy errors (edouard)
4489b05dda6c0104f3b4ec66064f249b34d4eeab fix ci: linter gui (edouard)

Pull request description:

ACKs for top commit:
  edouardparis:
    Self-ACK 635903118e07e9bc06b07c839e9fb2040ce36874

Tree-SHA512: 1ee48657edc1733486036e99604c1cf9ac6d41e36fee92fcc9c039ad5ef64061e10fc48f9b82ce0c7993c0d8675e6d3d8fae4194c4fe3b7bd95b6a18b1702d43
2022-11-16 10:30:45 +01:00
edouard
635903118e gui: fix clippy errors 2022-11-15 18:32:10 +01:00
edouard
4489b05dda fix ci: linter gui 2022-11-15 18:28:23 +01:00
edouard
edb4359087
Merge #89: installer: check xpub network
25056d0d5e173c2c9378cdc2a98c5880d7451c83 installer: check xpub network (edouard)

Pull request description:

Top commit has no ACKs.

Tree-SHA512: 3ff1b9e25c84ca086f7c9a5bd11293bc40506a002d9a2d23dc4dd58bfe287e85aa71140724218b41373817fd56ed2e82be78de84f7caa5c29a45492e784875f9
2022-11-15 17:57:07 +01:00
edouard
25056d0d5e installer: check xpub network 2022-11-14 19:33:00 +01:00
Antoine Poinsot
32f3bdeb16
bitcoind: check the rescan was successful, retry at most 10 times 2022-11-14 14:35:57 +01:00
Antoine Poinsot
337f422283
bitcoind: add the timestamp to the 'listdescriptors' entry 2022-11-14 14:13:48 +01:00
Antoine Poinsot
3c75e2e944
bitcoind: disable retry logic for noreply requests
Callers that use this client will have to use a custom retry logic.
2022-11-14 14:07:39 +01:00
Antoine Poinsot
55cf21fa2a
qa: unflake the getinfo RPC functional test 2022-11-14 09:48:09 +01:00
Antoine Poinsot
96b634b69c
bitcoind: make the rescan starting interface failible
This makes us more robust to races, where we'd crash previously
2022-11-14 09:47:43 +01:00
Antoine Poinsot
85cd261fcd
bitcoin: remove the BitcoinError enum, use String as error instead
It looks like we'd end up only using variants that contain a String, for
little benefit. Cut down on complexity for now.
2022-11-14 09:37:13 +01:00
Antoine Poinsot
9b253e7ea7
bitcoind: rescan with a range, handle spurious error when rescanning
Give the range to 'importdescriptors' when re-importing a descriptor for
rescanning. This is because the range must include the range of the
descriptor being updated.

Secondly, it is possible that the combination of our timeout-to-1s hack
and our retry logic trigger an edge case: we would retry after
successfully triggering a rescan, and therefore panic on a "a rescan is
already ongoing" error. Instead check before starting that we aren't
rescanning already, and assume that such an error after triggering the
rescan is because we succeeded. That's racy but only reasonably so (as
long as we don't crash, which isn't the case here).
2022-11-14 09:26:39 +01:00
Antoine Poinsot
ff753fecca
bitcoind: get more info from 'listdescriptors'
We'll need the range for the rescan, as a descriptor must be reimported with a range larger than the initial descriptor
2022-11-14 09:20:29 +01:00
Antoine Poinsot
4a7fd1af29
commands: check if the Bitcoin backend is already rescanning
This is racy, but good enough for now.
2022-11-14 09:20:29 +01:00
Antoine Poinsot
8a22f5e8c9
qa: functional tests for block chain rescans 2022-11-14 09:20:28 +01:00
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
edouard
5595e91e57
Merge #85: Delete install target datadir in case of failure
e9fa816be7c6ddbf64413dc4df6940d0f90c1f87 Delete install target datadir in case of failure (edouard)

Pull request description:

  close #20

ACKs for top commit:
  edouardparis:
    Self-ACK e9fa816be7c6ddbf64413dc4df6940d0f90c1f87

Tree-SHA512: 21b78bdad3a3e5127703211e5d119dc9ec88e4bc881ab744e1f6e20d51000af8b5aac4a12f19c775576c69ce958cac7d905378ec8fa4d69e4398fb5fedb61a05
2022-11-10 17:04:04 +01:00
edouard
e9fa816be7 Delete install target datadir in case of failure
close #20
2022-11-10 12:11:33 +01:00
edouard
e69d354e89
Merge #83: fix installer: check if setup exists before install
8903dedaf556d0032b4f72e76b78fc0b58b44e0d fix installer: check if setup exists before install (edouard)

Pull request description:

ACKs for top commit:
  edouardparis:
    Self-ACK 8903dedaf556d0032b4f72e76b78fc0b58b44e0d

Tree-SHA512: c2e97dc5cf8949d635ef5d6a441532c56e66df8121edf91088c3860450062a52c3ade5b757af891a49abac09318ffcc92896863abe784b1e1a7f1b78ed1fe48d
2022-11-10 09:04:01 +01:00
edouard
8903dedaf5 fix installer: check if setup exists before install 2022-11-09 18:45:25 +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