fix: update boatwalletCreate to fix one-time wallet failed
@@ -120,12 +120,11 @@ BSINT32 BoatWalletCreate( BoatProtocolType protocol_type, const BCHAR *wallet_na
BoatLog(BOAT_LOG_NORMAL, "Too many wallets was loaded.");
return BOAT_ERROR;
}
- if( wallet_name_str != NULL )
- {
+
+
if( wallet_config_ptr != NULL )
{
- /* create a persiststore wallet */
-
+ /* private key context update */
/* -step-1: generate prikeyCtxTmp */
switch(protocol_type)
{
@@ -158,6 +157,8 @@ BSINT32 BoatWalletCreate( BoatProtocolType protocol_type, const BCHAR *wallet_na
priKeyCtx_configTmp->prikey_content_length = 0;
memset( priKeyCtx_configTmp->prikey_content, 0, sizeof(priKeyCtx_configTmp->prikey_content) );
+ if( wallet_name_str != NULL )
+ {
/* -step-4: create persistent wallet / Overwrite existed configuration */
if( BOAT_SUCCESS != BoatPersistStore(wallet_name_str, wallet_config_ptr, wallet_config_size) )
{
@@ -167,6 +168,12 @@ BSINT32 BoatWalletCreate( BoatProtocolType protocol_type, const BCHAR *wallet_na
memcpy(loaded_wallet_config_array, wallet_config_ptr, wallet_config_size);
}
else
+ {
+ /* create one-time wallet */
+ memcpy(loaded_wallet_config_array, wallet_config_ptr, wallet_config_size);
+ }
+ }
+ else
{
/* Load persistent wallet */
if( BOAT_SUCCESS != BoatPersistRead(wallet_name_str, loaded_wallet_config_array, wallet_config_size) )
@@ -175,12 +182,6 @@ BSINT32 BoatWalletCreate( BoatProtocolType protocol_type, const BCHAR *wallet_na
return BOAT_ERROR;
}
}
- }
- else
- {
- /* create one-time wallet */
- memcpy(loaded_wallet_config_array, wallet_config_ptr, wallet_config_size);
- }
/* Check protocol type */
g_boat_iot_sdk_context.wallet_list[i].protocol_type = protocol_type;
