diff --git a/src/GeniusSDK.cpp b/src/GeniusSDK.cpp index bbad50c..98c5232 100644 --- a/src/GeniusSDK.cpp +++ b/src/GeniusSDK.cpp @@ -37,49 +37,49 @@ class JsonError : public boost::exception namespace { outcome::result ReadDevConfigFromJSON( const std::string &base_path ) -{ - std::ifstream file( base_path + "dev_config.json" ); - if ( !file.is_open() ) { - return outcome::failure( JsonError( "Configuration file \"dev_config.json\" not found on " + base_path ) ); - } - DevConfig_st config_from_file = {}; - std::stringstream buffer; - buffer << file.rdbuf(); - std::string jsonStr = buffer.str(); + std::ifstream file( base_path + "dev_config.json" ); + if ( !file.is_open() ) + { + return outcome::failure( JsonError( "Configuration file \"dev_config.json\" not found on " + base_path ) ); + } + DevConfig_st config_from_file = {}; + std::stringstream buffer; + buffer << file.rdbuf(); + std::string jsonStr = buffer.str(); - rapidjson::Document document; - rapidjson::ParseResult parseResult = document.Parse( jsonStr.c_str() ); + rapidjson::Document document; + rapidjson::ParseResult parseResult = document.Parse( jsonStr.c_str() ); if ( parseResult == nullptr ) - { - return outcome::failure( JsonError( "Parse error " ) ); - } + { + return outcome::failure( JsonError( "Parse error " ) ); + } - if ( !document.HasMember( "Address" ) || !document["Address"].IsString() ) - { - return outcome::failure( JsonError( "Missing or invalid 'Address'" ) ); - } - if ( !document.HasMember( "Cut" ) || !document["Cut"].IsDouble() ) - { - return outcome::failure( JsonError( "Missing or invalid 'Cut'" ) ); - } - if ( !document.HasMember( "TokenValue" ) || !document["TokenValue"].IsDouble() ) - { - return outcome::failure( JsonError( "Missing or invalid 'TokenValue'" ) ); - } - if ( !document.HasMember( "TokenID" ) || !document["TokenID"].IsInt() ) - { - return outcome::failure( JsonError( "Missing or invalid 'TokenID'" ) ); - } + if ( !document.HasMember( "Address" ) || !document["Address"].IsString() ) + { + return outcome::failure( JsonError( "Missing or invalid 'Address'" ) ); + } + if ( !document.HasMember( "Cut" ) || !document["Cut"].IsDouble() ) + { + return outcome::failure( JsonError( "Missing or invalid 'Cut'" ) ); + } + if ( !document.HasMember( "TokenValue" ) || !document["TokenValue"].IsDouble() ) + { + return outcome::failure( JsonError( "Missing or invalid 'TokenValue'" ) ); + } + if ( !document.HasMember( "TokenID" ) || !document["TokenID"].IsInt() ) + { + return outcome::failure( JsonError( "Missing or invalid 'TokenID'" ) ); + } - strncpy( config_from_file.Addr, document["Address"].GetString(), document["Address"].GetStringLength() ); - config_from_file.Cut = document["Cut"].GetDouble(); - config_from_file.TokenValueInGNUS = document["TokenValue"].GetDouble(); - config_from_file.TokenID = document["TokenID"].GetInt(); - strncpy( config_from_file.BaseWritePath, base_path.data(), base_path.size() ); + strncpy( config_from_file.Addr, document["Address"].GetString(), document["Address"].GetStringLength() ); + config_from_file.Cut = document["Cut"].GetDouble(); + config_from_file.TokenValueInGNUS = document["TokenValue"].GetDouble(); + config_from_file.TokenID = document["TokenID"].GetInt(); + strncpy( config_from_file.BaseWritePath, base_path.data(), base_path.size() ); - return outcome::success( config_from_file ); -} + return outcome::success( config_from_file ); + } GeniusMatrix matrix_from_vector_of_vector( const std::vector> &vec ) { @@ -97,7 +97,7 @@ namespace return matrix; } -std::shared_ptr GeniusNodeInstance; + std::shared_ptr GeniusNodeInstance; } const char *GeniusSDKInit( const char *base_path ) @@ -147,3 +147,7 @@ void GeniusSDKFreeTransactions( GeniusMatrix matrix ) free( matrix.ptr ); } +void GeniusSDKMintTokens( uint64_t amount ) +{ + GeniusNodeInstance->MintTokens( amount ); +} diff --git a/src/GeniusSDK.h b/src/GeniusSDK.h index ec7c681..a7d5049 100644 --- a/src/GeniusSDK.h +++ b/src/GeniusSDK.h @@ -49,6 +49,7 @@ GNUS_VISIBILITY_DEFAULT void GeniusSDKProcess( const ImagePath_t path, Pa GNUS_VISIBILITY_DEFAULT uint64_t GeniusSDKGetBalance(); GNUS_VISIBILITY_DEFAULT GeniusMatrix GeniusSDKGetTransactions(); GNUS_VISIBILITY_DEFAULT void GeniusSDKFreeTransactions( GeniusMatrix matrix ); +GNUS_VISIBILITY_DEFAULT void GeniusSDKMintTokens( uint64_t amount ); GNUS_EXPORT_END