05_wallet

Andrew Beyond edited this page Aug 13, 2018 · 2 revisions

5. Wallet

To request information about the state of the wallet, use the following API:

Request Type GET
URL /api/address/{address}
Parameters

{address} — wallet address in a text or binary representation as hex.

Examples:
AA100000001677722412 - address in a textual representation;
0x800140000100000B - address in a binary representation as hex.

Examples of requests (curl is used to execute http requests and the jq program for highlighting the json syntax):

image5

Description of the fields of the info block:

Field title Purpose
amount Wallet balance in various currencies. Only the currencies in which transactions were made are displayed.
lastblk Hash of the block in which the last transaction modified this wallet.
pubkey The public key for this wallet in a compact DER format.
seq The current value of seq for this address. Executing transactions through the API, the seq value should always be greater than the current value in the wallet (in other implementations the name is called nonce).
t The last transaction time in milliseconds.

Conversion of a public key into PEM format (usually this format is used for work with the openssl) can be performed as follows (example in php language):

function der2pem($der_data, $type='PUBLIC KEY') {
    $der_data = hex2bin('3036301006072a8648ce3d020106052b8104000a032200') . $der_data;
    $pem = chunk_split(base64_encode($der_data), 64, "\n");
    $pem = "-----BEGIN ".$type."-----\n".
        trim($pem) .
        "\n-----END ".$type."-----\n";
    return $pem;
}

An example of work. The program converts the public key of one of the wallets to PEM format, and also loads this key for further work with openssl. Execution of openssl_pkey_get_public fails due to the key problem. The resource (4) of type (OpenSSL key) row at the end says that there were no errors, the key was correctly converted and openssl accepted this key for further work.

image6

It is also possible to obtain a public key in PEM format. To do this, you must pass the GET parameter pubkey=pem:

image7

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.