Compare commits

..

2 Commits

Author SHA1 Message Date
Some Random Crypto Guy
9c83633120 fixed RPC functionality for TRANSFER functionality; bumped version 2024-07-08 21:12:06 +01:00
Some Random Crypto Guy
c424c5d544 fixed incorrect message for time ahead / behind blockchain 2024-07-08 21:11:20 +01:00
7 changed files with 46 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
# Salvium Zero v0.4.0
# Salvium Zero v0.4.1
Copyright (c) 2023-2024, Salvium
Portions Copyright (c) 2014-2023, The Monero Project
@@ -251,7 +251,7 @@ Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch (
```bash
git clone https://github.com/salvium/salvium
cd salvium
git checkout v0.4.0
git checkout v0.4.1
```
* Build:
@@ -370,10 +370,10 @@ application.
cd salvium
```
* If you would like a specific [version/tag](https://github.com/salvium/salvium/tags), do a git checkout for that version. eg. 'v0.4.0'. If you don't care about the version and just want binaries from master, skip this step:
* If you would like a specific [version/tag](https://github.com/salvium/salvium/tags), do a git checkout for that version. eg. 'v0.4.1'. If you don't care about the version and just want binaries from master, skip this step:
```bash
git checkout v0.4.0
git checkout v0.4.1
```
* If you are on a 64-bit system, run:

View File

@@ -401,7 +401,7 @@ namespace cryptonote
int64_t diff = static_cast<int64_t>(hshd.current_height) - static_cast<int64_t>(m_core.get_current_blockchain_height());
uint64_t abs_diff = std::abs(diff);
uint64_t max_block_height = std::max(hshd.current_height,m_core.get_current_blockchain_height());
uint64_t last_block_v1 = m_core.get_nettype() == TESTNET ? 624633 : m_core.get_nettype() == MAINNET ? 1009826 : (uint64_t)-1;
uint64_t last_block_v1 = 0;//m_core.get_nettype() == TESTNET ? 624633 : m_core.get_nettype() == MAINNET ? 1009826 : (uint64_t)-1;
uint64_t diff_v2 = max_block_height > last_block_v1 ? std::min(abs_diff, max_block_height - last_block_v1) : 0;
MCLOG(is_inital ? el::Level::Info : el::Level::Debug, "global", el::Color::Yellow, context << "Sync data returned a new top block candidate: " << m_core.get_current_blockchain_height() << " -> " << hshd.current_height
<< " [Your node is " << abs_diff << " blocks (" << tools::get_human_readable_timespan((abs_diff - diff_v2) * DIFFICULTY_TARGET_V1 + diff_v2 * DIFFICULTY_TARGET_V2) << ") "

View File

@@ -1,5 +1,5 @@
#define DEF_SALVIUM_VERSION_TAG "@VERSIONTAG@"
#define DEF_SALVIUM_VERSION "0.4.0"
#define DEF_SALVIUM_VERSION "0.4.1"
#define DEF_MONERO_VERSION_TAG "release"
#define DEF_MONERO_VERSION "0.18.3.3"
#define DEF_MONERO_RELEASE_NAME "Zero"

View File

@@ -2720,7 +2720,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
crypto::public_key P_change = crypto::null_pkey;
size_t change_idx = o;
THROW_WALLET_EXCEPTION_IF(!cryptonote::get_output_public_key(tx.vout[change_idx], P_change), error::wallet_internal_error, "Failed to get output public key");
m_subaddresses[P_change] = {0,0};
m_subaddresses[P_change] = tx_scan_info[o].received->index;//{0,0};
m_salvium_txs.insert({P_change, m_transfers.size()-1});
}
}
@@ -3001,7 +3001,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
// only for regular transfers
if (!miner_tx) {
for (auto& asset: total_received_1) {
if (asset.second != total_received_2[asset.first]) {
if (asset.second != total_received_2[asset.first] + (asset.first == source_asset ? sub_change : 0)) {
//if (source_asset == dest_asset && !miner_tx) {
//if (total_received_1 != total_received_2)
//{

View File

@@ -897,7 +897,7 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::validate_transfer(const std::list<wallet_rpc::transfer_destination>& destinations, const std::string& payment_id, std::vector<cryptonote::tx_destination_entry>& dsts, std::vector<uint8_t>& extra, bool at_least_one_destination, epee::json_rpc::error& er)
bool wallet_rpc_server::validate_transfer(const std::list<wallet_rpc::transfer_destination>& destinations, const std::string& source_asset, const std::string& dest_asset, const cryptonote::transaction_type& type, const std::string& payment_id, std::vector<cryptonote::tx_destination_entry>& dsts, std::vector<uint8_t>& extra, bool at_least_one_destination, epee::json_rpc::error& er)
{
crypto::hash8 integrated_payment_id = crypto::null_hash8;
std::string extra_nonce;
@@ -932,6 +932,7 @@ namespace tools
de.is_subaddress = info.is_subaddress;
de.amount = it->amount;
de.is_integrated = info.has_payment_id;
de.asset_type = it->asset_type;
dsts.push_back(de);
if (info.has_payment_id)
@@ -1107,8 +1108,11 @@ namespace tools
CHECK_MULTISIG_ENABLED();
// Cast the TX type into the correct var
const cryptonote::transaction_type type = static_cast<cryptonote::transaction_type>(req.tx_type);
// validate the transfer requested and populate dsts & extra
if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, true, er))
if (!validate_transfer(req.destinations, req.source_asset, req.dest_asset, type, req.payment_id, dsts, extra, true, er))
{
return false;
}
@@ -1117,7 +1121,7 @@ namespace tools
{
uint64_t mixin = m_wallet->adjust_mixin(req.ring_size ? req.ring_size - 1 : 0);
uint32_t priority = m_wallet->adjust_priority(req.priority);
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, req.source_asset, req.dest_asset, static_cast<cryptonote::transaction_type>(req.tx_type), mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices, req.subtract_fee_from_outputs);
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, req.source_asset, req.dest_asset, type, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices, req.subtract_fee_from_outputs);
if (ptx_vector.empty())
{
@@ -1161,8 +1165,11 @@ namespace tools
CHECK_MULTISIG_ENABLED();
// validate the transfer requested and populate dsts & extra; RPC_TRANSFER::request and RPC_TRANSFER_SPLIT::request are identical types.
if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, true, er))
// Cast the TX type into the correct var
const cryptonote::transaction_type type = static_cast<cryptonote::transaction_type>(req.tx_type);
// validate the transfer requested and populate dsts & extra
if (!validate_transfer(req.destinations, req.source_asset, req.dest_asset, type, req.payment_id, dsts, extra, true, er))
{
return false;
}
@@ -1172,7 +1179,7 @@ namespace tools
uint64_t mixin = m_wallet->adjust_mixin(req.ring_size ? req.ring_size - 1 : 0);
uint32_t priority = m_wallet->adjust_priority(req.priority);
LOG_PRINT_L2("on_transfer_split calling create_transactions_2");
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, req.source_asset, req.dest_asset, static_cast<cryptonote::transaction_type>(req.tx_type), mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices);
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, req.source_asset, req.dest_asset, type, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices);
LOG_PRINT_L2("on_transfer_split called create_transactions_2");
if (ptx_vector.empty())
@@ -1597,13 +1604,17 @@ namespace tools
CHECK_MULTISIG_ENABLED();
// validate the transfer requested and populate dsts & extra
std::list<wallet_rpc::transfer_destination> destination;
destination.push_back(wallet_rpc::transfer_destination());
destination.back().amount = 0;
destination.back().address = req.address;
std::string asset_type = req.asset_type.empty() ? "SAL" : req.asset_type;
if (!validate_transfer(destination, req.payment_id, dsts, extra, true, er))
// validate the transfer requested and populate dsts & extra
std::list<wallet_rpc::transfer_destination> destinations;
destinations.push_back(wallet_rpc::transfer_destination());
destinations.back().amount = 0;
destinations.back().address = req.address;
destinations.back().asset_type = asset_type;
// validate the transfer requested and populate dsts & extra
if (!validate_transfer(destinations, asset_type, asset_type, cryptonote::transaction_type::TRANSFER, req.payment_id, dsts, extra, true, er))
{
return false;
}
@@ -1665,12 +1676,17 @@ namespace tools
CHECK_MULTISIG_ENABLED();
std::string asset_type = req.asset_type.empty() ? "SAL" : req.asset_type;
// validate the transfer requested and populate dsts & extra
std::list<wallet_rpc::transfer_destination> destination;
destination.push_back(wallet_rpc::transfer_destination());
destination.back().amount = 0;
destination.back().address = req.address;
if (!validate_transfer(destination, req.payment_id, dsts, extra, true, er))
std::list<wallet_rpc::transfer_destination> destinations;
destinations.push_back(wallet_rpc::transfer_destination());
destinations.back().amount = 0;
destinations.back().address = req.address;
destinations.back().asset_type = asset_type;
// validate the transfer requested and populate dsts & extra
if (!validate_transfer(destinations, asset_type, asset_type, cryptonote::transaction_type::TRANSFER, req.payment_id, dsts, extra, true, er))
{
return false;
}

View File

@@ -268,7 +268,7 @@ namespace tools
bool get_tx_key, Ts& tx_key, Tu &amount, Ta &amounts_by_dest, Tu &fee, Tu &weight, std::string &multisig_txset, std::string &unsigned_txset, bool do_not_relay,
Ts &tx_hash, bool get_tx_hex, Ts &tx_blob, bool get_tx_metadata, Ts &tx_metadata, Tk &spent_key_images, epee::json_rpc::error &er);
bool validate_transfer(const std::list<wallet_rpc::transfer_destination>& destinations, const std::string& payment_id, std::vector<cryptonote::tx_destination_entry>& dsts, std::vector<uint8_t>& extra, bool at_least_one_destination, epee::json_rpc::error& er);
bool validate_transfer(const std::list<wallet_rpc::transfer_destination>& destinations, const std::string& source_asset, const std::string& dest_asset, const cryptonote::transaction_type& type, const std::string& payment_id, std::vector<cryptonote::tx_destination_entry>& dsts, std::vector<uint8_t>& extra, bool at_least_one_destination, epee::json_rpc::error& er);
void check_background_mining();

View File

@@ -465,9 +465,11 @@ namespace wallet_rpc
{
uint64_t amount;
std::string address;
std::string asset_type;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(amount)
KV_SERIALIZE(address)
KV_SERIALIZE(asset_type)
END_KV_SERIALIZE_MAP()
};
@@ -921,6 +923,7 @@ namespace wallet_rpc
bool do_not_relay;
bool get_tx_hex;
bool get_tx_metadata;
std::string asset_type;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(address)
@@ -934,6 +937,7 @@ namespace wallet_rpc
KV_SERIALIZE_OPT(do_not_relay, false)
KV_SERIALIZE_OPT(get_tx_hex, false)
KV_SERIALIZE_OPT(get_tx_metadata, false)
KV_SERIALIZE(asset_type)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;