Skip to content

Commit 2530785

Browse files
authored
Merge pull request #193 from nuttycom/feature/listunspent
rpc (z_listunspent): support the same arguments as `zcashd`s version of the RPC
2 parents 3c9ad46 + bb206fa commit 2530785

File tree

8 files changed

+314
-188
lines changed

8 files changed

+314
-188
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ tonic = "0.13"
119119

120120
[patch.crates-io]
121121
age = { git = "https://github.com/str4d/rage.git", rev = "84dc1e9f641994388f107ceebdbaa00126e30e16" }
122-
equihash = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
123-
transparent = { package = "zcash_transparent", git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
124-
zcash_address = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
125-
zcash_client_backend = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
126-
zcash_client_sqlite = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
127-
zcash_encoding = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
128-
zcash_history = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
129-
zcash_keys = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
130-
zcash_primitives = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
131-
zcash_proofs = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
132-
zcash_protocol = { git = "https://github.com/zcash/librustzcash.git", rev = "796abb548fc8366738f16a5252fd026d5bd92652" }
122+
equihash = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
123+
transparent = { package = "zcash_transparent", git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
124+
zcash_address = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
125+
zcash_client_backend = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
126+
zcash_client_sqlite = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
127+
zcash_encoding = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
128+
zcash_history = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
129+
zcash_keys = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
130+
zcash_primitives = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
131+
zcash_proofs = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
132+
zcash_protocol = { git = "https://github.com/zcash/librustzcash.git", rev = "7cb49e1b897f30adb7a672f37eaf170cab5c300d" }
133133

134134
zaino-fetch = { git = "https://github.com/zingolabs/zaino.git", rev = "fc4a51118328045e7a337a6004698779ec872654" }
135135
zaino-proto = { git = "https://github.com/zingolabs/zaino.git", rev = "fc4a51118328045e7a337a6004698779ec872654" }

book/src/zcashd/json_rpc.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ Changes to response:
7979
- `memoStr` field on outputs is no longer only omitted if `memo` does not
8080
contain valid UTF-8.
8181

82+
### `z_listunspent`
83+
84+
Changes to response:
85+
- For each output in the response array:
86+
- The `amount` field has been renamed to `value` for consistency with
87+
`z_viewtransaction`. The `amount` field may be reintroduced under a deprecation
88+
flag in the future if there is user demand.
89+
- A `valueZat` field has been added for consistency with `z_viewtransaction`
90+
- An `account_uuid` field identifying the account that received the output
91+
has been added.
92+
- The `account` field has been removed and there is no plan to reintroduce it;
93+
use the `account_uuid` field instead.
94+
- An `is_watch_only` field has been added.
95+
- The `spendable` field has been removed; use `is_watch_only` instead. The
96+
`spendable` field may be reintroduced under a deprecation flag in the
97+
future if there is user demand.
98+
- The `change` field has been removed, as determining whether an output
99+
qualifies as change involves a bunch of annoying subtleties and the
100+
meaning of this field has varied between Sapling and Orchard.
101+
- A `walletInternal` field has been added.
102+
82103
### `z_sendmany`
83104

84105
Changes to parameters:

supply-chain/config.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,15 @@ version = "0.7.1"
552552
criteria = "safe-to-deploy"
553553

554554
[[exemptions.equihash]]
555-
version = "0.2.2@git:796abb548fc8366738f16a5252fd026d5bd92652"
555+
version = "0.2.2@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
556556
criteria = "safe-to-deploy"
557557

558558
[[exemptions.eyre]]
559559
version = "0.6.12"
560560
criteria = "safe-to-deploy"
561561

562562
[[exemptions.f4jumble]]
563-
version = "0.1.1@git:796abb548fc8366738f16a5252fd026d5bd92652"
563+
version = "0.1.1@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
564564
criteria = "safe-to-deploy"
565565

566566
[[exemptions.fallible-iterator]]
@@ -1784,43 +1784,43 @@ version = "0.1.2@git:fc4a51118328045e7a337a6004698779ec872654"
17841784
criteria = "safe-to-deploy"
17851785

17861786
[[exemptions.zcash_address]]
1787-
version = "0.9.0@git:796abb548fc8366738f16a5252fd026d5bd92652"
1787+
version = "0.9.0@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
17881788
criteria = "safe-to-deploy"
17891789

17901790
[[exemptions.zcash_client_backend]]
1791-
version = "0.19.1@git:796abb548fc8366738f16a5252fd026d5bd92652"
1791+
version = "0.19.1@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
17921792
criteria = "safe-to-deploy"
17931793

17941794
[[exemptions.zcash_client_sqlite]]
1795-
version = "0.17.2@git:796abb548fc8366738f16a5252fd026d5bd92652"
1795+
version = "0.17.3@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
17961796
criteria = "safe-to-deploy"
17971797

17981798
[[exemptions.zcash_encoding]]
1799-
version = "0.3.0@git:796abb548fc8366738f16a5252fd026d5bd92652"
1799+
version = "0.3.0@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
18001800
criteria = "safe-to-deploy"
18011801

18021802
[[exemptions.zcash_history]]
1803-
version = "0.4.0@git:796abb548fc8366738f16a5252fd026d5bd92652"
1803+
version = "0.4.0@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
18041804
criteria = "safe-to-deploy"
18051805

18061806
[[exemptions.zcash_keys]]
1807-
version = "0.10.1@git:796abb548fc8366738f16a5252fd026d5bd92652"
1807+
version = "0.10.1@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
18081808
criteria = "safe-to-deploy"
18091809

18101810
[[exemptions.zcash_primitives]]
1811-
version = "0.24.0@git:796abb548fc8366738f16a5252fd026d5bd92652"
1811+
version = "0.24.0@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
18121812
criteria = "safe-to-deploy"
18131813

18141814
[[exemptions.zcash_proofs]]
1815-
version = "0.24.0@git:796abb548fc8366738f16a5252fd026d5bd92652"
1815+
version = "0.24.0@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
18161816
criteria = "safe-to-deploy"
18171817

18181818
[[exemptions.zcash_protocol]]
1819-
version = "0.6.1@git:796abb548fc8366738f16a5252fd026d5bd92652"
1819+
version = "0.6.1@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
18201820
criteria = "safe-to-deploy"
18211821

18221822
[[exemptions.zcash_transparent]]
1823-
version = "0.4.0@git:796abb548fc8366738f16a5252fd026d5bd92652"
1823+
version = "0.4.0@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
18241824
criteria = "safe-to-deploy"
18251825

18261826
[[exemptions.zebra-chain]]
@@ -1868,5 +1868,5 @@ version = "0.8.24"
18681868
criteria = "safe-to-deploy"
18691869

18701870
[[exemptions.zip321]]
1871-
version = "0.5.0@git:796abb548fc8366738f16a5252fd026d5bd92652"
1871+
version = "0.5.0@git:7cb49e1b897f30adb7a672f37eaf170cab5c300d"
18721872
criteria = "safe-to-deploy"

zallet/src/components/database/connection.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use zcash_client_backend::data_api::{AddressInfo, Balance, TargetValue, Zip32Der
1212
use zcash_client_backend::{
1313
address::UnifiedAddress,
1414
data_api::{
15-
AccountBirthday, AccountMeta, InputSource, NoteFilter, ORCHARD_SHARD_HEIGHT,
16-
SAPLING_SHARD_HEIGHT, SpendableNotes, WalletCommitmentTrees, WalletRead, WalletWrite,
15+
AccountBirthday, AccountMeta, InputSource, NoteFilter, ORCHARD_SHARD_HEIGHT, ReceivedNotes,
16+
SAPLING_SHARD_HEIGHT, WalletCommitmentTrees, WalletRead, WalletWrite,
1717
},
1818
keys::{UnifiedAddressRequest, UnifiedFullViewingKey, UnifiedSpendingKey},
1919
wallet::{Note, ReceivedNote, TransparentAddressMetadata, WalletTransparentOutput},
@@ -381,7 +381,7 @@ impl InputSource for DbConnection {
381381
target_height: TargetHeight,
382382
confirmations_policy: ConfirmationsPolicy,
383383
exclude: &[Self::NoteRef],
384-
) -> Result<SpendableNotes<Self::NoteRef>, Self::Error> {
384+
) -> Result<ReceivedNotes<Self::NoteRef>, Self::Error> {
385385
self.with(|db_data| {
386386
db_data.select_spendable_notes(
387387
account,
@@ -394,6 +394,16 @@ impl InputSource for DbConnection {
394394
})
395395
}
396396

397+
fn select_unspent_notes(
398+
&self,
399+
account: Self::AccountId,
400+
sources: &[ShieldedProtocol],
401+
target_height: TargetHeight,
402+
exclude: &[Self::NoteRef],
403+
) -> Result<ReceivedNotes<Self::NoteRef>, Self::Error> {
404+
self.with(|db_data| db_data.select_unspent_notes(account, sources, target_height, exclude))
405+
}
406+
397407
fn get_unspent_transparent_output(
398408
&self,
399409
outpoint: &OutPoint,

zallet/src/components/json_rpc/methods.rs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,29 @@ pub(crate) trait Rpc {
275275
/// returned, even though they are not immediately spendable.
276276
///
277277
/// # Arguments
278-
/// - `minconf` (default = 1)
278+
/// - `minconf`: Select outputs with at least this many confirmations (default = 1)
279+
/// - `maxconf`: Select outputs with at most this many confirmations (default = unlimited).
280+
/// - `include_watchonly`: Include notes/utxos for which the wallet does not provide spending
281+
/// capability (default = false).
282+
/// - `addresses`: A list of addresses for which to retrieve UTXOs. For shielded addresses that
283+
/// correspond to a unified account, unspent notes belonging to that account are returned
284+
/// irrespective of whether the provided address's diversifier corresponds to the diversifier
285+
/// of the address that received the funds. If this parameter is omitted or empty, all notes
286+
/// are returned, irrespective of account. (default = None)
287+
/// - `as_of_height`: Execute the query as if it were run when the blockchain was at the height
288+
/// specified by this argument. The default is to use the entire blockchain that the node is
289+
/// aware of. -1 can be used as in other RPC calls to indicate the current height (including
290+
/// the mempool), but this does not support negative values in general. A “future” height will
291+
/// fall back to the current height.
279292
#[method(name = "z_listunspent")]
280-
async fn list_unspent(&self) -> list_unspent::Response;
293+
async fn list_unspent(
294+
&self,
295+
minconf: Option<u32>,
296+
maxconf: Option<u32>,
297+
include_watchonly: Option<bool>,
298+
addresses: Option<Vec<String>>,
299+
as_of_height: Option<i64>,
300+
) -> list_unspent::Response;
281301

282302
#[method(name = "z_getnotescount")]
283303
async fn get_notes_count(
@@ -536,8 +556,22 @@ impl RpcServer for RpcImpl {
536556
view_transaction::call(self.wallet().await?.as_ref(), self.chain().await?, txid).await
537557
}
538558

539-
async fn list_unspent(&self) -> list_unspent::Response {
540-
list_unspent::call(self.wallet().await?.as_ref())
559+
async fn list_unspent(
560+
&self,
561+
minconf: Option<u32>,
562+
maxconf: Option<u32>,
563+
include_watchonly: Option<bool>,
564+
addresses: Option<Vec<String>>,
565+
as_of_height: Option<i64>,
566+
) -> list_unspent::Response {
567+
list_unspent::call(
568+
self.wallet().await?.as_ref(),
569+
minconf,
570+
maxconf,
571+
include_watchonly,
572+
addresses,
573+
as_of_height,
574+
)
541575
}
542576

543577
async fn get_notes_count(

0 commit comments

Comments
 (0)