Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
zeth_ls_notes.py
Go to the documentation of this file.
1 # Copyright (c) 2015-2022 Clearmatics Technologies Ltd
2 #
3 # SPDX-License-Identifier: LGPL-3.0+
4 
5 from zeth.cli.utils import open_web3_from_ctx, load_zeth_address_secret, \
6  open_wallet, load_mixer_description_from_ctx
7 from zeth.core.utils import EtherValue
8 from click import Context, command, option, pass_context
9 
10 
11 @command()
12 @option("--balance", is_flag=True, help="Show total balance")
13 @option("--spent", is_flag=True, help="Show spent notes")
14 @pass_context
15 def ls_notes(ctx: Context, balance: bool, spent: bool) -> None:
16  """
17  List the set of notes owned by this wallet
18  """
19  client_ctx = ctx.obj
20  web3 = open_web3_from_ctx(client_ctx)
21  mixer_desc = load_mixer_description_from_ctx(client_ctx)
22  mixer_instance = mixer_desc.mixer.instantiate(web3)
23  js_secret = load_zeth_address_secret(client_ctx)
24  wallet = open_wallet(mixer_instance, js_secret, client_ctx)
25 
26  total = EtherValue(0)
27  for addr, short_commit, value in wallet.note_summaries():
28  print(f"{short_commit}: value={value.ether()}, addr={addr}")
29  total = total + value
30 
31  if balance:
32  print(f"TOTAL BALANCE: {total.ether()}")
33 
34  if not spent:
35  return
36 
37  print("SPENT NOTES:")
38  for addr, short_commit, value in wallet.spent_note_summaries():
39  print(f"{short_commit}: value={value.ether()}, addr={addr}")
zeth.cli.utils.open_web3_from_ctx
Any open_web3_from_ctx(ClientConfig ctx)
Definition: utils.py:135
zeth.cli.utils.open_wallet
Wallet open_wallet(Any mixer_instance, ZethAddressPriv js_secret, ClientConfig ctx)
Definition: utils.py:275
zeth.cli.utils.load_mixer_description_from_ctx
MixerDescription load_mixer_description_from_ctx(ClientConfig ctx)
Definition: utils.py:220
zeth.cli.utils.load_zeth_address_secret
ZethAddressPriv load_zeth_address_secret(ClientConfig ctx)
Definition: utils.py:247
zeth.cli.utils
Definition: utils.py:1
zeth.cli.zeth_ls_notes.ls_notes
None ls_notes(Context ctx, bool balance, bool spent)
Definition: zeth_ls_notes.py:15
zeth.core.utils
Definition: utils.py:1
zeth.core.utils.EtherValue
Definition: utils.py:46