# Wallet API

To enable Wallet RPC API on the node, add "wallet" namespace in "PublicModules" in node_config.json

Dangerous RPC calls

Expose wallet module to public Internet, e.g. setting "HttpHost": "0.0.0.0" could be dangerous. Configure "HttpHost" and "WSHost" to "127.0.0.1" or remove wallet namespace from "PublicModules" in node_config.json after the node is set up.

Definitions:

  • Standard Directory: The default wallet directory on the node. For mainnet node on Linux or Mac, this directory is "~/.gvite/maindata/wallet"
  • Entropy File: A JSON keystore file to save entropy encrypted with AES-256 algorithm
  • Passphrase: A Scrypt password that is used to derive AES-256 key for entropy encryption. Please note this is NOT the bip39 passphrase. By default, an empty bip39 passphrase '' is used by wallet module when creating seeds from mnemonics and the value cannot be customized.
  • Primary Address: For each entropy file, the first Vite address at index 0 is called primary address.

# wallet_getEntropyFilesInStandardDir

List all entropy files in default wallet directory

  • Parameters: none

  • Returns:

    • Array<string> Absolute paths of entropy file
  • Example:

# wallet_getAllEntropyFiles

List all entropy files installed on node

  • Parameters: none

  • Returns:

    • Array<string> Absolute paths of entropy file
  • Example:

# wallet_exportMnemonic

Export mnemonic phrase from entropy file

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
    • passphrase: string Entropy file passphrase
  • Returns:

    • string Mnemonic phrase
  • Example:

# wallet_unlock

Unlock an entropy file with passphrase

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
    • passphrase: string Entropy file passphrase
  • Returns: null

  • Example:

# wallet_lock

Lock an entropy file

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
  • Returns: null

  • Example:

# wallet_deriveAddressesByIndexRange

Derive addresses from an entropy file by index range. The entropy file must be unlocked or the method will return an error.

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
    • startIndex: uint32 Start index, included
    • endIndex: uint32 End index, excluded. It must hold endIndexstartIndex5000endIndex - startIndex \le 5000
  • Returns:

    • Array<address> Addresses derived
  • Example:

# wallet_createEntropyFile

Create a new entropy file

  • Parameters:

    • passphrase: string A passphrase to encrypt the entropy file
  • Returns: CreateEntropyFileResponse

    • mnemonics: string Mnemonic phrase
    • primaryAddress: address Address at index 0
    • filePath: string Absolute path of the entropy file
  • Example:

# wallet_deriveAddressByIndex

Derive address from an entropy file by index. The entropy file must be unlocked or the method will return an error.

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
    • index: uint32 Index of address
  • Returns: DeriveResult

    • bip44Path: string Address's BIP44 path
    • address: address Derived address
    • privateKey: base64 Address's private key in base64 format
  • Example:

# wallet_deriveAddressByPath

Derive address from an entropy file by bip44 path. The entropy file must be unlocked or the method will return an error.

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
    • bip44Path: string BIP44 path
  • Returns: DeriveResult

    • bip44Path: string Address's BIP44 path
    • address: address Derived address
    • privateKey: base64 Address's private key in base64 format
  • Example:

# wallet_recoverEntropyFile

Restore an entropy file from mnemonic phrase

  • Parameters:

    • mnemonics: string Mnemonic phrase
    • passphrase: string A passphrase to encrypt the entropy file
  • Returns: CreateEntropyFileResponse

    • mnemonics: string Mnemonic phrase
    • primaryAddress: address Address at index 0
    • filePath: string Absolute path of the entropy file
  • Example:

# wallet_isUnlocked

Check if the entropy file is unlocked

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
  • Returns:

    • bool: true means the entropy file is unlocked
  • Example:

# wallet_findAddressInEntropyFile

Find an address in entropy file and return the index. Returns an error if the entropy file is locked or the address is not found in the entropy file.

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
    • address: address: Address to find
  • Returns: FindAddrResponse

    • entropyFile: string Absolute path of the entropy file
    • index: uint32 Index of address
  • Example:

# wallet_findAddress

Find an address in current unlocked entropy file and return the index. Returns an error if the address is not found.

  • Parameters:

    • address: address: Address to find
  • Returns: FindAddrResponse

    • entropyFile: string Absolute path of the entropy file
    • index: uint32 Index of address
  • Example:

# wallet_createTransaction

Send a transaction with the address in entropy file. If entropy file is not specified, this method will search in all entropy files with the passphrase for the address.

Note: Despite entropyFile can be omitted, passphrase is a mandatory field to unlock the entropy file

  • Parameters: CreateTransferTxParms

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory. Optional
    • address: address Address of sending account. Mandatory
    • toAddress: address Address of recipient. Mandatory
    • tokenId: tokenId Token id. Mandatory
    • passphrase: string Entropy file passphrase. Mandatory
    • amount: bigint string Transfer amount. Mandatory
    • data: base64 Transaction data. Optional
    • difficulty: bigint string PoW difficulty. Optional
  • Returns:

    • hash Hash of the account block that has been sent
  • Example:

# wallet_addEntropyStore

Install a new entropy file on the node. This method is used to add an entropy file not in standard directory.

  • Parameters:

    • entropyFile: string Absolute path of the entropy file, or primary address if the file is under standard directory.
  • Returns: null

  • Example:

# wallet_signData

Sign a 32 byte hex string with private key of the address. The address must be found in the current unlocked entropy file or the method will return an error.

The common use case of this method is to sign an account block hash to obtain the signature of the block

  • Parameters:

    • address: address Signing address
    • hexMsg: string 32 byte hex message or account block hash
  • Returns: HexSignedTuple

    • message: string Original message
    • signedData: string 64-byte signature in hex format
    • pubkey: string Public key in hex format
  • Example: