Published 15 February 2019

WalletBalanceGetResult WalletBalanceGet(1:Address address)

Description

Description

The command returns its balance in the form of a structure to the address of the wallet or smart contract

The address field is recoded: if the address string length is 64 characters, then recode it from 16 coded representation to a new string, otherwise - calculate the public key hash using blake2 algorithm.
To get the balance from the blockchain on the base of the calculated address, we are looking for the item with the specified address in the balance cache. If the balance in cache is not found in the last block, then:

Load the pool from the storage using the hash of the last block.
           While the public key is valid and the hash is not equal to the hash of the last block checked:
Due to all block transactions determine the balance in the transaction, if it refers to the sender of this address;
Due to all block transactions add the transaction price to the result, if it refers to the receiver of this address;
If the balance was found on the base of sender’s address, then add the balance to the result and exit the cycle;
Load the pool from the storage according to the hash of the previous unviewed block.
If the address of the wallet was found among senders, then add it to the result of the balance from the cache.

Save the balance in the balances cache due to the address of this wallet.

Parameters

Parameters

// Wallet or smart contract address

typedef binary Address

Return

Return

struct WalletBalanceGetResult

{

   1: general.APIResponse status

   2: Amount balance

}

Description of the returned structures and typedefs

Description of the returned structures and typedefs

struct APIResponse

{

// 0 for success, 1 for failure, 2 for not being implemented (currently unused)

   1: i8 code

// Explanation

   2: string message

}

struct Amount

{

 1: required i32 integral = 0;

 2: required i64 fraction = 0;

}

Votes 0, average rating 0

Contents