Funding Proposal 3: Deep scan for grin-wallet (Rust)

Adding a Deep-scan function to grin-wallet (Rust)

The idea is that currently neither Grin++ or grin-wallet (Rust) allow a user to reconstruct their history based on the creation or spending of outputs. The reason is that Grin is designed ‘to forget’ your transactions Cut-through allows any spend transaction output to be forgotten, meaning its commitment and range-proof are pruned and can be forgotten by nodes. This is a beautiful property of grin since it means the blockchain can stay rather minimal since a node only has to remember the kernel for any spend outputs but can remove the commits and space taking range-proofs.

So how can we than reconstruct the history of a wallet?

Short answer is, you cannot. Meaning you cannot reconstruct which outputs in a block where used to create outputs for you or which outputs you created in a transaction based on what is stored on the blockchain. However, if you run an archive node, you can see when outputs where created that belong to your wallets and when they were spend. Meaning that at least on the individual block level you can see when you spend or received Grin. Only if you would send multiple transaction in one block, or would receive and send within the same block, your wallet could not be able to reconstruct this information based on the full archive blockchain.


I would propose to add a deep-scan function to grin-wallet. I think this can be done without having to adding or modifying much existing code. Basically it would be like doing a normal scan, but then per block meaning you have to specify the start and ending block. This function would be a wrapper of existing functionalities, like scan, but than applied to range of block or single block. Perhaps for efficiency, updating the wallet database should not be done for each block individually but after collecting all the information per block.
The found receiving and spending of outputs should be added to the wallet transaction overview for found spend or received funds not already present in any transactions stored in the wallets memory.

Do we need this deep-scan feature?

It would come in handy for seeing the historic transactions from a wallet. It would be handy for example to reconstruct the CC Grin wallets history. I can also imagine this might be handy for other power users such as exchange that might encounter corruption of a wallet, or otherwise lose their wallet history. For regular users, this feature is less interesting.
This feature might be contained enough to be suitable for a small bounty. What do you think @Yeastplume, would this feature be suitable for a small bounty?

Tagging potential devs: @renzokuken, @ardocrat , @AceKaplin