diff --git a/dap_chain_wallet.c b/dap_chain_wallet.c index 3f329b92ece5c95c5ae799458570520042c7ca26..0b30adb47cf7b59d71787ce167e9df1de6a8b0f6 100755 --- a/dap_chain_wallet.c +++ b/dap_chain_wallet.c @@ -405,3 +405,22 @@ dap_chain_wallet_t * dap_chain_wallet_open(const char * a_wallet_name, const cha DAP_DELETE(l_file_name); return l_wallet; } + +/** + * @brief dap_chain_wallet_get_balance + * @param a_wallet + * @param a_net_id + * @return + */ +uint64_t dap_chain_wallet_get_balance(dap_chain_wallet_t *a_wallet, dap_chain_net_id_t a_net_id, char *a_token_ticker) +{ + dap_chain_net_t *l_net = dap_chain_net_by_id(a_net_id); + dap_chain_addr_t *l_addr =dap_chain_wallet_get_addr(a_wallet, a_net_id); + uint64_t l_balance = 0; + if (l_net) + { + dap_ledger_t *l_ledger = l_net->pub.ledger; + l_balance = dap_chain_ledger_calc_balance(l_ledger, l_addr, a_token_ticker); + } + return l_balance; +} diff --git a/dap_chain_wallet.h b/dap_chain_wallet.h index 963aae5dcd150441686c16a58d6115ad2a7dff6e..c58ca634974a7dc6048d90d9470aba0302ab8f09 100755 --- a/dap_chain_wallet.h +++ b/dap_chain_wallet.h @@ -58,4 +58,6 @@ size_t dap_chain_wallet_get_certs_number( dap_chain_wallet_t * a_wallet); dap_pkey_t * dap_chain_wallet_get_pkey( dap_chain_wallet_t * a_wallet,uint32_t a_key_idx); dap_enc_key_t * dap_chain_wallet_get_key( dap_chain_wallet_t * a_wallet,uint32_t a_key_idx); +uint64_t dap_chain_wallet_get_balance(dap_chain_wallet_t *a_wallet, dap_chain_net_id_t a_net_id, char *a_token_ticker); + int dap_chain_wallet_save_file( dap_chain_wallet_t * a_wallet);