Sapling client: add `show history` command
Status
For each commitment, there are two ciphertexts, one for the receiver (called payload_enc
in lib_sapling/core.ml
) and one for the sender (called payload_out
). They contain the following fields: memo, amount, address, rcm.
If a vk can decipher payload_enc
(or payload_out
), then it means that it is the receiver ( or the sender). If it can decipher both then it's both sender and receiver, which is usually the case for handling the change
in a UTXO model.
Right now this information is not used, except when getting the global balance of a key. It would be nice to have a command to show the history of a key.
Proposed command and sample output
tezos-client sapling show history using <contract> [--json]
# Contract : <contract>
## vk : <vk>
### received and sent / change
| pos | amount | memo | address |
| . | . | . | . |
### received only
| pos | amount | memo | address |
| . | . | . | . |
### sent only
| pos | amount | memo | address |
| . | . | . | . |
## vk : <vk>
...
Implementation
In lib_client_sapling/context.ml
the structure Account.t
keeps the status of each account after each scan of the Sapling state. It should contain a new field:
type kind = Sent | Received | Send_and_received
type history = {
memo : string;
amount : Shielded_tez.t;
address : Viewing_key.address;
kind : kind;
}
The command should return a nice visualization of this data and optionally a json representation of it.