Compare commits

...

25 Commits

Author SHA1 Message Date
Some Random Crypto Guy ea919eb6ea various translations updated; bumped version number 2024-08-31 21:46:57 +01:00
Some Random Crypto Guy 42aee311cd Merge branch 'develop' 2024-08-30 21:22:41 +01:00
Some Random Crypto Guy d51ca28d7b fixed crash on calling yield_info from new wallet 2024-08-30 21:21:58 +01:00
Some Random Crypto Guy 77683cafa1 Merge branch 'develop' 2024-08-29 12:44:29 +01:00
Some Random Crypto Guy e193d141bf new translations; tweaked API to allow GUI to obtain staking TX data; bumped version 2024-08-29 12:28:20 +01:00
Some Random Crypto Guy c248b78831 switched simple_wallet over to new routines for yield calculations; updated yield_info display to include yield earned on active STAKE TXs 2024-08-19 13:28:30 +01:00
Some Random Crypto Guy 6b75cb1fb5 fixed erroneous display of staked coins in all wallet balances 2024-08-19 11:07:45 +01:00
Some Random Crypto Guy a926092d9a Merge branch 'main' into develop 2024-08-19 11:06:52 +01:00
Some Random Crypto Guy 6d8e925fdb disabled Trezor until protobuf fixes are available; disabled moneropulse issues; bumped version number 2024-08-16 20:47:03 +01:00
Some Random Crypto Guy 0ee3c669d6 disabled staking from secondary accounts; basic search+replace for Monero in translations 2024-08-16 15:05:26 +01:00
Some Random Crypto Guy addd26cd47 Fixes include:
- setting DEFAULT_STACK_TRACE=OFF for all release builds (prevents boost weak_ptr crash on some Linux systems)
- setting RPC-SSL to disabled by default (fixes "no connection to daemon" error)
- updated BlockchainLMDB::get_circulating_supply() to report staked coins as something other than BURNT
- bumped to v0.4.5
2024-08-16 14:01:11 +01:00
Some Random Crypto Guy beffdd7ed9 fixed refresh height for testnet/stagenet; updated some DE translations; bumped version 2024-08-13 12:51:29 +01:00
Some Random Crypto Guy 9e96fcfe3a Merge branch 'main' into develop 2024-08-12 11:34:08 +01:00
Some Random Crypto Guy 91d52ba063 updated fast sync checkpoints; bumped version for BETA1 2024-08-12 11:27:30 +01:00
Some Random Crypto Guy 71d50f1b3f simplified blockchain height estimation, which should fix wallet restore height issue 2024-08-12 09:50:14 +01:00
Some Random Crypto Guy 1b0a1b6047 updated seed node IP addresses + port numbers 2024-08-12 09:49:32 +01:00
Some Random Crypto Guy 5a10a54563 changed seed URLs 2024-08-09 21:37:53 +01:00
Some Random Crypto Guy 2dfbcce6a4 possible fixes for 'make depends' build for Win64 2024-08-09 20:51:13 +01:00
Some Random Crypto Guy 9f34b46961 fixed wallet API to expose TX type to GUI wallet; updated Dockerfile 2024-08-09 16:03:18 +01:00
Some Random Crypto Guy 8a82655fa4 added GUI yield support 2024-07-31 12:39:06 +01:00
Some Random Crypto Guy 301f2973d7 various fixes to support GUI wallet; bumped version number 2024-07-31 10:52:58 +01:00
Some Random Crypto Guy 5f48afaf31 added support for GUI wallet staking 2024-07-26 10:51:20 +01:00
Some Random Crypto Guy b4379b005a revised error message when querying balance of empty wallet via RPC - thanks @GeraldoNonKYC 2024-07-10 12:56:49 +01:00
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
94 changed files with 65758 additions and 275397 deletions
+2 -2
View File
@@ -538,7 +538,7 @@ elseif (DEPENDS AND NOT LINUX)
set(DEFAULT_STACK_TRACE OFF)
set(LIBUNWIND_LIBRARIES "")
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW)
set(DEFAULT_STACK_TRACE ON)
set(DEFAULT_STACK_TRACE OFF)
set(STACK_TRACE_LIB "easylogging++") # for diag output only
set(LIBUNWIND_LIBRARIES "")
elseif (ARM)
@@ -547,7 +547,7 @@ elseif (ARM)
else()
find_package(Libunwind)
if(LIBUNWIND_FOUND)
set(DEFAULT_STACK_TRACE ON)
set(DEFAULT_STACK_TRACE OFF)
set(STACK_TRACE_LIB "libunwind") # for diag output only
else()
set(DEFAULT_STACK_TRACE OFF)
+13 -13
View File
@@ -41,26 +41,26 @@ RUN set -ex && \
rm -rf /var/lib/apt
COPY --from=builder /src/build/x86_64-linux-gnu/release/bin /usr/local/bin/
# Create monero user
RUN adduser --system --group --disabled-password monero && \
mkdir -p /wallet /home/monero/.bitmonero && \
chown -R monero:monero /home/monero/.bitmonero && \
chown -R monero:monero /wallet
# Create salvium user
RUN adduser --system --group --disabled-password salvium && \
mkdir -p /wallet /home/salvium/.salvium && \
chown -R salvium:salvium /home/salvium/.salvium && \
chown -R salvium:salvium /wallet
# Contains the blockchain
VOLUME /home/monero/.bitmonero
VOLUME /home/salvium/.salvium
# Generate your wallet via accessing the container and run:
# cd /wallet
# monero-wallet-cli
# salvium-wallet-cli
VOLUME /wallet
EXPOSE 18080
EXPOSE 18081
EXPOSE 19080
EXPOSE 19081
# switch to user monero
USER monero
# switch to user salvium
USER salvium
ENTRYPOINT ["monerod"]
CMD ["--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=18080", "--rpc-bind-ip=0.0.0.0", "--rpc-bind-port=18081", "--non-interactive", "--confirm-external-bind"]
ENTRYPOINT ["salviumd"]
CMD ["--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=19080", "--rpc-bind-ip=0.0.0.0", "--rpc-bind-port=19081", "--non-interactive", "--confirm-external-bind"]
+4 -4
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:
+3 -3
View File
@@ -6,10 +6,10 @@ function(_trezor_default_val val_name val_default)
endfunction()
# Define default options via env vars
_trezor_default_val(USE_DEVICE_TREZOR ON)
_trezor_default_val(USE_DEVICE_TREZOR OFF)
_trezor_default_val(USE_DEVICE_TREZOR_MANDATORY OFF)
_trezor_default_val(USE_DEVICE_TREZOR_PROTOBUF_TEST ON)
_trezor_default_val(USE_DEVICE_TREZOR_LIBUSB ON)
_trezor_default_val(USE_DEVICE_TREZOR_PROTOBUF_TEST OFF)
_trezor_default_val(USE_DEVICE_TREZOR_LIBUSB OFF)
_trezor_default_val(USE_DEVICE_TREZOR_UDP_RELEASE OFF)
_trezor_default_val(USE_DEVICE_TREZOR_DEBUG OFF)
_trezor_default_val(TREZOR_DEBUG OFF)
+1 -1
View File
@@ -1,4 +1,4 @@
mingw32_CFLAGS=-pipe
mingw32_CFLAGS=-pipe -pthread
mingw32_CXXFLAGS=$(mingw32_CFLAGS)
mingw32_ARFLAGS=cr
+1 -1
View File
@@ -5,7 +5,7 @@ $(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=6653ef5910f17954861fe72332e68b03ca6e4d9c7160eb3a8de5a5a913bfab43
define $(package)_set_vars
$(package)_config_opts=--without-documentation --disable-shared --without-libsodium --disable-curve
$(package)_config_opts=--without-documentation --disable-shared --without-libsodium --disable-curve --with-cv-impl=pthread
$(package)_config_opts_linux=--with-pic
$(package)_config_opts_freebsd=--with-pic
$(package)_cxxflags=-std=c++11
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
# Get the git information
TAG=`git tag -l --points-at HEAD`
COMMIT=`git rev-parse --short=9 HEAD`
# Build the 64-bit Apple Silicon release
USE_DEVICE_TREZOR=OFF make depends target=aarch64-apple-darwin -j12
pushd ./build/aarch64-apple-darwin/release/bin > /dev/null
zip -ur ~/releases/salvium-${TAG}-macos-arm64.zip salviumd salvium-wallet-cli salvium-wallet-rpc
popd > /dev/null
# Build the 64-bit MacOS Intel Silicon release
USE_DEVICE_TREZOR=OFF make depends target=x86_64-apple-darwin -j12
pushd ./build/x86_64-apple-darwin/release/bin > /dev/null
zip -ur ~/releases/salvium-${TAG}-macos-x86_64.zip salviumd salvium-wallet-cli salvium-wallet-rpc
popd > /dev/null
# Build the 64-bit Linux release
USE_DEVICE_TREZOR=OFF make depends target=x86_64-linux-gnu -j12
pushd ./build/x86_64-linux-gnu/release/bin > /dev/null
zip -ur ~/releases/salvium-${TAG}-linux-x86_64.zip salviumd salvium-wallet-cli salvium-wallet-rpc
popd > /dev/null
# Build the 64-bit Windows release
USE_DEVICE_TREZOR=OFF make depends target=x86_64-w64-mingw32 -j12
pushd ./build/x86_64-w64-mingw32/release/bin > /dev/null
zip -ur ~/releases/salvium-${TAG}-win64.zip salviumd.exe salvium-wallet-cli.exe salvium-wallet-rpc.exe
popd > /dev/null
# Finish
+2 -2
View File
@@ -1915,8 +1915,8 @@ public:
*/
virtual uint64_t get_database_size() const = 0;
virtual int get_yield_block_info(const uint64_t height, yield_block_info& ybi) = 0;
virtual int get_yield_tx_info(const uint64_t height, std::vector<yield_tx_info>& yti_container) = 0;
virtual int get_yield_block_info(const uint64_t height, yield_block_info& ybi) const = 0;
virtual int get_yield_tx_info(const uint64_t height, std::vector<yield_tx_info>& yti_container) const = 0;
/**
+17 -8
View File
@@ -800,7 +800,7 @@ estim:
return threshold_size;
}
int BlockchainLMDB::get_yield_block_info(const uint64_t height, yield_block_info& ybi)
int BlockchainLMDB::get_yield_block_info(const uint64_t height, yield_block_info& ybi) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
@@ -825,11 +825,13 @@ int BlockchainLMDB::get_yield_block_info(const uint64_t height, yield_block_info
yield_block_info *p = (yield_block_info*)v.mv_data;
ybi = *p;
TXN_POSTFIX_RDONLY();
// Return success to caller
return ret;
}
int BlockchainLMDB::get_yield_tx_info(const uint64_t height, std::vector<yield_tx_info>& yti_container)
int BlockchainLMDB::get_yield_tx_info(const uint64_t height, std::vector<yield_tx_info>& yti_container) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
@@ -858,6 +860,8 @@ int BlockchainLMDB::get_yield_tx_info(const uint64_t height, std::vector<yield_t
yti_container.emplace_back(*p);
}
TXN_POSTFIX_RDONLY();
// Return success to caller
return 0;
}
@@ -3469,9 +3473,12 @@ std::map<std::string,uint64_t> BlockchainLMDB::get_circulating_supply() const
uint64_t m_coinbase = get_block_already_generated_coins(m_height-1);
LOG_PRINT_L3("BlockchainLMDB::" << __func__ << " - mined supply for SAL = " << m_coinbase);
// SRCG: For V1, we can simply return this number, because there is no other source of coins
//circulating_supply["SAL"] = m_coinbase;
//return circulating_supply;
uint64_t staked_coins = 0;
yield_block_info ybi;
int result = get_yield_block_info(m_height-1, ybi);
if (result)
throw0(DB_ERROR(lmdb_error("Failed to get YBI when querying supply: ", result).c_str()));
staked_coins = ybi.locked_coins_tally;
check_open();
@@ -3480,8 +3487,6 @@ std::map<std::string,uint64_t> BlockchainLMDB::get_circulating_supply() const
MDB_val k;
MDB_val v;
int result = 0;
MDB_cursor_op op = MDB_FIRST;
while (1)
{
@@ -3513,7 +3518,11 @@ 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"];
// Adjust the supply to account for the staked coins
circulating_supply["STAKE"] = staked_coins;
circulating_supply["BURN"] = m_coinbase - circulating_supply["SAL"] - circulating_supply["STAKE"];
return circulating_supply;
}
+2 -2
View File
@@ -459,8 +459,8 @@ private:
//void migrate_0_1();
void cleanup_batch();
virtual int get_yield_block_info(const uint64_t height, yield_block_info& ybi);
virtual int get_yield_tx_info(const uint64_t height, std::vector<yield_tx_info>& yti_container);
virtual int get_yield_block_info(const uint64_t height, yield_block_info& ybi) const;
virtual int get_yield_tx_info(const uint64_t height, std::vector<yield_tx_info>& yti_container) const;
private:
MDB_env* m_env;
Binary file not shown.
+6 -6
View File
@@ -249,22 +249,22 @@ namespace cryptonote
std::vector<std::string> records;
// All four MoneroPulse domains have DNSSEC on and valid
static const std::vector<std::string> dns_urls = { "checkpoints.moneropulse.se"
static const std::vector<std::string> dns_urls = { /*"checkpoints.moneropulse.se"
, "checkpoints.moneropulse.org"
, "checkpoints.moneropulse.net"
, "checkpoints.moneropulse.co"
, "checkpoints.moneropulse.co"*/
};
static const std::vector<std::string> testnet_dns_urls = { "testpoints.moneropulse.se"
static const std::vector<std::string> testnet_dns_urls = { /*"testpoints.moneropulse.se"
, "testpoints.moneropulse.org"
, "testpoints.moneropulse.net"
, "testpoints.moneropulse.co"
, "testpoints.moneropulse.co"*/
};
static const std::vector<std::string> stagenet_dns_urls = { "stagenetpoints.moneropulse.se"
static const std::vector<std::string> stagenet_dns_urls = { /*"stagenetpoints.moneropulse.se"
, "stagenetpoints.moneropulse.org"
, "stagenetpoints.moneropulse.net"
, "stagenetpoints.moneropulse.co"
, "stagenetpoints.moneropulse.co"*/
};
if (!tools::dns_utils::load_txt_records_from_dns(records, nettype == TESTNET ? testnet_dns_urls : nettype == STAGENET ? stagenet_dns_urls : dns_urls))
+14 -7
View File
@@ -1478,7 +1478,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
}
//------------------------------------------------------------------
// SRCG
bool Blockchain::validate_protocol_transaction(const block& b, uint64_t height, std::vector<std::pair<transaction, blobdata>>& txs, const std::map<std::string, uint64_t>& circ_supply, uint8_t hf_version)
bool Blockchain::validate_protocol_transaction(const block& b, uint64_t height, std::vector<std::pair<transaction, blobdata>>& txs, uint8_t hf_version)
{
LOG_PRINT_L3("Blockchain::" << __func__);
CHECK_AND_ASSERT_MES(b.tx_hashes.size() == txs.size(), false, "Invalid number of TXs / hashes supplied");
@@ -1488,6 +1488,17 @@ bool Blockchain::validate_protocol_transaction(const block& b, uint64_t height,
CHECK_AND_ASSERT_MES(b.protocol_tx.vout.size() == 0, false, "void protocol transaction in the block has outputs");
return true;
}
if (!b.protocol_tx.vout.size()) {
// No money is minted, nothing to verify - bail out
return true;
}
// Get the circulating supply so we can verify
std::map<std::string, uint64_t> circ_supply;
if (hf_version >= HF_VERSION_ENABLE_CONVERT) {
circ_supply = get_db().get_circulating_supply();
}
// Build a map of outputs from the protocol_tx
std::map<crypto::public_key, std::tuple<std::string, uint64_t, uint64_t>> outputs;
@@ -4900,12 +4911,8 @@ leave:
}
TIME_MEASURE_FINISH(vmt);
TIME_MEASURE_START(gcs);
std::map<std::string, uint64_t> circ_supply = get_db().get_circulating_supply();
TIME_MEASURE_FINISH(gcs);
TIME_MEASURE_START(vpt);
if(!validate_protocol_transaction(bl, blockchain_height, txs, circ_supply, m_hardfork->get_current_version()))
if(!validate_protocol_transaction(bl, blockchain_height, txs, m_hardfork->get_current_version()))
{
MERROR_VER("Block with id: " << id << " has incorrect protocol transaction");
bvc.m_verifivation_failed = true;
@@ -6049,7 +6056,7 @@ void Blockchain::cancel()
}
#if defined(PER_BLOCK_CHECKPOINT)
static const char expected_block_hashes_hash[] = "df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119";
static const char expected_block_hashes_hash[] = "7f60b4980ea16b32e3f9fc1959d9d4116ba91f2b067bd70b3e21c44520096d14";
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
{
if (get_checkpoints == nullptr || !m_fast_sync)
+1 -1
View File
@@ -1521,7 +1521,7 @@ namespace cryptonote
*
* @return false if anything is found wrong with the protocol transaction, otherwise true
*/
bool validate_protocol_transaction(const block& b, uint64_t height, std::vector<std::pair<transaction, blobdata>>& txs, const std::map<std::string, uint64_t>& circ_supply, uint8_t hf_version);
bool validate_protocol_transaction(const block& b, uint64_t height, std::vector<std::pair<transaction, blobdata>>& txs, uint8_t hf_version);
/**
* @brief reverts the blockchain to its previous state following a failed switch
+1 -1
View File
@@ -1898,7 +1898,7 @@ namespace cryptonote
if (!tools::check_updates(software, buildtag, version, hash))
return false;
if (tools::vercmp(version.c_str(), MONERO_VERSION) <= 0)
if (tools::vercmp(version.c_str(), SALVIUM_VERSION) <= 0)
{
m_update_available = false;
return true;
@@ -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) << ") "
+3 -4
View File
@@ -299,10 +299,9 @@ namespace nodetool
private:
const std::vector<std::string> m_seed_nodes_list =
{ "seeds.moneroseeds.se"
, "seeds.moneroseeds.ae.org"
, "seeds.moneroseeds.ch"
, "seeds.moneroseeds.li"
{ "seed01.salvium.io"
, "seed02.salvium.io"
, "seed03.salvium.io"
};
bool islimitup=false;
+9 -17
View File
@@ -705,32 +705,24 @@ namespace nodetool
std::set<std::string> full_addrs;
if (m_nettype == cryptonote::TESTNET)
{
full_addrs.insert("176.9.0.187:28080");
full_addrs.insert("88.99.173.38:28080");
full_addrs.insert("51.79.173.165:28080");
full_addrs.insert("192.99.8.110:28080");
full_addrs.insert("37.187.74.171:28080");
full_addrs.insert("152.42.130.46:29080");
full_addrs.insert("45.55.138.87:29080");
full_addrs.insert("209.97.164.15:29080");
}
else if (m_nettype == cryptonote::STAGENET)
{
full_addrs.insert("176.9.0.187:38080");
full_addrs.insert("88.99.173.38:38080");
full_addrs.insert("51.79.173.165:38080");
full_addrs.insert("192.99.8.110:38080");
full_addrs.insert("37.187.74.171:38080");
full_addrs.insert("152.42.130.46:39080");
full_addrs.insert("45.55.138.87:39080");
full_addrs.insert("209.97.164.15:39080");
}
else if (m_nettype == cryptonote::FAKECHAIN)
{
}
else
{
full_addrs.insert("176.9.0.187:18080");
full_addrs.insert("88.198.163.90:18080");
full_addrs.insert("66.85.74.134:18080");
full_addrs.insert("88.99.173.38:18080");
full_addrs.insert("51.79.173.165:18080");
full_addrs.insert("192.99.8.110:18080");
full_addrs.insert("37.187.74.171:18080");
full_addrs.insert("152.42.130.46:19080");
full_addrs.insert("45.55.138.87:19080");
full_addrs.insert("209.97.164.15:19080");
}
return full_addrs;
}
+2 -2
View File
@@ -3183,7 +3183,7 @@ namespace cryptonote
return true;
}
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";
@@ -3204,7 +3204,7 @@ namespace cryptonote
res.status = "Error checking for updates";
return true;
}
if (tools::vercmp(version.c_str(), MONERO_VERSION) <= 0)
if (tools::vercmp(version.c_str(), SALVIUM_VERSION) <= 0)
{
res.update = false;
res.status = CORE_RPC_STATUS_OK;
+1 -1
View File
@@ -98,7 +98,7 @@ namespace cryptonote
, rpc_login({"rpc-login", rpc_args::tr("Specify username[:password] required for RPC server"), "", true})
, confirm_external_bind({"confirm-external-bind", rpc_args::tr("Confirm rpc-bind-ip value is NOT a loopback (local) IP")})
, rpc_access_control_origins({"rpc-access-control-origins", rpc_args::tr("Specify a comma separated list of origins to allow cross origin resource sharing"), ""})
, rpc_ssl({"rpc-ssl", rpc_args::tr("Enable SSL on RPC connections: enabled|disabled|autodetect"), "autodetect"})
, rpc_ssl({"rpc-ssl", rpc_args::tr("Enable SSL on RPC connections: enabled|disabled|autodetect"), "disabled"})
, rpc_ssl_private_key({"rpc-ssl-private-key", rpc_args::tr("Path to a PEM format private key"), ""})
, rpc_ssl_certificate({"rpc-ssl-certificate", rpc_args::tr("Path to a PEM format certificate"), ""})
, rpc_ssl_ca_certificates({"rpc-ssl-ca-certificates", rpc_args::tr("Path to file containing concatenated PEM format certificate(s) to replace system CA(s)."), ""})
+33 -77
View File
@@ -8394,86 +8394,42 @@ bool simple_wallet::supply_info(const std::vector<std::string> &args) {
//----------------------------------------------------------------------------------------------------
bool simple_wallet::yield_info(const std::vector<std::string> &args) {
// Get the total circulating supply of SALs
std::vector<std::pair<std::string, std::string>> supply_amounts;
if(!m_wallet->get_circulating_supply(supply_amounts)) {
fail_msg_writer() << "failed to get circulating supply. Make sure you are connected to a daemon.";
return false;
}
boost::multiprecision::uint128_t total_supply_128 = 0;
for (auto supply_asset: supply_amounts) {
if (supply_asset.first == "SAL") {
boost::multiprecision::uint128_t supply_128(supply_asset.second);
total_supply_128 = supply_128;
break;
}
}
// EXPERIMENTAL - change to get_yield_summary_info() method
uint64_t t_burnt, t_supply, t_locked, t_yield, yps, ybi_size;
std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> yield_payouts;
bool ok = m_wallet->get_yield_summary_info(t_burnt, t_supply, t_locked, t_yield, yps, ybi_size, yield_payouts);
// Get the yield data from the blockchain
std::vector<cryptonote::yield_block_info> ybi_data;
bool r = m_wallet->get_yield_info(ybi_data);
if (!r)
return false;
// Scan the entries we have received to gather the state (total yield over period captured)
uint64_t total_burnt = 0;
uint64_t total_yield = 0;
uint64_t yield_per_stake = 0;
for (size_t idx=1; idx<ybi_data.size(); ++idx) {
if (ybi_data[idx].locked_coins_tally == 0) {
total_burnt += ybi_data[idx].slippage_total_this_block;
} else {
total_yield += ybi_data[idx].slippage_total_this_block;
}
}
// Calculate the yield_per_staked_SAL value
if (ybi_data.back().locked_coins_tally > 0) {
boost::multiprecision::uint128_t yield_per_stake_128 = ybi_data.back().slippage_total_this_block;
yield_per_stake_128 *= COIN;
yield_per_stake_128 /= ybi_data.back().locked_coins_tally;
yield_per_stake = yield_per_stake_128.convert_to<uint64_t>();
}
// Get the chain height
const uint64_t blockchain_height = m_wallet->get_blockchain_current_height();
// Output the necessary information about yield stats
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)
% print_money(total_yield)
% print_money(yield_per_stake);
// 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) {
const tools::wallet2::transfer_details& td = transfers[idx];
//if (td.m_block_height < ybi_data[0].block_height) break;
if (td.m_tx.type == cryptonote::transaction_type::STAKE) {
if (payouts.count(idx)) {
message_writer(console_color_green, true) << boost::format(tr("Height %d, txid %s, staked %s SAL, earned %s SAL"))
% td.m_block_height
% td.m_txid
% print_money(td.m_tx.amount_burnt)
% print_money(transfers[payouts[idx]].m_amount - td.m_tx.amount_burnt);
} else {
message_writer(console_color_green, false) << boost::format(tr("Height %d, txid %s, staked %s SAL"))
% td.m_block_height
% td.m_txid
% print_money(td.m_tx.amount_burnt);
}
} else if (td.m_tx.type == cryptonote::transaction_type::PROTOCOL) {
// Store list of reverse-lookup indices to tell YIELD TXs how much they earned
if (transfers[td.m_td_origin_idx].m_tx.type == cryptonote::transaction_type::STAKE)
payouts[td.m_td_origin_idx] = idx;
}
}
for (auto &p: yield_payouts) {
uint64_t height, burnt, yield;
std::string txid;
std::tie(height, txid, burnt, yield) = p;
if (blockchain_height > ybi_size + height)
message_writer(console_color_green, true) << boost::format(tr("Height %d, txid %s, staked %s SAL, earned %s SAL"))
% height
% txid
% print_money(burnt)
% print_money(yield);
else
message_writer(console_color_green, false) << boost::format(tr("Height %d, txid %s, staked %s SAL, %s SAL accrued so far"))
% height
% txid
% print_money(burnt)
% print_money(yield);
}
// Output the necessary information about yield stats
message_writer(console_color_default, false) << boost::format(tr("\nYIELD 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_size-1) * DIFFICULTY_TARGET_V2)
% print_money(t_burnt)
% print_money(t_locked)
% get_human_readable_timespan((ybi_size-1) * DIFFICULTY_TARGET_V2)
% print_money(t_yield)
% print_money(yps);
return true;
}
//----------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -1,5 +1,5 @@
#define DEF_SALVIUM_VERSION_TAG "@VERSIONTAG@"
#define DEF_SALVIUM_VERSION "0.4.0"
#define DEF_SALVIUM_VERSION "0.5.2"
#define DEF_MONERO_VERSION_TAG "release"
#define DEF_MONERO_VERSION "0.18.3.3"
#define DEF_MONERO_RELEASE_NAME "Zero"
+2
View File
@@ -35,6 +35,7 @@ set(wallet_api_sources
wallet_manager.cpp
transaction_info.cpp
transaction_history.cpp
yield_info.cpp
pending_transaction.cpp
utils.cpp
address_book.cpp
@@ -50,6 +51,7 @@ set(wallet_api_private_headers
wallet_manager.h
transaction_info.h
transaction_history.h
yield_info.h
pending_transaction.h
common_defines.h
address_book.h
+4
View File
@@ -150,6 +150,7 @@ void TransactionHistoryImpl::refresh()
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = (wallet_height > pd.m_block_height) ? wallet_height - pd.m_block_height : 0;
ti->m_unlock_time = pd.m_unlock_time;
ti->m_type = static_cast<Monero::transaction_type>(static_cast<uint8_t>(pd.m_tx_type));
m_history.push_back(ti);
}
@@ -193,6 +194,7 @@ void TransactionHistoryImpl::refresh()
ti->m_label = pd.m_subaddr_indices.size() == 1 ? m_wallet->m_wallet->get_subaddress_label({pd.m_subaddr_account, *pd.m_subaddr_indices.begin()}) : "";
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = (wallet_height > pd.m_block_height) ? wallet_height - pd.m_block_height : 0;
ti->m_type = static_cast<Monero::transaction_type>(static_cast<uint8_t>(pd.m_tx.type));
// single output transaction might contain multiple transfers
for (const auto &d: pd.m_dests) {
@@ -229,6 +231,7 @@ void TransactionHistoryImpl::refresh()
ti->m_label = pd.m_subaddr_indices.size() == 1 ? m_wallet->m_wallet->get_subaddress_label({pd.m_subaddr_account, *pd.m_subaddr_indices.begin()}) : "";
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = 0;
ti->m_type = static_cast<Monero::transaction_type>(static_cast<uint8_t>(pd.m_tx.type));
for (const auto &d : pd.m_dests)
{
ti->m_transfers.push_back({d.amount, d.address(m_wallet->m_wallet->nettype(), pd.m_payment_id)});
@@ -258,6 +261,7 @@ void TransactionHistoryImpl::refresh()
ti->m_label = m_wallet->m_wallet->get_subaddress_label(pd.m_subaddr_index);
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = 0;
ti->m_type = static_cast<Monero::transaction_type>(static_cast<uint8_t>(pd.m_tx_type));
m_history.push_back(ti);
LOG_PRINT_L1(__FUNCTION__ << ": Unconfirmed payment found " << pd.m_amount);
+5
View File
@@ -149,4 +149,9 @@ uint64_t TransactionInfoImpl::unlockTime() const
return m_unlock_time;
}
Monero::transaction_type TransactionInfoImpl::type() const
{
return m_type;
}
} // namespace
+2
View File
@@ -62,6 +62,7 @@ public:
virtual const std::vector<Transfer> &transfers() const override;
virtual uint64_t confirmations() const override;
virtual uint64_t unlockTime() const override;
virtual Monero::transaction_type type() const override;
private:
int m_direction;
@@ -81,6 +82,7 @@ private:
std::vector<Transfer> m_transfers;
uint64_t m_confirmations;
uint64_t m_unlock_time;
Monero::transaction_type m_type;
friend class TransactionHistoryImpl;
+30 -5
View File
@@ -30,6 +30,7 @@
#include "wallet.h"
#include "yield_info.h"
#include "pending_transaction.h"
#include "unsigned_transaction.h"
#include "transaction_history.h"
@@ -1430,6 +1431,19 @@ PendingTransaction* WalletImpl::restoreMultisigTransaction(const string& signDat
return nullptr;
}
PendingTransaction *WalletImpl::createStakeTransaction(uint64_t amount, uint32_t mixin_count, PendingTransaction::Priority priority, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices)
{
// Need to populate {dst_entr, payment_id, asset_type, is_return}
const string dst_addr = m_wallet->get_subaddress_as_str({subaddr_account, 0});//MY LOCAL (SUB)ADDRESS
const string payment_id = "";
const string asset_type = "SAL";
const bool is_return = false;
LOG_ERROR("createStakeTransaction: called");
return createTransactionMultDest(Monero::transaction_type::STAKE, std::vector<string> {dst_addr}, payment_id, amount ? (std::vector<uint64_t> {amount}) : (optional<std::vector<uint64_t>>()), mixin_count, asset_type, is_return, priority, subaddr_account, subaddr_indices);
}
// TODO:
// 1 - properly handle payment id (add another menthod with explicit 'payment_id' param)
// 2 - check / design how "Transaction" can be single interface
@@ -1440,7 +1454,7 @@ PendingTransaction* WalletImpl::restoreMultisigTransaction(const string& signDat
// - unconfirmed_transfer_details;
// - confirmed_transfer_details)
PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<string> &dst_addr, const string &payment_id, optional<std::vector<uint64_t>> amount, uint32_t mixin_count, PendingTransaction::Priority priority, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices)
PendingTransaction *WalletImpl::createTransactionMultDest(const Monero::transaction_type &tx_type, const std::vector<string> &dst_addr, const string &payment_id, optional<std::vector<uint64_t>> amount, uint32_t mixin_count, const std::string &asset_type, const bool is_return, PendingTransaction::Priority priority, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices)
{
clearStatus();
@@ -1451,6 +1465,8 @@ PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<stri
uint32_t adjusted_priority = m_wallet->adjust_priority(static_cast<uint32_t>(priority));
const cryptonote::transaction_type converted_tx_type = static_cast<cryptonote::transaction_type>(static_cast<uint8_t>(tx_type));
PendingTransactionImpl * transaction = new PendingTransactionImpl(*this);
do {
@@ -1496,8 +1512,10 @@ PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<stri
de.original = dst_addr[i];
de.addr = info.address;
de.amount = (*amount)[i];
de.asset_type = asset_type;
de.is_subaddress = info.is_subaddress;
de.is_integrated = info.has_payment_id;
de.is_return = is_return;
dsts.push_back(de);
} else {
if (subaddr_indices.empty()) {
@@ -1518,11 +1536,11 @@ PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<stri
fake_outs_count = m_wallet->adjust_mixin(mixin_count);
if (amount) {
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, "SAL", "SAL", cryptonote::transaction_type::TRANSFER, fake_outs_count, 0 /* unlock_time */,
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, "SAL", "SAL", converted_tx_type, fake_outs_count, 0 /* unlock_time */,
adjusted_priority,
extra, subaddr_account, subaddr_indices);
} else {
transaction->m_pending_tx = m_wallet->create_transactions_all(0, cryptonote::transaction_type::TRANSFER, "SAL", info.address, info.is_subaddress, 1, fake_outs_count, 0 /* unlock_time */,
transaction->m_pending_tx = m_wallet->create_transactions_all(0, converted_tx_type, "SAL", info.address, info.is_subaddress, 1, fake_outs_count, 0 /* unlock_time */,
adjusted_priority,
extra, subaddr_account, subaddr_indices);
}
@@ -1605,10 +1623,10 @@ PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<stri
}
PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const string &payment_id, optional<uint64_t> amount, uint32_t mixin_count,
PendingTransaction::Priority priority, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices)
const std::string &asset_type, const bool is_return, PendingTransaction::Priority priority, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices)
{
return createTransactionMultDest(std::vector<string> {dst_addr}, payment_id, amount ? (std::vector<uint64_t> {*amount}) : (optional<std::vector<uint64_t>>()), mixin_count, priority, subaddr_account, subaddr_indices);
return createTransactionMultDest(Monero::transaction_type::TRANSFER, std::vector<string> {dst_addr}, payment_id, amount ? (std::vector<uint64_t> {*amount}) : (optional<std::vector<uint64_t>>()), mixin_count, asset_type, is_return, priority, subaddr_account, subaddr_indices);
}
PendingTransaction *WalletImpl::createSweepUnmixableTransaction()
@@ -2590,4 +2608,11 @@ uint64_t WalletImpl::getBytesSent()
return m_wallet->get_bytes_sent();
}
YieldInfo * WalletImpl::getYieldInfo()
{
auto yi = new YieldInfoImpl(*this);
bool ok = m_wallet->get_yield_summary_info(yi->m_burnt, yi->m_supply, yi->m_locked, yi->m_yield, yi->m_yield_per_stake, yi->m_num_entries, yi->m_payouts);
return yi;
}
} // namespace
+21 -9
View File
@@ -42,6 +42,7 @@
namespace Monero {
class TransactionHistoryImpl;
class YieldInfoImpl;
class PendingTransactionImpl;
class UnsignedTransactionImpl;
class AddressBookImpl;
@@ -152,16 +153,24 @@ public:
bool hasMultisigPartialKeyImages() const override;
PendingTransaction* restoreMultisigTransaction(const std::string& signData) override;
PendingTransaction * createTransactionMultDest(const std::vector<std::string> &dst_addr, const std::string &payment_id,
optional<std::vector<uint64_t>> amount, uint32_t mixin_count,
PendingTransaction::Priority priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) override;
PendingTransaction * createStakeTransaction(uint64_t amount,
uint32_t mixin_count,
PendingTransaction::Priority priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) override;
PendingTransaction * createTransactionMultDest(const transaction_type &tx_type,
const std::vector<std::string> &dst_addr, const std::string &payment_id,
optional<std::vector<uint64_t>> amount, uint32_t mixin_count,
const std::string &asset_type, const bool is_return,
PendingTransaction::Priority priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) override;
PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id,
optional<uint64_t> amount, uint32_t mixin_count,
PendingTransaction::Priority priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) override;
optional<uint64_t> amount, uint32_t mixin_count,
const std::string &asset_type, const bool is_return,
PendingTransaction::Priority priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) override;
virtual PendingTransaction * createSweepUnmixableTransaction() override;
bool submitTransaction(const std::string &fileName) override;
virtual UnsignedTransaction * loadUnsignedTx(const std::string &unsigned_filename) override;
@@ -225,6 +234,8 @@ public:
virtual uint64_t getBytesReceived() override;
virtual uint64_t getBytesSent() override;
YieldInfo * getYieldInfo() override;
private:
void clearStatus() const;
void setStatusError(const std::string& message) const;
@@ -239,6 +250,7 @@ private:
bool doInit(const std::string &daemon_address, const std::string &proxy_address, uint64_t upper_transaction_size_limit = 0, bool ssl = false);
private:
friend class YieldInfoImpl;
friend class PendingTransactionImpl;
friend class UnsignedTransactionImpl;
friend class TransactionHistoryImpl;
+68 -5
View File
@@ -49,6 +49,18 @@ enum NetworkType : uint8_t {
STAGENET
};
enum transaction_type : uint8_t {
UNSET = 0,
MINER = 1,
PROTOCOL = 2,
TRANSFER = 3,
CONVERT = 4,
BURN = 5,
STAKE = 6,
RETURN = 7,
MAX = 7
};
namespace Utils {
bool isAddressLocal(const std::string &hostaddr);
void onStartup();
@@ -67,6 +79,28 @@ enum NetworkType : uint8_t {
bool set;
};
struct YieldInfo
{
enum Status {
Status_Ok,
Status_Error
};
virtual ~YieldInfo() = 0;
virtual int status() const = 0;
virtual std::string errorString() const = 0;
virtual bool update() = 0;
virtual uint64_t burnt() const = 0;
virtual uint64_t locked() const = 0;
virtual uint64_t supply() const = 0;
virtual uint64_t ybi_data_size() const = 0;
virtual uint64_t yield() const = 0;
virtual uint64_t yield_per_stake() const = 0;
virtual std::string period() const = 0;
virtual std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> payouts() const = 0;
};
/**
* @brief Transaction-like interface for sending money
*/
@@ -199,6 +233,7 @@ struct TransactionInfo
virtual std::string paymentId() const = 0;
//! only applicable for output transactions
virtual const std::vector<Transfer> & transfers() const = 0;
virtual Monero::transaction_type type() const = 0;
};
/**
* @brief The TransactionHistory - interface for displaying transaction history
@@ -826,12 +861,32 @@ struct Wallet
*/
virtual PendingTransaction* restoreMultisigTransaction(const std::string& signData) = 0;
/*!
* \brief createStakeTransaction creates staking transaction.
* \param amount amount
* \param mixin_count mixin count. if 0 passed, wallet will use default value
* \param subaddr_account subaddress account from which the input funds are taken
* \param subaddr_indices set of subaddress indices to use for transfer or sweeping. if set empty, all are chosen when sweeping, and one or more are automatically chosen when transferring. after execution, returns the set of actually used indices
* \param priority
* \return PendingTransaction object. caller is responsible to check PendingTransaction::status()
* after object returned
*/
virtual PendingTransaction * createStakeTransaction(uint64_t amount,
uint32_t mixin_count,
PendingTransaction::Priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) = 0;
/*!
* \brief createTransactionMultDest creates transaction with multiple destinations. if dst_addr is an integrated address, payment_id is ignored
* \param tx_type the type of transaction being created
* \param dst_addr vector of destination address as string
* \param payment_id optional payment_id, can be empty string
* \param amount vector of amounts
* \param mixin_count mixin count. if 0 passed, wallet will use default value
* \param asset_type type of asset to create as output
* \param is_return whether this is a return_payment or not
* \param subaddr_account subaddress account from which the input funds are taken
* \param subaddr_indices set of subaddress indices to use for transfer or sweeping. if set empty, all are chosen when sweeping, and one or more are automatically chosen when transferring. after execution, returns the set of actually used indices
* \param priority
@@ -839,11 +894,13 @@ struct Wallet
* after object returned
*/
virtual PendingTransaction * createTransactionMultDest(const std::vector<std::string> &dst_addr, const std::string &payment_id,
optional<std::vector<uint64_t>> amount, uint32_t mixin_count,
PendingTransaction::Priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) = 0;
virtual PendingTransaction * createTransactionMultDest(const transaction_type &tx_type,
const std::vector<std::string> &dst_addr, const std::string &payment_id,
optional<std::vector<uint64_t>> amount, uint32_t mixin_count,
const std::string &asset_type, const bool is_return,
PendingTransaction::Priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) = 0;
/*!
* \brief createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored
@@ -851,6 +908,8 @@ struct Wallet
* \param payment_id optional payment_id, can be empty string
* \param amount amount
* \param mixin_count mixin count. if 0 passed, wallet will use default value
* \param asset_type type of asset to create as output
* \param is_return whether this is a return_payment or not
* \param subaddr_account subaddress account from which the input funds are taken
* \param subaddr_indices set of subaddress indices to use for transfer or sweeping. if set empty, all are chosen when sweeping, and one or more are automatically chosen when transferring. after execution, returns the set of actually used indices
* \param priority
@@ -860,6 +919,7 @@ struct Wallet
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id,
optional<uint64_t> amount, uint32_t mixin_count,
const std::string &asset_type, const bool is_return,
PendingTransaction::Priority = PendingTransaction::Priority_Low,
uint32_t subaddr_account = 0,
std::set<uint32_t> subaddr_indices = {}) = 0;
@@ -1092,6 +1152,9 @@ struct Wallet
//! get bytes sent
virtual uint64_t getBytesSent() = 0;
//! get yield information
virtual YieldInfo * getYieldInfo() = 0;
};
/**
+1 -1
View File
@@ -370,7 +370,7 @@ std::tuple<bool, std::string, std::string, std::string, std::string> WalletManag
if (!tools::check_updates(software, buildtag, version, hash))
return std::make_tuple(false, "", "", "", "");
if (tools::vercmp(version.c_str(), current_version != nullptr ? current_version : MONERO_VERSION) > 0)
if (tools::vercmp(version.c_str(), current_version != nullptr ? current_version : SALVIUM_VERSION) > 0)
{
std::string user_url = tools::get_update_url(software, subdir, buildtag, version, true);
std::string auto_url = tools::get_update_url(software, subdir, buildtag, version, false);
+131
View File
@@ -0,0 +1,131 @@
// Copyright (c) 2024, Salvium (author: SRCG)
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include "yield_info.h"
#include "wallet.h"
#include "common_defines.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "common/base58.h"
#include <memory>
#include <vector>
#include <sstream>
#include <boost/format.hpp>
#include <boost/filesystem.hpp>
using namespace std;
namespace Monero {
YieldInfo::~YieldInfo() {}
YieldInfoImpl::YieldInfoImpl(WalletImpl &wallet)
: m_wallet(wallet)
{
m_status = Status_Ok;
m_burnt = 0;
m_locked = 0;
m_supply = 0;
m_yield = 0;
m_yield_per_stake = 0;
m_num_entries = 0;
}
YieldInfoImpl::~YieldInfoImpl()
{
}
int YieldInfoImpl::status() const
{
return m_status;
}
string YieldInfoImpl::errorString() const
{
return m_errorString;
}
std::string YieldInfoImpl::period() const
{
// Calculate the number of entries as a human-readable time period
uint64_t ts = m_num_entries * 120;
std::string result;
stringstream ss;
ss << std::setfill('0') << std::setw(2) << (ts / 86400)
<< ":" << std::setw(2) << ((ts % 86400) / 3600)
<< ":" << std::setw(2) << ((ts % 3600) / 60)
<< ":" << std::setw(2) << (ts % 60) << " (DD:HH:MM:SS)";
return ss.str();
}
bool YieldInfoImpl::update()
{
return false;
}
uint64_t YieldInfoImpl::burnt() const
{
return m_burnt;
}
uint64_t YieldInfoImpl::locked() const
{
return m_locked;
}
uint64_t YieldInfoImpl::supply() const
{
return m_supply;
}
uint64_t YieldInfoImpl::ybi_data_size() const
{
return m_num_entries;
}
uint64_t YieldInfoImpl::yield() const
{
return m_yield;
}
uint64_t YieldInfoImpl::yield_per_stake() const
{
return m_yield_per_stake;
}
std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> YieldInfoImpl::payouts() const
{
return m_payouts;
}
}
+74
View File
@@ -0,0 +1,74 @@
// Copyright (c) 2024, Salvium (author: SRCG)
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include "wallet/api/wallet2_api.h"
#include "wallet/wallet2.h"
#include <string>
#include <vector>
namespace Monero {
class WalletImpl;
class YieldInfoImpl : public YieldInfo
{
public:
YieldInfoImpl(WalletImpl &wallet);
~YieldInfoImpl();
int status() const override;
std::string errorString() const override;
bool update() override;
uint64_t burnt() const override;
uint64_t locked() const override;
uint64_t supply() const override;
uint64_t ybi_data_size() const override;
uint64_t yield() const override;
uint64_t yield_per_stake() const override;
std::string period() const override;
std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> payouts() const override;
private:
friend class WalletImpl;
WalletImpl &m_wallet;
int m_status;
std::string m_errorString;
uint64_t m_burnt;
uint64_t m_locked;
uint64_t m_supply;
uint64_t m_yield;
uint64_t m_yield_per_stake;
uint64_t m_num_entries;
std::string m_period;
std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> m_payouts;
};
}
+145 -11
View File
@@ -2380,6 +2380,141 @@ bool wallet2::get_yield_info(std::vector<cryptonote::yield_block_info>& ybi_data
}
}
//----------------------------------------------------------------------------------------------------
bool wallet2::get_yield_summary_info(uint64_t &total_burnt,
uint64_t &total_supply,
uint64_t &total_locked,
uint64_t &total_yield,
uint64_t &yield_per_stake,
uint64_t &ybi_data_size,
std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> &payouts
)
{
// Get the total circulating supply of SALs
std::vector<std::pair<std::string, std::string>> supply_amounts;
if(!get_circulating_supply(supply_amounts)) {
return false;
}
boost::multiprecision::uint128_t total_supply_128 = 0;
for (auto supply_asset: supply_amounts) {
if (supply_asset.first == "SAL") {
boost::multiprecision::uint128_t supply_128(supply_asset.second);
total_supply_128 = supply_128;
break;
}
}
total_supply = total_supply_128.convert_to<uint64_t>();
// Get the yield data from the blockchain
std::vector<cryptonote::yield_block_info> ybi_data;
bool r = get_yield_info(ybi_data);
if (!r)
return false;
ybi_data_size = ybi_data.size();
// Iterate over the transfers in our wallet
std::map<size_t, size_t> map_payouts;
std::map<std::string, std::pair<size_t, std::pair<uint64_t, uint64_t>>> payouts_active;
if (m_transfers.size() > 0) {
for (size_t idx = m_transfers.size()-1; idx>0; --idx) {
const tools::wallet2::transfer_details& td = m_transfers[idx];
//if (td.m_block_height < ybi_data[0].block_height) break;
if (td.m_tx.type == cryptonote::transaction_type::STAKE) {
if (map_payouts.count(idx)) {
payouts.push_back(std::make_tuple(td.m_block_height, epee::string_tools::pod_to_hex(td.m_txid), td.m_tx.amount_burnt, m_transfers[map_payouts[idx]].m_amount - td.m_tx.amount_burnt));
} else {
//payouts.push_back(std::make_tuple(td.m_block_height, epee::string_tools::pod_to_hex(td.m_txid), td.m_tx.amount_burnt, 0));
payouts_active[epee::string_tools::pod_to_hex(td.m_txid)] = std::make_pair(td.m_block_height, std::make_pair(td.m_tx.amount_burnt, 0));
}
} else if (td.m_tx.type == cryptonote::transaction_type::PROTOCOL) {
// Store list of reverse-lookup indices to tell YIELD TXs how much they earned
if (m_transfers[td.m_td_origin_idx].m_tx.type == cryptonote::transaction_type::STAKE)
map_payouts[td.m_td_origin_idx] = idx;
}
}
}
// Scan the entries we have received to gather the state (total yield over period captured)
total_burnt = 0;
total_yield = 0;
yield_per_stake = 0;
for (size_t idx=1; idx<ybi_data.size(); ++idx) {
if (ybi_data[idx].locked_coins_tally == 0) {
total_burnt += ybi_data[idx].slippage_total_this_block;
} else {
total_yield += ybi_data[idx].slippage_total_this_block;
// EXPERIMENTAL - add up yield earned for active STAKE TXs
for (auto &payout: payouts_active) {
if (ybi_data[idx].block_height < payout.second.first) continue;
boost::multiprecision::uint128_t amount_128 = ybi_data[idx].slippage_total_this_block;
amount_128 *= payout.second.second.first;
amount_128 /= ybi_data[idx].locked_coins_tally;
payout.second.second.second += amount_128.convert_to<uint64_t>();
}
}
}
for (auto &payout: payouts_active) {
// Copy to the list of payouts proper
payouts.push_back(std::make_tuple(payout.second.first, payout.first, payout.second.second.first, payout.second.second.second));
}
// Get the total currently locked
total_locked = ybi_data.back().locked_coins_tally;
// Calculate the yield_per_staked_SAL value
if (ybi_data.back().locked_coins_tally > 0) {
boost::multiprecision::uint128_t yield_per_stake_128 = ybi_data.back().slippage_total_this_block;
yield_per_stake_128 *= COIN;
yield_per_stake_128 /= ybi_data.back().locked_coins_tally;
yield_per_stake = yield_per_stake_128.convert_to<uint64_t>();
}
/*
// Iterate over the transfers in our wallet
std::map<size_t, size_t> map_payouts;
for (size_t idx = m_transfers.size()-1; idx>0; --idx) {
const tools::wallet2::transfer_details& td = m_transfers[idx];
//if (td.m_block_height < ybi_data[0].block_height) break;
if (td.m_tx.type == cryptonote::transaction_type::STAKE) {
if (map_payouts.count(idx)) {
payouts.push_back(std::make_tuple(td.m_block_height, epee::string_tools::pod_to_hex(td.m_txid), td.m_tx.amount_burnt, m_transfers[map_payouts[idx]].m_amount - td.m_tx.amount_burnt));
} else {
payouts.push_back(std::make_tuple(td.m_block_height, epee::string_tools::pod_to_hex(td.m_txid), td.m_tx.amount_burnt, 0));
}
} else if (td.m_tx.type == cryptonote::transaction_type::PROTOCOL) {
// Store list of reverse-lookup indices to tell YIELD TXs how much they earned
if (m_transfers[td.m_td_origin_idx].m_tx.type == cryptonote::transaction_type::STAKE)
map_payouts[td.m_td_origin_idx] = idx;
}
}
*/
// Return success to caller
return true;
}
//----------------------------------------------------------------------------------------------------
bool wallet2::get_yield_payouts(std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> &payouts) {
// Iterate over the transfers in our wallet
std::map<size_t, size_t> map_payouts;
for (size_t idx = m_transfers.size()-1; idx>0; --idx) {
const tools::wallet2::transfer_details& td = m_transfers[idx];
//if (td.m_block_height < ybi_data[0].block_height) break;
if (td.m_tx.type == cryptonote::transaction_type::STAKE) {
if (map_payouts.count(idx)) {
payouts.push_back(std::make_tuple(td.m_block_height, epee::string_tools::pod_to_hex(td.m_txid), td.m_tx.amount_burnt, m_transfers[map_payouts[idx]].m_amount - td.m_tx.amount_burnt));
} else {
payouts.push_back(std::make_tuple(td.m_block_height, epee::string_tools::pod_to_hex(td.m_txid), td.m_tx.amount_burnt, 0));
}
} else if (td.m_tx.type == cryptonote::transaction_type::PROTOCOL) {
// Store list of reverse-lookup indices to tell YIELD TXs how much they earned
if (m_transfers[td.m_td_origin_idx].m_tx.type == cryptonote::transaction_type::STAKE)
map_payouts[td.m_td_origin_idx] = idx;
}
}
return true;
}
//----------------------------------------------------------------------------------------------------
void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote::transaction& tx, const std::vector<uint64_t> &o_indices, const std::vector<uint64_t> &asset_type_output_indices, uint64_t height, uint8_t block_version, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache, bool ignore_callbacks)
{
PERF_TIMER(process_new_transaction);
@@ -2720,7 +2855,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 +3136,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)
//{
@@ -6822,7 +6957,7 @@ uint64_t wallet2::balance(uint32_t index_major, const std::string& asset_type, b
uint64_t amount = 0;
for (const auto& i : balance_per_subaddress(index_major, asset_type, strict))
amount += i.second;
if (asset_type == "SAL") {
if (index_major == 0 && asset_type == "SAL") {
// Iterate over the locked coins, adding them to the _locked_ balance
for (const auto& i : m_locked_coins)
amount += i.second.m_amount;
@@ -10493,6 +10628,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
break;
case transaction_type::STAKE:
THROW_WALLET_EXCEPTION_IF(dest_asset != "SAL", error::wallet_internal_error, "Yield TX must specify 'SAL' destination asset type");
THROW_WALLET_EXCEPTION_IF(subaddr_account != 0, error::wallet_internal_error, "Staking is only permitted from main account, not secondary accounts");
break;
default:
THROW_WALLET_EXCEPTION(error::wallet_internal_error, "Invalid tx type specified: " + static_cast<uint64_t>(tx_type));
@@ -13007,18 +13143,16 @@ uint64_t wallet2::get_daemon_blockchain_target_height(string &err)
uint64_t wallet2::get_approximate_blockchain_height() const
{
// time of v2 fork
const time_t fork_time = m_nettype == TESTNET ? 1448285909 : m_nettype == STAGENET ? 1520937818 : 1458748658;
// v2 fork block
const uint64_t fork_block = m_nettype == TESTNET ? 624634 : m_nettype == STAGENET ? 32000 : 1009827;
if (m_nettype != MAINNET) return 0;
// time of v1 fork
const time_t fork_time = 1719997643;
// v1 fork block
const uint64_t fork_block = 0;
// avg seconds per block
const int seconds_per_block = DIFFICULTY_TARGET_V2;
// Calculated blockchain height
uint64_t approx_blockchain_height = fork_block + (time(NULL) - fork_time)/seconds_per_block;
// testnet and stagenet got some huge rollbacks, so the estimation is way off
static const uint64_t approximate_rolled_back_blocks = m_nettype == TESTNET ? 342100 : 30000;
if ((m_nettype == TESTNET || m_nettype == STAGENET) && approx_blockchain_height > approximate_rolled_back_blocks)
approx_blockchain_height -= approximate_rolled_back_blocks;
LOG_PRINT_L2("Calculated blockchain height: " << approx_blockchain_height);
return approx_blockchain_height;
}
+9
View File
@@ -1747,6 +1747,15 @@ private:
bool get_pricing_record(oracle::pricing_record& pr, const uint64_t height);
bool get_circulating_supply(std::vector<std::pair<std::string, std::string>> &amounts);
bool get_yield_info(std::vector<cryptonote::yield_block_info>& ybi_data);
bool get_yield_summary_info(uint64_t &total_burnt,
uint64_t &total_supply,
uint64_t &total_locked,
uint64_t &total_yield,
uint64_t &yield_per_stake,
uint64_t &ybi_data_size,
std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> &payouts
);
bool get_yield_payouts(std::vector<std::tuple<size_t, std::string, uint64_t, uint64_t>> &payouts);
private:
/*!
+34 -18
View File
@@ -462,7 +462,7 @@ namespace tools
std::string asset_type = req.asset_type.empty() ? "SAL" : boost::algorithm::to_upper_copy(req.asset_type);
// verify that the asset is in the list of in-wallet assets
if (std::find(assets_in_wallet.begin(), assets_in_wallet.end(), asset_type) == assets_in_wallet.end()) {
er.message = std::string("Invalid source asset specified: ") + asset_type;
er.message = std::string("Source asset '") + asset_type + "' not found in wallet";
return false;
}
std::vector<std::string> assets = req.all_assets ? assets_in_wallet : std::vector<std::string>{asset_type};
@@ -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;
}
+1 -1
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();
@@ -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;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+6
View File
@@ -1,4 +1,10 @@
de
es
fr
it
ja
nl
pt-pt
ru
sv
zh-cn
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/perl -w -CS
use 5.010;
use strict;
use utf8;
use warnings;
use HTML::Entities;
use XML::LibXML;
use open qw( :std :encoding(UTF-8) );
#Name of the CSV File
my $csvfile = $ARGV[0];
my $lang;
if ($csvfile =~ /salvium_([a-z]{2}).csv/) {
# got a match
$lang = $1;
} else {
die "input language code '$lang' is invalid";
}
# Open the correct input file
open(CSV, $csvfile) or die "Failed to open $csvfile: $!\n";
# Open the correct output file
my $xmlfile = "salvium_$lang.ts";
open(TS, '>', $xmlfile) or die "Failed to open $xmlfile: $!\n";
# Print the preamble
print TS "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE TS>\n<TS version=\"2.1\" language=\"$lang\">\n";
# Print the records
my $context_name = "";
my $first_context = 1;
while (my $csv_line = <CSV>) {
# Split the current line based on "===" delimiter
my @fields = split("===", $csv_line);
if ($fields[0] ne $context_name) {
$context_name = $fields[0];
if ($first_context) {
$first_context = 0;
} else {
print TS "</context>\n";
}
print TS "<context>\n <name>$context_name</name>\n";
}
print TS " <message>\n";
# Split the location entries
my @locations = split(/\^/, $fields[3]);
foreach (@locations) {
if ($_ ne "") {
# Split into filename + line
my($filename, $line) = split(":", $_, 2);
$line =~ s/\\n/\n/g;
$line =~ s/\r\n/\n/g;
$line =~ s/\r//g;
chomp($line);
print TS " <location filename=\"$filename\" line=\"$line\"/>\n";
}
}
# Output source + translation
my $source = $fields[1];
$source =~ s/\\n/\n/g;
$source =~ s/\r\n/\n/g;
$source =~ s/\r//g;
my $translation = $fields[2];
$translation =~ s/\\n/\n/g;
$translation =~ s/\r\n/\n/g;
$translation =~ s/\r//g;
print TS " <source>" . $source . "</source>\n";
if (length($translation)) {
print TS " <translation>" . $translation . "</translation>\n";
} else {
print TS " <translation type=\"unfinished\">" . $translation . "</translation>\n";
}
print TS " </message>\n";
}
# Print the postamble
print TS "</context>\n";
print TS "</TS>\n";
# Close the files
close($xmlfile);
close($csvfile);
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/perl -w -CS
use 5.010;
use strict;
use utf8;
use warnings;
use HTML::Entities;
use XML::LibXML;
use open qw( :std :encoding(UTF-8) );
#Name of the XML File
my $xmlfile = "salvium.ts";
my $lang = $ARGV[0];
if (length($lang) != 2) {
die "input language code '$lang' is invalid";
}
my $csvfile = "salvium_$lang.csv";
open(CSV, '>', $csvfile);
#Collect the XML and set nodes
my $dom = XML::LibXML->load_xml(location=>$xmlfile);
foreach my $context ($dom->findnodes('/TS/context')) {
foreach my $message ($context->findnodes('./message')) {
my $source = $message->findvalue('./source');
$source =~ s/\n/\\n/g;
print CSV $context->findvalue('./name') . "===";
print CSV encode_entities($source,'<>&"') . "======";
my @locations = ();
foreach my $location ($message->findnodes('./location')) {
my $temp = $location->getAttribute('filename') . ":" . $location->getAttribute('line');
push(@locations, $temp);
}
print CSV join("^", @locations) . "\n";
}
}
close($csvfile);
+8
View File
@@ -0,0 +1,8 @@
# Configuration for salviumd
# Syntax: any command line option may be specified as 'clioptionname=value'.
# Boolean options such as 'no-igd' are specified as 'no-igd=1'.
# See 'salviumd --help' for all available options.
data-dir=/var/lib/salvium
log-file=/var/log/salvium/salvium.log
log-level=0
+20
View File
@@ -0,0 +1,20 @@
[Unit]
Description=Salvium Full Node
After=network.target
[Service]
User=salvium
Group=salvium
WorkingDirectory=~
StateDirectory=salvium
LogsDirectory=salvium
Type=simple
ExecStart=/usr/bin/salviumd --config-file /etc/salviumd.conf --non-interactive
StandardOutput=null
StandardError=null
Restart=always
[Install]
WantedBy=multi-user.target
+1 -1
View File
@@ -21,7 +21,7 @@ then
languages=""
for language in $(cat translations/ready)
do
languages="$languages translations/monero_$language.ts"
languages="$languages translations/salvium_$language.ts"
done
else
languages="translations/*.ts"