Zebra/zebra-state/src
Janito Vaqueiro Ferreira Filho e5f00c5902
feat(rpc): Implement `getaddressbalance` RPC (#4138)
* Add `Amount::serialize_as_string` helper method

A helper method that makes it easier to serialize an `Amount` as a
string. This is needed for the response type of the `getaccountbalance`
RPC.

* Implement state service call for address balance

Add `Read{Request,Response}::AddressBalance` variants and implement the
handler that calls the query function.

* Create an `AddressBalance` response type

Only contains the `balance` field which is needed by `lightwalletd`.
That field is serialized as a string, following the RPC specification.

* Implement `get_address_balance` RPC

Query the read-only state service for the information, and wrap it in an
`AddressBalance` response type so that it is serialized correctly.

* Run `rustfmt` inside `proptest!` block

Fix some minor formatting details.

* Test `get_address_balance` with valid addresses

Check that the RPC leads to a query to the mocked state service for a
balance amount.

* Test `get_address_balance` with invalid addresses

An error message should be returned by the RPC.

* Rename metric to `address_balance`

Keep it consistent with how it's named in other places.

Co-authored-by: teor <teor@riseup.net>

* Revert "Add `Amount::serialize_as_string` helper method"

This reverts commit 01b432e3d2ac2313a90d55d06b3fa855c0b71330.

* Serialize amount as an integer

This is different from what the documentation says, but it's what
lightwalletd expects.

* Add reference to RPC documentation

Make sure it is linked to for easy access.

* Create an `AddressStrings` type

To be used as the input for the `get_address_balance` RPC method.

* Use `AddressStrings` in `get_address_balance` RPC

Fix the input parameter so that the list of address strings is placed
inside a JSON map.

* Update property tests to use `AddressStrings`

Make sure the proper input type is created.

Co-authored-by: teor <teor@riseup.net>
2022-04-20 18:27:00 +00:00
..
service refactor: document coinbase rules, refactor to ease understanding (#4056) 2022-04-20 09:31:12 +00:00
tests feat(state): add transparent address indexes to the non-finalized state (#4022) 2022-04-12 17:21:46 +00:00
arbitrary.rs feat(state): add transparent address indexes to the non-finalized state (#4022) 2022-04-12 17:21:46 +00:00
config.rs 2. refactor(state): move all RocksDB API calls to the disk_db module (#3578) 2022-02-22 12:59:44 +00:00
constants.rs change(nu5): use new V5 transaction script verification API (#3799) 2022-04-19 10:14:16 +10:00
error.rs Validate sapling, orchard anchors (#3084) 2021-11-30 16:05:35 +00:00
lib.rs feat(state): add transparent address indexes to the non-finalized state (#4022) 2022-04-12 17:21:46 +00:00
request.rs feat(rpc): Implement `getaddressbalance` RPC (#4138) 2022-04-20 18:27:00 +00:00
response.rs feat(rpc): Implement `getaddressbalance` RPC (#4138) 2022-04-20 18:27:00 +00:00
service.rs feat(rpc): Implement `getaddressbalance` RPC (#4138) 2022-04-20 18:27:00 +00:00
tests.rs ZIP-221 and ZIP-244 commitment validation in non-finalized state (#2609) 2021-08-17 11:49:27 -03:00
util.rs feat(log): log the state tip height as part of sync progress logs (#3437) 2022-01-28 19:12:19 -03:00