[quorum][#690]add wallet create function
@@ -651,6 +651,61 @@ BSINT32 BoatWalletCreate(BoatProtocolType protocol_type, const BCHAR *wallet_nam
g_boat_iot_sdk_context.wallet_list[i].wallet_ptr = wallet_ptr;
break;
#endif
+ #if PROTOCOL_USE_QUORUM == 1
+ case BOAT_PROTOCOL_QUORUM:
+ if (wallet_config_ptr != NULL)
+ {
+ memcpy(boatwalletStore_ptr, wallet_config_ptr, wallet_config_size);
+ ((BoatQuorumWalletConfig*)wallet_config_ptr)->load_existed_wallet = false;
+ wallet_ptr = BoatQuorumWalletInit((BoatQuorumWalletConfig*)wallet_config_ptr, wallet_config_size);
+ if (wallet_ptr != NULL)
+ {
+ memcpy(boatwalletStore_ptr + wallet_config_size, &((BoatQuorumWallet*)wallet_ptr)->account_info.prikeyCtx, sizeof(BoatWalletPriKeyCtx));
+ if (wallet_name_str != NULL)
+ {
+ /* create persistent wallet / Overwrite existed configuration */
+ if (BOAT_SUCCESS != BoatPersistStore(wallet_name_str, boatwalletStore_ptr, wallet_config_size + sizeof(BoatWalletPriKeyCtx)))
+ {
+ BoatLog(BOAT_LOG_NORMAL, "persistent wallet create failed.");
+ BoatFree(boatwalletStore_ptr);
+ return BOAT_ERROR_PERSISTER_STORE_FAIL;
+ }
+ }
+ else
+ {
+ /* create one-time wallet */
+ // nothing to do
+ }
+ }
+ }
+ else
+ {
+ /* Load persistent wallet */
+ if (BOAT_SUCCESS != BoatPersistRead(wallet_name_str, boatwalletStore_ptr, wallet_config_size + sizeof(BoatWalletPriKeyCtx)))
+ {
+ BoatLog(BOAT_LOG_NORMAL, "persistent wallet load failed.");
+ BoatFree(boatwalletStore_ptr);
+ return BOAT_ERROR_PERSISTER_READ_FAIL;
+ }
+ //
+ BoatQuorumWalletConfig *load_wallet_config_ptr = (BoatQuorumWalletConfig*)boatwalletStore_ptr;
+ load_wallet_config_ptr->prikeyCtx_config.prikey_content.field_ptr = NULL;
+ load_wallet_config_ptr->prikeyCtx_config.prikey_content.field_len = 0;
+ load_wallet_config_ptr->load_existed_wallet = true;
+ wallet_ptr = BoatQuorumWalletInit(load_wallet_config_ptr, wallet_config_size);
+ if (wallet_ptr != NULL)
+ {
+ // re-assign private key context
+ memcpy( &((BoatQuorumWallet*)wallet_ptr)->account_info.prikeyCtx, boatwalletStore_ptr + wallet_config_size, sizeof(BoatWalletPriKeyCtx));
+ // compute address
+ BoatHash(BOAT_HASH_KECCAK256, ((BoatQuorumWallet*)wallet_ptr)->account_info.prikeyCtx.pubkey_content, 64, pubkeyHashDummy, &hashLenDummy, NULL);
+ memcpy(((BoatQuorumWallet*)wallet_ptr)->account_info.address, &pubkeyHashDummy[32 - BOAT_QUORUM_ADDRESS_SIZE], BOAT_QUORUM_ADDRESS_SIZE);
+ }
+ }
+
+ g_boat_iot_sdk_context.wallet_list[i].wallet_ptr = wallet_ptr;
+ break;
+ #endif
default:
g_boat_iot_sdk_context.wallet_list[i].wallet_ptr = NULL;
