diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 82adc191a..ef22fdffb 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1725,7 +1725,7 @@ bool Blockchain::validate_protocol_transaction(const block& b, uint64_t height, } // Verify the correct metadata type is provided - CHECK_AND_ASSERT_MES(ct_data.second.token.type() == typeid(cryptonote::sal_token_t), false, "Incorred CREATE_TOKEN metadata type detected in protocol_tx"); + CHECK_AND_ASSERT_MES(ct_data.second.token.type() == typeid(cryptonote::sal_token_t), false, "Incorrect CREATE_TOKEN metadata type detected in protocol_tx"); cryptonote::sal_token_t token = boost::get(ct_data.second.token); // Verify the output amount @@ -2066,7 +2066,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block, // create the protocol transaction entries for CREATE_TOKEN TXs if (b.major_version >= HF_VERSION_ENABLE_TOKENS) { for (const auto& ct_data_entry: create_token_entries) { - CHECK_AND_ASSERT_MES(ct_data_entry.second.token.type() == typeid(cryptonote::sal_token_t), false, "Incorred CREATE_TOKEN metadata type detected in protocol_tx"); + CHECK_AND_ASSERT_MES(ct_data_entry.second.token.type() == typeid(cryptonote::sal_token_t), false, "Incorrect CREATE_TOKEN metadata type detected in protocol_tx"); cryptonote::sal_token_t token = boost::get(ct_data_entry.second.token); cryptonote::protocol_data_entry entry; uint64_t hi, lo; @@ -4097,6 +4097,8 @@ bool Blockchain::check_tx_type_and_version(const transaction& tx, tx_verificatio CHECK_AND_ASSERT_MES(tx.token_metadata.token.type() == typeid(cryptonote::sal_token_t), false, "Invalid CREATE_TOKEN metadata type"); cryptonote::sal_token_t token = boost::get(tx.token_metadata.token); CHECK_AND_ASSERT_MES(token.supply > 0 && token.supply <= (MONEY_SUPPLY / COIN), false, "Invalid SUPPLY value for CREATE_TOKEN"); + // Validate the amount burnt matches the token creation price + CHECK_AND_ASSERT_MES(tx.amount_burnt == cryptonote::get_token_creation_price(tx.token_metadata.asset_type), false, "Invalid fee paid for CREATE_TOKEN"); } // Check for invalid TX types diff --git a/src/version.cpp.in b/src/version.cpp.in index 89e0beddf..bc0f5197b 100644 --- a/src/version.cpp.in +++ b/src/version.cpp.in @@ -1,5 +1,5 @@ #define DEF_SALVIUM_VERSION_TAG "@VERSIONTAG@" -#define DEF_SALVIUM_VERSION "1.1.0-rc1" +#define DEF_SALVIUM_VERSION "1.1.0-rc2" #define DEF_MONERO_VERSION_TAG "release" #define DEF_MONERO_VERSION "0.18.3.4" #define DEF_MONERO_RELEASE_NAME "One" diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 3b8bd7205..0c5abd57f 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1301,13 +1301,13 @@ namespace tools return false; } - if (req.coin_symbol.empty()) { + if (req.ticker.empty()) { er.code = WALLET_RPC_ERROR_CODE_DENIED; - er.message = "Empty asset type is not allowed."; + er.message = "Empty ticker is not allowed."; return false; } - std::string asset_type = req.coin_symbol; + std::string asset_type = req.ticker; std::transform(asset_type.begin(), asset_type.end(), asset_type.begin(), ::toupper); if (asset_type.length() != 4) { er.code = WALLET_RPC_ERROR_CODE_DENIED; @@ -1352,21 +1352,13 @@ namespace tools } // Verify supply amount is acceptable - if (req.coin_supply < 1 || req.coin_supply > MONEY_SUPPLY) + if (req.supply < 1 || req.supply > MONEY_SUPPLY) { er.code = WALLET_RPC_ERROR_CODE_DENIED; er.message = "Supply amount must be between 1 and MONEY_SUPPLY."; return false; } - // // Verify decimals amount is acceptable - // if (req.coin_decimals > 8) - // { - // er.code = WALLET_RPC_ERROR_CODE_DENIED; - // er.message = "Invalid decimals amount. Maximum allowed is 8."; - // return false; - // } - // convert req.hash to hash crypto::hash hash_signature{}; if (!req.hash.empty()) { @@ -1386,7 +1378,7 @@ namespace tools token_metadata_hex = req.token_metadata_hex; } - //cryptonote::sal_token_t sal_token{1, req.coin_supply, req.size, req.name, req.url, hash_signature}; + //cryptonote::sal_token_t sal_token{1, req.supply, req.size, req.name, req.url, hash_signature}; //cryptonote::token_metadata_t token{1, asset_type, sal_token}; try @@ -1394,7 +1386,7 @@ namespace tools // Call the wallet create_token() method auto ptx_vector = m_wallet->create_token( asset_type, - req.coin_supply, + req.supply, token_metadata_hex, req.account_index, req.subaddr_indices diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index 3b12690c6..132ae54f4 100644 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -2943,8 +2943,8 @@ namespace wallet_rpc { struct request_t { - std::string coin_symbol; - uint64_t coin_supply; + std::string ticker; + uint64_t supply; uint32_t account_index; std::set subaddr_indices; std::string name; @@ -2959,15 +2959,15 @@ namespace wallet_rpc bool get_tx_metadata; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(coin_symbol) - KV_SERIALIZE(coin_supply) + KV_SERIALIZE(ticker) + KV_SERIALIZE(supply) KV_SERIALIZE(account_index) KV_SERIALIZE(subaddr_indices) - KV_SERIALIZE(name) - KV_SERIALIZE(url) - KV_SERIALIZE(hash) - KV_SERIALIZE(size) - KV_SERIALIZE(token_metadata_hex) + KV_SERIALIZE_OPT(name, (std::string)"") + KV_SERIALIZE_OPT(url, (std::string)"") + KV_SERIALIZE_OPT(hash, (std::string)"") + KV_SERIALIZE_OPT(size, (uint64_t)0) + KV_SERIALIZE_OPT(token_metadata_hex, (std::string)"") KV_SERIALIZE_OPT(get_tx_keys, false) KV_SERIALIZE_OPT(do_not_relay, false) KV_SERIALIZE_OPT(get_tx_hex, false)