[chainmaker][#547]add set url interface
@@ -185,8 +185,11 @@ BoatHlchainmakerWallet *BoatHlchainmakerWalletInit(const BoatHlchainmakerWalletC
wallet_ptr->tls_ca_cert_info.field_ptr = NULL;
wallet_ptr->tls_ca_cert_info.field_len = 0;
wallet_ptr->http2Context_ptr = NULL;
+ wallet_ptr->node_info.node_url_info = NULL;
+
+ BoatChainmakerWalletSetNodeUrl(wallet_ptr, config_ptr->node_url_cfg);
+
wallet_ptr->node_info.host_name_info = config_ptr->host_name_cfg;
- wallet_ptr->node_info.node_url_info = config_ptr->node_url_cfg;
wallet_ptr->node_info.chain_id_info = config_ptr->chain_id_cfg;
wallet_ptr->node_info.org_id_info = config_ptr->org_id_cfg;
@@ -547,3 +550,50 @@ BOAT_RESULT BoatHlchainmakerContractQuery(BoatHlchainmakerTx *tx_ptr, char* meth
}
return result;
}
+
+
+BOAT_RESULT BoatChainmakerWalletSetNodeUrl(BoatHlchainmakerWallet *wallet_ptr, const BCHAR *node_url_ptr)
+{
+ BOAT_RESULT result;
+
+ if ((wallet_ptr == NULL) || (node_url_ptr == NULL))
+ {
+ BoatLog(BOAT_LOG_CRITICAL, "wallet_ptr or node_url_ptr cannot be NULL.");
+ return BOAT_ERROR_COMMON_INVALID_ARGUMENT;
+ }
+
+ if (strchr(node_url_ptr, ':') == NULL)
+ {
+ BoatLog(BOAT_LOG_CRITICAL, "node URL has a invalid format: %s.", node_url_ptr);
+ return BOAT_ERROR_COMMON_INVALID_ARGUMENT;
+ }
+
+ // string length check
+ if (BOAT_SUCCESS != UtilityStringLenCheck(node_url_ptr))
+ {
+ BoatLog(BOAT_LOG_CRITICAL, "node URL length out of limit: %s.", node_url_ptr);
+ return BOAT_ERROR_COMMON_INVALID_ARGUMENT;
+ }
+
+ // Set Node URL
+
+ if (wallet_ptr->node_info.node_url_info != NULL)
+ {
+ BoatFree(wallet_ptr->node_info.node_url_info);
+ }
+
+ // +1 for NULL Terminator
+ wallet_ptr->node_info.node_url_info = BoatMalloc(strlen(node_url_ptr) + 1);
+ if (wallet_ptr->node_info.node_url_info == NULL)
+ {
+ BoatLog(BOAT_LOG_CRITICAL, "Fail to allocate memory for Node URL string.");
+ result = BOAT_ERROR_COMMON_OUT_OF_MEMORY;
+ }
+ else
+ {
+ strcpy(wallet_ptr->node_info.node_url_info, node_url_ptr);
+ result = BOAT_SUCCESS;
+ }
+
+ return result;
+}
\ No newline at end of file
