Compare commits

...

8 Commits

Author SHA1 Message Date
Some Random Crypto Guy 7ad904a9ae fixed output type checking for all HF versions; bumped TESTNET version; bumped version 2024-06-24 17:02:19 +01:00
Some Random Crypto Guy 12cf6be402 Merge branch 'main' into develop 2024-06-24 10:10:54 +01:00
Some Random Crypto Guy 292845d721 changed some errant monero strings to salvium 2024-06-24 10:10:13 +01:00
Some Random Crypto Guy 9bc0ccc14d bumped version 2024-06-23 14:43:38 +01:00
Some Random Crypto Guy c20ab30963 fixed error when popping blocks containing multiple STAKE TXs; fixed 'version' command in daemon; bumped version number 2024-06-23 08:56:59 +01:00
Some Random Crypto Guy 3e012bc1fb fixed segfault in clean wallet when calling yield_info 2024-06-22 20:34:40 +01:00
Some Random Crypto Guy f07d3942e1 fixed stake returned wallet balance; updated yield_info and supply_info commands 2024-06-22 19:40:19 +01:00
Neil Coggins b93cf3a2d0 bumped chain version; updated premine wallet for testnet 2024-06-21 14:16:20 +01:00
12 changed files with 59 additions and 34 deletions
+17 -5
View File
@@ -1381,7 +1381,7 @@ void BlockchainLMDB::remove_transaction_data(const crypto::hash& tx_hash, const
LOG_PRINT_L1("tx ID " << tip->data.tx_id << "\n\tTally before burn = " << source_tally.str() << "\n\tTally after burn = " << final_source_tally.str());
}
if (tx.type == cryptonote::transaction_type::CONVERT || tx.type == cryptonote::transaction_type::BURN || tx.type == cryptonote::transaction_type::STAKE) {
if (tx.type == cryptonote::transaction_type::BURN || tx.type == cryptonote::transaction_type::CONVERT || tx.type == cryptonote::transaction_type::STAKE) {
// Get the current tally value for the source currency type
MDB_val_copy<uint64_t> source_idx(cryptonote::asset_id_from_type(tx.source_asset_type));
@@ -1442,17 +1442,28 @@ void BlockchainLMDB::remove_transaction_data(const crypto::hash& tx_hash, const
throw1(DB_ERROR(lmdb_error("Failed to add removal of tx outputs to db transaction: ", result).c_str()));
}
// SRCG: The following code is designed to clean up the STAKE transactions, but it is very poorly written
// Since transactions are ALWAYS supposed to be created in order, it stands that they should ALWAYS be
// removed in REVERSE ORDER. Yet the following loop starts from the beginning - this is the worst possible
// implementation in performance terms, since it will ALWAYS take the longest possible time to remove the
// correct TX.
// RECODE TO START FROM THE END OF THE DATABASE TABLE, AND THROW AN EXCEPTION IF YOU DO NOT MATCH FIRST TIME!
// Is there yield_tx data to remove?
if (tx.type == cryptonote::transaction_type::STAKE) {
// Remove any yield_tx data for this transaction
MDB_val_set(val_height, m_height);
MDB_val v;
MDB_cursor_op op = MDB_SET;
while (1) {
result = mdb_cursor_get(m_cur_yield_txs, &val_height, &v, MDB_SET);
if (result == MDB_NOTFOUND)
break;
else if (result)
result = mdb_cursor_get(m_cur_yield_txs, &val_height, &v, op);
if (result == MDB_NOTFOUND) {
throw1(DB_ERROR("Failed to locate yield tx for removal from db transaction"));
} else if (result) {
throw1(DB_ERROR(lmdb_error("Failed to locate yield_tx data for removal: ", result).c_str()));
}
op = MDB_NEXT_DUP;
const yield_tx_info yti = *(const yield_tx_info*)v.mv_data;
if (yti.tx_hash == tx_hash) {
result = mdb_cursor_del(m_cur_yield_txs, 0);
@@ -3502,6 +3513,7 @@ std::map<std::string,uint64_t> BlockchainLMDB::get_circulating_supply() const
if (circulating_supply.empty()) {
circulating_supply["SAL"] = m_coinbase;
}
circulating_supply["BURN"] = m_coinbase - circulating_supply["SAL"];
return circulating_supply;
}
@@ -959,7 +959,7 @@ static void open_db(const std::string &filename, MDB_env **env, MDB_txn **txn, M
dbr = mdb_env_set_maxdbs(*env, 1);
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to set max env dbs: " + std::string(mdb_strerror(dbr)));
const std::string actual_filename = filename;
MINFO("Opening monero blockchain at " << actual_filename);
MINFO("Opening Salvium blockchain at " << actual_filename);
dbr = mdb_env_open(*env, actual_filename.c_str(), flags, 0664);
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to open rings database file '"
+ actual_filename + "': " + std::string(mdb_strerror(dbr)));
@@ -1256,6 +1256,11 @@ namespace cryptonote
<< o.target.type().name() << " and " << tx.vout[0].target.type().name() << ", "
<< "expected matching variant types in transaction id=" << get_transaction_hash(tx));
}
// Verify the asset type
std::string asset_type;
CHECK_AND_ASSERT_MES(cryptonote::get_output_asset_type(o, asset_type), false, "failed to get asset type");
CHECK_AND_ASSERT_MES(asset_type == "SAL", false, "wrong output asset type:" << asset_type);
}
return true;
}
+2 -2
View File
@@ -216,7 +216,7 @@
#define HF_VERSION_ENABLE_ORACLE 2
#define HF_VERSION_SLIPPAGE_YIELD 2
#define TESTNET_VERSION 7
#define TESTNET_VERSION 9
#define STAGENET_VERSION 1
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
@@ -337,7 +337,7 @@ namespace config
boost::uuids::uuid const NETWORK_ID = { {
0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x82, 0x53, 0x41, 0x4C, 0x00, TESTNET_VERSION
} };
std::string const GENESIS_TX = "020001ff000180c0d0c7bbbff6030279e90d3da9f9568396c5795833e6aed334d10b6bc08219de189e3ac6fade73c50353414c3c00000000000000210118c0fd33040975cb28c52cca0005a909661afeec61944e42b8646e069fd04209010000";
std::string const GENESIS_TX = "020001ff000180c0d0c7bbbff60302800b6eb882218e901c1c36bce474224456d82226260226d252459dfbadf186f70353414c3c00000000000000210171af115cca70fdcfdac362854ed9de472e242c8be5a3684e8a809d54f5dbdb18010000";
uint32_t const GENESIS_NONCE = 10001;
const uint64_t STAKE_LOCK_PERIOD = 20;
+1 -1
View File
@@ -3555,7 +3555,7 @@ bool Blockchain::check_tx_outputs(const transaction& tx, tx_verification_context
}
}
// from v15, require view tags on outputs
// from v15, require view tags and asset types on outputs
if (!check_output_types(tx, hf_version))
{
tvc.m_invalid_output = true;
+3 -3
View File
@@ -170,7 +170,7 @@ namespace cryptonote
};
static const command_line::arg_descriptor<std::string> arg_check_updates = {
"check-updates"
, "Check for new versions of monero: [disabled|notify|download|update]"
, "Check for new versions of Salvium: [disabled|notify|download|update]"
, "disabled"
};
static const command_line::arg_descriptor<bool> arg_fluffy_blocks = {
@@ -504,7 +504,7 @@ namespace cryptonote
if (boost::filesystem::exists(old_files / "blockchain.bin"))
{
MWARNING("Found old-style blockchain.bin in " << old_files.string());
MWARNING("Monero now uses a new format. You can either remove blockchain.bin to start syncing");
MWARNING("Salvium now uses a new format. You can either remove blockchain.bin to start syncing");
MWARNING("the blockchain anew, or use salvium-blockchain-export and salvium-blockchain-import to");
MWARNING("convert your existing blockchain.bin to the new format. See README.md for instructions.");
return false;
@@ -1878,7 +1878,7 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------
bool core::check_updates()
{
static const char software[] = "monero";
static const char software[] = "salvium";
#ifdef BUILD_TAG
static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
static const char subdir[] = "cli"; // because it can never be simple
+1 -1
View File
@@ -45,7 +45,7 @@ namespace rpc
bool is_version_string_valid(const std::string& str)
{
return std::regex_match(str, std::regex(
"^\\d{1,2}(\\.\\d{1,2}){3}(-(release|[0-9a-f]{9}))?$",
"^\\d{1,2}(\\.\\d{1,2}){2}(-(release|[0-9a-f]{9}))?.+$",
std::regex_constants::nosubs
));
}
+6 -4
View File
@@ -8370,7 +8370,7 @@ bool simple_wallet::supply_info(const std::vector<std::string> &args) {
//supply_128 /= COIN;
uint64_t supply = supply_128.convert_to<uint64_t>();
message_writer(console_color_default, false) << boost::format(tr("\t%s\t:\t%d")) % supply_asset.first % print_money(supply);
message_writer(console_color_default, false) << boost::format(tr("\t%6s : %21.8d")) % supply_asset.first % print_money(supply);
/*
// get price
@@ -8431,8 +8431,8 @@ bool simple_wallet::yield_info(const std::vector<std::string> &args) {
}
// Output the necessary information about yield stats
message_writer(console_color_default, false) << boost::format(tr("YIELD INFO:\n\tTotal SAL supply: %d\n\tTotal coins burnt: %d\n\tTotal coins locked: %d\n\tYield accrued over last %s: %d\n\tYield per SAL staked: %d"))
% print_money(total_supply_128.convert_to<uint64_t>())
message_writer(console_color_default, false) << boost::format(tr("YIELD INFO:\n\tSupply coins burnt over last %s: %d\n\tTotal coins locked: %d\n\tYield accrued over last %s: %d\n\tYield per SAL staked: %d"))
% get_human_readable_timespan((ybi_data.size()-1) * DIFFICULTY_TARGET_V2)
% print_money(total_burnt)
% print_money(ybi_data.back().locked_coins_tally)
% get_human_readable_timespan((ybi_data.size()-1) * DIFFICULTY_TARGET_V2)
@@ -8442,7 +8442,9 @@ bool simple_wallet::yield_info(const std::vector<std::string> &args) {
// Now summarise our own YIELD TXs that are yet to amture
tools::wallet2::transfer_container transfers;
m_wallet->get_transfers(transfers);
if (transfers.empty())
return true;
std::map<size_t, size_t> payouts;
message_writer(console_color_default, false) << boost::format(tr("\nSTAKED FUNDS:"));
for (size_t idx = transfers.size()-1; idx>0; --idx) {
+3 -3
View File
@@ -1,6 +1,6 @@
#define DEF_SALVIUM_VERSION_TAG "7f6b8da"
#define DEF_SALVIUM_VERSION "0.3.0"
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
#define DEF_SALVIUM_VERSION_TAG "@VERSIONTAG@"
#define DEF_SALVIUM_VERSION "0.3.3"
#define DEF_MONERO_VERSION_TAG "release"
#define DEF_MONERO_VERSION "0.18.3.3"
#define DEF_MONERO_RELEASE_NAME "Zero"
#define DEF_MONERO_VERSION_FULL DEF_SALVIUM_VERSION "-" DEF_SALVIUM_VERSION_TAG ", based on Monero " DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
+17 -10
View File
@@ -2169,8 +2169,8 @@ void wallet2::scan_output(const cryptonote::transaction &tx, bool miner_tx, cons
if (!m_encrypt_keys_after_refresh)
{
boost::optional<epee::wipeable_string> pwd = m_callback->on_get_password(pool ? "output found in pool" : "output received");
THROW_WALLET_EXCEPTION_IF(!pwd, error::password_needed, tr("Password is needed to compute key image for incoming monero"));
THROW_WALLET_EXCEPTION_IF(!verify_password(*pwd), error::password_needed, tr("Invalid password: password is needed to compute key image for incoming monero"));
THROW_WALLET_EXCEPTION_IF(!pwd, error::password_needed, tr("Password is needed to compute key image for incoming SALs"));
THROW_WALLET_EXCEPTION_IF(!verify_password(*pwd), error::password_needed, tr("Invalid password: password is needed to compute key image for incoming SALs"));
m_encrypt_keys_after_refresh.reset(new wallet_keys_unlocker(*this, m_ask_password == AskPasswordToDecrypt && !m_unattended && !m_watch_only, *pwd));
}
}
@@ -2543,12 +2543,6 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
bool ok = m_account.get_device().derive_subaddress_public_key(output_public_key, derivation, i, pk_change);
THROW_WALLET_EXCEPTION_IF(!ok, error::wallet_internal_error, "Failed to derive subaddress public key for TRANSFER TX");
// Find the TX public key for P_change
//auto search = m_salvium_txs.find(pk_change);
//if (search != m_salvium_txs.end()) {
// Store the origin index for the TX - this is needed when we want to SPEND the returned funds
check_acc_out_precomp_once(tx.vout[i], derivation, additional_derivations, i, is_out_data_ptr, tx_scan_info[i], output_found[i]);
THROW_WALLET_EXCEPTION_IF(tx_scan_info[i].error, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys());
if (tx_scan_info[i].received)
@@ -2564,6 +2558,19 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
// Copy the origin TD
td_origin_idx = tx_scan_info[i].origin_idx;
if (tx.type == cryptonote::transaction_type::PROTOCOL) {
THROW_WALLET_EXCEPTION_IF(td_origin_idx >= get_num_transfer_details(), error::wallet_internal_error, "cannot locate protocol TX origin in m_transfers");
const transfer_details& td_origin = get_transfer_details(td_origin_idx);
THROW_WALLET_EXCEPTION_IF(td_origin.m_tx.type != cryptonote::transaction_type::STAKE, error::wallet_internal_error, "incorrect TX type for protocol_tx origin in m_transfers");
// Get the output key for the change entry
crypto::public_key pk_locked_coins = crypto::null_pkey;
THROW_WALLET_EXCEPTION_IF(!get_output_public_key(td_origin.m_tx.vout[td_origin.m_internal_output_index], pk_locked_coins), error::wallet_internal_error, "Failed to get output public key for locked coins");
// At this point, we need to clear the "locked coins" count, because otherwise we will be counting yield stakes twice in our balance
THROW_WALLET_EXCEPTION_IF(!m_locked_coins.erase(pk_locked_coins), error::wallet_internal_error, "Failed to remove protocol_tx entry from m_locked_coins");
}
}
}
}
@@ -2691,7 +2698,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
if (tx.type == cryptonote::transaction_type::STAKE) {
// Additionally, with YIELD TXs, we need to update our "balance staked" subtotal, because otherwise our balance is out by the staked coins until they mature!
// SRCG: must remember to deduct the number of staked coins when they mature!!
LOG_ERROR("***** STAKED COINS : " << tx.amount_burnt << " *****");
LOG_PRINT_L1("***** STAKED COINS : " << tx.amount_burnt << " *****");
m_locked_coins.insert({P_change, {0, tx.amount_burnt}});
}
@@ -14901,7 +14908,7 @@ mms::multisig_wallet_state wallet2::get_multisig_wallet_state() const
state.num_transfer_details = m_transfers.size();
if (state.multisig)
{
THROW_WALLET_EXCEPTION_IF(!m_original_keys_available, error::wallet_internal_error, "MMS use not possible because own original Monero address not available");
THROW_WALLET_EXCEPTION_IF(!m_original_keys_available, error::wallet_internal_error, "MMS use not possible because own original Salvium address not available");
state.address = m_original_address;
state.view_secret_key = m_original_view_secret_key;
}
+1 -2
View File
@@ -149,8 +149,7 @@ namespace wallet_args
if (command_line::get_arg(vm, command_line::arg_help))
{
Print(print) << "Salvium '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL;
Print(print) << wallet_args::tr("This is the command line monero wallet. It needs to connect to a monero\n"
"daemon to work correctly.") << ENDL;
Print(print) << wallet_args::tr("This is the command line Salvium wallet. It needs to connect to a Salvium daemon to work correctly.") << ENDL;
Print(print) << wallet_args::tr("Usage:") << ENDL << " " << usage;
Print(print) << desc_all;
should_terminate = true;
+2 -2
View File
@@ -320,7 +320,7 @@ namespace tools
{
MINFO("The daemon is not set up to background mine.");
MINFO("With background mining enabled, the daemon will mine when idle and not on battery.");
MINFO("Enabling this supports the network you are using, and makes you eligible for receiving new monero");
MINFO("Enabling this supports the network you are using, and makes you eligible for receiving new SALs");
MINFO("Set setup-background-mining to 1 in salvium-wallet-cli to change.");
return;
}
@@ -4780,7 +4780,7 @@ int main(int argc, char** argv) {
std::tie(vm, should_terminate) = wallet_args::main(
argc, argv,
"salvium-wallet-rpc [--wallet-file=<file>|--generate-from-json=<file>|--wallet-dir=<directory>] [--rpc-bind-port=<port>]",
tools::wallet_rpc_server::tr("This is the RPC monero wallet. It needs to connect to a monero\ndaemon to work correctly."),
tools::wallet_rpc_server::tr("This is the RPC Salvium wallet. It needs to connect to a Salvium daemon to work correctly."),
desc_params,
po::positional_options_description(),
[](const std::string &s, bool emphasis){ tools::scoped_message_writer(emphasis ? epee::console_color_white : epee::console_color_default, true) << s; },