GetWalletInfo()

Summary

Route
Type
Example

/monitor/getwalletinfo

POST

http://176.113.80.7:62000/api/monitor/getwalletinfo

Description

Gets information about the wallet balance, including a detailed list of outgoing and incoming delegations.

Request

Request Structure

{

// Parameters common for all requests

// Wallet address

"PublicKey": "public key in base 58 format",

}

Request Parameters

string: PublicKey - Wallet address (public key) in Base58

Response

JSON output depends on the request type and its success.

If there’s an error, request returns to the node basic Result:

  • Success: False

  • Message:

If successful, requested information is returned.

Response Structure

{

// Wallet balance as is in SWT

"balance":"decimal_value",

// Ordinal number of the last transaction of the wallet

"lastTransaction":"i64_value",

"delegated":

[

//Sum of all incoming delegations at the moment

"incoming":"decimal_value",

//Sum of all outgoing delegations at the moment

"outgoing":"decimal_value",

//List of donors with indications of the amount and duration of the delegation

"Donors":

[

"address":"base58_value",

"sum":"decimal_value",

// delegation time (date is in Unix format), if time limit equals to 0, delegation is considered indefinite and can be revoked with the corresponding transaction

"validUntil":"i64"

],

"Recipients":

[

"address":"base58_value",

"sum":"decimal_value",

"validUntil":"i64"

]

]

}

Example Code

Python

import requests
import json
def getwalletinfo():
    url =  'http://176.113.80.7:62000/api/monitor/getwalletinfo'
    headers = {
        'Content-type': 'application/json'
        , 'Accept': 'application/json'
        , 'Content-Encoding': 'utf-8'
        }
    data = {
        "authKey": ""
        , "NetworkAlias":"Mainnet"
        , "PublicKey":"QTRbkssQSGLdKs94khX7i858YcBAhjg6wj48F7FTr8H"
        }
    answer = requests.post(url, data=json.dumps(data), headers=headers)
    response = answer.json()
    print(response)
getwalletinfo()

C++

#include <iostream>

#include <cpprest/http_client.h>
#include <cpprest/filestream.h>

using namespace utility;                    // Common utilities like string conversions
using namespace web;                        // Common features like URIs.
using namespace web::http;                  // Common HTTP functionality
using namespace web::http::client;          // HTTP client features
using namespace concurrency::streams;       // Asynchronous streams
using namespace web::json;

int main(int argc, char* argv[])
{
    web::json::value json_v;
    web::json::value json_return;
    json_v[L"authKey"] = web::json::value::string(L"");
    json_v[L"NetworkAlias"] = web::json::value::string(L"Mainnet");
    json_v[L"PublicKey"] = web::json::value::string(L"QTRbkssQSGLdKs94khX7i858YcBAhjg6wj48F7FTr8H");
    http_client client(U("http://176.113.80.7:62000"));

    client.request(web::http::methods::POST, U("/api/monitor/getwalletinfo"), json_v)
        .then([](const web::http::http_response& response) {
        return response.extract_json();
    })
        .then([&json_return](const pplx::task<web::json::value>& task) {
        try {
            json_return = task.get();
        }
        catch (const web::http::http_exception& e) {
            std::cout << "error " << e.what() << std::endl;
        }
    })
        .wait();

    std::wcout << json_return.serialize() << std::endl;

    return 0;
}

C#

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Program.Getinfo
{
    public class getwalletinfo
    {
        static readonly HttpClient client = new HttpClient();
        public class body
        {
            public string authKey { get; set; }
            public string networkAlias { get; set; }
            public string PublicKey { get; set; }
        }
        public static async Task Main()
        {
            try
            {
                var body = new body
                {
                    authKey = "",
                    networkAlias = "Mainnet",
                    PublicKey = "QTRbkssQSGLdKs94khX7i858YcBAhjg6wj48F7FTr8H"
                };
                var httpContent = new StringContent(JsonConvert.SerializeObject(body),
                    Encoding.UTF8, "application/json");
                var response = await client.PostAsync("http://176.113.80.7:62000/api/monitor/getwalletinfo",
                    httpContent);
                Console.WriteLine("RESPONSE=" +
                    await response.Content.ReadAsStringAsync());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
    }
}

Last updated