diff --git a/dap-sdk/core/src/dap_strfuncs.c b/dap-sdk/core/src/dap_strfuncs.c index c95ff68bb8aa653fa4004d0c1f9f86f1dd997a88..163882b51d80daa2c00267de15f586b0afb50f7b 100755 --- a/dap-sdk/core/src/dap_strfuncs.c +++ b/dap-sdk/core/src/dap_strfuncs.c @@ -312,7 +312,7 @@ char* dap_strdup_vprintf(const char *a_format, va_list a_args) * @return char* a newly-allocated string holding the result */ -char* dap_strdup_printf(const char *a_format, ...) +DAP_PRINTF_ATTR(1,2) char *dap_strdup_printf(const char *a_format, ...) { char *l_buffer; va_list l_args; diff --git a/dap-sdk/net/client/dap_client_pvt.c b/dap-sdk/net/client/dap_client_pvt.c index ad7cddd9b2ff4789bcacb0eb6086773203b93984..4dc04661e783517de391d5560a68120cfebae637 100644 --- a/dap-sdk/net/client/dap_client_pvt.c +++ b/dap-sdk/net/client/dap_client_pvt.c @@ -161,6 +161,48 @@ void dap_client_pvt_new(dap_client_pvt_t * a_client_pvt) +/** + * @brief dap_client_set_auth_cert + * @param a_client + * @param a_chain_net_name + * @param a_option + */ +void dap_client_set_auth_cert(dap_client_t *a_client, const char *a_chain_net_name) +{ + const char *l_auth_hash_str = NULL; + + if(a_client == NULL || a_chain_net_name == NULL){ + log_it(L_ERROR,"Chain-net is NULL for dap_client_set_auth_cert"); + return; + } + + char *l_path = dap_strdup_printf("network/%s", a_chain_net_name); + if (!l_path) { + log_it(L_ERROR, "Can't allocate memory: file: %s line: %d", __FILE__, __LINE__); + return; + } + + dap_config_t *l_cfg = dap_config_open(l_path); + free(l_path); + if (!l_cfg) { + log_it(L_ERROR, "Can't allocate memory: file: %s line: %d", __FILE__, __LINE__); + return; + } + + dap_cert_t *l_cert = dap_cert_find_by_name(dap_config_get_item_str(l_cfg, "general", "auth_cert")); + if (!l_cert) { + dap_config_close(l_cfg); + log_it(L_ERROR,"l_cert is NULL by dap_cert_find_by_name"); + return; + } + dap_client_set_auth_cert_unsafe(a_client, l_cert); + + //dap_cert_delete(l_cert); + dap_config_close(l_cfg); +} + + + /** * @brief dap_client_pvt_delete_unsafe * @param a_client_pvt diff --git a/modules/common/dap_chain_common.c b/modules/common/dap_chain_common.c index f3fdf186d27e9340c554fd2b3d9a6fa3374e3ce2..a0a9fafc2dc013ed513110a7994380d9e48e0355 100644 --- a/modules/common/dap_chain_common.c +++ b/modules/common/dap_chain_common.c @@ -247,6 +247,16 @@ uint64_t dap_chain_uint256_to(uint256_t a_from) #endif } +// 256 +uint128_t dap_chain_uint128_from_uint256(uint256_t a_from) +{ + if ( !( EQUAL_128(a_from.hi, uint128_0) ) ) { + log_it(L_ERROR, "Can't convert to uint128_t. It's too big."); + } + return a_from.lo; +} + + char *dap_chain_balance_print128(uint128_t a_balance) { char *l_buf = DAP_NEW_Z_SIZE(char, DATOSHI_POW + 3); diff --git a/modules/net/dap_chain_node_client.c b/modules/net/dap_chain_node_client.c index 83b6e136d05d7876dd6aa4bbfcac52f8bcc636b0..819f9ac4e984af9cd1ae9e98eff8901e333a6fdc 100644 --- a/modules/net/dap_chain_node_client.c +++ b/modules/net/dap_chain_node_client.c @@ -676,7 +676,7 @@ static bool dap_chain_node_client_connect_internal(dap_chain_node_client_t *a_no a_node_client->client->_inheritor = a_node_client; dap_client_set_active_channels_unsafe(a_node_client->client, a_active_channels); - //dap_client_set_auth_cert(a_node_client->client, dap_cert_find_by_name("auth")); // TODO provide the certificate choice + dap_client_set_auth_cert(a_node_client->client, a_node_client->net->pub.name); int hostlen = 128; char host[hostlen];