Working with QEDIT Wallets

A QEDIT node hosts one or more wallets. A wallet is a container for digital assets. Most QEDIT API calls are made to a specific wallet. For example, checking the asset balances in the wallet, getting the transactions history of a wallet, and transferring an asset from a specific wallet to a specified address. This section will focus on the API calls that are used to interact with wallets.

Generating a new wallet

A single wallet can contain many different types of assets. Still, you may want to create several different wallets for different purposes (e.g. “items in warehouse 1” vs. “items in warehouse 2”) or to separate access control to the wallets (e.g. “only Alice is allowed to ship items from warehouse 1, while only Bob is allowed to ship items from warehouse 2”).

Request

POST /node/generate_wallet
{
   "wallet_id": "source_wallet",
   "authorization": "PrivacyIsAwesome"
}

Response

Getting the asset balances of a wallet

A QEDIT wallet can contain different amounts of many different asset types. You can call the QEDIT API to get all the balances of all the asset types that currently are held by a specified wallet in the node.

Request

POST /wallet/get_balances
{
   "wallet_id": "source_wallet"
}

Response

{
  "wallet_id": "source_wallet",
  "assets": [
    {
      "asset_id": "bank-a.loans.1",
      "amount": 8
    },
    {
      "asset_id": "bank-a.loans.2",
      "amount": 200
    }
  ]
}

Generating an address for a wallet

In order to receive assets you must provide others with an address of your wallet. You can call the QEDIT API to generate an address to a specified wallet. The same address can be used multiple times. All the security guarantees afforded by QEDIT are still maintained in such a case (e.g. the details of the transaction are not revealed to other Blockchain nodes). However, in some use cases you may want to mask that the same address was used in previous transactions even from the party you are transacting with. In such a case you can call the QEDIT API again to generate a new address to the same specified wallet. A wallet can have multiple addresses. Regardless of which address was used to transfer or issue assets to the wallet, API calls to the wallet will always reflect all the assets it contains.

Request

POST /wallet/get_new_address
{
   "wallet_id": "source_wallet"
}

Response

{
  "wallet_id": "source_wallet",
  "recipient_address": "q1dxlf6vap2566t8w3z8f5j5lxy9n036zfsaytjve7fedsw6w8c9q9ctrwfz6ryyjwkgvj6tjg70f"
}

Getting the public key of a wallet

Each wallet has a cryptographic public key. Among other functions this public key is used when defining issuance permissions in the network, and to identifier the sender to the reciever in asset transfer calls.

Request

POST /wallet/get_public_key
{
   "wallet_id": "source_wallet"
}

Response

{
  "wallet_id": "source_wallet",
  "public_key": "bf45ab74bd4a46fe7a2432ba05e2f726bf4fe42a80052849e13e2541230d3204"
}

Getting the activity history of a wallet

The activity history of a wallet includes all the transfers it sent or received, the assets issuances it generated (if permitted) or received, and all the issuance rules it defined or deleted (if permitted). The QEDIT API provides an endpoint to list all past activity of a specified wallet. You can also filter the list by specified tx_hash values.

Request

POST /wallet/get_activity
{
   "wallet_id": "source_wallet",
   "start_index": 0,
   "number_of_results": 1
}

Response

{
  "transactions": [
    {
      "content": {
        "amount": 1,
        "asset_id": "BANK1.USD",
        "is_incoming": true,
        "recipient_address": "q1s27es7k9lpdv6a8yek9ydgpnm62e6947038j6g37aur5h84ucutfyq02qs8lnpp40tlszefsr20",
        "sender_id": "7c4142655b6ab9bfe6b941ffebd7a39ed436d66b0d8c1e951bc80e3d56004687"
      },
      "metadata": {
        "timestamp": "2019-11-03T13:28:20Z",
        "tx_hash": "93635776cd43b4d2f58ec8f819db3edfb26b3c68e678a6c22fb8ba0005ff7a9f",
        "type": "Transfer"
      }
    }
  ],
  "wallet_id": "source_wallet"
}

Exporting a QEDIT wallet

You can export a QEDIT wallet for backup purposes or in order to import it to a different QEDIT node.

Request

POST /node/export_wallet
{
  "wallet_id": "source_wallet"
}

Response

{
  "wallet_id": "source_wallet",
  "encrypted_sk": "44d2836bbfcc7c69dd35dbe854d54a093be9a1be7f9d658325a8d2526f67ede16abf0d1430edab07be9b8c12070260af",
  "salt": "27ca2bf75fe4c1564398459bd2f39a89645bf98aeeb1f99a9c9efa6e5c39cbfe"
}

Importing a QEDIT wallet

You can import a QEDIT wallet that was previously exported using the /node/export_wallet endpoint.

Request

POST /node/import_wallet
{
  "wallet_id": "source_wallet",
  "encrypted_sk": "44d2836bbfcc7c69dd35dbe854d54a093be9a1be7f9d658325a8d2526f67ede16abf0d1430edab07be9b8c12070260af",
  "salt": "27ca2bf75fe4c1564398459bd2f39a89645bf98aeeb1f99a9c9efa6e5c39cbfe"
}

Response

{
  "id": "70a88558-2b8b-4b63-a5b6-2c54b24377f5"
}

Deleting a QEDIT wallet

You can delete a QEDIT wallet from a node. Note that deleting a QEDIT wallet does not delete the assets it held at the time of the deletion. If you have exported the wallet using the /node/export_wallet endpoint prior to the deletion you will be able to recoup the wallet and its assets by importing it in the future.

Request

POST /node/delete_wallet
{
  "wallet_id": "source_wallet",
  "authorization": "PrivacyIsAwesome"
}

Response

{
  "id": "70a88558-2b8b-4b63-a5b6-2c54b24377f5"
}