118 Commits

Author SHA1 Message Date
Antoine Poinsot
57add1d86b
commands: return the DB's block height in 'getinfo'
It makes more sense than to return the Bitcoin backend's. And it's helpful to wait for sync in functional tests.
2022-10-17 11:47:41 +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
cce227f80f
bitcoin: interface to get the common block in our and the backend's chains
This will be used to get the common ancestor in the chain upon detecting
a block chain reorganization.
2022-10-17 10:26:23 +02:00
Antoine Poinsot
efe2cf634d
Merge #60: Clippification
7e911b8bb7ccca866db2afadb357615d3712a4cb ci: add Clippy check for both the daemon and the GUI (Antoine Poinsot)
6871407b1a2514c8c3b259a88cd5c267b206761e gui: clippification (Antoine Poinsot)
8b4866158bc2097a14857194d38bfb058678a55b daemon: clippification (Antoine Poinsot)

Pull request description:

  This fixes *all* clippy warning from the whole repository. Some of them are... Well very opinionated to say the least. But to avoid bikeshedding i just applied all of them. Let's start fresh!

  @edouardparis can you skim through the clippy fixes in the GUI folder? I checked the daemon one already.

  Fixes #10.

ACKs for top commit:
  edouardparis:
    ACK 7e911b8bb7ccca866db2afadb357615d3712a4cb

Tree-SHA512: acebc86425039511d090b58139e12c149463d7a288d0d2aed3ba75d303aa2034db65f39f7e00436d556e86aa382686acab6699e65afe10ea31238c0a48a0635c
2022-10-14 12:31:20 +02:00
Antoine Poinsot
7e911b8bb7
ci: add Clippy check for both the daemon and the GUI 2022-10-13 14:24:25 +02:00
Antoine Poinsot
6871407b1a
gui: clippification 2022-10-13 14:24:25 +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
2a3214460e
Merge #29: Check spend status in bitcoin poller
172cda19a0a72b77e3832f2e29ed7ff6f8062c44 bitcoin: avoid an unnecessary large clone() (Antoine Poinsot)
7513bcbf09f13f1625b989d52c52087048d90a73 bitcoind: use and_then instead of map().flatten() (Antoine Poinsot)
51f11a9e2f51945c7ec1f59a9acfd43d2f3977d3 looper: cleanup the check for spending coins' confirmation (Antoine Poinsot)
c9b6c6dedbc1e28b05543191238d0a81a92ba238 db: re-rename list_unspent_coins into unspent_coins (Antoine Poinsot)
3534e35b8721c5026b27d4d3c07b87dc6e4fa3dd bitcoin: remove erroneous block height check (Antoine Poinsot)
bb9897bdbb9926f6c3f8d9fb95339e45546372e2 Update coin txid if conflicting tx was confirmed (edouard)
3cf6bcbb98fc0034bc46ed58564e8aa4a1b6ffa6 add spent_coins to bitcoind poller (edouard)
94ee94edbdcdd917df131ad87893406f5f8597a2 Add blocktime and spent_at to coins table (edouard)

Pull request description:

  Add two new columns:

  - `blocktime`: timestamp of the block containing the transaction funding the coin.
  - `spent_at`: timestamp of the block containing the transaction spending the coin.

  Update the coin `spent_at` when the spend transaction is confirmed

ACKs for top commit:
  darosior:
    ACK 172cda19a0a72b77e3832f2e29ed7ff6f8062c44

Tree-SHA512: 4f12dd273784c1e8fab7f6427800fd10e6404d47e07e2293106d4454165dffb856cd65c5f4e4537867be403bd1790ce363968bfb94fec58ab02af3624ed68f22
2022-10-12 17:27:46 +02:00
Antoine Poinsot
172cda19a0
bitcoin: avoid an unnecessary large clone() 2022-10-12 17:25:56 +02:00
Antoine Poinsot
7513bcbf09
bitcoind: use and_then instead of map().flatten() 2022-10-12 17:25:22 +02:00
Antoine Poinsot
51f11a9e2f
looper: cleanup the check for spending coins' confirmation 2022-10-12 17:24:27 +02:00
Antoine Poinsot
c9b6c6dedb
db: re-rename list_unspent_coins into unspent_coins 2022-10-12 17:19:27 +02:00
Antoine Poinsot
3534e35b87
bitcoin: remove erroneous block height check 2022-10-12 17:17:45 +02:00
edouard
bb9897bdbb Update coin txid if conflicting tx was confirmed 2022-10-05 17:41:16 +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
ac6e0443ea
Merge #30: Spend transactions listing and deletion
c73e8a42dd050c1e24daf295c666f6aa625f3bee commands: add a new 'delspendtx' command (Antoine Poinsot)
d5bd10add8270c1e0aae1855e6f8a96649323e24 commands: add a change_index field to listspendtxs entries (Antoine Poinsot)
c6e004806aecef54c640119439406b5308fbacd0 commands: add a 'list_spend' command (and 'listspendtxs' RPC) (Antoine Poinsot)

Pull request description:

  Based on #27 this implements listing and deletion of Spend transaction from database. The API was based off revaultd's one and @edouardparis' suggestions in #1. We could be smarter in various places but at the moment we KISS.

ACKs for top commit:
  darosior:
    ACK c73e8a42dd050c1e24daf295c666f6aa625f3bee

Tree-SHA512: d4a13b9cbc9a6d48f698ba2f113c5de116b17cc51ed1f8dba578c041d9a70249699627729562ea199b32db6aaa9d2eb973d2b890f35a5e398e9c34940701ea86
2022-10-04 02:06:00 +02:00
Antoine Poinsot
9c787d061d
Merge #27: Spend transactions creation and storage
3dfc7261db33a4db85772dfa9db5f61f8d8952e2 jsonrpc: a new 'updatespend' RPC (Antoine Poinsot)
cf45ba0fa5ead02997f1ffe7fea4faf83894ec8d commands: add a new 'update_spend' command (Antoine Poinsot)
bafcadf39870c02b89a9a4627a6918fce6c54f30 db: interface to upsert a Spend PSBT and query it by txid (Antoine Poinsot)
7d015bcf435897fa6e129b931fd2bea742ff7bc5 jsonrpc: add a 'createspend' RPC command (Antoine Poinsot)
7468a7fcfb37736c4585d16c091fb5db68bf50cc qa: add PSBT and transaction serialization to the test framework (Antoine Poinsot)
09f59c417ba04a153887a7cdf1e284703c9647aa qa: fix the UDS class' forwarding method calls as JSONRPC calls (Antoine Poinsot)
9afd44061e12c4b50720571d7e6aa0c260e725eb commands: add a new create_spend command (Antoine Poinsot)
12188f0c52d5ab141c1dcea194851ba01c04a57d descriptors: add more utilities to the derived descriptor type (Antoine Poinsot)
46320d5fc09371d1657044fd1a8507e919bcaff4 db: an interface to query coins by their outpoints (Antoine Poinsot)

Pull request description:

  This implements two new commands to create and store a Spend transaction PSBT. We'll need a `listspendtxs` and `delspendtx` eventually as in `revaultd`.

  This has poor change management (address reuse for simplicity). I was thinking of using odd/even indexes to differentiate receive/change addresses before we have [multi-path descriptors](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-July/020791.html). Now i wonder if it makes sense at all to implement this odd/even thing and just stick with address reuse before multi-paths descriptors. Nobody is supposed to use that anyways.

ACKs for top commit:
  darosior:
    ACK 3dfc7261db33a4db85772dfa9db5f61f8d8952e2

Tree-SHA512: 7f148c4d0d9ff8054c6405ca3031c2629c79917cdbf0134949ce7e066fa5aa157eb5bbe823d56a165a14c946d72c615d7dafa920899ba21d8471cc935c14790b
2022-10-04 01:54:09 +02:00
Antoine Poinsot
2397b4a889
Merge #31: ci: add a Cirrus configuration for the functional tests
24cf9645e0897ab880949813daceac07ddb67234 ci: add a Cirrus configuration for the functional tests (Antoine Poinsot)

Pull request description:

  Taken and adapted from revaultd.

  Now that 24.0rc1 of Bitcoin Core is released we can actually have a CI for functional tests.

  Fixes #14.

ACKs for top commit:
  darosior:
    ACK 24cf9645e0897ab880949813daceac07ddb67234

Tree-SHA512: d1157fc6caf507c6507a2c73df02b097c9e2f1b8ecb2330f8b2f65ffe8a368e7d6265a9d0538c5c9ed3623df6fd03f49dff259bdd0019784008106f392e0ab0b
2022-10-01 16:44:38 +02:00
Antoine Poinsot
24cf9645e0
ci: add a Cirrus configuration for the functional tests
Taken and adapted from revaultd.
2022-10-01 15:30:59 +02:00
Antoine Poinsot
c73e8a42dd
commands: add a new 'delspendtx' command 2022-10-01 14:05:27 +02:00
Antoine Poinsot
d5bd10add8
commands: add a change_index field to listspendtxs entries 2022-10-01 13:40:49 +02:00
Antoine Poinsot
c6e004806a
commands: add a 'list_spend' command (and 'listspendtxs' RPC) 2022-10-01 13:33:08 +02:00
Antoine Poinsot
3dfc7261db
jsonrpc: a new 'updatespend' RPC 2022-09-15 11:41:34 +02:00
Antoine Poinsot
cf45ba0fa5
commands: add a new 'update_spend' command
Store a Spend PSBT in database, and update it if it already exists.
Merge signatures between the given PSBT and the one in db.
2022-09-15 11:41:34 +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
7d015bcf43
jsonrpc: add a 'createspend' RPC command
Since the Spend transaction command requires some parameters, this
implements the parameter-getting logic on the JSONRPC side as well.

This allows us to implement an end-to-end functional test of the
transaction flow using an external way to broadcast it. From the input
coins creation, to the Spend transaction broadcast.
2022-09-15 11:41:33 +02:00
Antoine Poinsot
7468a7fcfb
qa: add PSBT and transaction serialization to the test framework
Copied it from revaultd.
2022-09-15 11:41:32 +02:00
Antoine Poinsot
09f59c417b
qa: fix the UDS class' forwarding method calls as JSONRPC calls
We weren't passing arguments if they were a list!
2022-09-15 11:41:32 +02:00
Antoine Poinsot
9afd44061e
commands: add a new create_spend command 2022-09-15 11:41:31 +02:00
Antoine Poinsot
12188f0c52
descriptors: add more utilities to the derived descriptor type
We'll need those to add them to PSBTs we create.
2022-09-15 11:41:30 +02:00
Antoine Poinsot
46320d5fc0
db: an interface to query coins by their outpoints 2022-09-15 11:41:29 +02:00
edouard
dab40527ae
Merge #17: Typesafe descriptor management
ee86a1bd5ebbda39885f1e8869bf8ae03552d682 descriptors: add a helper to get the value of the timelock (Antoine Poinsot)
0fd57db8a893ae2621ca5f3cc03c6393c3a65646 Use the descriptor newtype instead of the raw miniscript Descriptor type (Antoine Poinsot)
44eb0fad9b758f7b81caea735b1a6ea41b29ebd6 descriptors: introduce a newtype for derived descriptors (Antoine Poinsot)
869d370daa354c76292517448646d0b7f76facba descriptors: introduce an InheritanceDescriptor type (Antoine Poinsot)

Pull request description:

  This introduces types for our inheritance descriptor. This is taken and adapted from revaultd, where it turned out to be very helpful.

  This also adds a helper to query the timelock of the heir's spending path in the inheritance descriptor for downstream users to be able to compute the expiration block of each coin.

  This is based on #13.

ACKs for top commit:
  edouardparis:
    utACK ee86a1bd5ebbda39885f1e8869bf8ae03552d682

Tree-SHA512: 948720967052fcd0e83c3f061f981b25d79c4cc62bbd521de5ea27ee0f08ed1c50c3c089c9cb0729e1bdc59f4acfed1fa05decdbe4fd8b549abd3345c34d66a5
2022-09-15 09:43:35 +02:00
edouard
f5387f7ed9
Merge #22: gui: Home and Receive panels
7f9fd84beead64ef8fe259f1174e01cbc0dd4cfa Add balance to panel home (edouard)
157d9b39333e9eae1b1fc231bc6abd2f6661bca6 Add coins to cache (edouard)
f32b4d52d2facf409d73b8e27a67d05e13255373 daemon: add list_coins method (edouard)
647b74ebcf789e8df7bf530e83258a3a38286be9 Add unit test for receive panel state (edouard)
ebc239733c3a508f08f5539a862d3029d45c753f Add sandbox and daemon mock to utils mod (edouard)
928294b32e2afa0ae4472817f8bbb1e477b8afdb Add receive panel (edouard)
1026d2b487c3f0d9955b93d1cf1b79a0a8ad94bf Add get_new_address to daemon trait (edouard)
2286a19e20cfde07d4c7eb4bdd3190abea3a09d1 Update minisafe master:#4a802890 (edouard)

Pull request description:

ACKs for top commit:
  edouardparis:
    Self ACK 7f9fd84beead64ef8fe259f1174e01cbc0dd4cfa

Tree-SHA512: b0c0b89540ede0f7f895197595af8b97fa515d5e4b6b7f3dcd4e29b02bfcb0a9ce338f3ee5644e486892ab132c456fca29ad4189a3f71f6420f535f99dbe77ba
2022-09-07 15:25:10 +02:00
edouard
7f9fd84bee Add balance to panel home 2022-09-07 15:12:08 +02:00
edouard
157d9b3933 Add coins to cache 2022-09-07 15:12:08 +02:00
edouard
f32b4d52d2 daemon: add list_coins method 2022-09-07 15:12:08 +02:00
edouard
647b74ebcf Add unit test for receive panel state 2022-09-07 15:12:08 +02:00
edouard
ebc239733c Add sandbox and daemon mock to utils mod 2022-09-07 15:12:08 +02:00
edouard
928294b32e Add receive panel 2022-09-07 15:12:08 +02:00
edouard
1026d2b487 Add get_new_address to daemon trait 2022-09-07 15:12:08 +02:00
edouard
2286a19e20 Update minisafe master:#4a802890 2022-09-07 15:12:08 +02:00
edouard
4a80289063
Merge #23: gui: fix clippy errors and wrong title
baa87375d046046478bc9195ff4802518a3247d3 fix windows title and doc (edouard)
b77d331792923eb0dc1bad7dd67e565698ef93c1 fix clippy errors (edouard)

Pull request description:

ACKs for top commit:
  edouardparis:
    ACK baa87375d046046478bc9195ff4802518a3247d3

Tree-SHA512: c9cefb39664512c0618422710e5d9d0e6a980f5a724d1e0f62cc2269f7520db8fc5529102e236c3ac3624a742da74864986e6766b19e015b7f058cde2b6956f5
2022-09-06 09:10:35 +02:00
edouard
baa87375d0 fix windows title and doc 2022-09-05 18:36:33 +02:00
edouard
b77d331792 fix clippy errors 2022-09-05 18:34:45 +02:00
Antoine Poinsot
3d427713e1
Merge #13: Coin tracking
9d0c68dae34f96a96d318f75cbbb5dbefffdd3d8 commands: add a 'list_coins' command. (Antoine Poinsot)
99a9cbf0f83fda6f98892c23ac89324f04b650ff poller: query derivation index by address from DB (Antoine Poinsot)
3f17e9f0c32db9724b384b9bd58c097653e9d04f database: change interface from update_der_index to increment_der_index (Antoine Poinsot)
e74ea4c2d36d17d0aa05044991d2cfff311d9f37 sqlite: a table for a mapping from address to derivation index. (Antoine Poinsot)
c9ef068fa5cb0ec39a9a88ec581434f6abb84048 poller: update our coins on each poll (Antoine Poinsot)
c6a25adfcdd371a1a2581cc210fb4dc03dfced2d bitcoin: interface for coins discovery and updates (Antoine Poinsot)
05b3af1b5a9faaa54106e11f87e38b391ebff744 database: interface and implementation for coins storage and update (Antoine Poinsot)

Pull request description:

ACKs for top commit:
  edouardparis:
    ACK 9d0c68dae34f96a96d318f75cbbb5dbefffdd3d8

Tree-SHA512: 0087ff04939326ae7affbb4c0defbe5573fc58d15f4b2fb47a71a03880187c4105742cc9eda868c3fe0ee5890931dc57eb3c63b4ef79335f434771d5cc089483
2022-08-25 10:29:50 +02:00
edouard
4e26f18bc2
Merge #19: Gui settings
29e134748df363963092e16dcd288ed6431d7434 Add settings panel to gui (edouard)

Pull request description:

  based on #8

ACKs for top commit:
  edouardparis:
    ACK 29e134748df363963092e16dcd288ed6431d7434

Tree-SHA512: 7a09c00d53ddef091219ffe5bf702795171bc0575b55f4930680a251d712d8cfdf30afd1ad38218c01c8430346fe95625202eb30b8cb9e1190d40806a7e6d226
2022-08-24 17:30:07 +02:00