-
Notifications
You must be signed in to change notification settings - Fork 4
Architecture
As a multi-chain wallet, MaskWalletCore is designed to support multiple elliptic curves, hashing, address derivation and transaction signing methods.
The two main components of MaskWalletCore are StoredKey and Account:
-
StoredKeyis named as it is created with secure "key" data. The "key" data could be a private key or a mnemonic phrases string.StoredKey"stored" the "key" data as the origin of other information, applications could use anyAccountrequests to createAccountstructs. -
Accountcontains the blockchain-specific address with several metadata. AStoredKeypreserves a list ofAccounts.
| Name | type | Description |
|---|---|---|
| r#type | StoredKeyType | Indicate the creation type of this StoredKey. Either PrivateKey or Mnemonic |
| id | String | UUID generated when the StoredKey created. |
| hash | String | Hex encoded string, calculated using the double-sha256 hash. |
| version | String | StoredKey definition version. Currently "0.1.0" |
| payload | EncryptionParams | Encrypted secure data, required to be decrypted with a password to execute "mutating" methods |
| accounts | Vec | List of derived accounts |
| Name | Type | Description |
|---|---|---|
| address | String | Blockchain-specific address of the account |
| name | String | Alias name set by users |
| coin | Coin | The blockchain for which this account is derived |
| derivation_path | DevirationPath | The derivation path used to derived this account. Would be an empty string for an account generated by the imported private key. |
| extended_public_key | String | Not used on Ethereum. Always be an empty string for now |
MaskWalletCore defines the Entry trait, all blockchain implementations must implement it and provide their other information following the New-Chain-Integration-Checklist
| Name | Parameters | Return Value Type | Description |
|---|---|---|---|
| get_supported_import_types | &self | Vec | Return the all supported import types of blockchain |
| get_supported_export_types | &self | Vec | Return the all supported export types of blockchain |
| validate_address | &self, address: &str | bool | Return whether the address is valid on this blockchain |
| derive_address | &self, coin: &Coin, public_key: &PublicKey, p2pkh: &[u8], hrp: &[u8] | Result<String, Error> | Derive with the input parameters and return the calculated address. Return error when fails to derive |
| sign | &self, coin: &Coin, private_key: &PrivateKey, payload: &[u8] | Result<Vec, Error> | Sign with the private key and encoded payload and return the signed output. Return error when fails to sign |