Skip to content
BradGao edited this page May 24, 2021 · 2 revisions

Usage

All the features of MaskWalletCore are provided through the request function. Request function receives Protobuf encoded messages and returns Protobuf encoded responses.

All .proto files are located in chain-common/proto directory.

Common Structure

Enum

Coin

The blockchain type

  1. Ethereum
  2. Polkadot, still under development

StoredKeyType

The type of StoredKey, indicates the StoredKey is created with which kind of data.

  1. PrivateKey
  2. Mnemonic

StoredKeyImportType

Indicate the import type of creating a StoredKey

  1. PrivateKeyImportType
  2. MnemonicImportType
  3. KeyStoreJSONImportType

StoredKeyExportType

Indicate the export type of creating a StoredKey

  1. PrivateKeyExportType
  2. MnemonicExportType
  3. KeyStoreJSONExportType

Structure

StoredKeyInfo

StoredKeyInfo contains the "public" information of a StoredKey and the encoded data of the whole StoredKey. Refer to StoredKey

Name Type Description
id string UUID of the created StoredKey
hash string The unique hash of the StoredKey, users could check whether two StoredKeys are same by comparing the hash
type StoredKeyType Type of the StoredKey
data Bytes Raw data of the StoredKey, used in requests required an existing StoredKey. Need to be updated after mutating the StoredKey

StoredKeyAccountInfo

StoredKeyAccountInfo contains all the account information. Refer to Account

Name Type Description
address string Blockchain specific address
name string Alias name set by users
derivationPath string The derivation path used to derived this account. Would be an empty string for an account generated by the imported private key.
coin string Coin id of the address, is the same as the raw value of enum Coin
extendedPublicKey string Not used on Ethereum. Always be an empty string for now

PasswordValidationParam

Struct used to check whether a password is valid for a StoredKey

Name Type Description
storedKeyData bytes Raw bytes of the StoredKey
password string The password to be checked

AddressValidationParam

Struct used to check whether an address is valid for a blockchain type

Name Type Description
address string The address to be checked
coin Coin Blockchain type

Requests and Responses

Since almost all requests and responses are used in pairs, the following section will list the structure of each request and its corresponding response.

Common Requests

GetVersionParam

No Parameters

Use this request to get the version of MaskWalletCore.

GetVersionResp

Name Type Description
version string The version of MaskWalletCore

StoredKey Requests

GetKeyStoreSupportImportTypeParam

Name Type Description
coin Coin Blockchain type

Use this request to get the supported import type of a specific blockchain.

GetKeyStoreSupportImportTypeResp

Name Type Description
type repeated StoredKeyImportType List of supported StoredKeyImportTypes

GetKeyStoreSupportExportTypeParam

Name Type Description
coin Coin Blockchain type

Use this request to get the supported export type of a specific blockchain.

GetKeyStoreSupportExportTypeResp

Name Type Description
type repeated StoredKeyExportType List of supported StoredKeyExportTypes

LoadStoredKeyParam

Name Type Description
data repeated bytes List of encoded raw bytes of StoredKey

Use this request to get the information of the StoredKey raw bytes.

LoadStoredKeyResp

Name Type Description
StoredKeys repeated StoredKeyInfo List of supported StoredKeyExportTypes

CreateStoredKeyParam

Name Type Description
password string Password to create a new StoredKey

Use this request to create a new mnemonic type StoredKey with randomly generated mnemonic phrases.

This request does NOT create an account.

CreateStoredKeyResp

Name Type Description
StoredKey StoredKeyInfo Created StoredKeyInfo
mnemonic string The random mnemonic phrases of the created StoredKey

ImportPrivateStoredKeyParam

Name Type Description
privateKey string Hex encoded private key string
password string Password to create a new StoredKey
name string The name of created account

Use this request to create a new private key type StoredKey with an existing private key.

This request DO create an account.

ImportPrivateStoredKeyResp

Name Type Description
StoredKey StoredKeyInfo Created StoredKeyInfo

ImportMnemonicStoredKeyParam

Name Type Description
mnemonic string Hex encoded private key string
password string Password to create a new StoredKey
name string The name of created account

Use this request to create a new mnemonic key type StoredKey with an existing mnemonic.

This request does NOT create an account.

ImportMnemonicStoredKeyResp

Name Type Description
StoredKey StoredKeyInfo Created StoredKeyInfo

ImportJsonStoredKeyParam

Name Type Description
json string KeyStoreJson string
password string Password to create a new StoredKey
name string The name of created account
coin Coin Blockchain type

Use this request to create a new private key type StoredKey with an existing KeyStoreJson.

This request DO create an account.

ImportJsonStoredKeyResp

Name Type Description
StoredKey StoredKeyInfo Created StoredKeyInfo

UpdateStoredKeyPasswordParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey to be updated
oldPassword string Current password of the StoredKey
newPassword string New password of the StoredKey

Use this request to update the password of the StoredKey.

UpdateStoredKeyPasswordResp

Name Type Description
StoredKey StoredKeyInfo The updated StoredKeyInfo

ExportKeyStorePrivateKeyParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey to be exported
password string Password of the StoredKey
coin Coin Blockchain type

Use this request to export the private key of the StoredKey on the coin's base derivation path.

ExportKeyStorePrivateKeyResp

Name Type Description
privateKey string The exported private key

ExportKeyStorePrivateKeyOfPathParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey to be exported
password string Password of the StoredKey
coin Coin Blockchain type
derivationPath string The derivation path of the exported private key

Use this request to export the private key of the StoredKey on the specified derivation path.

Fail if the StoredKey is not a mnemonic type StoredKey

ExportKeyStorePrivateKeyResp

Name Type Description
privateKey string The exported private key

ExportKeyStoreMnemonicParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey to be exported
password string Password of the StoredKey

Use this request to export the mnemonic of the StoredKey.

Fail if the StoredKey is not a mnemonic type StoredKey

ExportKeyStoreMnemonicResp

Name Type Description
mnemonic string The exported mnemonic

ExportKeyStoreJSONOfAddressParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey to be exported
password string Password of the StoredKey
newPassword string The password used to encrypt the exported KeyStoreJson
coin Coin Blockchain type
address string The address of the account of which the private key to be exported as KeyStoreJson

Use this request to export the KeyStoreJson of the private key with the specified address in the StoredKey.

ExportKeyStoreJSONResp

Name Type Description
json string The exported KeyStoreJson

ExportKeyStoreJSONOfPathParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey to be exported
password string Password of the StoredKey
newPassword string The password used to encrypt the exported KeyStoreJson
coin Coin Blockchain type
derivationPath string The derivation path of the account of which the private key to be exported as KeyStoreJson

Use this request to export the KeyStoreJson of the private key with the specified derivation path in the StoredKey.

ExportKeyStoreJSONResp

Name Type Description
json string The exported KeyStoreJson

Account Requests

CreateStoredKeyNewAccountAtPathParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey
name string Name of the created account
password string The password of the stored key
coin Coin Blockchain type
derivationPath string The derivation path to create the account

Use this request to create a new account to the StoredKey at the specific derivation path.

Fail if the StoredKey is not a mnemonic type StoredKey

CreateStoredKeyNewAccountAtPathResp

Name Type Description
account StoredKeyAccountInfo The created StoredKeyAccountInfo
storedKey StoredKeyInfo The updated StoredKeyInfo

GetStoredKeyAccountCountParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey

Use this request to get the count of accounts of a StoredKey.

GetStoredKeyAccountCountResp

Name Type Description
count uint32 The count of accounts

GetStoredKeyAccountParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey
index uint32 Index of the requested account, begin from 0

Use this request to get the account at the specified index of a StoredKey.

Fail if the requested index is larger than the count of the existing accounts

GetStoredKeyAccountResp

Name Type Description
account StoredKeyAccountInfo The requested StoredKeyAccountInfo

GetStoredKeyAllAccountParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey

Use this request to get all accounts of a StoredKey.

GetStoredKeyAllAccountResp

Name Type Description
account repeated StoredKeyAccountInfo The list of StoredKeyAccountInfo

GetStoredKeyAccountsOfCoinParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey
coin Coin Blockchain type

Use this request to get all accounts of the specific blockchain type of a StoredKey.

GetStoredKeyAccountsOfCoinResp

Name Type Description
account repeated StoredKeyAccountInfo The list of StoredKeyAccountInfo

UpdateStoredKeyAccountNameOfAddressParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey
address string The address of the account to be updated
name string The new name of the account

Use this request to update the name of an account of the specific address of a StoredKey.

UpdateStoredKeyAccountNameOfAddressResp

Name Type Description
storedKey StoredKeyInfo The updated StoredKeyInfo
account StoredKeyAccountInfo The updated StoredKeyAccountInfo

RemoveStoredKeyAccountOfCoinParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey
coin Coin Blockchain type

Use this request to remove all accounts of the specific blockchain of a StoredKey.

RemoveStoredKeyAccountOfCoinResp

Name Type Description
storedKey StoredKeyInfo The updated StoredKeyInfo

RemoveStoredKeyAccountOfAddressParam

Name Type Description
StoredKeyData bytes Raw bytes of the StoredKey
coin Coin Blockchain type
address string The address to the account to be removed

Use this request to remove the account of the specific address of a StoredKey.

RemoveStoredKeyAccountOfAddressResp

Name Type Description
storedKey StoredKeyInfo The updated StoredKeyInfo

Validation Requests

ValidateParam

Name Type Description
privateKey string The private key to be checked
mnemonic string The mnemonic to be checked
keyStoreJSON string The KeyStoreJson to be checked
storedKeyPassword PasswordValidationParam The password and StoredKey to be checked
addressValidationParam AddressValidationParam The address to be checked

Use this request to check whether a type of data is valid.

Since the parameter of this request is oneof, users could choose only 1 validation type at a time.

ValidateResp

Name Type Description
valid bool Whether the data to be checked is valid

Transaction Request

SignTransactionParam

Name Type Description
storedKeyData bytes Raw bytes of the StoredKey used to sign
address string Address of the account used to sign
password string Password of the StoredKey
coin Coin Blockchain type
input oneof input The input parameter specified by each blockchain

Use this request to sign a transaction.

Please note that the actual input parameter type should be the same as the coin blockchain, e.g. to sign an Ethereum transaction, users should set coin to Ethereum, and the input should be the type of ethereum.SignInput.

Currently, only Ethereum is supported.

SignTransactionResp

Name Type Description
output oneof output The signed output, type varies on different blockchain

Clone this wiki locally