Wallet DB
The wallet uses a RocksDB database, located by default at %userprofile%\.GrinPP\MAINNET\WALLET
.
As of 0.4.0, there are 6 tables(column families) used by the Grin++ wallet:
Each user has a single entry in the SEED
table.
KEY: username
VALUE:
Field | Bytes |
---|---|
Version | 1 |
Init. Vector | 16 |
Salt | 8 |
AES encrypted seed | VAR |
PLANNED CHANGES: This table will be replaced with a separate seed file, making manual backups much easier.
Each user has a single entry in the metadata table.
KEY: Hex(Blake2b(username))
VALUE:
Field | Type | Description |
---|---|---|
Version | u8 | Indicates the serialization format. Current version is 0. |
Next Tx Id | u32 | Starts at 0 and increments with each transaction sent/received. |
Refresh Height | u64 | UNUSED. Replaced by restore index. |
Restore Index | u64 | Index of last output MMR leaf scanned for outputs owned by the wallet. |
Currently, only 1 "account" is used. That is, all addresses are derived from the parent KeyChainPath of m/0/0
. However, this table was designed to support multiple "accounts" (parent KeyChainPaths) per user in the future.
KEY: Hex(Blake2b(username)) | ParentKeyChainPath
VALUE: KeyChainPath to use when deriving the next child address. Example: 'm/0/7/1'
Stores secret information used when building a slate.
KEY: Hex(Blake2b(username)) | slate UUID
VALUE:
Field | Type | Description |
---|---|---|
Version | u8 | Indicates the serialization format. Current version is 0. |
Blinding Factor | u8[32] | Blinding factor XOR'd with blake2b(masterSeed+slate UUID+"blind") |
Nonce | u8[32] | Nonce XOR'd with blake2b(masterSeed+slate UUID+"nonce") |
An in-progress, confirmed, or canceled wallet transaction.
KEY: Hex(Blake2b(username)) | WalletTxId
VALUE: Encrypted using AES-256(See 'Encryption' section below) using "WALLET_TX" as the AES256 key.
Field | Type | Description |
---|---|---|
Version | u8 | Indicates the serialization format. Current version is 1. |
Wallet Tx Id | u32 | Wallet-generated identifier for the transaction. |
Type/Status | u8 | Values: Coinbase(0), Sent(1), Received(2), SendCanceled(3), RcvCanceled(4), SendPending(5), RcvPending(6), Finalized(7) |
Slate Id | Opt(UUID) | UUID of the slate used to build this transaction. |
Slate Msg | Opt(str) | Slate message. Version >= 1 only. |
Creation Time | i64 | Timestamp transaction was created |
Confirmation Time | i64 | Timestamp transaction was confirmed. 0 if not yet confirmed. |
Confirmed Height | u64 | Block height when transaction was confirmed. 0 if not yet confirmed. |
Amount Credited | u64 | Number of nanogrins the transaction adds to the wallet balance. |
Amount Debited | u64 | Number of nanogrins the transaction deducts from the wallet balance. |
FeeKnown | u8 | 1 if fee is known. 0 if unknown. |
Fee | Opt(u64) | The fee that was included as part of the transaction. |
Transaction | Opt(VAR) | If the transaction is known, this will contain the full Transaction using the protocol's serialization format. |
PLANNED CHANGES: Split Type/Status into a separate type (Coinbase, Send, Receive) and status (Confirmed, Canceled, Started, Finalized).
One entry for each output belonging to the wallet.
KEY: Hex(Blake2b(username)) | KeyChainPath | Optional("_" | MMRIndex)
VALUE: Encrypted using AES-256(See 'Encryption' section below) using "OUTPUT" as the AES256 key.
Field | Type | Description |
---|---|---|
Version | u8 | Indicates the encryption/serialization format. Current version is 0. |
KeyChainPath | str | BIP32 path to the address used to generate the address. Example: m/0/0/7 |
Blinding Factor | u8[32] | Blinding factor used when generating the output. |
Output | Output in the protocol serialization format (features+commit+rangeproof) | |
Amount | u64 | Transaction amount in nanogrins. |
MMR Index | u64 | MMR index of the output. 0 if not yet confirmed. |
Block Height | u64 | Block the output was included in. |
The values in the TX
and OUTPUT
tables are serialized in the below specified formats, but are stored encrypted using the following format:
Field | Type | Description |
---|---|---|
Version | u8 | Indicates the encryption/serialization format. Current version is 0. |
IV | u8[16] | Randomly generated initialization vector. |
Encrypted data | vec | Data encrypted using AES256 with blake2b(masterSeed+nonce) as the key. |