Wallet API (1.0.0)
Download OpenAPI specification:Download
A request/response interceptor is available at src/main/java/com/webapp/modules/interceptor/LightWalletInterceptor.java
This interceptor modifies the request such that all endpoints return with the following headers:
Access-Control-Allow-Origin: *Access-Control-Allow-Method: *
(Source: LightWalletInterceptor.java#preHandle)
This interceptor also checks each request for the headers Company-ID and Partner-ID. If either of these values is invalid, an error payload is returned by the endpoints (using response code 200 OK).
All request handlers extend from the class BaseApiAct (/src/main/java/com/webapp/modules/common/action/BaseApiAct.java). This class contains two methods: success and error that are called by child classes to return responses. For successful responses, the payload always returns with three properties and the values "0" and "success":
{
code: "0",
message: "success",
data: <any>
}
Key exchange
This endpoint caches the user-supplied public RSA key in Redis. At the same time, it also creates a RSA keypair. The private key is cached in Redis along with the user-supplied public key. The public key is returned in the payload.
This endpoint has to be called first to perform the key exchange before the /api/light/register endpoint can be called.
Authorizations:
header Parameters
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Request Body schema: application/json
string The email address of the user registering. | |
| publicKey | string The client-generated public RSA key. This key will be stored ephemerally in Redis. |
Responses
Request samples
- Payload
{- "email": "hy@me3.io",
- "publicKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCcxFxfqSgL5CMbeeCypAb4UdKnu4xzP0c6YrGaytuYlMJEjap9x51MVGEvxoash1LmJVZK6lQy7Qs188GUQV37d3QsXNmh9yfyDyFHRjblq7Jwq8iyFRhtobw2R7VtRBnAxDqE6jun7y5AIRJ+XD2GIS5jt4nztgasvF8yxGKfqwIDAQAB"
}Response samples
- 200
{- "code": "0",
- "msg": "success",
- "data": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCjvwgwgOiVKzLzlnrmi5TyVEHmv2L18Pf6eUOQxBWgdkJjkJLsH6Lei9qgHuGJ0TvFx0TdLjLTEEw9m+zmEcrGJTlinjKj4m6+rCPARvLF95t4D9IhOMKF+tBuO1nAPtFMY2MtOSWZYK507DQSgf8ABiIgY8u321wOpfnW5dXQBwIDAQAB"
}User registration
The query parameter faceId is used to determine if the user is a new account or an existing one.
If the user is new, the Partner-ID value in the header is linked to the user during account creation. If the partner account is disabled, a 200 response is returned with the error code 100001.
If the user already exists, the partner account is checked if the partner status is suspended or not. If so, a 200 response is returned with the error code 100001.
(It also seems like the chains associated with the partner are then associated with the newly created user.)
This endpoint creates a LightToken for the user (BaseApiAct.java#getLightToken). This newly generated one replaces any existing token for the user in the database.
The LightToken is a MD5 hash of the concatenation of the following:
- The database ID of the user.
- The current time in milliseconds.
- a randomly generated number.
This LightToken is associated with the user (uid) and company (company_id) in the database via the table light_token
Note: The faceId is passed as a query parameter for this POST endpoint instead of the body.
The return payload is encrypted using ChaCha20-Poly1305 cipher. The cipher is keyed using a random 32 bytes key (generated at the time of response). The encrypted payload is then base64-encoded and placed in the data field of the return JSON object.
The randomly generated key is RSA encrypted using the public RSA key associated with the user. This key is read from Redis (CipherV2Util.java#rsaReadKey). After the random (ChaCha) key is encrypted, it is passed along with the payload under the field secret.
The public RSA key associated with the user is registered at the endpoint /api/light/exchange/key.
Authorizations:
query Parameters
| faceId | string Example: faceId=hy@me3.io |
header Parameters
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Responses
Response samples
- 200
{- "code": "0",
- "data": {
- "secret": "EJQLnLY/MZbdClCl2/B+01t3qqMPOH1YKmKccwo6ZOyKKufCVYbP2SdVoC097x8YM4kDmXRmzfZeBJr8yCCu9cGyRP3pizOWkCCmiaep/O3UGRMgy9XFASbC2FTKglc5nPA/+TZVKxWkH0/4bT00TUY029nxHN3RSn8or+7kzKw=",
- "data": "4F3kP7k/VyyApS/sGgygjrzM+0y+uS0KEy6BzHa2nlJSrmRtF2yqD7yxbNusXK0jYkxawAEwgs3g3k2uGatpOBOg1UGjIqIl"
}, - "msg": "success"
}Registers the Google Drive file ID
This endpoint stores in the database the ID of the file that is created in Google Drive. This is so that the front-end library (Keysmith) knows which file to retrieve.
Authorizations:
query Parameters
| fileId | string Example: fileId=123abc If this parameter is not specified, this endpoint treats the request like a GET method and returns a payload with the key If this parameter is specified (and not empty), the value is saved in the |
header Parameters
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Responses
Response samples
- 200
{- "code": "0",
- "msg": "success",
- "data": {
- "fileId": "1kY7wXiM2AF7Nn6Vri1qzlDnWdq_WsT9o5QoTyil4ipA"
}
}Get User Information
Retrieves user information from the request context.
The return payload consists of mainly the fields from the light_user table but also the partnerId property which is not in the table but populated when the user is logged on.
Authorizations:
header Parameters
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Responses
Response samples
- 200
{- "code": "0",
- "msg": "success",
- "data": {
- "id": 115,
- "faceId": "hy@me3.io",
- "userName": "L1QV4D",
- "profilePhoto": "",
- "dynamicPwd": "",
- "description": "1323",
- "status": 0,
- "limitStatus": 0,
- "purchaseLimit": 0,
- "partnerId": "0f48c2ed-0a48-5c57-aeda-de224c92704b",
- "createTime": 1676999569000,
- "updateTime": 1677235416000
}
}Company Main Chain List
Gets the information about chains with coins based on a specific currency.
The currency is specified in the header currency.
The payload returns mainly the entities from the table company_main_chain. The entities are decorated with rate associated with the currency and change over 24 hours.
Authorizations:
header Parameters
| currency | string Example: USD The currency with which chains are associated with. Case-sensitive. If not specified, the default value assumed is |
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Responses
Response samples
- 200
{- "code": "0",
- "msg": "success",
- "data": [
- {
- "id": 7,
- "name": "BTCTest",
- "symbol": "BTC",
- "description": "TestBitcoin",
- "chainId": null,
- "node": "",
- "series": "BTC",
- "hdCoinId": 0,
- "path": "",
- "sort": 1,
- "state": 1,
- "companyId": 2000,
- "supportNft": 0,
- "supportDapp": 0,
- "ctime": 1646191229000,
- "mtime": 1653357082000,
- "currency": "USD",
- "symbolRate": 21421,
- "change": "-0.56564"
}, - {
- "id": 2,
- "name": "ETH",
- "symbol": "ETH",
- "description": "Ethereum\n",
- "chainId": 1,
- "series": "ETH",
- "hdCoinId": 60,
- "path": "m/44'/60'/0'/0/",
- "sort": 2,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1626336341000,
- "mtime": 1654482353000,
- "currency": "USD",
- "symbolRate": 1666.52,
- "change": "-0.60501"
}, - {
- "id": 1,
- "name": "RINKEBY",
- "symbol": "ETH",
- "description": "Rinkeby\n",
- "chainId": 4,
- "series": "ETH",
- "hdCoinId": 60,
- "path": "m/44'/60'/0'/0/",
- "sort": 4,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1626248536000,
- "mtime": 1653647610000,
- "currency": "USD",
- "symbolRate": 1666.52,
- "change": "-0.60501"
}, - {
- "id": 3,
- "name": "Polygon",
- "symbol": "MATIC",
- "description": "Polygon",
- "chainId": 137,
- "series": "ETH",
- "hdCoinId": null,
- "path": "m/44'/60'/0'/0/",
- "sort": 4,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1626744235000,
- "mtime": 1660672218000,
- "currency": "USD",
- "symbolRate": 0.814506,
- "change": "-0.50559"
}, - {
- "id": 18,
- "name": "BSC",
- "symbol": "BNB",
- "description": "BSC",
- "chainId": 56,
- "series": "ETH",
- "hdCoinId": 60,
- "path": "m/44'/60'/0'/0/",
- "sort": 4,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1660776026000,
- "mtime": 1660776026000,
- "currency": "USD",
- "symbolRate": 296.63,
- "change": "-0.30542"
}, - {
- "id": 4,
- "name": "PolygonTest",
- "symbol": "MATIC",
- "description": "Polygon Test",
- "chainId": 80001,
- "series": "ETH",
- "hdCoinId": 60,
- "path": "m/44'/60'/0'/0/",
- "sort": 7,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1626744476000,
- "mtime": 1653644329000,
- "currency": "USD",
- "symbolRate": 0.814506,
- "change": "-0.50559"
}, - {
- "id": 8,
- "name": "BSCTest",
- "symbol": "BNB",
- "description": "BSCTest",
- "chainId": 97,
- "series": "ETH",
- "hdCoinId": 60,
- "path": "m/44'/60'/0'/0/",
- "sort": 10,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1647072143000,
- "mtime": 1653701948000,
- "currency": "USD",
- "symbolRate": 296.63,
- "change": "-0.30542"
}, - {
- "id": 9,
- "name": "HECOTest",
- "symbol": "HT",
- "description": "HECOTest",
- "chainId": 256,
- "series": "ETH",
- "hdCoinId": 60,
- "path": "m/44'/60'/0'/0/",
- "sort": 11,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1647072416000,
- "mtime": 1653718385000,
- "currency": "USD",
- "symbolRate": 4.75,
- "change": "0.63944"
}, - {
- "id": 16,
- "name": "Fuji",
- "symbol": "AVAX",
- "description": "AVAXTest\n",
- "chainId": 43113,
- "series": "ETH",
- "hdCoinId": null,
- "path": "m/44'/60'/0'/0/",
- "sort": 18,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1653471985000,
- "mtime": 1653991808000,
- "currency": "USD",
- "symbolRate": 22.71,
- "change": "-2.06752"
}, - {
- "id": 17,
- "name": "Avax",
- "symbol": "AVAX",
- "description": "AVAX\n",
- "chainId": 43114,
- "series": "ETH",
- "hdCoinId": null,
- "path": "m/44'/60'/0'/0/",
- "sort": 18,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1653471985000,
- "mtime": 1660687441000,
- "currency": "USD",
- "symbolRate": 22.71,
- "change": "-2.06752"
}, - {
- "id": 11,
- "name": "FILTest",
- "symbol": "FIL",
- "description": "FileCoinTest",
- "chainId": null,
- "series": "FIL",
- "hdCoinId": 461,
- "path": "m/44'/461'/0'/0/",
- "sort": 22,
- "state": 1,
- "companyId": 2000,
- "supportNft": 0,
- "supportDapp": 0,
- "ctime": 1648795029000,
- "mtime": 1660608170000,
- "currency": "USD",
- "symbolRate": 6.22,
- "change": "-2.59405"
}, - {
- "id": 12,
- "name": "Westend",
- "symbol": "WND",
- "description": "Westend",
- "chainId": 42,
- "node": "wss://westend-rpc.polkadot.io",
- "series": "DOT",
- "hdCoinId": null,
- "path": "",
- "sort": 30,
- "state": 1,
- "companyId": 2000,
- "supportNft": 0,
- "supportDapp": 0,
- "ctime": 1649483001000,
- "mtime": 1653357292000,
- "currency": "USD",
- "symbolRate": 0.204689,
- "change": "1.33796"
}, - {
- "id": 13,
- "name": "BCH",
- "symbol": "BCH",
- "description": "BCH",
- "chainId": null,
- "node": "",
- "series": "BCH",
- "hdCoinId": null,
- "path": "",
- "sort": 33,
- "state": 1,
- "companyId": 2000,
- "supportNft": 0,
- "supportDapp": 0,
- "ctime": 1649907970000,
- "mtime": 1653883953000,
- "currency": "USD",
- "symbolRate": 128.11,
- "change": "-1.61606"
}, - {
- "id": 14,
- "name": "LTC",
- "symbol": "LTC",
- "description": "Litcoin",
- "chainId": null,
- "node": "",
- "series": "LTC",
- "hdCoinId": null,
- "path": "",
- "sort": 55,
- "state": 1,
- "companyId": 2000,
- "supportNft": 0,
- "supportDapp": 0,
- "ctime": 1650449910000,
- "mtime": 1653884007000,
- "currency": "USD",
- "symbolRate": 55.48,
- "change": "-1.81334"
}, - {
- "id": 15,
- "name": "ETCTest",
- "symbol": "KOT",
- "description": "ETH Class Test",
- "chainId": 6,
- "series": "ETH",
- "hdCoinId": null,
- "path": "m/44'/60'/0'/0/",
- "sort": 66,
- "state": 1,
- "companyId": 2000,
- "supportNft": 0,
- "supportDapp": 1,
- "ctime": 1650452588000,
- "mtime": 1653359884000,
- "currency": "USD",
- "symbolRate": 0.01735767,
- "change": "-4.16546"
}
]
}User-subscribed Chain List
Authorizations:
query Parameters
| chainName | string Example: chainName=BSCTest |
| sort | integer Example: sort=1 Whether to sort the results ( |
header Parameters
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Responses
Response samples
- 200
{- "code": "0",
- "msg": "success",
- "data": [
- {
- "id": 1540,
- "uid": 115,
- "chainName": "BSCTest",
- "sort": 10,
- "ping": 0,
- "createTime": 1676999569000,
- "updateTime": 1676999569000,
- "balance": null,
- "currencyBalance": null,
- "mainChainInfo": {
- "id": 8,
- "name": "BSCTest",
- "symbol": "BNB",
- "description": "BSCTest",
- "chainId": 97,
- "series": "ETH",
- "hdCoinId": 60,
- "path": "m/44'/60'/0'/0/",
- "sort": 10,
- "state": 1,
- "companyId": 2000,
- "supportNft": 1,
- "supportDapp": 1,
- "ctime": 1647072143000,
- "mtime": 1653701948000,
- "currency": null,
- "symbolRate": null,
- "change": null
}, - "chainDescription": "BSCTest"
}
]
}List Transactions History
This endpoint returns the list of transactions for a user.
The actual fetching from the database is done in the file com/webapp/modules/lightwallet/service/impl/LightAddressTransactionLogServiceImpl.java, line 63 txHistory. After retrieving the data from the database, the data is mapped into the LightTxRes entity.
The transactions (from the table light_address_transaction_log) retrieved from the database in descending order of tx_time. The trade_type of the field is used to determine if it is an outgoing transaction (value 1) or incoming one (value 2).
An outgoing transaction is translated into a TRANSFER_TYPE LightTxRes with the address set to the recipient of the transaction.
Conversely, an incoming transaction is translated into a COLLECT_TYPE LightTxRes with the address set to the sender of the transaction.
Authorizations:
query Parameters
| page required | integer Example: page=1 |
| pageSize required | integer Example: pageSize=5 |
| type required | integer Example: type=1 1 -> Transfer Type Transaction 2 -> Collect Type Transaction 3 -> Error Type Transaction |
| address | string Example: address=0x55959f0D5e1b7DC57fe4079e596b8BBafFF123B1 Wallet Address |
| symbolType required | string Example: symbolType=RINKEBY Symbol Type |
header Parameters
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Responses
Response samples
- 200
{- "code": "0",
- "msg": "success",
- "data": {
- "pageCount": 34,
- "lightTxResList": [
- {
- "type": 1,
- "address": "0x1ab8ffcb47f31efa7b12758c6ef94af7d59572fd",
- "amount": "0.01",
- "dateTime": "2022-08-16",
- "confirmations": 3,
- "confirmation_all": 3,
- "txid": "0x7fb51497b2d396163f54b989160d9b1275ab60e2f3d811155e2af100ea58b233",
- "tx_status": "1",
- "txTime": 1660638222000,
- "symbol": "ETH"
}, - {
- "type": 1,
- "address": "0x28aa8b3ee50e8e6fea7b9926b1ef0477c10d12a1",
- "amount": "999",
- "dateTime": "2022-08-15",
- "confirmations": 1,
- "confirmation_all": 3,
- "txid": "0x61dd3cedd60e46206d3e172ea8bddd68f1a15098b35a40a98dbda11ee50d44bc",
- "tx_status": "1",
- "txTime": 1660559820000,
- "symbol": "KBKC"
}, - {
- "type": 1,
- "address": "0x28aa8b3ee50e8e6fea7b9926b1ef0477c10d12a1",
- "amount": "100",
- "dateTime": "2022-08-15",
- "confirmations": 1,
- "confirmation_all": 3,
- "txid": "0x110beb2f62cbc048feb4a6ce8a8d95da039184f36f5ba94b65de6ce675e82f6b",
- "tx_status": "1",
- "txTime": 1660559592000,
- "symbol": "KBKC"
}, - {
- "type": 1,
- "address": "0x4a3541f269fe03fde790b2ae81b7042cf08745c7",
- "amount": "0",
- "dateTime": "2022-08-15",
- "confirmations": 1,
- "confirmation_all": 3,
- "txid": "0xb908780dd6ee2c799f436273d8c2e43fae78a6b1459c7ea33f1f781e6145d538",
- "tx_status": "1",
- "txTime": 1660548646000,
- "symbol": "ETH"
}, - {
- "type": 1,
- "address": "0x4a3541f269fe03fde790b2ae81b7042cf08745c7",
- "amount": "0",
- "dateTime": "2022-08-15",
- "confirmations": 1,
- "confirmation_all": 3,
- "txid": "0x759d7f37f46141b922d7845862c1051223c08012639e46623e1d097397966192",
- "tx_status": "1",
- "txTime": 1660548644000,
- "symbol": "ETH"
}
]
}
}Get Transaction History
Authorizations:
query Parameters
| symbol | string Example: symbol=ETH The coin symbol for the chain in which the transaction is retrieved for. |
| address | string Example: address=0x55959f0D5e1b7DC57fe4079e596b8BBafFF123B1 The wallet address. |
| txid | string Example: txid=0x7fb51497b2d396163f54b989160d9b1275ab60e2f3d811155e2af100ea58b233 The transaction ID. |
| symbolType | string Example: symbolType=RINKEBY Symbol Type is an internal representation of the supported chains. |
| coinType | integer Example: coinType=1 Indicates whether is native to the chain? |
header Parameters
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Responses
Response samples
- 200
{- "code": "string",
- "msg": "string",
- "data": {
- "symbol": "string",
- "tx_status": "string",
- "confirmations": 0,
- "confirmations_all": 3,
- "amount": "string",
- "tx_time": "string",
- "fees": "string",
- "remarks": "string",
- "txid": "string",
- "to_address": "string",
- "from_address": "string",
- "trade_type": "string"
}
}Sync Kyberswap Tokens/Assets to DB
Makes a request to the URL https://api.github.com/repos/KyberNetwork/ks-assets/git/trees/main. From the result, the tree value is parsed to get the url value of the tree value containing path: tokenLists. This URL value is used to get the list of supported chains by Kyberswap.
From the list of supported chains, this endpoint then gets the list of supported tokens (from URls starting with https://raw.githubusercontent.com/KyberNetwork/ks-assets/main/tokenLists/) from each of the chains.
These tokens are then transformed into light_wallet_coin to be saved or updated in the database.
Authorizations:
header Parameters
| Company-ID | integer Example: 2222 |
| Partner-ID | string Example: 0f48c2ed-0a48-5c57-aeda-de224c92704a The ID of the partner. |
Responses
Response samples
- 200
{- "code": "0",
- "msg": "success",
- "data": {
- "updates": 259,
- "inserts": 0
}
}