Zcash Extensible Wallet Interchange Format (ZeWIF) Meeting

I was working on a project called uzw-parser or Universal Zcash Wallet Parser:

Concept

The idea was to create a lib that can parse many wallet formats and export into a common rust structure, so it can be used to extract seeds, keys or even convert to another formats.

Here’s the basic struct:

pub struct WalletAccount {
    pub name: String,
    pub seed: Option<Vec<u8>>,
    pub birthday: BlockHeight,
    pub keys: WalletKeys
}

pub struct Wallet {
    pub wallet_name: String,
    pub version: u64,
    pub accounts: Vec<WalletAccount>
}

Explanation:
A Wallet struct holds information about the source wallet, e.g. ZecWallet Lite, YWallet, and so on … and version number, for compatibility tracking.
A Wallet also has one or more WalletAccounts, which hold a account name, seed and keys. The keys is yet another struct that contains sk, ivk, account index and key source (HD or imported)

Parsing wallet files

I implemented parsers for ZecWallet lite, but it’s imcomplete, it can only parse ZecWallet files version 25 (latest), cannot parse encrypted wallet files and cannot parse the birthday height.
I also implemented basic YWallet parsing.

Maybe Ze-WIF prototype?

I believe this lib and structs are basically the skeleton for a ZeWIF of some sorts. Just remove redundancies, serialize and encode this struct and there we go.

WalletParser <> WalletWriter

Basically the project has a WalletParser and WalletWriter trait bounds, which when implemented can generate the struct mentioned above and save to another format.

As a test, I implemented a writer for YWallet, so the lib can parse a ZecWallet lite file, construct a Wallet struct and then write it to Ywallet compatible seqlite db. No tests was made to see if the generated wallet actually works, but at least it syncs.

I’m still very new to Rust development, but in this project I was trying to use generics to allow implementations for any wallet format in a easy manner, anyone fell free to fork the code and do your own parsers and writers.

See it in action

If you wan to see the parsing in action, edit cli/src/main.rs and uncomment lines 6 and 17 (and maybe comment lines 7 and 8) , then run cargo run to see the the results (example wallet files are provided in the repo).

This was a learning project and should not be considered a production ready code.

I’m probably attending the zoom call, I want to learn more from the experts.

8 Likes