Compare commits
53 Commits
v0.2.8
...
v0.5.3-rc2
| Author | SHA1 | Date | |
|---|---|---|---|
| 218911d9fc | |||
| da3ef2511d | |||
| 8b2b039036 | |||
| d1eed6e9ff | |||
| 30a2931067 | |||
| 1c73dd0c9f | |||
| 1c84c00fe6 | |||
| ea919eb6ea | |||
| 42aee311cd | |||
| d51ca28d7b | |||
| 77683cafa1 | |||
| e193d141bf | |||
| c248b78831 | |||
| 6b75cb1fb5 | |||
| a926092d9a | |||
| 6d8e925fdb | |||
| 0ee3c669d6 | |||
| addd26cd47 | |||
| beffdd7ed9 | |||
| 9e96fcfe3a | |||
| 91d52ba063 | |||
| 71d50f1b3f | |||
| 1b0a1b6047 | |||
| 5a10a54563 | |||
| 2dfbcce6a4 | |||
| 9f34b46961 | |||
| 8a82655fa4 | |||
| 301f2973d7 | |||
| 5f48afaf31 | |||
| b4379b005a | |||
| 9c83633120 | |||
| c424c5d544 | |||
| 8d5018ea0a | |||
| c6a6ae724a | |||
| a743288940 | |||
| d91729268f | |||
| 1c3d026972 | |||
| 847db19867 | |||
| 0663a5ead7 | |||
| 7ad904a9ae | |||
| 12cf6be402 | |||
| 292845d721 | |||
| 9bc0ccc14d | |||
| c20ab30963 | |||
| 3e012bc1fb | |||
| f07d3942e1 | |||
| b93cf3a2d0 | |||
| 9ce266cea2 | |||
| 193a22d55c | |||
| 2f08b2fe2e | |||
| 6404d34e33 | |||
| f41c20ee7c | |||
| 7bb90f57d4 |
+2
-2
@@ -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
@@ -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"]
|
||||
|
||||
|
||||
@@ -1 +1,647 @@
|
||||
# Welcome to Salvium
|
||||
# Salvium Zero v0.4.1
|
||||
|
||||
Copyright (c) 2023-2024, Salvium
|
||||
Portions Copyright (c) 2014-2023, The Monero Project
|
||||
Portions Copyright (c) 2012-2013 The Cryptonote developers.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Development resources](#development-resources)
|
||||
- [Introduction](#introduction)
|
||||
- [About this project](#about-this-project)
|
||||
- [Supporting the project](#supporting-the-project)
|
||||
- [License](#license)
|
||||
- [Contributing](#contributing)
|
||||
- [Compiling Salvium from source](#compiling-salvium-from-source)
|
||||
- [Dependencies](#dependencies)
|
||||
- [Gitian builds](#gitian-builds)
|
||||
- [Internationalization](#Internationalization)
|
||||
- [Debugging](#Debugging)
|
||||
- [Known issues](#known-issues)
|
||||
|
||||
## Development resources
|
||||
|
||||
- Web: [salvium.io](https://salvium.io)
|
||||
- Mail: [dev@salvium.io](mailto:dev@salvium.io)
|
||||
- GitHub: [https://github.com/salvium/salvium](https://github.com/salvium/salvium)
|
||||
|
||||
## Introduction
|
||||
|
||||
Salvium is a private, secure, untraceable, decentralised digital currency. You are your bank, you control your funds, and nobody can trace your transfers unless you allow them to do so.
|
||||
|
||||
**Privacy:** Salvium uses a cryptographically sound system to allow you to send and receive funds without your transactions being easily revealed on the blockchain (the ledger of transactions that everyone has). This ensures that your purchases, receipts, and all transfers remain private by default.
|
||||
|
||||
**Security:** Using the power of a distributed peer-to-peer consensus network, every transaction on the network is cryptographically secured. Individual wallets have a 25-word mnemonic seed that is only displayed once and can be written down to backup the wallet. Wallet files should be encrypted with a strong passphrase to ensure they are useless if ever stolen.
|
||||
|
||||
**Untraceability:** By taking advantage of ring signatures, a special property of a certain type of cryptography, Salvium is able to ensure that transactions are not only untraceable but have an optional measure of ambiguity that ensures that transactions cannot easily be tied back to an individual user or computer.
|
||||
|
||||
**Decentralization:** The utility of Salvium depends on its decentralised peer-to-peer consensus network - anyone should be able to run the salvium software, validate the integrity of the blockchain, and participate in all aspects of the salvium network using consumer-grade commodity hardware. Decentralization of the salvium network is maintained by software development that minimizes the costs of running the salvium software and inhibits the proliferation of specialized, non-commodity hardware.
|
||||
|
||||
## About this project
|
||||
|
||||
This is the core implementation of Salvium. It is open source and completely free to use without restrictions, except for those specified in the license agreement below. There are no restrictions on anyone creating an alternative implementation of Salvium that uses the protocol and network in a compatible manner.
|
||||
|
||||
As with many development projects, the repository on GitHub is considered to be the "staging" area for the latest changes. Before changes are merged into that branch on the main repository, they are tested by individual developers in their own branches, submitted as a pull request, and then subsequently tested by contributors who focus on testing and code reviews. That having been said, the repository should be carefully considered before using it in a production environment, unless there is a patch in the repository for a particular show-stopping issue you are experiencing. It is generally a better idea to use a tagged release for stability.
|
||||
|
||||
**Anyone is welcome to contribute to Salvium's codebase!** If you have a fix or code change, feel free to submit it as a pull request directly to the "master" branch. In cases where the change is relatively small or does not affect other parts of the codebase, it may be merged in immediately by any one of the collaborators. On the other hand, if the change is particularly large or complex, it is expected that it will be discussed at length either well in advance of the pull request being submitted, or even directly on the pull request.
|
||||
|
||||
## Supporting the project
|
||||
|
||||
Salvium is a 100% community-sponsored endeavor. If you want to join our efforts, the easiest thing you can do is support the project financially. Go to [https://salvium.io/donate/](https://salvium.io/donate/) for more information.
|
||||
|
||||
## License
|
||||
|
||||
See [LICENSE](LICENSE).
|
||||
|
||||
## Contributing
|
||||
|
||||
If you want to help out, see [CONTRIBUTING](docs/CONTRIBUTING.md) for a set of guidelines.
|
||||
|
||||
## Compiling Salvium from source
|
||||
|
||||
### Dependencies
|
||||
|
||||
The following table summarizes the tools and libraries required to build. A
|
||||
few of the libraries are also included in this repository (marked as
|
||||
"Vendored"). By default, the build uses the library installed on the system
|
||||
and ignores the vendored sources. However, if no library is found installed on
|
||||
the system, then the vendored source will be built and used. The vendored
|
||||
sources are also used for statically-linked builds because distribution
|
||||
packages often include only shared library binaries (`.so`) but not static
|
||||
library archives (`.a`).
|
||||
|
||||
| Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Void pkg | Fedora pkg | Optional | Purpose |
|
||||
| ------------ | ------------- | -------- | -------------------- | ------------ | ------------------ | ------------------- | -------- | --------------- |
|
||||
| GCC | 7 | NO | `build-essential` | `base-devel` | `base-devel` | `gcc` | NO | |
|
||||
| CMake | 3.5 | NO | `cmake` | `cmake` | `cmake` | `cmake` | NO | |
|
||||
| pkg-config | any | NO | `pkg-config` | `base-devel` | `base-devel` | `pkgconf` | NO | |
|
||||
| Boost | 1.58 | NO | `libboost-all-dev` | `boost` | `boost-devel` | `boost-devel` | NO | C++ libraries |
|
||||
| OpenSSL | basically any | NO | `libssl-dev` | `openssl` | `openssl-devel` | `openssl-devel` | NO | sha256 sum |
|
||||
| libzmq | 4.2.0 | NO | `libzmq3-dev` | `zeromq` | `zeromq-devel` | `zeromq-devel` | NO | ZeroMQ library |
|
||||
| OpenPGM | ? | NO | `libpgm-dev` | `libpgm` | | `openpgm-devel` | NO | For ZeroMQ |
|
||||
| libnorm[2] | ? | NO | `libnorm-dev` | | | | YES | For ZeroMQ |
|
||||
| libunbound | 1.4.16 | NO | `libunbound-dev` | `unbound` | `unbound-devel` | `unbound-devel` | NO | DNS resolver |
|
||||
| libsodium | ? | NO | `libsodium-dev` | `libsodium` | `libsodium-devel` | `libsodium-devel` | NO | cryptography |
|
||||
| libunwind | any | NO | `libunwind8-dev` | `libunwind` | `libunwind-devel` | `libunwind-devel` | YES | Stack traces |
|
||||
| liblzma | any | NO | `liblzma-dev` | `xz` | `liblzma-devel` | `xz-devel` | YES | For libunwind |
|
||||
| libreadline | 6.3.0 | NO | `libreadline6-dev` | `readline` | `readline-devel` | `readline-devel` | YES | Input editing |
|
||||
| expat | 1.1 | NO | `libexpat1-dev` | `expat` | `expat-devel` | `expat-devel` | YES | XML parsing |
|
||||
| GTest | 1.5 | YES | `libgtest-dev`[1] | `gtest` | `gtest-devel` | `gtest-devel` | YES | Test suite |
|
||||
| ccache | any | NO | `ccache` | `ccache` | `ccache` | `ccache` | YES | Compil. cache |
|
||||
| Doxygen | any | NO | `doxygen` | `doxygen` | `doxygen` | `doxygen` | YES | Documentation |
|
||||
| Graphviz | any | NO | `graphviz` | `graphviz` | `graphviz` | `graphviz` | YES | Documentation |
|
||||
| lrelease | ? | NO | `qttools5-dev-tools` | `qt5-tools` | `qt5-tools` | `qt5-linguist` | YES | Translations |
|
||||
| libhidapi | ? | NO | `libhidapi-dev` | `hidapi` | `hidapi-devel` | `hidapi-devel` | YES | Hardware wallet |
|
||||
| libusb | ? | NO | `libusb-1.0-0-dev` | `libusb` | `libusb-devel` | `libusbx-devel` | YES | Hardware wallet |
|
||||
| libprotobuf | ? | NO | `libprotobuf-dev` | `protobuf` | `protobuf-devel` | `protobuf-devel` | YES | Hardware wallet |
|
||||
| protoc | ? | NO | `protobuf-compiler` | `protobuf` | `protobuf` | `protobuf-compiler` | YES | Hardware wallet |
|
||||
| libudev | ? | NO | `libudev-dev` | `systemd` | `eudev-libudev-devel` | `systemd-devel` | YES | Hardware wallet |
|
||||
|
||||
[1] On Debian/Ubuntu `libgtest-dev` only includes sources and headers. You must
|
||||
build the library binary manually. This can be done with the following command `sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make`
|
||||
then:
|
||||
|
||||
* on Debian:
|
||||
`sudo mv libg* /usr/lib/`
|
||||
* on Ubuntu:
|
||||
`sudo mv lib/libg* /usr/lib/`
|
||||
|
||||
[2] libnorm-dev is needed if your zmq library was built with libnorm, and not needed otherwise
|
||||
|
||||
Install all dependencies at once on Debian/Ubuntu:
|
||||
|
||||
```
|
||||
sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz
|
||||
```
|
||||
|
||||
Install all dependencies at once on Arch:
|
||||
```
|
||||
sudo pacman -Syu --needed base-devel cmake boost openssl zeromq libpgm unbound libsodium libunwind xz readline expat gtest python3 ccache doxygen graphviz qt5-tools hidapi libusb protobuf systemd
|
||||
```
|
||||
|
||||
Install all dependencies at once on Fedora:
|
||||
```
|
||||
sudo dnf install gcc gcc-c++ cmake pkgconf boost-devel openssl-devel zeromq-devel openpgm-devel unbound-devel libsodium-devel libunwind-devel xz-devel readline-devel expat-devel gtest-devel ccache doxygen graphviz qt5-linguist hidapi-devel libusbx-devel protobuf-devel protobuf-compiler systemd-devel
|
||||
```
|
||||
|
||||
Install all dependencies at once on openSUSE:
|
||||
|
||||
```
|
||||
sudo zypper ref && sudo zypper in cppzmq-devel libboost_chrono-devel libboost_date_time-devel libboost_filesystem-devel libboost_locale-devel libboost_program_options-devel libboost_regex-devel libboost_serialization-devel libboost_system-devel libboost_thread-devel libexpat-devel libminiupnpc-devel libsodium-devel libunwind-devel unbound-devel cmake doxygen ccache fdupes gcc-c++ libevent-devel libopenssl-devel pkgconf-pkg-config readline-devel xz-devel libqt5-qttools-devel patterns-devel-C-C++-devel_C_C++
|
||||
```
|
||||
|
||||
Install all dependencies at once on macOS with the provided Brewfile:
|
||||
|
||||
```
|
||||
brew update && brew bundle --file=contrib/brew/Brewfile
|
||||
```
|
||||
|
||||
FreeBSD 12.1 one-liner required to build dependencies:
|
||||
|
||||
```
|
||||
pkg install git gmake cmake pkgconf boost-libs libzmq4 libsodium unbound
|
||||
```
|
||||
|
||||
### Cloning the repository
|
||||
|
||||
Clone recursively to pull-in needed submodule(s):
|
||||
|
||||
```
|
||||
git clone --recursive https://github.com/salvium/salvium
|
||||
```
|
||||
|
||||
If you already have a repo cloned, initialize and update:
|
||||
|
||||
```
|
||||
cd salvium && git submodule init && git submodule update
|
||||
```
|
||||
|
||||
*Note*: If there are submodule differences between branches, you may need
|
||||
to use `git submodule sync && git submodule update` after changing branches
|
||||
to build successfully.
|
||||
|
||||
### Build instructions
|
||||
|
||||
Salvium uses the CMake build system and a top-level [Makefile](Makefile) that
|
||||
invokes cmake commands as needed.
|
||||
|
||||
#### On Linux and macOS
|
||||
|
||||
* Install the dependencies
|
||||
* Change to the root of the source code directory, change to the most recent release branch, and build:
|
||||
|
||||
```bash
|
||||
cd salvium
|
||||
git checkout release-v0.18
|
||||
make
|
||||
```
|
||||
|
||||
*Optional*: If your machine has several cores and enough memory, enable
|
||||
parallel build by running `make -j<number of threads>` instead of `make`. For
|
||||
this to be worthwhile, the machine should have one core and about 2GB of RAM
|
||||
available per thread.
|
||||
|
||||
*Note*: The instructions above will compile the most stable release of the
|
||||
Salvium software. If you would like to use and test the most recent software,
|
||||
use `git checkout master`. The master branch may contain updates that are
|
||||
both unstable and incompatible with release software, though testing is always
|
||||
encouraged.
|
||||
|
||||
* The resulting executables can be found in `build/release/bin`
|
||||
|
||||
* Add `PATH="$PATH:$HOME/salvium/build/release/bin"` to `.profile`
|
||||
|
||||
* Run Salvium with `salviumd --detach`
|
||||
|
||||
* **Optional**: build and run the test suite to verify the binaries:
|
||||
|
||||
```bash
|
||||
make release-test
|
||||
```
|
||||
|
||||
*NOTE*: `core_tests` test may take a few hours to complete.
|
||||
|
||||
* **Optional**: to build binaries suitable for debugging:
|
||||
|
||||
```bash
|
||||
make debug
|
||||
```
|
||||
|
||||
* **Optional**: to build statically-linked binaries:
|
||||
|
||||
```bash
|
||||
make release-static
|
||||
```
|
||||
|
||||
Dependencies need to be built with -fPIC. Static libraries usually aren't, so you may have to build them yourself with -fPIC. Refer to their documentation for how to build them.
|
||||
|
||||
* **Optional**: build documentation in `doc/html` (omit `HAVE_DOT=YES` if `graphviz` is not installed):
|
||||
|
||||
```bash
|
||||
HAVE_DOT=YES doxygen Doxyfile
|
||||
```
|
||||
|
||||
* **Optional**: use ccache not to rebuild translation units, that haven't really changed. Salvium's CMakeLists.txt file automatically handles it
|
||||
|
||||
```bash
|
||||
sudo apt install ccache
|
||||
```
|
||||
|
||||
#### On the Raspberry Pi
|
||||
|
||||
Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch (2017-09-07 or later) from https://www.raspberrypi.org/downloads/raspbian/. If you are using Raspian Jessie, [please see note in the following section](#note-for-raspbian-jessie-users).
|
||||
|
||||
* `apt-get update && apt-get upgrade` to install all of the latest software
|
||||
|
||||
* Install the dependencies for Salvium from the 'Debian' column in the table above.
|
||||
|
||||
* Increase the system swap size:
|
||||
|
||||
```bash
|
||||
sudo /etc/init.d/dphys-swapfile stop
|
||||
sudo nano /etc/dphys-swapfile
|
||||
CONF_SWAPSIZE=2048
|
||||
sudo /etc/init.d/dphys-swapfile start
|
||||
```
|
||||
|
||||
* If using an external hard disk without an external power supply, ensure it gets enough power to avoid hardware issues when syncing, by adding the line "max_usb_current=1" to /boot/config.txt
|
||||
|
||||
* Clone Salvium and checkout the most recent release version:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/salvium/salvium
|
||||
cd salvium
|
||||
git checkout v0.4.1
|
||||
```
|
||||
|
||||
* Build:
|
||||
|
||||
```bash
|
||||
USE_SINGLE_BUILDDIR=1 make release
|
||||
```
|
||||
|
||||
* Wait 4-6 hours
|
||||
|
||||
* The resulting executables can be found in `build/release/bin`
|
||||
|
||||
* Add `export PATH="$PATH:$HOME/salvium/build/release/bin"` to `$HOME/.profile`
|
||||
|
||||
* Run `source $HOME/.profile`
|
||||
|
||||
* Run Salvium with `salviumd --detach`
|
||||
|
||||
* You may wish to reduce the size of the swap file after the build has finished, and delete the boost directory from your home directory
|
||||
|
||||
#### *Note for Raspbian Jessie users:*
|
||||
|
||||
If you are using the older Raspbian Jessie image, compiling Salvium is a bit more complicated. The version of Boost available in the Debian Jessie repositories is too old to use with Salvium, and thus you must compile a newer version yourself. The following explains the extra steps and has been tested on a Raspberry Pi 2 with a clean install of minimal Raspbian Jessie.
|
||||
|
||||
* As before, `apt-get update && apt-get upgrade` to install all of the latest software, and increase the system swap size
|
||||
|
||||
```bash
|
||||
sudo /etc/init.d/dphys-swapfile stop
|
||||
sudo nano /etc/dphys-swapfile
|
||||
CONF_SWAPSIZE=2048
|
||||
sudo /etc/init.d/dphys-swapfile start
|
||||
```
|
||||
|
||||
|
||||
* Then, install the dependencies for Salvium except for `libunwind` and `libboost-all-dev`
|
||||
|
||||
* Install the latest version of boost (this may first require invoking `apt-get remove --purge libboost*-dev` to remove a previous version if you're not using a clean install):
|
||||
|
||||
```bash
|
||||
cd
|
||||
wget https://sourceforge.net/projects/boost/files/boost/1.72.0/boost_1_72_0.tar.bz2
|
||||
tar xvfo boost_1_72_0.tar.bz2
|
||||
cd boost_1_72_0
|
||||
./bootstrap.sh
|
||||
sudo ./b2
|
||||
```
|
||||
|
||||
* Wait ~8 hours
|
||||
|
||||
```bash
|
||||
sudo ./bjam cxxflags=-fPIC cflags=-fPIC -a install
|
||||
```
|
||||
|
||||
* Wait ~4 hours
|
||||
|
||||
* From here, follow the [general Raspberry Pi instructions](#on-the-raspberry-pi) from the "Clone Salvium and checkout most recent release version" step.
|
||||
|
||||
#### On Windows:
|
||||
|
||||
Binaries for Windows are built on Windows using the MinGW toolchain within
|
||||
[MSYS2 environment](https://www.msys2.org). The MSYS2 environment emulates a
|
||||
POSIX system. The toolchain runs within the environment and *cross-compiles*
|
||||
binaries that can run outside of the environment as a regular Windows
|
||||
application.
|
||||
|
||||
**Preparing the build environment**
|
||||
|
||||
* Download and install the [MSYS2 installer](https://www.msys2.org), either the 64-bit or the 32-bit package, depending on your system.
|
||||
* Open the MSYS shell via the `MSYS2 Shell` shortcut
|
||||
* Update packages using pacman:
|
||||
|
||||
```bash
|
||||
pacman -Syu
|
||||
```
|
||||
|
||||
* Exit the MSYS shell using Alt+F4
|
||||
* Edit the properties for the `MSYS2 Shell` shortcut changing "msys2_shell.bat" to "msys2_shell.cmd -mingw64" for 64-bit builds or "msys2_shell.cmd -mingw32" for 32-bit builds
|
||||
* Restart MSYS shell via modified shortcut and update packages again using pacman:
|
||||
|
||||
```bash
|
||||
pacman -Syu
|
||||
```
|
||||
|
||||
|
||||
* Install dependencies:
|
||||
|
||||
To build for 64-bit Windows:
|
||||
|
||||
```bash
|
||||
pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-unbound
|
||||
```
|
||||
|
||||
To build for 32-bit Windows:
|
||||
|
||||
```bash
|
||||
pacman -S mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-zeromq mingw-w64-i686-libsodium mingw-w64-i686-hidapi mingw-w64-i686-unbound
|
||||
```
|
||||
|
||||
* Open the MingW shell via `MinGW-w64-Win64 Shell` shortcut on 64-bit Windows
|
||||
or `MinGW-w64-Win64 Shell` shortcut on 32-bit Windows. Note that if you are
|
||||
running 64-bit Windows, you will have both 64-bit and 32-bit MinGW shells.
|
||||
|
||||
**Cloning**
|
||||
|
||||
* To git clone, run:
|
||||
|
||||
```bash
|
||||
git clone --recursive https://github.com/salvium/salvium
|
||||
```
|
||||
|
||||
**Building**
|
||||
|
||||
* Change to the cloned directory, run:
|
||||
|
||||
```bash
|
||||
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.1'. If you don't care about the version and just want binaries from master, skip this step:
|
||||
|
||||
```bash
|
||||
git checkout v0.4.1
|
||||
```
|
||||
|
||||
* If you are on a 64-bit system, run:
|
||||
|
||||
```bash
|
||||
make release-static-win64
|
||||
```
|
||||
|
||||
* If you are on a 32-bit system, run:
|
||||
|
||||
```bash
|
||||
make release-static-win32
|
||||
```
|
||||
|
||||
* The resulting executables can be found in `build/release/bin`
|
||||
|
||||
* **Optional**: to build Windows binaries suitable for debugging on a 64-bit system, run:
|
||||
|
||||
```bash
|
||||
make debug-static-win64
|
||||
```
|
||||
|
||||
* **Optional**: to build Windows binaries suitable for debugging on a 32-bit system, run:
|
||||
|
||||
```bash
|
||||
make debug-static-win32
|
||||
```
|
||||
|
||||
* The resulting executables can be found in `build/debug/bin`
|
||||
|
||||
### On FreeBSD:
|
||||
|
||||
The project can be built from scratch by following instructions for Linux above(but use `gmake` instead of `make`).
|
||||
If you are running Salvium in a jail, you need to add `sysvsem="new"` to your jail configuration, otherwise lmdb will throw the error message: `Failed to open lmdb environment: Function not implemented`.
|
||||
|
||||
### On OpenBSD:
|
||||
|
||||
You will need to add a few packages to your system. `pkg_add cmake gmake zeromq libiconv boost libunbound`.
|
||||
|
||||
The `doxygen` and `graphviz` packages are optional and require the xbase set.
|
||||
Running the test suite also requires `py3-requests` package.
|
||||
|
||||
Build salvium: `gmake`
|
||||
|
||||
Note: you may encounter the following error when compiling the latest version of Salvium as a normal user:
|
||||
|
||||
```
|
||||
LLVM ERROR: out of memory
|
||||
c++: error: unable to execute command: Abort trap (core dumped)
|
||||
```
|
||||
|
||||
Then you need to increase the data ulimit size to 2GB and try again: `ulimit -d 2000000`
|
||||
|
||||
### On NetBSD:
|
||||
|
||||
Check that the dependencies are present: `pkg_info -c libexecinfo boost-headers boost-libs protobuf readline libusb1 zeromq git-base pkgconf gmake cmake | more`, and install any that are reported missing, using `pkg_add` or from your pkgsrc tree. Readline is optional but worth having.
|
||||
|
||||
Third-party dependencies are usually under `/usr/pkg/`, but if you have a custom setup, adjust the "/usr/pkg" (below) accordingly.
|
||||
|
||||
Clone the salvium repository recursively and checkout the most recent release as described above. Then build salvium: `gmake BOOST_ROOT=/usr/pkg LDFLAGS="-Wl,-R/usr/pkg/lib" release`. The resulting executables can be found in `build/NetBSD/[Release version]/Release/bin/`.
|
||||
|
||||
### On Solaris:
|
||||
|
||||
The default Solaris linker can't be used, you have to install GNU ld, then run cmake manually with the path to your copy of GNU ld:
|
||||
|
||||
```bash
|
||||
mkdir -p build/release
|
||||
cd build/release
|
||||
cmake -DCMAKE_LINKER=/path/to/ld -D CMAKE_BUILD_TYPE=Release ../..
|
||||
cd ../..
|
||||
```
|
||||
|
||||
Then you can run make as usual.
|
||||
|
||||
### Building portable statically linked binaries
|
||||
|
||||
By default, in either dynamically or statically linked builds, binaries target the specific host processor on which the build happens and are not portable to other processors. Portable binaries can be built using the following targets:
|
||||
|
||||
* ```make release-static-linux-x86_64``` builds binaries on Linux on x86_64 portable across POSIX systems on x86_64 processors
|
||||
* ```make release-static-linux-i686``` builds binaries on Linux on x86_64 or i686 portable across POSIX systems on i686 processors
|
||||
* ```make release-static-linux-armv8``` builds binaries on Linux portable across POSIX systems on armv8 processors
|
||||
* ```make release-static-linux-armv7``` builds binaries on Linux portable across POSIX systems on armv7 processors
|
||||
* ```make release-static-linux-armv6``` builds binaries on Linux portable across POSIX systems on armv6 processors
|
||||
* ```make release-static-win64``` builds binaries on 64-bit Windows portable across 64-bit Windows systems
|
||||
* ```make release-static-win32``` builds binaries on 64-bit or 32-bit Windows portable across 32-bit Windows systems
|
||||
|
||||
### Cross Compiling
|
||||
|
||||
You can also cross-compile static binaries on Linux for Windows and macOS with the `depends` system.
|
||||
|
||||
* ```make depends target=x86_64-linux-gnu``` for 64-bit linux binaries.
|
||||
* ```make depends target=x86_64-w64-mingw32``` for 64-bit windows binaries.
|
||||
* Requires: `python3 g++-mingw-w64-x86-64 wine1.6 bc`
|
||||
* You also need to run:
|
||||
```update-alternatives --set x86_64-w64-mingw32-g++ x86_64-w64-mingw32-g++-posix && update-alternatives --set x86_64-w64-mingw32-gcc x86_64-w64-mingw32-gcc-posix```
|
||||
* ```make depends target=x86_64-apple-darwin``` for macOS binaries.
|
||||
* Requires: `cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev`
|
||||
* ```make depends target=i686-linux-gnu``` for 32-bit linux binaries.
|
||||
* Requires: `g++-multilib bc`
|
||||
* ```make depends target=i686-w64-mingw32``` for 32-bit windows binaries.
|
||||
* Requires: `python3 g++-mingw-w64-i686`
|
||||
* ```make depends target=arm-linux-gnueabihf``` for armv7 binaries.
|
||||
* Requires: `g++-arm-linux-gnueabihf`
|
||||
* ```make depends target=aarch64-linux-gnu``` for armv8 binaries.
|
||||
* Requires: `g++-aarch64-linux-gnu`
|
||||
* ```make depends target=riscv64-linux-gnu``` for RISC V 64 bit binaries.
|
||||
* Requires: `g++-riscv64-linux-gnu`
|
||||
* ```make depends target=x86_64-unknown-freebsd``` for freebsd binaries.
|
||||
* Requires: `clang-8`
|
||||
* ```make depends target=arm-linux-android``` for 32bit android binaries
|
||||
* ```make depends target=aarch64-linux-android``` for 64bit android binaries
|
||||
|
||||
|
||||
The required packages are the names for each toolchain on apt. Depending on your distro, they may have different names. The `depends` system has been tested on Ubuntu 18.04 and 20.04.
|
||||
|
||||
Using `depends` might also be easier to compile Salvium on Windows than using MSYS. Activate Windows Subsystem for Linux (WSL) with a distro (for example Ubuntu), install the apt build-essentials and follow the `depends` steps as depicted above.
|
||||
|
||||
The produced binaries still link libc dynamically. If the binary is compiled on a current distribution, it might not run on an older distribution with an older installation of libc. Passing `-DBACKCOMPAT=ON` to cmake will make sure that the binary will run on systems having at least libc version 2.17.
|
||||
|
||||
### Trezor hardware wallet support
|
||||
|
||||
If you have an issue with building Salvium with Trezor support, you can disable it by setting `USE_DEVICE_TREZOR=OFF`, e.g.,
|
||||
|
||||
```bash
|
||||
USE_DEVICE_TREZOR=OFF make release
|
||||
```
|
||||
|
||||
For more information, please check out Trezor [src/device_trezor/README.md](src/device_trezor/README.md).
|
||||
|
||||
### Gitian builds
|
||||
|
||||
See [contrib/gitian/README.md](contrib/gitian/README.md).
|
||||
|
||||
## Running salviumd
|
||||
|
||||
The build places the binary in `bin/` sub-directory within the build directory
|
||||
from which cmake was invoked (repository root by default). To run in the
|
||||
foreground:
|
||||
|
||||
```bash
|
||||
./bin/salviumd
|
||||
```
|
||||
|
||||
To list all available options, run `./bin/salviumd --help`. Options can be
|
||||
specified either on the command line or in a configuration file passed by the
|
||||
`--config-file` argument. To specify an option in the configuration file, add
|
||||
a line with the syntax `argumentname=value`, where `argumentname` is the name
|
||||
of the argument without the leading dashes, for example, `log-level=1`.
|
||||
|
||||
To run in background:
|
||||
|
||||
```bash
|
||||
./bin/salviumd --log-file salviumd.log --detach
|
||||
```
|
||||
|
||||
To run as a systemd service, copy
|
||||
[salviumd.service](utils/systemd/salviumd.service) to `/etc/systemd/system/` and
|
||||
[salviumd.conf](utils/conf/salviumd.conf) to `/etc/`. The [example
|
||||
service](utils/systemd/salviumd.service) assumes that the user `salvium` exists
|
||||
and its home is the data directory specified in the [example
|
||||
config](utils/conf/salviumd.conf).
|
||||
|
||||
If you're on Mac, you may need to add the `--max-concurrency 1` option to
|
||||
salvium-wallet-cli, and possibly salviumd, if you get crashes refreshing.
|
||||
|
||||
## Internationalization
|
||||
|
||||
See [README.i18n.md](docs/README.i18n.md).
|
||||
|
||||
## Debugging
|
||||
|
||||
This section contains general instructions for debugging failed installs or problems encountered with Salvium. First, ensure you are running the latest version built from the GitHub repo.
|
||||
|
||||
### Obtaining stack traces and core dumps on Unix systems
|
||||
|
||||
We generally use the tool `gdb` (GNU debugger) to provide stack trace functionality, and `ulimit` to provide core dumps in builds which crash or segfault.
|
||||
|
||||
* To use `gdb` in order to obtain a stack trace for a build that has stalled:
|
||||
|
||||
Run the build.
|
||||
|
||||
Once it stalls, enter the following command:
|
||||
|
||||
```bash
|
||||
gdb /path/to/salviumd `pidof salviumd`
|
||||
```
|
||||
|
||||
Type `thread apply all bt` within gdb in order to obtain the stack trace
|
||||
|
||||
* If however the core dumps or segfaults:
|
||||
|
||||
Enter `ulimit -c unlimited` on the command line to enable unlimited filesizes for core dumps
|
||||
|
||||
Enter `echo core | sudo tee /proc/sys/kernel/core_pattern` to stop cores from being hijacked by other tools
|
||||
|
||||
Run the build.
|
||||
|
||||
When it terminates with an output along the lines of "Segmentation fault (core dumped)", there should be a core dump file in the same directory as salviumd. It may be named just `core`, or `core.xxxx` with numbers appended.
|
||||
|
||||
You can now analyse this core dump with `gdb` as follows:
|
||||
|
||||
```bash
|
||||
gdb /path/to/salviumd /path/to/dumpfile`
|
||||
```
|
||||
|
||||
Print the stack trace with `bt`
|
||||
|
||||
* If a program crashed and cores are managed by systemd, the following can also get a stack trace for that crash:
|
||||
|
||||
```bash
|
||||
coredumpctl -1 gdb
|
||||
```
|
||||
|
||||
#### To run Salvium within gdb:
|
||||
|
||||
Type `gdb /path/to/salviumd`
|
||||
|
||||
Pass command-line options with `--args` followed by the relevant arguments
|
||||
|
||||
Type `run` to run salviumd
|
||||
|
||||
### Analysing memory corruption
|
||||
|
||||
There are two tools available:
|
||||
|
||||
#### ASAN
|
||||
|
||||
Configure Salvium with the -D SANITIZE=ON cmake flag, eg:
|
||||
|
||||
```bash
|
||||
cd build/debug && cmake -D SANITIZE=ON -D CMAKE_BUILD_TYPE=Debug ../..
|
||||
```
|
||||
|
||||
You can then run the salvium tools normally. Performance will typically halve.
|
||||
|
||||
#### valgrind
|
||||
|
||||
Install valgrind and run as `valgrind /path/to/salviumd`. It will be very slow.
|
||||
|
||||
### LMDB
|
||||
|
||||
Instructions for debugging suspected blockchain corruption as per @HYC
|
||||
|
||||
There is an `mdb_stat` command in the LMDB source that can print statistics about the database but it's not routinely built. This can be built with the following command:
|
||||
|
||||
```bash
|
||||
cd ~/salvium/external/db_drivers/liblmdb && make
|
||||
```
|
||||
|
||||
The output of `mdb_stat -ea <path to blockchain dir>` will indicate inconsistencies in the blocks, block_heights and block_info table.
|
||||
|
||||
The output of `mdb_dump -s blocks <path to blockchain dir>` and `mdb_dump -s block_info <path to blockchain dir>` is useful for indicating whether blocks and block_info contain the same keys.
|
||||
|
||||
These records are dumped as hex data, where the first line is the key and the second line is the data.
|
||||
|
||||
# Known Issues
|
||||
|
||||
## Protocols
|
||||
|
||||
### Socket-based
|
||||
|
||||
Because of the nature of the socket-based protocols that drive salvium, certain protocol weaknesses are somewhat unavoidable at this time. While these weaknesses can theoretically be fully mitigated, the effort required (the means) may not justify the ends. As such, please consider taking the following precautions if you are a salvium node operator:
|
||||
|
||||
- Run `salviumd` on a "secured" machine. If operational security is not your forte, at a very minimum, have a dedicated a computer running `salviumd` and **do not** browse the web, use email clients, or use any other potentially harmful apps on your `salviumd` machine. **Do not click links or load URL/MUA content on the same machine**. Doing so may potentially exploit weaknesses in commands which accept "localhost" and "127.0.0.1".
|
||||
- If you plan on hosting a public "remote" node, start `salviumd` with `--restricted-rpc`. This is a must.
|
||||
|
||||
### Blockchain-based
|
||||
|
||||
Certain blockchain "features" can be considered "bugs" if misused correctly. Consequently, please consider the following:
|
||||
|
||||
- When receiving salvium, be aware that it may be locked for an arbitrary time if the sender elected to, preventing you from spending that salvium until the lock time expires. You may want to hold off acting upon such a transaction until the unlock time lapses. To get a sense of that time, you can consider the remaining blocktime until unlock as seen in the `show_transfers` command.
|
||||
|
||||
@@ -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,4 +1,4 @@
|
||||
mingw32_CFLAGS=-pipe
|
||||
mingw32_CFLAGS=-pipe -pthread
|
||||
mingw32_CXXFLAGS=$(mingw32_CFLAGS)
|
||||
mingw32_ARFLAGS=cr
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Vendored
+1
-1
Submodule external/randomx updated: 901f8ef765...102f8acf90
Vendored
+1
-1
Submodule external/rapidjson updated: 973dc9c06d...129d19ba7f
Vendored
+1
-1
Submodule external/trezor-common updated: bff7fdfe43...bc28c316d0
Executable
+31
@@ -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
|
||||
@@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1179,21 +1183,38 @@ uint64_t BlockchainLMDB::add_transaction_data(const crypto::hash& blk_hash, cons
|
||||
throw0(DB_ERROR(lmdb_error("Failed to add prunable tx prunable hash to db transaction: ", result).c_str()));
|
||||
}
|
||||
|
||||
if (tx.type == cryptonote::transaction_type::MINER) {
|
||||
|
||||
// Update the circulating supply tally because of potentially burnt block_reward proportion
|
||||
MDB_val_copy<uint64_t> source_idx(cryptonote::asset_id_from_type("SAL"));
|
||||
boost::multiprecision::int128_t source_tally = 0;
|
||||
result = read_circulating_supply_data(m_cur_circ_supply_tally, source_idx, source_tally);
|
||||
if (result && (m_height>0 || result != MDB_NOTFOUND))
|
||||
throw0(DB_ERROR(lmdb_error("Failed to get circulating supply tally when adding db transaction: ", result).c_str()));
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally;
|
||||
for (const auto& out: tx.vout) {
|
||||
|
||||
// Sanity check - prevent overflow
|
||||
if (final_source_tally > final_source_tally + out.amount)
|
||||
throw0(DB_ERROR("numeric overflow detected when adding miner_tx for db transaction"));
|
||||
|
||||
// Fetch the amount for this output
|
||||
final_source_tally += out.amount;
|
||||
}
|
||||
write_circulating_supply_data(m_cur_circ_supply_tally, source_idx, final_source_tally);
|
||||
LOG_PRINT_L1("tx ID " << tx_id << "\n\tTally before burn = " << source_tally.str() << "\n\tTally after burn = " << final_source_tally.str());
|
||||
}
|
||||
|
||||
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));
|
||||
boost::multiprecision::int128_t source_tally = 0;
|
||||
result = read_circulating_supply_data(m_cur_circ_supply_tally, source_idx, source_tally);
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally - tx.amount_burnt;
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally - tx.amount_burnt - tx.rct_signatures.txnFee;
|
||||
boost::multiprecision::int128_t coinbase = get_block_already_generated_coins(m_height-1);
|
||||
if (source_tally == 0 && result == MDB_NOTFOUND) {
|
||||
if (tx.source_asset_type == "SAL") {
|
||||
final_source_tally += coinbase;
|
||||
} else {
|
||||
throw0(DB_ERROR("burn underflow - asset balance is zero for non-SAL asset"));
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Failed to get circulating supply tally when adding db transaction: ", result).c_str()));
|
||||
write_circulating_supply_data(m_cur_circ_supply_tally, source_idx, final_source_tally);
|
||||
LOG_PRINT_L1("tx ID " << tx_id << "\n\tTally before burn = " << source_tally.str() << "\n\tTally after burn = " << final_source_tally.str());
|
||||
}
|
||||
@@ -1219,6 +1240,8 @@ uint64_t BlockchainLMDB::add_transaction_data(const crypto::hash& blk_hash, cons
|
||||
MDB_val_copy<uint64_t> source_idx(asset.first);
|
||||
boost::multiprecision::int128_t source_tally = 0;
|
||||
result = read_circulating_supply_data(m_cur_circ_supply_tally, source_idx, source_tally);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Failed to get circulating supply tally when adding db transaction: ", result).c_str()));
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally + asset.second;
|
||||
boost::multiprecision::int128_t coinbase = get_block_already_generated_coins(m_height-1);
|
||||
if (source_tally == 0 && result == MDB_NOTFOUND) {
|
||||
@@ -1238,7 +1261,17 @@ uint64_t BlockchainLMDB::add_transaction_data(const crypto::hash& blk_hash, cons
|
||||
yield_tx_info yield_data;
|
||||
yield_data.block_height = m_height;
|
||||
yield_data.tx_hash = tx_hash;
|
||||
yield_data.return_address = tx.return_address;
|
||||
if (tx.version == TRANSACTION_VERSION_2_OUTS) {
|
||||
if (tx.return_address == crypto::null_pkey)
|
||||
throw0(DB_ERROR("missing return_address entry (needed to create yield data for PROTOCOL_TX) - v2 STAKE"));
|
||||
yield_data.return_address = tx.return_address;
|
||||
} else if (tx.version >= TRANSACTION_VERSION_N_OUTS) {
|
||||
if (tx.return_address_list.empty())
|
||||
throw0(DB_ERROR("no return_address_list entry (needed to create yield data for the PROTOCOL_TX)"));
|
||||
else if (tx.return_address_list.size() > 1)
|
||||
throw0(DB_ERROR("too many return_address_list entries provided (only one needed to create yield data for the PROTOCOL_TX)"));
|
||||
yield_data.return_address = tx.return_address_list[0];
|
||||
}
|
||||
yield_data.locked_coins = tx.amount_burnt;
|
||||
if (tx.vin.empty())
|
||||
throw0(DB_ERROR("tx.vin is empty (needed to create yield data for the PROTOCOL_TX)"));
|
||||
@@ -1340,7 +1373,29 @@ void BlockchainLMDB::remove_transaction_data(const crypto::hash& tx_hash, const
|
||||
throw1(DB_ERROR(lmdb_error("Failed to add removal of prunable hash tx to db transaction: ", result).c_str()));
|
||||
}
|
||||
|
||||
if (tx.type == cryptonote::transaction_type::CONVERT || tx.type == cryptonote::transaction_type::BURN) {
|
||||
if (tx.type == cryptonote::transaction_type::MINER) {
|
||||
|
||||
// Update the circulating supply tally because of potentially burnt block_reward proportion
|
||||
MDB_val_copy<uint64_t> source_idx(cryptonote::asset_id_from_type("SAL"));
|
||||
boost::multiprecision::int128_t source_tally = 0;
|
||||
result = read_circulating_supply_data(m_cur_circ_supply_tally, source_idx, source_tally);
|
||||
if (result && (m_height>0 || result != MDB_NOTFOUND))
|
||||
throw0(DB_ERROR(lmdb_error("remove_transaction_data() - Failed to get circulating supply tally when removing db transaction: ", result).c_str()));
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally;
|
||||
for (const auto& out: tx.vout) {
|
||||
|
||||
// Sanity check - prevent underflow
|
||||
if (final_source_tally < final_source_tally - out.amount)
|
||||
throw0(DB_ERROR("remove_transaction_data() - numeric underflow detected when removing miner_tx for db transaction"));
|
||||
|
||||
// Fetch the amount for this output
|
||||
final_source_tally -= out.amount;
|
||||
}
|
||||
write_circulating_supply_data(m_cur_circ_supply_tally, source_idx, final_source_tally);
|
||||
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::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));
|
||||
@@ -1348,8 +1403,10 @@ void BlockchainLMDB::remove_transaction_data(const crypto::hash& tx_hash, const
|
||||
result = read_circulating_supply_data(m_cur_circ_supply_tally, source_idx, source_tally);
|
||||
if (result == MDB_NOTFOUND)
|
||||
throw0(DB_ERROR("remove_transaction_data() - minted asset not found"));
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally + tx.amount_burnt;
|
||||
boost::multiprecision::int128_t coinbase = get_block_already_generated_coins(m_height-1);
|
||||
// Sanity check - prevent overflow
|
||||
if (source_tally > source_tally + tx.amount_burnt + tx.rct_signatures.txnFee)
|
||||
throw0(DB_ERROR("remove_transaction_data() - numeric overflow detected when processing C/B/S for db transaction"));
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally + tx.amount_burnt + tx.rct_signatures.txnFee;
|
||||
write_circulating_supply_data(m_cur_circ_supply_tally, source_idx, final_source_tally);
|
||||
LOG_PRINT_L1("tx ID " << tip->data.tx_id << "\n\tTally before remint =" << source_tally.str() << "\n\tTally after remint =" << final_source_tally.str());
|
||||
}
|
||||
@@ -1399,17 +1456,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);
|
||||
@@ -3415,11 +3483,13 @@ 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();
|
||||
|
||||
TXN_PREFIX_RDONLY();
|
||||
@@ -3427,8 +3497,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)
|
||||
{
|
||||
@@ -3460,8 +3528,12 @@ std::map<std::string,uint64_t> BlockchainLMDB::get_circulating_supply() const
|
||||
if (circulating_supply.empty()) {
|
||||
circulating_supply["SAL"] = m_coinbase;
|
||||
}
|
||||
|
||||
// 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;
|
||||
*/
|
||||
}
|
||||
|
||||
uint64_t BlockchainLMDB::num_outputs() const
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -133,59 +133,69 @@ monero_private_headers(blockchain_stats
|
||||
${blockchain_stats_private_headers})
|
||||
|
||||
|
||||
#monero_add_executable(blockchain_import
|
||||
# ${blockchain_import_sources}
|
||||
# ${blockchain_import_private_headers})
|
||||
set(blockchain_scanner_sources
|
||||
blockchain_scanner.cpp
|
||||
)
|
||||
|
||||
#target_link_libraries(blockchain_import
|
||||
# PRIVATE
|
||||
# crypto
|
||||
# cncrypto
|
||||
# cryptonote_core
|
||||
# blockchain_db
|
||||
# oracle
|
||||
# version
|
||||
# epee
|
||||
# ${Boost_FILESYSTEM_LIBRARY}
|
||||
# ${Boost_SYSTEM_LIBRARY}
|
||||
# ${Boost_THREAD_LIBRARY}
|
||||
# ${CMAKE_THREAD_LIBS_INIT}
|
||||
# ${EXTRA_LIBRARIES}
|
||||
# ${Blocks})
|
||||
set(blockchain_scanner_private_headers)
|
||||
|
||||
#if(ARCH_WIDTH)
|
||||
# target_compile_definitions(blockchain_import
|
||||
# PUBLIC -DARCH_WIDTH=${ARCH_WIDTH})
|
||||
#endif()
|
||||
monero_private_headers(blockchain_scanner
|
||||
${blockchain_scanner_private_headers})
|
||||
|
||||
#set_property(TARGET blockchain_import
|
||||
# PROPERTY
|
||||
# OUTPUT_NAME "salvium-blockchain-import")
|
||||
#install(TARGETS blockchain_import DESTINATION bin)
|
||||
|
||||
#monero_add_executable(blockchain_export
|
||||
# ${blockchain_export_sources}
|
||||
# ${blockchain_export_private_headers})
|
||||
monero_add_executable(blockchain_import
|
||||
${blockchain_import_sources}
|
||||
${blockchain_import_private_headers})
|
||||
|
||||
#target_link_libraries(blockchain_export
|
||||
# PRIVATE
|
||||
# crypto
|
||||
# cncrypto
|
||||
# cryptonote_core
|
||||
# blockchain_db
|
||||
# oracle
|
||||
# version
|
||||
# epee
|
||||
# ${Boost_FILESYSTEM_LIBRARY}
|
||||
# ${Boost_SYSTEM_LIBRARY}
|
||||
# ${Boost_THREAD_LIBRARY}
|
||||
# ${CMAKE_THREAD_LIBS_INIT}
|
||||
# ${EXTRA_LIBRARIES})
|
||||
target_link_libraries(blockchain_import
|
||||
PRIVATE
|
||||
crypto
|
||||
cncrypto
|
||||
cryptonote_core
|
||||
blockchain_db
|
||||
oracle
|
||||
version
|
||||
epee
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${EXTRA_LIBRARIES}
|
||||
${Blocks})
|
||||
|
||||
#set_property(TARGET blockchain_export
|
||||
# PROPERTY
|
||||
# OUTPUT_NAME "salvium-blockchain-export")
|
||||
#install(TARGETS blockchain_export DESTINATION bin)
|
||||
if(ARCH_WIDTH)
|
||||
target_compile_definitions(blockchain_import
|
||||
PUBLIC -DARCH_WIDTH=${ARCH_WIDTH})
|
||||
endif()
|
||||
|
||||
set_property(TARGET blockchain_import
|
||||
PROPERTY
|
||||
OUTPUT_NAME "salvium-blockchain-import")
|
||||
install(TARGETS blockchain_import DESTINATION bin)
|
||||
|
||||
monero_add_executable(blockchain_export
|
||||
${blockchain_export_sources}
|
||||
${blockchain_export_private_headers})
|
||||
|
||||
target_link_libraries(blockchain_export
|
||||
PRIVATE
|
||||
crypto
|
||||
cncrypto
|
||||
cryptonote_core
|
||||
blockchain_db
|
||||
oracle
|
||||
version
|
||||
epee
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
set_property(TARGET blockchain_export
|
||||
PROPERTY
|
||||
OUTPUT_NAME "salvium-blockchain-export")
|
||||
install(TARGETS blockchain_export DESTINATION bin)
|
||||
|
||||
monero_add_executable(blockchain_blackball
|
||||
${blockchain_blackball_sources}
|
||||
@@ -213,95 +223,116 @@ set_property(TARGET blockchain_blackball
|
||||
install(TARGETS blockchain_blackball DESTINATION bin)
|
||||
|
||||
|
||||
#monero_add_executable(blockchain_usage
|
||||
# ${blockchain_usage_sources}
|
||||
# ${blockchain_usage_private_headers})
|
||||
monero_add_executable(blockchain_usage
|
||||
${blockchain_usage_sources}
|
||||
${blockchain_usage_private_headers})
|
||||
|
||||
#target_link_libraries(blockchain_usage
|
||||
# PRIVATE
|
||||
# crypto
|
||||
# cncrypto
|
||||
# cryptonote_core
|
||||
# blockchain_db
|
||||
# oracle
|
||||
# version
|
||||
# epee
|
||||
# ${Boost_FILESYSTEM_LIBRARY}
|
||||
# ${Boost_SYSTEM_LIBRARY}
|
||||
# ${Boost_THREAD_LIBRARY}
|
||||
# ${CMAKE_THREAD_LIBS_INIT}
|
||||
# ${EXTRA_LIBRARIES})
|
||||
target_link_libraries(blockchain_usage
|
||||
PRIVATE
|
||||
crypto
|
||||
cncrypto
|
||||
cryptonote_core
|
||||
blockchain_db
|
||||
oracle
|
||||
version
|
||||
epee
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
#set_property(TARGET blockchain_usage
|
||||
# PROPERTY
|
||||
# OUTPUT_NAME "salvium-blockchain-usage")
|
||||
#nstall(TARGETS blockchain_usage DESTINATION bin)
|
||||
set_property(TARGET blockchain_usage
|
||||
PROPERTY
|
||||
OUTPUT_NAME "salvium-blockchain-usage")
|
||||
install(TARGETS blockchain_usage DESTINATION bin)
|
||||
|
||||
#monero_add_executable(blockchain_ancestry
|
||||
# ${blockchain_ancestry_sources}
|
||||
# ${blockchain_ancestry_private_headers})
|
||||
monero_add_executable(blockchain_ancestry
|
||||
${blockchain_ancestry_sources}
|
||||
${blockchain_ancestry_private_headers})
|
||||
|
||||
#target_link_libraries(blockchain_ancestry
|
||||
# PRIVATE
|
||||
# cryptonote_core
|
||||
# blockchain_db
|
||||
# oracle
|
||||
# version
|
||||
# epee
|
||||
# ${Boost_FILESYSTEM_LIBRARY}
|
||||
# ${Boost_SYSTEM_LIBRARY}
|
||||
# ${Boost_THREAD_LIBRARY}
|
||||
# ${CMAKE_THREAD_LIBS_INIT}
|
||||
# ${EXTRA_LIBRARIES})
|
||||
target_link_libraries(blockchain_ancestry
|
||||
PRIVATE
|
||||
cryptonote_core
|
||||
blockchain_db
|
||||
oracle
|
||||
version
|
||||
epee
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
#set_property(TARGET blockchain_ancestry
|
||||
# PROPERTY
|
||||
# OUTPUT_NAME "salvium-blockchain-ancestry")
|
||||
#install(TARGETS blockchain_ancestry DESTINATION bin)
|
||||
set_property(TARGET blockchain_ancestry
|
||||
PROPERTY
|
||||
OUTPUT_NAME "salvium-blockchain-ancestry")
|
||||
install(TARGETS blockchain_ancestry DESTINATION bin)
|
||||
|
||||
# monero_add_executable(blockchain_depth
|
||||
# ${blockchain_depth_sources}
|
||||
# ${blockchain_depth_private_headers})
|
||||
monero_add_executable(blockchain_depth
|
||||
${blockchain_depth_sources}
|
||||
${blockchain_depth_private_headers})
|
||||
|
||||
#target_link_libraries(blockchain_depth
|
||||
# PRIVATE
|
||||
# cryptonote_core
|
||||
# blockchain_db
|
||||
# oracle
|
||||
# version
|
||||
# epee
|
||||
# ${Boost_FILESYSTEM_LIBRARY}
|
||||
# ${Boost_SYSTEM_LIBRARY}
|
||||
# ${Boost_THREAD_LIBRARY}
|
||||
# ${CMAKE_THREAD_LIBS_INIT}
|
||||
# ${EXTRA_LIBRARIES})
|
||||
target_link_libraries(blockchain_depth
|
||||
PRIVATE
|
||||
cryptonote_core
|
||||
blockchain_db
|
||||
oracle
|
||||
version
|
||||
epee
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
#set_property(TARGET blockchain_depth
|
||||
# PROPERTY
|
||||
# OUTPUT_NAME "salvium-blockchain-depth")
|
||||
#install(TARGETS blockchain_depth DESTINATION bin)
|
||||
set_property(TARGET blockchain_depth
|
||||
PROPERTY
|
||||
OUTPUT_NAME "salvium-blockchain-depth")
|
||||
install(TARGETS blockchain_depth DESTINATION bin)
|
||||
|
||||
#monero_add_executable(blockchain_stats
|
||||
# ${blockchain_stats_sources}
|
||||
# ${blockchain_stats_private_headers})
|
||||
monero_add_executable(blockchain_scanner
|
||||
${blockchain_scanner_sources}
|
||||
${blockchain_scanner_private_headers})
|
||||
|
||||
#target_link_libraries(blockchain_stats
|
||||
# PRIVATE
|
||||
# cryptonote_core
|
||||
# blockchain_db
|
||||
# oracle
|
||||
# version
|
||||
# epee
|
||||
# ${Boost_FILESYSTEM_LIBRARY}
|
||||
# ${Boost_SYSTEM_LIBRARY}
|
||||
# ${Boost_THREAD_LIBRARY}
|
||||
# ${CMAKE_THREAD_LIBS_INIT}
|
||||
# ${EXTRA_LIBRARIES})
|
||||
target_link_libraries(blockchain_scanner
|
||||
PRIVATE
|
||||
cryptonote_core
|
||||
blockchain_db
|
||||
version
|
||||
epee
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
#set_property(TARGET blockchain_stats
|
||||
# PROPERTY
|
||||
# OUTPUT_NAME "salvium-blockchain-stats")
|
||||
#install(TARGETS blockchain_stats DESTINATION bin)
|
||||
set_property(TARGET blockchain_scanner
|
||||
PROPERTY
|
||||
OUTPUT_NAME "salvium-blockchain-scanner")
|
||||
install(TARGETS blockchain_scanner DESTINATION bin)
|
||||
|
||||
monero_add_executable(blockchain_stats
|
||||
${blockchain_stats_sources}
|
||||
${blockchain_stats_private_headers})
|
||||
|
||||
target_link_libraries(blockchain_stats
|
||||
PRIVATE
|
||||
cryptonote_core
|
||||
blockchain_db
|
||||
oracle
|
||||
version
|
||||
epee
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
set_property(TARGET blockchain_stats
|
||||
PROPERTY
|
||||
OUTPUT_NAME "salvium-blockchain-stats")
|
||||
install(TARGETS blockchain_stats DESTINATION bin)
|
||||
|
||||
monero_add_executable(blockchain_prune_known_spent_data
|
||||
${blockchain_prune_known_spent_data_sources}
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -174,7 +174,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (command_line::get_arg(vm, command_line::arg_help))
|
||||
{
|
||||
std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL;
|
||||
std::cout << "Salvium '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL;
|
||||
std::cout << desc_options << std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ int main(int argc, char* argv[])
|
||||
/*
|
||||
* The default output can be plotted with GnuPlot using these commands:
|
||||
set key autotitle columnhead
|
||||
set title "Monero Blockchain Growth"
|
||||
set title "Salvium Blockchain Growth"
|
||||
set timefmt "%Y-%m-%d"
|
||||
set xdata time
|
||||
set xrange ["2014-04-17":*]
|
||||
|
||||
Binary file not shown.
@@ -182,74 +182,29 @@ namespace cryptonote
|
||||
|
||||
bool checkpoints::init_default_checkpoints(network_type nettype)
|
||||
{
|
||||
if (nettype == TESTNET)
|
||||
{
|
||||
ADD_CHECKPOINT2(0, "48ca7cd3c8de5b6a4d53d2861fbdaedca141553559f9be9520068053cda8430b", "0x1");
|
||||
ADD_CHECKPOINT2(1000000, "46b690b710a07ea051bc4a6b6842ac37be691089c0f7758cfeec4d5fc0b4a258", "0x7aaad7153");
|
||||
ADD_CHECKPOINT2(1058600, "12904f6b4d9e60fd875674e07147d2c83d6716253f046af7b894c3e81da7e1bd", "0x971efd119");
|
||||
ADD_CHECKPOINT2(1450000, "87562ca6786f41556b8d5b48067303a57dc5ca77155b35199aedaeca1550f5a0", "0xa639e2930e");
|
||||
return true;
|
||||
if (nettype == MAINNET) {
|
||||
ADD_CHECKPOINT2(1, "b6b45052e7e182ebaeb14ab713db29ad979115e664d766aa0910e325564a27a6", "0x2");
|
||||
ADD_CHECKPOINT2(10, "82724681cf6bd934eb3253d041de50206a77627ce40ffe418ce6e0fe392ec684", "0x7812a");
|
||||
ADD_CHECKPOINT2(20, "4dac7b512d876df05bfa4f39b8dbacd75cb1483fbced8bfc5446ebe21b25a04f", "0xba98f");
|
||||
ADD_CHECKPOINT2(30, "668246360c93ef791a59157cec9cd09722b32a966051feea399082433138f07b", "0xcc235");
|
||||
ADD_CHECKPOINT2(40, "9a4183bc1d6e9828eac46505c5ef37ae5447ba6c9325dca02be9e1201f939a7d", "0xdf077");
|
||||
ADD_CHECKPOINT2(50, "5cd8b089d2e77aed9b803b398c6bff07ca652100cb8fa114c91b72509aeeb7e9", "0xf37eb");
|
||||
ADD_CHECKPOINT2(60, "0e1acf00dd38e0757996dcdc4b69ad54baf7ebe10ae1e8168b192acb1a0ed7f2", "0x10993b");
|
||||
ADD_CHECKPOINT2(70, "988977507f388221a927e279307b548a0ae0de10ded8c4f22c315e1b483f921a", "0x121537");
|
||||
ADD_CHECKPOINT2(80, "88ea1c49b20e7596e21ca8137b2a9fa98558df269a15816fe7d7495f1c63ea43", "0x13a290");
|
||||
ADD_CHECKPOINT2(90, "254800bb6f9794aad95b2226ffc1a1eef0a817472e1877ae08fac6becb55b147", "0x153a55");
|
||||
ADD_CHECKPOINT2(100, "ba8d75fad878af26ac2504b4868893a7f86c59f013d0f096925cf53271dd04e8", "0x16e91e");
|
||||
ADD_CHECKPOINT2(110, "dca0779bfe403730b923fa0918645daeec6096b953be2c554f133460c6fcce35", "0x18acb9");
|
||||
ADD_CHECKPOINT2(120, "5a57287f6b5c105ae264b88050731c5b9ad1313b916143d7585af1d345e70247", "0x1a88f5");
|
||||
ADD_CHECKPOINT2(130, "4fd292ac0774461e968924f8097e78ec03eee43a2997deaddbc7993e470a61d6", "0x1c6edd");
|
||||
ADD_CHECKPOINT2(140, "5a3b6ceeef5fd498ea3330acb8a0e87f2c1566c9b0100ad67237e5664d1f053b", "0x1e4991");
|
||||
ADD_CHECKPOINT2(150, "78f26d08d39f7d5e1a3548277321471e16c95096fa9bcecbe8a420d406ee249b", "0x202406");
|
||||
ADD_CHECKPOINT2(160, "7acaab1037ccfbadd3126d2612d5dc154020297f980df0b8df462f9c761d3326", "0x22154b");
|
||||
ADD_CHECKPOINT2(170, "9541ae934e40fa6749ca3453e47cf5fdf38efbac9efcaa2714121e8a21dd2d24", "0x241ce7");
|
||||
ADD_CHECKPOINT2(180, "e20bc8ac6aabb6b0792f23a29ce42a577c6a57d177a8ac1a51b68fb6de508045", "0x262b40");
|
||||
ADD_CHECKPOINT2(190, "f69fdad7a15471b63a82668b618ee5b2a384291269d944b11974a723c1604124", "0x2856a3");
|
||||
ADD_CHECKPOINT2(200, "eba53fa7006dfcdc837a56c0bc8f0e1883cf34861c26934d680252a6878a3f5d", "0x2aa022");
|
||||
}
|
||||
if (nettype == STAGENET)
|
||||
{
|
||||
ADD_CHECKPOINT2(0, "76ee3cc98646292206cd3e86f74d88b4dcc1d937088645e9b0cbca84b7ce74eb", "0x1");
|
||||
ADD_CHECKPOINT2(10000, "1f8b0ce313f8b9ba9a46108bfd285c45ad7c2176871fd41c3a690d4830ce2fd5", "0x1d73ba");
|
||||
ADD_CHECKPOINT2(550000, "409f68cddd8e74b37469b41c1e61250d81c5776b42264f416d5d27c4626383ed", "0x5f3d4d03e");
|
||||
return true;
|
||||
}
|
||||
ADD_CHECKPOINT2(1, "771fbcd656ec1464d3a02ead5e18644030007a0fc664c0a964d30922821a8148", "0x2");
|
||||
ADD_CHECKPOINT2(10, "c0e3b387e47042f72d8ccdca88071ff96bff1ac7cde09ae113dbb7ad3fe92381", "0x2a974");
|
||||
ADD_CHECKPOINT2(100, "ac3e11ca545e57c49fca2b4e8c48c03c23be047c43e471e1394528b1f9f80b2d", "0x35d14b");
|
||||
ADD_CHECKPOINT2(1000, "5acfc45acffd2b2e7345caf42fa02308c5793f15ec33946e969e829f40b03876", "0x36a0373");
|
||||
ADD_CHECKPOINT2(10000, "c758b7c81f928be3295d45e230646de8b852ec96a821eac3fea4daf3fcac0ca2", "0x60a91390");
|
||||
ADD_CHECKPOINT2(22231, "7cb10e29d67e1c069e6e11b17d30b809724255fee2f6868dc14cfc6ed44dfb25", "0x1e288793d");
|
||||
ADD_CHECKPOINT2(29556, "53c484a8ed91e4da621bb2fa88106dbde426fe90d7ef07b9c1e5127fb6f3a7f6", "0x71f64cce8");
|
||||
ADD_CHECKPOINT2(50000, "0fe8758ab06a8b9cb35b7328fd4f757af530a5d37759f9d3e421023231f7b31c", "0x893044b400");
|
||||
ADD_CHECKPOINT2(80000, "a62dcd7b536f22e003ebae8726e9e7276f63d594e264b6f0cd7aab27b66e75e3", "0x5cc113f1076");
|
||||
ADD_CHECKPOINT2(202612, "bbd604d2ba11ba27935e006ed39c9bfdd99b76bf4a50654bc1e1e61217962698", "0x73310a259eb2");
|
||||
ADD_CHECKPOINT2(202613, "e2aa337e78df1f98f462b3b1e560c6b914dec47b610698b7b7d1e3e86b6197c2", "0x733154039b97");
|
||||
ADD_CHECKPOINT2(202614, "c29e3dc37d8da3e72e506e31a213a58771b24450144305bcba9e70fa4d6ea6fb", "0x73319dc90cb6");
|
||||
ADD_CHECKPOINT2(205000, "5d3d7a26e6dc7535e34f03def711daa8c263785f73ec1fadef8a45880fde8063", "0x75fcc3d85123");
|
||||
ADD_CHECKPOINT2(220000, "9613f455933c00e3e33ac315cc6b455ee8aa0c567163836858c2d9caff111553", "0x89cfed0cae3c");
|
||||
ADD_CHECKPOINT2(230300, "bae7a80c46859db355556e3a9204a337ae8f24309926a1312323fdecf1920e61", "0x967d13e5baa9");
|
||||
ADD_CHECKPOINT2(230700, "93e631240ceac831da1aebfc5dac8f722c430463024763ebafa888796ceaeedf", "0x96fb9663ebe7");
|
||||
ADD_CHECKPOINT2(231350, "b5add137199b820e1ea26640e5c3e121fd85faa86a1e39cf7e6cc097bdeb1131", "0x97b9919177bf");
|
||||
ADD_CHECKPOINT2(232150, "955de8e6b6508af2c24f7334f97beeea651d78e9ade3ab18fec3763be3201aa8", "0x98a038b612e8");
|
||||
ADD_CHECKPOINT2(249380, "654fb0a81ce3e5caf7e3264a70f447d4bd07586c08fa50f6638cc54da0a52b2d", "0xac9739634e6d");
|
||||
ADD_CHECKPOINT2(460000, "75037a7aed3e765db96c75bcf908f59d690a5f3390baebb9edeafd336a1c4831", "0x167799549bdda");
|
||||
ADD_CHECKPOINT2(500000, "2428f0dbe49796be05ed81b347f53e1f7f44aed0abf641446ec2b94cae066b02", "0x188ce145e4ba9");
|
||||
ADD_CHECKPOINT2(600000, "f5828ebf7d7d1cb61762c4dfe3ccf4ecab2e1aad23e8113668d981713b7a54c5", "0x1d9f3759e1554");
|
||||
ADD_CHECKPOINT2(700000, "12be9b3d210b93f574d2526abb9c1ab2a881b479131fd0d4f7dac93875f503cd", "0x2201e4ee39c2c");
|
||||
ADD_CHECKPOINT2(825000, "56503f9ad766774b575be3aff73245e9d159be88132c93d1754764f28da2ff60", "0x27565a442d5df");
|
||||
ADD_CHECKPOINT2(900000, "d9958d0e7dcf91a5a7b11de225927bf7efc6eb26240315ce12372be902cc1337", "0x2a6334031546e");
|
||||
ADD_CHECKPOINT2(913193, "5292d5d56f6ba4de33a58d9a34d263e2cb3c6fee0aed2286fd4ac7f36d53c85f", "0x2aefe7f40f5ea");
|
||||
ADD_CHECKPOINT2(1000000, "a886ef5149902d8342475fee9bb296341b891ac67c4842f47a833f23c00ed721", "0x2edd71370f0e5");
|
||||
ADD_CHECKPOINT2(1100000, "3fd720c5c8b3072fc1ccda922dec1ef25f9ed88a1e6ad4103d0fe00b180a5903", "0x390eb0035c53a");
|
||||
ADD_CHECKPOINT2(1150000, "1dd16f626d18e1e988490dfd06de5920e22629c972c58b4d8daddea0038627b2", "0x422d5662e9e37");
|
||||
ADD_CHECKPOINT2(1200000, "fa7d13a90850882060479d100141ff84286599ae39c3277c8ea784393f882d1f", "0x4c73503fc4aa3");
|
||||
ADD_CHECKPOINT2(1300000, "31b34272343a44a9f4ac7de7a8fcf3b7d8a3124d7d6870affd510d2f37e74cd0", "0x723f49bc249d5");
|
||||
ADD_CHECKPOINT2(1390000, "a8f5649dd4ded60eedab475f2bec8c934681c07e3cf640e9be0617554f13ff6c", "0xb4bba65e2841b");
|
||||
ADD_CHECKPOINT2(1450000, "ac94e8860093bc7c83e4e91215cba1d663421ecf4067a0ae609c3a8b52bcfac2", "0x11a4aabdca9511");
|
||||
ADD_CHECKPOINT2(1530000, "01759bce497ec38e63c78b1038892169203bb78f87e488172f6b854fcd63ba7e", "0x2819ce9f9e91e5");
|
||||
ADD_CHECKPOINT2(1579000, "7d0d7a2346373afd41ed1e744a939fc5d474a7dbaa257be5c6fff4009e789241", "0x357a590e7dda83");
|
||||
ADD_CHECKPOINT2(1668900, "ac2dcaf3d2f58ffcf8391639f0f1ebafcb8eac43c49479c7c37f611868d07568", "0x474226e475cc3b");
|
||||
ADD_CHECKPOINT2(1775600, "1c6e01c661dc22cab939e79ec6a5272190624ce8356d2f7b958e4f9a57fdb05e", "0x5e3b9d206a27c6");
|
||||
ADD_CHECKPOINT2(1856000, "9b57f17f29c71a3acd8a7904b93c41fa6eb8d2b7c73936ce4f1702d14880ba29", "0x6bde5e1caccee1");
|
||||
ADD_CHECKPOINT2(1958000, "98a5d6e51afdf3146e0eefb10a66e8648d8d4d5c2742be8835e976ba217c9bb2", "0x79dd46d2a0971a");
|
||||
ADD_CHECKPOINT2(2046000, "5e867f0b8baefed9244a681df97fc885d8ab36c3dfcd24c7a3abf3b8ac8b8314", "0x9cb8b6ff2978c6");
|
||||
ADD_CHECKPOINT2(2092500, "c4e00820c9c7989b49153d5e90ae095a18a11d990e82fcc3be54e6ed785472b5", "0xb4e585a31369cb");
|
||||
ADD_CHECKPOINT2(2182500, "0d22b5f81982eff21d094af9e821dc2007e6342069e3b1a37b15d97646353124", "0xead4a874083492");
|
||||
ADD_CHECKPOINT2(2661600, "41c9060e8426012238e8a26da26fcb90797436896cc70886a894c2c560bcccf2", "0x2e0d87526ff161f");
|
||||
ADD_CHECKPOINT2(2677000, "1b9fee6246eeb176bd17d637bf252e9af54a4218675f01b4449cc0901867f9eb", "0x2f165bc1a5163ba");
|
||||
ADD_CHECKPOINT2(2706000, "d8eb144c5e1fe6b329ecc900ec95e7792fccff84175fb23a25ed59d7299a511c", "0x310f7d89372f705");
|
||||
ADD_CHECKPOINT2(2720000, "b19fb41dff15bd1016afbee9f8469f05aab715c9e5d1b974466a11fd58ecbb86", "0x3216b5851ddbb61");
|
||||
ADD_CHECKPOINT2(2817000, "39726d19ccaac01d150bec827b877ffae710b516bd633503662036ef4422e577", "0x3900669561954c1");
|
||||
ADD_CHECKPOINT2(2844000, "28fc7b446dfef5b469f5778eb72ddf32a307a5f5a9823d1c394e772349e05d40", "0x3af384ec0e97d12");
|
||||
ADD_CHECKPOINT2(2851000, "5bf0e47fc782263191a33f63a67db6c711781dc2a3c442e17ed901ec401be5c9", "0x3b6cd8a8ed610e8");
|
||||
ADD_CHECKPOINT2(2971000, "3d4cac5ac515eeabd18769ab943af85f36db51d28720def0d0e6effc2c8f5ce3", "0x436e532738b8b5b");
|
||||
ADD_CHECKPOINT2(2985000, "08f5e6b7301c1b6ed88268a28f8677a06e8ff943b3f9e48d3080f71f9c134bfb", "0x444b7b42a633c96");
|
||||
ADD_CHECKPOINT2(3088000, "bddf8ca09110d33d6d497f13a113630c2b6af1c84d4f3a6f35cb1446f2604ade", "0x4aed3615c2f8c3e");
|
||||
ADD_CHECKPOINT2(3102800, "083f4a34f9490403b564286e7f13fd1ed45c52c86fa47195f151594e5bc87504", "0x4bbed52d4da5dfb");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -294,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))
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace tools
|
||||
|
||||
std::string get_update_url(const std::string &software, const std::string &subdir, const std::string &buildtag, const std::string &version, bool user)
|
||||
{
|
||||
const char *base = user ? "https://downloads.salvium.network/" : "https://updates.salvium.network/";
|
||||
const char *base = user ? "https://downloads.salvium.io/" : "https://updates.salvium.io/";
|
||||
#ifdef _WIN32
|
||||
static const char *extension = strncmp(buildtag.c_str(), "source", 6) ? (strncmp(buildtag.c_str(), "install-", 8) ? ".zip" : ".exe") : ".tar.bz2";
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
@@ -71,7 +71,7 @@ target_link_libraries(cncrypto
|
||||
epee
|
||||
randomx
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${SODIUM_LIBRARY}
|
||||
${sodium_LIBRARIES}
|
||||
PRIVATE
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace cryptonote
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(key)
|
||||
FIELD(asset_type)
|
||||
FIELD(unlock_time)
|
||||
VARINT_FIELD(unlock_time)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
@@ -200,8 +200,11 @@ namespace cryptonote
|
||||
std::vector<uint8_t> extra;
|
||||
// TX type
|
||||
cryptonote::transaction_type type;
|
||||
// Return address
|
||||
crypto::public_key return_address;
|
||||
// Return address list (must be at least 1 and at most BULLETPROOF_MAX_OUTPUTS-1 - the "-1" is for the change output)
|
||||
std::vector<crypto::public_key> return_address_list;
|
||||
//return_address_change_mask
|
||||
std::vector<uint8_t> return_address_change_mask;
|
||||
// Return TX public key
|
||||
crypto::public_key return_pubkey;
|
||||
// Source asset type
|
||||
@@ -224,8 +227,13 @@ namespace cryptonote
|
||||
if (type != cryptonote::transaction_type::PROTOCOL) {
|
||||
VARINT_FIELD(amount_burnt)
|
||||
if (type != cryptonote::transaction_type::MINER) {
|
||||
FIELD(return_address)
|
||||
FIELD(return_pubkey)
|
||||
if (type == cryptonote::transaction_type::TRANSFER && version >= TRANSACTION_VERSION_N_OUTS) {
|
||||
FIELD(return_address_list)
|
||||
FIELD(return_address_change_mask)
|
||||
} else {
|
||||
FIELD(return_address)
|
||||
FIELD(return_pubkey)
|
||||
}
|
||||
FIELD(source_asset_type)
|
||||
FIELD(destination_asset_type)
|
||||
VARINT_FIELD(amount_slippage_limit)
|
||||
@@ -244,6 +252,8 @@ namespace cryptonote
|
||||
extra.clear();
|
||||
type = cryptonote::transaction_type::UNSET;
|
||||
return_address = crypto::null_pkey;
|
||||
return_address_list.clear();
|
||||
return_address_change_mask.clear();
|
||||
return_pubkey = crypto::null_pkey;
|
||||
source_asset_type.clear();
|
||||
destination_asset_type.clear();
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace cryptonote {
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool get_block_reward(size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version) {
|
||||
static_assert(DIFFICULTY_TARGET_V2%60==0&&DIFFICULTY_TARGET_V1%60==0,"difficulty targets must be a multiple of 60");
|
||||
const int target = version < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
|
||||
const int target = DIFFICULTY_TARGET_V2;
|
||||
const int target_minutes = target / 60;
|
||||
const int emission_speed_factor = EMISSION_SPEED_FACTOR_PER_MINUTE - (target_minutes-1);
|
||||
|
||||
@@ -316,6 +316,53 @@ namespace cryptonote {
|
||||
bool operator ==(const cryptonote::block& a, const cryptonote::block& b) {
|
||||
return cryptonote::get_block_hash(a) == cryptonote::get_block_hash(b);
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
int compare_hash32_reversed_nbits(const crypto::hash& ha, const crypto::hash& hb, unsigned int nbits)
|
||||
{
|
||||
static_assert(sizeof(uint64_t) * 4 == sizeof(crypto::hash), "hash is wrong size");
|
||||
|
||||
// We have to copy these buffers b/c of the strict aliasing rule
|
||||
uint64_t va[4];
|
||||
memcpy(va, &ha, sizeof(crypto::hash));
|
||||
uint64_t vb[4];
|
||||
memcpy(vb, &hb, sizeof(crypto::hash));
|
||||
|
||||
for (int n = 3; n >= 0 && nbits; --n)
|
||||
{
|
||||
const unsigned int msb_nbits = std::min<unsigned int>(64, nbits);
|
||||
const uint64_t lsb_nbits_dropped = static_cast<uint64_t>(64 - msb_nbits);
|
||||
const uint64_t van = SWAP64LE(va[n]) >> lsb_nbits_dropped;
|
||||
const uint64_t vbn = SWAP64LE(vb[n]) >> lsb_nbits_dropped;
|
||||
nbits -= msb_nbits;
|
||||
|
||||
if (van < vbn) return -1; else if (van > vbn) return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
crypto::hash make_hash32_loose_template(unsigned int nbits, const crypto::hash& h)
|
||||
{
|
||||
static_assert(sizeof(uint64_t) * 4 == sizeof(crypto::hash), "hash is wrong size");
|
||||
|
||||
// We have to copy this buffer b/c of the strict aliasing rule
|
||||
uint64_t vh[4];
|
||||
memcpy(vh, &h, sizeof(crypto::hash));
|
||||
|
||||
for (int n = 3; n >= 0; --n)
|
||||
{
|
||||
const unsigned int msb_nbits = std::min<unsigned int>(64, nbits);
|
||||
const uint64_t mask = msb_nbits ? (~((std::uint64_t(1) << (64 - msb_nbits)) - 1)) : 0;
|
||||
nbits -= msb_nbits;
|
||||
|
||||
vh[n] &= SWAP64LE(mask);
|
||||
}
|
||||
|
||||
crypto::hash res;
|
||||
memcpy(&res, vh, sizeof(crypto::hash));
|
||||
return res;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
@@ -39,15 +39,6 @@ namespace cryptonote {
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
template<class t_array>
|
||||
struct array_hasher: std::unary_function<t_array&, std::size_t>
|
||||
{
|
||||
std::size_t operator()(const t_array& val) const
|
||||
{
|
||||
return boost::hash_range(&val.data[0], &val.data[sizeof(val.data)]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct public_address_outer_blob
|
||||
@@ -121,6 +112,41 @@ namespace cryptonote {
|
||||
|
||||
bool operator ==(const cryptonote::transaction& a, const cryptonote::transaction& b);
|
||||
bool operator ==(const cryptonote::block& a, const cryptonote::block& b);
|
||||
|
||||
/************************************************************************/
|
||||
/* K-anonymity helper functions */
|
||||
/************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Compares two hashes up to `nbits` bits in reverse byte order ("LMDB key order")
|
||||
*
|
||||
* The comparison essentially goes from the 31th, 30th, 29th, ..., 0th byte and compares the MSBs
|
||||
* to the LSBs in each byte, up to `nbits` bits. If we use up `nbits` bits before finding a
|
||||
* difference in the bits between the two hashes, we return 0. If we encounter a zero bit in `ha`
|
||||
* where `hb` has a one in that bit place, then we reutrn -1. If the converse scenario happens,
|
||||
* we return a 1. When `nbits` == 256 (there are 256 bits in `crypto::hash`), calling this is
|
||||
* functionally identical to `BlockchainLMDB::compare_hash32`.
|
||||
*
|
||||
* @param ha left hash
|
||||
* @param hb right hash
|
||||
* @param nbits the number of bits to consider, a higher value means a finer comparison
|
||||
* @return int 0 if ha == hb, -1 if ha < hb, 1 if ha > hb
|
||||
*/
|
||||
int compare_hash32_reversed_nbits(const crypto::hash& ha, const crypto::hash& hb, unsigned int nbits);
|
||||
|
||||
/**
|
||||
* @brief Make a template which matches `h` in LMDB order up to `nbits` bits, safe for k-anonymous fetching
|
||||
*
|
||||
* To be more technical, this function creates a hash which satifies the following property:
|
||||
* For all `H_prime` s.t. `0 == compare_hash32_reversed_nbits(real_hash, H_prime, nbits)`,
|
||||
* `1 > compare_hash32_reversed_nbits(real_hash, H_prime, 256)`.
|
||||
* In other words, we return the "least" hash nbit-equal to `real_hash`.
|
||||
*
|
||||
* @param nbits The number of "MSB" bits to include in the template
|
||||
* @param real_hash The original hash which contains more information than we want to disclose
|
||||
* @return crypto::hash hash template that contains `nbits` bits matching real_hash and no more
|
||||
*/
|
||||
crypto::hash make_hash32_loose_template(unsigned int nbits, const crypto::hash& real_hash);
|
||||
}
|
||||
|
||||
bool parse_hash256(const std::string &str_hash, crypto::hash& hash);
|
||||
|
||||
@@ -166,24 +166,7 @@ namespace boost
|
||||
inline void serialize(Archive &a, cryptonote::transaction_prefix &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.version;
|
||||
a & x.vin;
|
||||
a & x.vout;
|
||||
a & x.extra;
|
||||
a & x.type;
|
||||
if (x.type != cryptonote::transaction_type::MINER && x.type != cryptonote::transaction_type::PROTOCOL) {
|
||||
a & x.return_address;
|
||||
a & x.return_pubkey;
|
||||
a & x.source_asset_type;
|
||||
a & x.destination_asset_type;
|
||||
a & x.amount_burnt;
|
||||
a & x.amount_slippage_limit;
|
||||
}
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, cryptonote::transaction &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.version;
|
||||
a & x.unlock_time;
|
||||
a & x.vin;
|
||||
a & x.vout;
|
||||
a & x.extra;
|
||||
@@ -191,8 +174,39 @@ namespace boost
|
||||
if (x.type != cryptonote::transaction_type::PROTOCOL) {
|
||||
a & x.amount_burnt;
|
||||
if (x.type != cryptonote::transaction_type::MINER) {
|
||||
a & x.return_address;
|
||||
a & x.return_pubkey;
|
||||
if (x.type == cryptonote::transaction_type::TRANSFER && x.version >= TRANSACTION_VERSION_N_OUTS) {
|
||||
a & x.return_address_list;
|
||||
a & x.return_address_change_mask;
|
||||
} else {
|
||||
a & x.return_address;
|
||||
a & x.return_pubkey;
|
||||
}
|
||||
a & x.source_asset_type;
|
||||
a & x.destination_asset_type;
|
||||
a & x.amount_slippage_limit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, cryptonote::transaction &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.version;
|
||||
a & x.unlock_time;
|
||||
a & x.vin;
|
||||
a & x.vout;
|
||||
a & x.extra;
|
||||
a & x.type;
|
||||
if (x.type != cryptonote::transaction_type::PROTOCOL) {
|
||||
a & x.amount_burnt;
|
||||
if (x.type != cryptonote::transaction_type::MINER) {
|
||||
if (x.type == cryptonote::transaction_type::TRANSFER && x.version >= TRANSACTION_VERSION_N_OUTS) {
|
||||
a & x.return_address_list;
|
||||
a & x.return_address_change_mask;
|
||||
} else {
|
||||
a & x.return_address;
|
||||
a & x.return_pubkey;
|
||||
}
|
||||
a & x.source_asset_type;
|
||||
a & x.destination_asset_type;
|
||||
a & x.amount_slippage_limit;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1719,7 +1724,7 @@ namespace cryptonote
|
||||
blobdata blob = t_serializable_object_to_blob(static_cast<block_header>(b));
|
||||
crypto::hash tree_root_hash = get_tx_tree_hash(b);
|
||||
blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash));
|
||||
blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
|
||||
blob.append(tools::get_varint_data(b.tx_hashes.size() + (b.major_version >= HF_VERSION_ENABLE_N_OUTS ? 2 : 1)));
|
||||
return blob;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
@@ -1790,6 +1795,7 @@ namespace cryptonote
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to parse block from blob");
|
||||
b.invalidate_hashes();
|
||||
b.miner_tx.invalidate_hashes();
|
||||
b.protocol_tx.invalidate_hashes();
|
||||
if (block_hash)
|
||||
{
|
||||
calculate_block_hash(b, *block_hash, &b_blob);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <boost/math/special_functions/round.hpp>
|
||||
|
||||
#include "int-util.h"
|
||||
#include "crypto/hash.h"
|
||||
@@ -239,6 +240,63 @@ namespace cryptonote {
|
||||
return res.convert_to<difficulty_type>();
|
||||
}
|
||||
|
||||
difficulty_type next_difficulty_v2(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds) {
|
||||
|
||||
// LWMA difficulty algorithm
|
||||
// Copyright (c) 2017-2018 Zawy
|
||||
// MIT license http://www.opensource.org/licenses/mit-license.php.
|
||||
// This is an improved version of Tom Harding's (Deger8) "WT-144"
|
||||
// Karbowanec, Masari, Bitcoin Gold, and Bitcoin Cash have contributed.
|
||||
// See https://github.com/zawy12/difficulty-algorithms/issues/3 for other algos.
|
||||
// Do not use "if solvetime < 0 then solvetime = 1" which allows a catastrophic exploit.
|
||||
// T= target_solvetime;
|
||||
// N=45, 55, 70, 90, 120 for T=600, 240, 120, 90, and 60
|
||||
|
||||
const int64_t T = static_cast<int64_t>(target_seconds);
|
||||
size_t N = DIFFICULTY_WINDOW;
|
||||
|
||||
if (timestamps.size() > N) {
|
||||
timestamps.resize(N + 1);
|
||||
cumulative_difficulties.resize(N + 1);
|
||||
}
|
||||
size_t n = timestamps.size();
|
||||
assert(n == cumulative_difficulties.size());
|
||||
assert(n <= DIFFICULTY_WINDOW);
|
||||
// If new coin, just "give away" first 5 blocks at low difficulty
|
||||
if ( n < 6 ) { return 1; }
|
||||
// If height "n" is from 6 to N, then reset N to n-1.
|
||||
else if (n < N+1) { N=n-1; }
|
||||
|
||||
// To get an average solvetime to within +/- ~0.1%, use an adjustment factor.
|
||||
// adjust=0.99 for 90 < N < 130
|
||||
const long double adjust = 0.998;
|
||||
// The divisor k normalizes LWMA.
|
||||
const long double k = N * (N + 1) / 2;
|
||||
|
||||
long double LWMA(0), sum_inverse_D(0), harmonic_mean_D(0), nextDifficulty(0);
|
||||
int64_t solveTime(0);
|
||||
uint64_t difficulty(0), next_difficulty(0);
|
||||
|
||||
// Loop through N most recent blocks.
|
||||
for (size_t i = 1; i <= N; i++) {
|
||||
solveTime = static_cast<int64_t>(timestamps[i]) - static_cast<int64_t>(timestamps[i - 1]);
|
||||
solveTime = std::min<int64_t>((T * 7), std::max<int64_t>(solveTime, (-7 * T)));
|
||||
difficulty = (cumulative_difficulties[i] - cumulative_difficulties[i - 1]).convert_to<uint64_t>();
|
||||
LWMA += (int64_t)(solveTime * i) / k;
|
||||
sum_inverse_D += 1 / static_cast<double>(difficulty);
|
||||
}
|
||||
|
||||
// Keep LWMA sane in case something unforeseen occurs.
|
||||
if (static_cast<int64_t>(boost::math::round(LWMA)) < T / 20)
|
||||
LWMA = static_cast<double>(T / 20);
|
||||
|
||||
harmonic_mean_D = N / sum_inverse_D * adjust;
|
||||
nextDifficulty = harmonic_mean_D * T / LWMA;
|
||||
next_difficulty = static_cast<uint64_t>(nextDifficulty);
|
||||
|
||||
return next_difficulty;
|
||||
}
|
||||
|
||||
std::string hex(difficulty_type v)
|
||||
{
|
||||
static const char chars[] = "0123456789abcdef";
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace cryptonote
|
||||
bool check_hash_128(const crypto::hash &hash, difficulty_type difficulty);
|
||||
bool check_hash(const crypto::hash &hash, difficulty_type difficulty);
|
||||
difficulty_type next_difficulty(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
|
||||
|
||||
difficulty_type next_difficulty_v2(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
|
||||
|
||||
std::string hex(difficulty_type v);
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ namespace cryptonote
|
||||
b.nonce = nonce;
|
||||
crypto::hash h;
|
||||
|
||||
if ((b.major_version >= RX_BLOCK_VERSION) && !rx_set)
|
||||
if (!rx_set)
|
||||
{
|
||||
crypto::rx_set_miner_thread(th_local_index, tools::get_max_concurrency());
|
||||
rx_set = true;
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace cryptonote
|
||||
bool m_fee_too_low;
|
||||
bool m_too_few_outputs;
|
||||
bool m_tx_extra_too_big;
|
||||
bool m_version_mismatch; // TX version wrong for the currently-active HF version
|
||||
};
|
||||
|
||||
struct block_verification_context
|
||||
|
||||
+17
-13
@@ -42,7 +42,9 @@
|
||||
#define CRYPTONOTE_MAX_TX_PER_BLOCK 0x10000000
|
||||
#define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
|
||||
#define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 60
|
||||
#define CURRENT_TRANSACTION_VERSION 2
|
||||
#define CURRENT_TRANSACTION_VERSION 3
|
||||
#define TRANSACTION_VERSION_2_OUTS 2
|
||||
#define TRANSACTION_VERSION_N_OUTS 3
|
||||
#define CURRENT_BLOCK_MAJOR_VERSION 1
|
||||
#define CURRENT_BLOCK_MINOR_VERSION 1
|
||||
#define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT 60*60*2
|
||||
@@ -52,7 +54,7 @@
|
||||
|
||||
// MONEY_SUPPLY - total number coins to be generated
|
||||
#define MONEY_SUPPLY ((uint64_t)(18440000000000000ull)) // 184.4M coins * pow(10, 8)
|
||||
#define EMISSION_SPEED_FACTOR_PER_MINUTE (20)
|
||||
#define EMISSION_SPEED_FACTOR_PER_MINUTE (21)
|
||||
#define FINAL_SUBSIDY_PER_MINUTE ((uint64_t)30000000) // 3 * pow(10, 7)
|
||||
|
||||
#define BURN_LOCK_PERIOD 0
|
||||
@@ -208,15 +210,17 @@
|
||||
#define HF_VERSION_REJECT_SIGS_IN_COINBASE 1
|
||||
#define HF_VERSION_BULLETPROOF_PLUS 1
|
||||
#define HF_VERSION_ENABLE_RETURN 1
|
||||
#define HF_VERSION_VIEW_TAGS 1
|
||||
|
||||
#define HF_VERSION_LONG_TERM_BLOCK_WEIGHT 2
|
||||
#define HF_VERSION_VIEW_TAGS 2
|
||||
#define HF_VERSION_2021_SCALING 2
|
||||
#define HF_VERSION_ENABLE_CONVERT 2
|
||||
#define HF_VERSION_ENABLE_ORACLE 2
|
||||
#define HF_VERSION_SLIPPAGE_YIELD 2
|
||||
#define HF_VERSION_ENABLE_N_OUTS 2
|
||||
|
||||
#define TESTNET_VERSION 7
|
||||
#define HF_VERSION_ENABLE_CONVERT 255
|
||||
#define HF_VERSION_ENABLE_ORACLE 255
|
||||
#define HF_VERSION_SLIPPAGE_YIELD 255
|
||||
|
||||
#define TESTNET_VERSION 11
|
||||
#define STAGENET_VERSION 1
|
||||
|
||||
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
|
||||
@@ -263,13 +267,13 @@ namespace config
|
||||
0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x82, 0x53, 0x41, 0x4C, 0xFF, 0x10
|
||||
} };
|
||||
|
||||
std::string const GENESIS_TX = "0201ff000180c0d0c7bbbff60302c33815291bac1b6d5c685129c1de6383e550688d005a3ce2b66a96b7050579060353414c3c00000000000000210149117096744b390170a118fc14d8f13edb40a7d2764fde3043d9fbae7d2efdef010000";
|
||||
std::string const GENESIS_TX = "020001ff000180c0d0c7bbbff603031c7d3e2240c8ddbc2966c9dcbf703c3aa99624d34b82fbfebd71dcfa001c59800353414c3cb42101d7be8f8312cdd54e1ae390e86d6733c3d8f1ef7be27f75f5acbf0dc57aa8e60d010000";
|
||||
|
||||
uint32_t const GENESIS_NONCE = 10000;
|
||||
|
||||
const uint64_t STAKE_LOCK_PERIOD = 30*24*30;
|
||||
|
||||
std::string const TREASURY_ADDRESS = "SaLvdVTaMJp5hrGv2rDWzaCrM6Wrq2T4tNBPX8kvuAJv7iUiYNy4vceFskGRAawnBDiqZ9jWYXZmWemRnEKtWmNMeuSXZg6jwtx";
|
||||
std::string const TREASURY_ADDRESS = "SaLvdZR6w1A21sf2Wh6jYEh1wzY4GSbT7RX6FjyPsnLsffWLrzFQeXUXJcmBLRWDzZC2YXeYe5t7qKsnrg9FpmxmEcxPHsEYfqA";
|
||||
|
||||
// Hash domain separators
|
||||
const char HASH_KEY_BULLETPROOF_EXPONENT[] = "bulletproof";
|
||||
@@ -298,7 +302,7 @@ namespace config
|
||||
// Multisig
|
||||
const uint32_t MULTISIG_MAX_SIGNERS{16};
|
||||
|
||||
std::array<std::string, 3> const ORACLE_URLS = {{"oracle.salvium.network:8443", "oracle.salvium.network:8443", "oracle.salvium.network:8443"}};
|
||||
std::array<std::string, 3> const ORACLE_URLS = {{"oracle.salvium.io:8443", "oracle.salvium.io:8443", "oracle.salvium.io:8443"}};
|
||||
|
||||
std::string const ORACLE_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\n"
|
||||
"MIIDRDCCAjYGByqGSM44BAEwggIpAoIBAQCZP7IJ5PcNvGbWiEqAioKF9wViVxEN\n"
|
||||
@@ -337,12 +341,12 @@ 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 = "020001ff000180c0d0c7bbbff60302838f76f69b70bb0d0f1961a12f6082a033d22285c07d4f12ec93c28197ae2a600353414c3c2101009e8b0abce686c417a1b1344eb7337176bdca90cc928b0facec8a9516190645010000";
|
||||
uint32_t const GENESIS_NONCE = 10001;
|
||||
|
||||
const uint64_t STAKE_LOCK_PERIOD = 20;
|
||||
|
||||
std::array<std::string, 3> const ORACLE_URLS = {{"oracle.salvium.network:8443", "oracle.salvium.network:8443", "oracle.salvium.network:8443"}};
|
||||
std::array<std::string, 3> const ORACLE_URLS = {{"oracle.salvium.io:8443", "oracle.salvium.io:8443", "oracle.salvium.io:8443"}};
|
||||
|
||||
std::string const ORACLE_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\n"
|
||||
"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE5YBxWx1AZCA9jTUk8Pr2uZ9jpfRt\n"
|
||||
@@ -368,7 +372,7 @@ namespace config
|
||||
|
||||
const uint64_t STAKE_LOCK_PERIOD = 20;
|
||||
|
||||
std::array<std::string, 3> const ORACLE_URLS = {{"oracle.salvium.network:8443", "oracle.salvium.network:8443", "oracle.salvium.network:8443"}};
|
||||
std::array<std::string, 3> const ORACLE_URLS = {{"oracle.salvium.io:8443", "oracle.salvium.io:8443", "oracle.salvium.io:8443"}};
|
||||
|
||||
std::string const ORACLE_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\n"
|
||||
"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE5YBxWx1AZCA9jTUk8Pr2uZ9jpfRt\n"
|
||||
|
||||
@@ -967,7 +967,13 @@ start:
|
||||
}
|
||||
|
||||
size_t target = get_difficulty_target();
|
||||
difficulty_type diff = next_difficulty(timestamps, difficulties, target);
|
||||
difficulty_type diff;
|
||||
uint8_t version = get_current_hard_fork_version();
|
||||
if (version == 1) {
|
||||
diff = next_difficulty(timestamps, difficulties, target);
|
||||
} else {
|
||||
diff = next_difficulty_v2(timestamps, difficulties, target);
|
||||
}
|
||||
|
||||
CRITICAL_REGION_LOCAL1(m_difficulty_lock);
|
||||
m_difficulty_for_next_block_top_hash = top_hash;
|
||||
@@ -1026,6 +1032,7 @@ size_t Blockchain::recalculate_difficulties(boost::optional<uint64_t> start_heig
|
||||
|
||||
std::vector<uint64_t> timestamps;
|
||||
std::vector<difficulty_type> difficulties;
|
||||
uint8_t version = get_current_hard_fork_version();
|
||||
timestamps.reserve(DIFFICULTY_BLOCKS_COUNT + 1);
|
||||
difficulties.reserve(DIFFICULTY_BLOCKS_COUNT + 1);
|
||||
if (start_height > 1)
|
||||
@@ -1044,8 +1051,10 @@ size_t Blockchain::recalculate_difficulties(boost::optional<uint64_t> start_heig
|
||||
std::vector<difficulty_type> new_cumulative_difficulties;
|
||||
for (uint64_t height = start_height; height <= top_height; ++height)
|
||||
{
|
||||
size_t target = get_ideal_hard_fork_version(height) < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
|
||||
difficulty_type recalculated_diff = next_difficulty(timestamps, difficulties, target);
|
||||
size_t target = DIFFICULTY_TARGET_V2;
|
||||
difficulty_type recalculated_diff = (version == 1)
|
||||
? next_difficulty(timestamps, difficulties, target)
|
||||
: next_difficulty_v2(timestamps, difficulties, target);
|
||||
|
||||
boost::multiprecision::uint256_t recalculated_cum_diff_256 = boost::multiprecision::uint256_t(recalculated_diff) + last_cum_diff;
|
||||
CHECK_AND_ASSERT_THROW_MES(recalculated_cum_diff_256 <= std::numeric_limits<difficulty_type>::max(), "Difficulty overflow!");
|
||||
@@ -1299,6 +1308,7 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std:
|
||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
std::vector<uint64_t> timestamps;
|
||||
std::vector<difficulty_type> cumulative_difficulties;
|
||||
uint8_t version = get_current_hard_fork_version();
|
||||
|
||||
// if the alt chain isn't long enough to calculate the difficulty target
|
||||
// based on its blocks alone, need to get more blocks from the main chain
|
||||
@@ -1351,10 +1361,14 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std:
|
||||
}
|
||||
|
||||
// FIXME: This will fail if fork activation heights are subject to voting
|
||||
size_t target = get_ideal_hard_fork_version(bei.height) < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
|
||||
size_t target = DIFFICULTY_TARGET_V2;
|
||||
|
||||
// calculate the difficulty target for the block and return it
|
||||
return next_difficulty(timestamps, cumulative_difficulties, target);
|
||||
if (version == 1) {
|
||||
return next_difficulty(timestamps, cumulative_difficulties, target);
|
||||
} else {
|
||||
return next_difficulty_v2(timestamps, cumulative_difficulties, target);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
// This function does a sanity check on basic things that all miner
|
||||
@@ -1448,6 +1462,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
|
||||
|
||||
switch (version) {
|
||||
case HF_VERSION_BULLETPROOF_PLUS:
|
||||
case HF_VERSION_ENABLE_N_OUTS:
|
||||
if (b.miner_tx.amount_burnt > 0) {
|
||||
CHECK_AND_ASSERT_MES(money_in_use + b.miner_tx.amount_burnt > money_in_use, false, "miner transaction is overflowed by amount_burnt");
|
||||
money_in_use += b.miner_tx.amount_burnt;
|
||||
@@ -1478,7 +1493,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 +1503,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;
|
||||
@@ -3555,7 +3581,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;
|
||||
@@ -3565,6 +3591,43 @@ bool Blockchain::check_tx_outputs(const transaction& tx, tx_verification_context
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool Blockchain::check_tx_type_and_version(const transaction& tx, tx_verification_context &tvc) const
|
||||
{
|
||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||
|
||||
const uint8_t hf_version = m_hardfork->get_current_version();
|
||||
|
||||
// Prior to v2, only allow TX v2
|
||||
if (hf_version < HF_VERSION_ENABLE_N_OUTS) {
|
||||
|
||||
// Check for N-out TXs
|
||||
if (tx.version >= TRANSACTION_VERSION_N_OUTS) {
|
||||
MERROR_VER("N-out TXs are not permitted prior to v" + std::to_string(HF_VERSION_ENABLE_N_OUTS));
|
||||
tvc.m_version_mismatch = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for v1 TXs - genesis block protocol_tx exception required!
|
||||
if (tx.version == 1 && epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(tx)) == "4f78ff511e860acd03138737a71505eb62eb78b620e180e58c8e13ed0e1e3e19") {
|
||||
MERROR("v1 TXs are not permitted");
|
||||
tvc.m_version_mismatch = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// After v2 allow N-out TXs for TRANSFER ONLY
|
||||
if (hf_version >= HF_VERSION_ENABLE_N_OUTS) {
|
||||
if (tx.version >= TRANSACTION_VERSION_N_OUTS && tx.type != cryptonote::transaction_type::TRANSFER) {
|
||||
MERROR("N-out TXs are only permitted for TRANSFER TX type");
|
||||
tvc.m_version_mismatch = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool Blockchain::have_tx_keyimges_as_spent(const transaction &tx) const
|
||||
{
|
||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
@@ -3579,7 +3642,7 @@ bool Blockchain::have_tx_keyimges_as_spent(const transaction &tx) const
|
||||
bool Blockchain::expand_transaction_2(transaction &tx, const crypto::hash &tx_prefix_hash, const std::vector<std::vector<rct::ctkey>> &pubkeys, const uint8_t &hf_version)
|
||||
{
|
||||
PERF_TIMER(expand_transaction_2);
|
||||
CHECK_AND_ASSERT_MES(tx.version == 2, false, "Transaction version is not 2");
|
||||
CHECK_AND_ASSERT_MES(tx.version == 2 || tx.version == 3, false, "Transaction version is not 2/3");
|
||||
|
||||
rct::rctSig &rv = tx.rct_signatures;
|
||||
|
||||
@@ -3768,7 +3831,7 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
|
||||
}
|
||||
|
||||
// min/max tx version based on HF, and we accept v1 txes if having a non mixable
|
||||
const size_t max_tx_version = (hf_version < HF_VERSION_SLIPPAGE_YIELD) ? 2 : CURRENT_TRANSACTION_VERSION;
|
||||
const size_t max_tx_version = (hf_version >= HF_VERSION_ENABLE_N_OUTS) ? TRANSACTION_VERSION_N_OUTS : TRANSACTION_VERSION_2_OUTS;
|
||||
if (tx.version > max_tx_version)
|
||||
{
|
||||
MERROR_VER("transaction version " << (unsigned)tx.version << " is higher than max accepted version " << max_tx_version);
|
||||
@@ -4336,7 +4399,7 @@ bool Blockchain::calculate_yield_payouts(const uint64_t start_height, std::vecto
|
||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
|
||||
// Clear the yield payout amounts
|
||||
yield_container.empty();
|
||||
yield_container.clear();
|
||||
|
||||
// Get the YIELD TX information for matured staked coins
|
||||
std::vector<cryptonote::yield_tx_info> yield_entries;
|
||||
@@ -4900,12 +4963,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;
|
||||
@@ -5978,7 +6037,7 @@ bool Blockchain::get_hard_fork_voting_info(uint8_t version, uint32_t &window, ui
|
||||
|
||||
uint64_t Blockchain::get_difficulty_target() const
|
||||
{
|
||||
return get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
|
||||
return DIFFICULTY_TARGET_V2;
|
||||
}
|
||||
|
||||
std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> Blockchain:: get_output_histogram(const std::vector<uint64_t> &amounts, bool unlocked, uint64_t recent_cutoff, uint64_t min_count) const
|
||||
@@ -6049,7 +6108,7 @@ void Blockchain::cancel()
|
||||
}
|
||||
|
||||
#if defined(PER_BLOCK_CHECKPOINT)
|
||||
static const char expected_block_hashes_hash[] = "2c95b5af1f3ee41893ae0c585fd59207a40f28ed4addbaad64a46a39b82955e7";
|
||||
static const char expected_block_hashes_hash[] = "b8639efef99951207b401131ed9f88e37c856a693d237fc6fad349b929aa1059";
|
||||
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
|
||||
{
|
||||
if (get_checkpoints == nullptr || !m_fast_sync)
|
||||
|
||||
@@ -725,6 +725,19 @@ namespace cryptonote
|
||||
*/
|
||||
bool check_tx_outputs(const transaction& tx, tx_verification_context &tvc) const;
|
||||
|
||||
/**
|
||||
* @brief check that a transaction's version & type conforms to current standards
|
||||
*
|
||||
* This function checks, for example at the time of this writing, that
|
||||
* the TX version and type is supported by the current HF version on-chain.
|
||||
*
|
||||
* @param tx the transaction to check the version and type of
|
||||
* @param tvc returned info about tx verification
|
||||
*
|
||||
* @return false if the TX version and/or type is unsupported, otherwise true
|
||||
*/
|
||||
bool check_tx_type_and_version(const transaction& tx, tx_verification_context &tvc) const;
|
||||
|
||||
/**
|
||||
* @brief gets the block weight limit based on recent blocks
|
||||
*
|
||||
@@ -1521,7 +1534,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
|
||||
|
||||
@@ -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 = {
|
||||
@@ -209,7 +209,7 @@ namespace cryptonote
|
||||
static const command_line::arg_descriptor<std::string> arg_block_rate_notify = {
|
||||
"block-rate-notify"
|
||||
, "Run a program when the block rate undergoes large fluctuations. This might "
|
||||
"be a sign of large amounts of hash rate going on and off the Monero network, "
|
||||
"be a sign of large amounts of hash rate going on and off the Salvium network, "
|
||||
"and thus be of potential interest in predicting attacks. %t will be replaced "
|
||||
"by the number of minutes for the observation window, %b by the number of "
|
||||
"blocks observed within that window, and %e by the number of blocks that was "
|
||||
@@ -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;
|
||||
@@ -842,8 +842,8 @@ namespace cryptonote
|
||||
}
|
||||
bad_semantics_txes_lock.unlock();
|
||||
|
||||
uint8_t version = m_blockchain_storage.get_current_hard_fork_version();
|
||||
const size_t max_tx_version = (version < HF_VERSION_SLIPPAGE_YIELD) ? 2 : CURRENT_TRANSACTION_VERSION;
|
||||
uint8_t hf_version = m_blockchain_storage.get_current_hard_fork_version();
|
||||
const size_t max_tx_version = (hf_version >= HF_VERSION_ENABLE_N_OUTS) ? TRANSACTION_VERSION_N_OUTS : TRANSACTION_VERSION_2_OUTS;
|
||||
if (tx.version == 0 || tx.version > max_tx_version)
|
||||
{
|
||||
// v2 is the latest one we know
|
||||
@@ -1294,6 +1294,7 @@ namespace cryptonote
|
||||
std::vector<transaction> txs;
|
||||
std::vector<crypto::hash> missed_txs;
|
||||
uint64_t coinbase_amount = get_outs_money_amount(b.miner_tx);
|
||||
coinbase_amount += b.miner_tx.amount_burnt;
|
||||
this->get_transactions(b.tx_hashes, txs, missed_txs, true);
|
||||
uint64_t tx_fee_amount = 0;
|
||||
for(const auto& tx: txs)
|
||||
@@ -1829,7 +1830,7 @@ namespace cryptonote
|
||||
{
|
||||
std::string main_message;
|
||||
if (m_offline)
|
||||
main_message = "The daemon is running offline and will not attempt to sync to the Monero network.";
|
||||
main_message = "The daemon is running offline and will not attempt to sync to the Salvium network.";
|
||||
else
|
||||
main_message = "The daemon will start synchronizing with the network. This may take a long time to complete.";
|
||||
MGINFO_YELLOW(ENDL << "**********************************************************************" << ENDL
|
||||
@@ -1877,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
|
||||
@@ -1897,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;
|
||||
@@ -2072,7 +2073,7 @@ namespace cryptonote
|
||||
MDEBUG("blocks in the last " << seconds[n] / 60 << " minutes: " << b << " (probability " << p << ")");
|
||||
if (p < threshold)
|
||||
{
|
||||
MWARNING("There were " << b << (b == max_blocks_checked ? " or more" : "") << " blocks in the last " << seconds[n] / 60 << " minutes, there might be large hash rate changes, or we might be partitioned, cut off from the Monero network or under attack, or your computer's time is off. Or it could be just sheer bad luck.");
|
||||
MWARNING("There were " << b << (b == max_blocks_checked ? " or more" : "") << " blocks in the last " << seconds[n] / 60 << " minutes, there might be large hash rate changes, or we might be partitioned, cut off from the Salvium network or under attack, or your computer's time is off. Or it could be just sheer bad luck.");
|
||||
|
||||
std::shared_ptr<tools::Notify> block_rate_notify = m_block_rate_notify;
|
||||
if (block_rate_notify)
|
||||
|
||||
@@ -46,6 +46,11 @@ using namespace epee;
|
||||
#include "ringct/rctSigs.h"
|
||||
#include "oracle/asset_types.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "crypto/keccak.h"
|
||||
#include "crypto/crypto-ops.h"
|
||||
}
|
||||
using namespace crypto;
|
||||
|
||||
namespace cryptonote
|
||||
@@ -583,6 +588,7 @@ namespace cryptonote
|
||||
// Different forks take a different proportion of the block_reward for stakers
|
||||
switch (hard_fork_version) {
|
||||
case HF_VERSION_BULLETPROOF_PLUS:
|
||||
case HF_VERSION_ENABLE_N_OUTS:
|
||||
// SRCG: subtract 20% that will be rewarded to staking users
|
||||
CHECK_AND_ASSERT_MES(tx.amount_burnt == 0, false, "while creating outs: amount_burnt is nonzero");
|
||||
tx.amount_burnt = amount / 5;
|
||||
@@ -653,8 +659,11 @@ namespace cryptonote
|
||||
tx.set_null();
|
||||
amount_keys.clear();
|
||||
|
||||
if (hf_version >= HF_VERSION_SLIPPAGE_YIELD) {
|
||||
tx.version = 3;
|
||||
tx.type = (tx_type == cryptonote::transaction_type::RETURN) ? cryptonote::TRANSFER : tx_type;
|
||||
|
||||
// Configure the correct TX version for the current HF + TX type
|
||||
if (hf_version >= HF_VERSION_ENABLE_N_OUTS && tx.type == cryptonote::transaction_type::TRANSFER) {
|
||||
tx.version = TRANSACTION_VERSION_N_OUTS;
|
||||
} else {
|
||||
tx.version = 2;
|
||||
}
|
||||
@@ -662,8 +671,6 @@ namespace cryptonote
|
||||
tx.extra = extra;
|
||||
crypto::public_key txkey_pub;
|
||||
|
||||
tx.type = (tx_type == cryptonote::transaction_type::RETURN) ? cryptonote::TRANSFER : tx_type;
|
||||
|
||||
tx.source_asset_type = source_asset;
|
||||
tx.destination_asset_type = dest_asset;
|
||||
|
||||
@@ -849,7 +856,7 @@ namespace cryptonote
|
||||
uint64_t summary_outs_money = 0;
|
||||
//fill outputs
|
||||
size_t output_index = 0;
|
||||
size_t change_index = 0;
|
||||
uint8_t change_index = 0;
|
||||
for(const tx_destination_entry& dst_entr: destinations)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(dst_entr.amount > 0 || tx.version > 1, false, "Destination with wrong amount: " << dst_entr.amount);
|
||||
@@ -891,7 +898,7 @@ namespace cryptonote
|
||||
need_additional_txkeys, additional_tx_keys,
|
||||
additional_tx_public_keys, amount_keys, out_eph_public_key,
|
||||
use_view_tags, view_tag);
|
||||
|
||||
|
||||
tx_out out;
|
||||
cryptonote::set_tx_out(dst_entr.amount, dst_entr.asset_type, dst_entr.is_change ? 0 : unlock_time, out_eph_public_key, use_view_tags, view_tag, out);
|
||||
tx.vout.push_back(out);
|
||||
@@ -902,7 +909,51 @@ namespace cryptonote
|
||||
|
||||
remove_field_from_tx_extra(tx.extra, typeid(tx_extra_additional_pub_keys));
|
||||
|
||||
if (tx.type == cryptonote::transaction_type::TRANSFER || tx.type == cryptonote::transaction_type::STAKE) {
|
||||
if (hf_version >= HF_VERSION_ENABLE_N_OUTS && tx.type == cryptonote::transaction_type::TRANSFER) {
|
||||
|
||||
// Get the output public key for the change output
|
||||
crypto::public_key P_change = crypto::null_pkey;
|
||||
CHECK_AND_ASSERT_MES(tx.vout.size() >= 2, false, "Internal error - too few outputs for TRANSFER tx");
|
||||
CHECK_AND_ASSERT_MES(cryptonote::get_output_public_key(tx.vout[change_index], P_change), false, "Internal error - failed to get TX change output public key");
|
||||
CHECK_AND_ASSERT_MES(P_change != crypto::null_pkey, false, "Internal error - not found TX change output for TRANSFER tx");
|
||||
|
||||
// Calculate the F points and change mask for every destination
|
||||
for (size_t op_index=0; op_index<tx.vout.size(); ++op_index) {
|
||||
|
||||
// Calculate the y value for return_payment support
|
||||
ec_scalar y;
|
||||
struct {
|
||||
char domain_separator[8];
|
||||
rct::key amount_key;
|
||||
} buf;
|
||||
std::memset(buf.domain_separator, 0x0, sizeof(buf.domain_separator));
|
||||
std::strncpy(buf.domain_separator, "RETURN", 7);
|
||||
buf.amount_key = amount_keys[op_index];
|
||||
crypto::hash_to_scalar(&buf, sizeof(buf), y);
|
||||
|
||||
// Now generate the return address (and TX pubkey, although we will discard that)
|
||||
crypto::public_key F = crypto::null_pkey;
|
||||
crypto::public_key F_txpubkey = crypto::null_pkey;
|
||||
CHECK_AND_ASSERT_MES(get_return_address(tx.version, tx.type, y, sender_account_keys, P_change, additional_tx_public_keys[op_index], F, F_txpubkey, hwdev), false, "Failed to get return_address");
|
||||
|
||||
// Push the F point into the TX vector of F points
|
||||
tx.return_address_list.push_back(F);
|
||||
|
||||
// Calculate the encrypted_change_index data for this output
|
||||
struct {
|
||||
char domain_separator[8];
|
||||
rct::key amount_key;
|
||||
} eci_buf;
|
||||
std::memset(eci_buf.domain_separator, 0x0, sizeof(buf.domain_separator));
|
||||
std::strncpy(eci_buf.domain_separator, "CHG_IDX", 8);
|
||||
eci_buf.amount_key = amount_keys[op_index];
|
||||
crypto::secret_key eci_out;
|
||||
keccak((uint8_t *)&eci_buf, sizeof(eci_buf), (uint8_t*)&eci_out, sizeof(eci_out));
|
||||
uint8_t eci_data = change_index ^ eci_out.data[0];
|
||||
tx.return_address_change_mask.push_back(eci_data);
|
||||
}
|
||||
|
||||
} else if (tx.type == cryptonote::transaction_type::TRANSFER || tx.type == cryptonote::transaction_type::STAKE) {
|
||||
|
||||
// Get the output public key for the change output
|
||||
crypto::public_key P_change = crypto::null_pkey;
|
||||
@@ -1236,29 +1287,16 @@ namespace cryptonote
|
||||
|
||||
bool get_block_longhash(const Blockchain *pbc, const blobdata& bd, crypto::hash& res, const uint64_t height, const int major_version, const crypto::hash *seed_hash, const int miners)
|
||||
{
|
||||
// block 202612 bug workaround
|
||||
if (height == 202612)
|
||||
crypto::hash hash;
|
||||
if (pbc != NULL)
|
||||
{
|
||||
static const std::string longhash_202612 = "84f64766475d51837ac9efbef1926486e58563c95a19fef4aec3254f03000000";
|
||||
epee::string_tools::hex_to_pod(longhash_202612, res);
|
||||
return true;
|
||||
}
|
||||
if (major_version >= RX_BLOCK_VERSION)
|
||||
const uint64_t seed_height = rx_seedheight(height);
|
||||
hash = seed_hash ? *seed_hash : pbc->get_pending_block_id_by_height(seed_height);
|
||||
} else
|
||||
{
|
||||
crypto::hash hash;
|
||||
if (pbc != NULL)
|
||||
{
|
||||
const uint64_t seed_height = rx_seedheight(height);
|
||||
hash = seed_hash ? *seed_hash : pbc->get_pending_block_id_by_height(seed_height);
|
||||
} else
|
||||
{
|
||||
memset(&hash, 0, sizeof(hash)); // only happens when generating genesis block
|
||||
}
|
||||
rx_slow_hash(hash.data, bd.data(), bd.size(), res.data);
|
||||
} else {
|
||||
const int pow_variant = major_version >= 7 ? major_version - 6 : 0;
|
||||
crypto::cn_slow_hash(bd.data(), bd.size(), res, pow_variant, height);
|
||||
memset(&hash, 0, sizeof(hash)); // only happens when generating genesis block
|
||||
}
|
||||
rx_slow_hash(hash.data, bd.data(), bd.size(), res.data);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ namespace cryptonote
|
||||
FIELD(original)
|
||||
VARINT_FIELD(amount)
|
||||
FIELD(addr)
|
||||
FIELD(asset_type)
|
||||
FIELD(is_subaddress)
|
||||
FIELD(is_integrated)
|
||||
FIELD(is_change)
|
||||
|
||||
@@ -259,7 +259,14 @@ namespace cryptonote
|
||||
tvc.m_invalid_output = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check the TX type
|
||||
if (!m_blockchain.check_tx_type_and_version(tx, tvc)) {
|
||||
LOG_PRINT_L1("Transaction with id= "<< id << " has invalid type " << (uint8_t)tx.type << " and/or version " << tx.version);
|
||||
tvc.m_verifivation_failed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// assume failure during verification steps until success is certain
|
||||
tvc.m_verifivation_failed = true;
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ bool ver_rct_non_semantics_simple_cached
|
||||
// mixring. Future versions of the protocol may differ in this regard, but if this assumptions
|
||||
// holds true in the future, enable the verification hash by modifying the `untested_tx`
|
||||
// condition below.
|
||||
const bool untested_tx = tx.version > 2 || tx.rct_signatures.type > rct::RCTTypeBulletproofPlus;
|
||||
const bool untested_tx = tx.version > 3 || tx.rct_signatures.type > rct::RCTTypeBulletproofPlus;
|
||||
VER_ASSERT(!untested_tx, "Unknown TX type. Make sure RCT cache works correctly with this type and then enable it in the code here.");
|
||||
|
||||
// Don't cache older (or newer) rctSig types
|
||||
|
||||
@@ -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) << ") "
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace cryptonote
|
||||
CONVERT = 4,
|
||||
BURN = 5,
|
||||
STAKE = 6,
|
||||
RETURN = 7
|
||||
RETURN = 7,
|
||||
MAX = 7
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace daemon_args
|
||||
{
|
||||
std::string const WINDOWS_SERVICE_NAME = "Monero Daemon";
|
||||
std::string const WINDOWS_SERVICE_NAME = "Salvium Daemon";
|
||||
|
||||
const command_line::arg_descriptor<std::string, false, true, 2> arg_config_file = {
|
||||
"config-file"
|
||||
|
||||
@@ -45,8 +45,8 @@ const hardfork_t testnet_hard_forks[] = {
|
||||
// version 1 from the start of the blockchain
|
||||
{ 1, 1, 0, 1341378000 },
|
||||
|
||||
// version 2 starts from block 1000, which is on or around the 23rd of November, 2015. Fork time finalised on 2015-11-20. No fork voting occurs for the v2 fork.
|
||||
//{ 2, 1000, 0, 1445355000 },
|
||||
// version 2 starts from block 250
|
||||
{ 2, 250, 0, 1445355000 },
|
||||
};
|
||||
const size_t num_testnet_hard_forks = sizeof(testnet_hard_forks) / sizeof(testnet_hard_forks[0]);
|
||||
const uint64_t testnet_hard_fork_version_1_till = ((uint64_t)-1);
|
||||
|
||||
+3
-4
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2016-2022, The Monero Project
|
||||
# Copyright (c) 2016-2023, The Monero Project
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, The Monero Project
|
||||
// Copyright (c) 2017-2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, The Monero Project
|
||||
// Copyright (c) 2017-2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, The Monero Project
|
||||
// Copyright (c) 2017-2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, The Monero Project
|
||||
// Copyright (c) 2017-2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
||||
+44
-42
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, The Monero Project
|
||||
// Copyright (c) 2017-2023, The Monero Project
|
||||
|
||||
//
|
||||
// All rights reserved.
|
||||
@@ -57,28 +57,28 @@ extern "C"
|
||||
// 1 1 52.8 70.4 70.2
|
||||
|
||||
// Pippenger:
|
||||
// 1 2 3 4 5 6 7 8 9 bestN
|
||||
// 2 555 598 621 804 1038 1733 2486 5020 8304 1
|
||||
// 4 783 747 800 1006 1428 2132 3285 5185 9806 2
|
||||
// 8 1174 1071 1095 1286 1640 2398 3869 6378 12080 2
|
||||
// 16 2279 1874 1745 1739 2144 2831 4209 6964 12007 4
|
||||
// 32 3910 3706 2588 2477 2782 3467 4856 7489 12618 4
|
||||
// 64 7184 5429 4710 4368 4010 4672 6027 8559 13684 5
|
||||
// 128 14097 10574 8452 7297 6841 6718 8615 10580 15641 6
|
||||
// 256 27715 20800 16000 13550 11875 11400 11505 14090 18460 6
|
||||
// 512 55100 41250 31740 26570 22030 19830 20760 21380 25215 6
|
||||
// 1024 111520 79000 61080 49720 43080 38320 37600 35040 36750 8
|
||||
// 2048 219480 162680 122120 102080 83760 70360 66600 63920 66160 8
|
||||
// 4096 453320 323080 247240 210200 180040 150240 132440 114920 110560 9
|
||||
// 1 2 3 4 5 6 7 8 9 bestN
|
||||
// 2 555 598 621 804 1038 1733 2486 5020 8304 1
|
||||
// 4 783 747 800 1006 1428 2132 3285 5185 9806 2
|
||||
// 8 1174 1071 1095 1286 1640 2398 3869 6378 12080 2
|
||||
// 16 2279 1874 1745 1739 2144 2831 4209 6964 12007 4
|
||||
// 32 3910 3706 2588 2477 2782 3467 4856 7489 12618 4
|
||||
// 64 7184 5429 4710 4368 4010 4672 6027 8559 13684 5
|
||||
// 128 14097 10574 8452 7297 6841 6718 8615 10580 15641 6
|
||||
// 256 27715 20800 16000 13550 11875 11400 11505 14090 18460 6
|
||||
// 512 55100 41250 31740 26570 22030 19830 20760 21380 25215 6
|
||||
// 1024 111520 79000 61080 49720 43080 38320 37600 35040 36750 8
|
||||
// 2048 219480 162680 122120 102080 83760 70360 66600 63920 66160 8
|
||||
// 4096 453320 323080 247240 210200 180040 150240 132440 114920 110560 9
|
||||
|
||||
// 2 4 8 16 32 64 128 256 512 1024 2048 4096
|
||||
// Bos Coster 858 994 1316 1949 3183 5512 9865 17830 33485 63160 124280 246320
|
||||
// Straus 226 341 548 980 1870 3538 7039 14490 29020 57200 118640 233640
|
||||
// Straus/cached 226 315 485 785 1514 2858 5753 11065 22970 45120 98880 194840
|
||||
// Pippenger 555 747 1071 1739 2477 4010 6718 11400 19830 35040 63920 110560
|
||||
// 2 4 8 16 32 64 128 256 512 1024 2048 4096
|
||||
// Bos Coster 858 994 1316 1949 3183 5512 9865 17830 33485 63160 124280 246320
|
||||
// Straus 226 341 548 980 1870 3538 7039 14490 29020 57200 118640 233640
|
||||
// Straus/cached 226 315 485 785 1514 2858 5753 11065 22970 45120 98880 194840
|
||||
// Pippenger 555 747 1071 1739 2477 4010 6718 11400 19830 35040 63920 110560
|
||||
|
||||
// Best/cached Straus Straus Straus Straus Straus Straus Straus Straus Pip Pip Pip Pip
|
||||
// Best/uncached Straus Straus Straus Straus Straus Straus Pip Pip Pip Pip Pip Pip
|
||||
// Best/cached Straus Straus Straus Straus Straus Straus Straus Straus Pip Pip Pip Pip
|
||||
// Best/uncached Straus Straus Straus Straus Straus Straus Pip Pip Pip Pip Pip Pip
|
||||
|
||||
// New timings:
|
||||
// Pippenger:
|
||||
@@ -443,7 +443,7 @@ size_t straus_get_cache_size(const std::shared_ptr<straus_cached_data> &cache)
|
||||
return sz;
|
||||
}
|
||||
|
||||
rct::key straus(const std::vector<MultiexpData> &data, const std::shared_ptr<straus_cached_data> &cache, size_t STEP)
|
||||
ge_p3 straus_p3(const std::vector<MultiexpData> &data, const std::shared_ptr<straus_cached_data> &cache, size_t STEP)
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(cache == NULL || cache->size >= data.size(), "Cache is too small");
|
||||
MULTIEXP_PERF(PERF_TIMER_UNIT(straus, 1000000));
|
||||
@@ -554,7 +554,13 @@ skipfirst:
|
||||
ge_p1p1_to_p3(&res_p3, &p1);
|
||||
}
|
||||
|
||||
return res_p3;
|
||||
}
|
||||
|
||||
rct::key straus(const std::vector<MultiexpData> &data, const std::shared_ptr<straus_cached_data> &cache, size_t STEP)
|
||||
{
|
||||
rct::key res;
|
||||
const ge_p3 res_p3 = straus_p3(data, cache, STEP);
|
||||
ge_p3_tobytes(res.bytes, &res_p3);
|
||||
return res;
|
||||
}
|
||||
@@ -571,14 +577,6 @@ size_t get_pippenger_c(size_t N)
|
||||
return 9;
|
||||
}
|
||||
|
||||
struct pippenger_cached_data
|
||||
{
|
||||
size_t size;
|
||||
ge_cached *cached;
|
||||
pippenger_cached_data(): size(0), cached(NULL) {}
|
||||
~pippenger_cached_data() { aligned_free(cached); }
|
||||
};
|
||||
|
||||
std::shared_ptr<pippenger_cached_data> pippenger_init_cache(const std::vector<MultiexpData> &data, size_t start_offset, size_t N)
|
||||
{
|
||||
MULTIEXP_PERF(PERF_TIMER_START_UNIT(pippenger_init_cache, 1000000));
|
||||
@@ -586,13 +584,11 @@ std::shared_ptr<pippenger_cached_data> pippenger_init_cache(const std::vector<Mu
|
||||
if (N == 0)
|
||||
N = data.size() - start_offset;
|
||||
CHECK_AND_ASSERT_THROW_MES(N <= data.size() - start_offset, "Bad cache base data");
|
||||
std::shared_ptr<pippenger_cached_data> cache(new pippenger_cached_data());
|
||||
std::shared_ptr<pippenger_cached_data> cache = std::make_shared<pippenger_cached_data>();
|
||||
|
||||
cache->size = N;
|
||||
cache->cached = (ge_cached*)aligned_realloc(cache->cached, N * sizeof(ge_cached), 4096);
|
||||
CHECK_AND_ASSERT_THROW_MES(cache->cached, "Out of memory");
|
||||
cache->resize(N);
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
ge_p3_to_cached(&cache->cached[i], &data[i+start_offset].point);
|
||||
ge_p3_to_cached(&(*cache)[i], &data[i+start_offset].point);
|
||||
|
||||
MULTIEXP_PERF(PERF_TIMER_STOP(pippenger_init_cache));
|
||||
return cache;
|
||||
@@ -600,14 +596,14 @@ std::shared_ptr<pippenger_cached_data> pippenger_init_cache(const std::vector<Mu
|
||||
|
||||
size_t pippenger_get_cache_size(const std::shared_ptr<pippenger_cached_data> &cache)
|
||||
{
|
||||
return cache->size * sizeof(*cache->cached);
|
||||
return cache->size() * sizeof(ge_cached);
|
||||
}
|
||||
|
||||
rct::key pippenger(const std::vector<MultiexpData> &data, const std::shared_ptr<pippenger_cached_data> &cache, size_t cache_size, size_t c)
|
||||
ge_p3 pippenger_p3(const std::vector<MultiexpData> &data, const std::shared_ptr<pippenger_cached_data> &cache, size_t cache_size, size_t c)
|
||||
{
|
||||
if (cache != NULL && cache_size == 0)
|
||||
cache_size = cache->size;
|
||||
CHECK_AND_ASSERT_THROW_MES(cache == NULL || cache_size <= cache->size, "Cache is too small");
|
||||
cache_size = cache->size();
|
||||
CHECK_AND_ASSERT_THROW_MES(cache == NULL || cache_size <= cache->size(), "Cache is too small");
|
||||
if (c == 0)
|
||||
c = get_pippenger_c(data.size());
|
||||
CHECK_AND_ASSERT_THROW_MES(c <= 9, "c is too large");
|
||||
@@ -661,9 +657,9 @@ rct::key pippenger(const std::vector<MultiexpData> &data, const std::shared_ptr<
|
||||
if (buckets_init[bucket])
|
||||
{
|
||||
if (i < cache_size)
|
||||
add(buckets[bucket], local_cache->cached[i]);
|
||||
add(buckets[bucket], (*local_cache)[i]);
|
||||
else
|
||||
add(buckets[bucket], local_cache_2->cached[i - cache_size]);
|
||||
add(buckets[bucket], (*local_cache_2)[i - cache_size]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -700,8 +696,14 @@ rct::key pippenger(const std::vector<MultiexpData> &data, const std::shared_ptr<
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rct::key pippenger(const std::vector<MultiexpData> &data, const std::shared_ptr<pippenger_cached_data> &cache, const size_t cache_size, const size_t c)
|
||||
{
|
||||
rct::key res;
|
||||
ge_p3_tobytes(res.bytes, &result);
|
||||
const ge_p3 result_p3 = pippenger_p3(data, cache, cache_size, c);
|
||||
ge_p3_tobytes(res.bytes, &result_p3);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, The Monero Project
|
||||
// Copyright (c) 2017-2023, The Monero Project
|
||||
|
||||
//
|
||||
// All rights reserved.
|
||||
@@ -35,10 +35,16 @@
|
||||
#define MULTIEXP_H
|
||||
|
||||
#include <vector>
|
||||
extern "C"
|
||||
{
|
||||
#include "crypto/crypto-ops.h"
|
||||
}
|
||||
#include "crypto/crypto.h"
|
||||
#include "rctTypes.h"
|
||||
#include "misc_log_ex.h"
|
||||
|
||||
#include <boost/align/aligned_allocator.hpp>
|
||||
|
||||
namespace rct
|
||||
{
|
||||
|
||||
@@ -55,17 +61,19 @@ struct MultiexpData {
|
||||
};
|
||||
|
||||
struct straus_cached_data;
|
||||
struct pippenger_cached_data;
|
||||
using pippenger_cached_data = std::vector<ge_cached, boost::alignment::aligned_allocator<ge_cached, 4096>>;
|
||||
|
||||
rct::key bos_coster_heap_conv(std::vector<MultiexpData> data);
|
||||
rct::key bos_coster_heap_conv_robust(std::vector<MultiexpData> data);
|
||||
std::shared_ptr<straus_cached_data> straus_init_cache(const std::vector<MultiexpData> &data, size_t N =0);
|
||||
size_t straus_get_cache_size(const std::shared_ptr<straus_cached_data> &cache);
|
||||
ge_p3 straus_p3(const std::vector<MultiexpData> &data, const std::shared_ptr<straus_cached_data> &cache = NULL, size_t STEP = 0);
|
||||
rct::key straus(const std::vector<MultiexpData> &data, const std::shared_ptr<straus_cached_data> &cache = NULL, size_t STEP = 0);
|
||||
std::shared_ptr<pippenger_cached_data> pippenger_init_cache(const std::vector<MultiexpData> &data, size_t start_offset = 0, size_t N =0);
|
||||
size_t pippenger_get_cache_size(const std::shared_ptr<pippenger_cached_data> &cache);
|
||||
size_t get_pippenger_c(size_t N);
|
||||
rct::key pippenger(const std::vector<MultiexpData> &data, const std::shared_ptr<pippenger_cached_data> &cache = NULL, size_t cache_size = 0, size_t c = 0);
|
||||
ge_p3 pippenger_p3(const std::vector<MultiexpData> &data, const std::shared_ptr<pippenger_cached_data> &cache = NULL, size_t cache_size = 0, size_t c = 0);
|
||||
rct::key pippenger(const std::vector<MultiexpData> &data, const std::shared_ptr<pippenger_cached_data> &cache = NULL, const size_t cache_size = 0, const size_t c = 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014-2022, The Monero Project
|
||||
// Copyright (c) 2014-2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014-2022, The Monero Project
|
||||
// Copyright (c) 2014-2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2016, Monero Research Labs
|
||||
// Copyright (c) 2016-2023, Monero Research Labs
|
||||
//
|
||||
// Author: Shen Noether <shen.noether@gmx.com>
|
||||
//
|
||||
@@ -671,7 +671,7 @@ namespace rct {
|
||||
|
||||
//Elliptic Curve Diffie Helman: encodes and decodes the amount b and mask a
|
||||
// where C= aG + bH
|
||||
static key ecdhHash(const key &k)
|
||||
key genAmountEncodingFactor(const key &k)
|
||||
{
|
||||
char data[38];
|
||||
rct::key hash;
|
||||
@@ -700,7 +700,7 @@ namespace rct {
|
||||
if (v2)
|
||||
{
|
||||
unmasked.mask = zero();
|
||||
xor8(unmasked.amount, ecdhHash(sharedSec));
|
||||
xor8(unmasked.amount, genAmountEncodingFactor(sharedSec));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -715,7 +715,7 @@ namespace rct {
|
||||
if (v2)
|
||||
{
|
||||
masked.mask = genCommitmentMask(sharedSec);
|
||||
xor8(masked.amount, ecdhHash(sharedSec));
|
||||
xor8(masked.amount, genAmountEncodingFactor(sharedSec));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
//#define DBG
|
||||
// Copyright (c) 2016, Monero Research Labs
|
||||
// Copyright (c) 2016-2023, Monero Research Labs
|
||||
//
|
||||
// Author: Shen Noether <shen.noether@gmx.com>
|
||||
//
|
||||
@@ -184,6 +184,7 @@ namespace rct {
|
||||
|
||||
//Elliptic Curve Diffie Helman: encodes and decodes the amount b and mask a
|
||||
// where C= aG + bH
|
||||
key genAmountEncodingFactor(const key &k);
|
||||
key genCommitmentMask(const key &sk);
|
||||
void ecdhEncode(ecdhTuple & unmasked, const key & sharedSec, bool v2);
|
||||
void ecdhDecode(ecdhTuple & masked, const key & sharedSec, bool v2);
|
||||
|
||||
+38
-14
@@ -2982,13 +2982,13 @@ namespace cryptonote
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_get_circulating_supply(const COMMAND_RPC_GET_CIRCULATING_SUPPLY::request& req, COMMAND_RPC_GET_CIRCULATING_SUPPLY::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
||||
bool core_rpc_server::on_get_supply_info(const COMMAND_RPC_GET_SUPPLY_INFO::request& req, COMMAND_RPC_GET_SUPPLY_INFO::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
||||
{
|
||||
PERF_TIMER(on_get_circulating_supply);
|
||||
PERF_TIMER(on_get_supply_info);
|
||||
std::map<std::string, uint64_t> amounts = m_core.get_blockchain_storage().get_db().get_circulating_supply();
|
||||
for (const auto &i: amounts)
|
||||
{
|
||||
COMMAND_RPC_GET_CIRCULATING_SUPPLY::supply_entry se(i.first, std::to_string(i.second));
|
||||
COMMAND_RPC_GET_SUPPLY_INFO::supply_entry se(i.first, std::to_string(i.second));
|
||||
res.supply_tally.push_back(se);
|
||||
}
|
||||
res.height = m_core.get_current_blockchain_height();
|
||||
@@ -3006,20 +3006,44 @@ namespace cryptonote
|
||||
return true;
|
||||
}
|
||||
// Iterate over the cache, supplying the data in a more accessible format
|
||||
res.total_burnt = res.total_staked = res.total_yield = res.yield_per_stake = 0;
|
||||
res.yield_data.clear();
|
||||
for (const auto& entry: ybi_cache) {
|
||||
// Skip this entry if out-of=range
|
||||
|
||||
// Check for last entry
|
||||
if (entry.first == height - 1) {
|
||||
res.total_staked = entry.second.locked_coins_tally;
|
||||
if (entry.second.locked_coins_tally > 0) {
|
||||
boost::multiprecision::uint128_t yield_per_stake = entry.second.slippage_total_this_block;
|
||||
yield_per_stake *= COIN;
|
||||
yield_per_stake /= entry.second.locked_coins_tally;
|
||||
res.yield_per_stake = yield_per_stake.convert_to<uint64_t>();
|
||||
}
|
||||
}
|
||||
|
||||
// Skip this entry if out-of-range
|
||||
if (req.from_height > 0 and entry.first < req.from_height) continue;
|
||||
if (req.to_height > 0 and entry.first > req.to_height) continue;
|
||||
|
||||
// Clone the data into the response
|
||||
COMMAND_RPC_GET_YIELD_INFO::yield_data_t yd;
|
||||
yd.block_height = entry.second.block_height;
|
||||
yd.slippage_total_this_block = entry.second.slippage_total_this_block;
|
||||
yd.locked_coins_this_block = entry.second.locked_coins_this_block;
|
||||
yd.locked_coins_tally = entry.second.locked_coins_tally;
|
||||
yd.network_health_percentage = entry.second.network_health_percentage;
|
||||
res.yield_data.push_back(yd);
|
||||
// Do we need to include raw data?
|
||||
if (req.include_raw_data) {
|
||||
|
||||
// Clone the data into the response
|
||||
COMMAND_RPC_GET_YIELD_INFO::yield_data_t yd;
|
||||
yd.block_height = entry.second.block_height;
|
||||
yd.slippage_total_this_block = entry.second.slippage_total_this_block;
|
||||
yd.locked_coins_this_block = entry.second.locked_coins_this_block;
|
||||
yd.locked_coins_tally = entry.second.locked_coins_tally;
|
||||
yd.network_health_percentage = entry.second.network_health_percentage;
|
||||
res.yield_data.push_back(yd);
|
||||
}
|
||||
|
||||
// Perform the aggregation
|
||||
if (entry.second.locked_coins_tally == 0) {
|
||||
res.total_burnt += entry.second.slippage_total_this_block;
|
||||
} else {
|
||||
res.total_yield += entry.second.slippage_total_this_block;
|
||||
}
|
||||
}
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
return true;
|
||||
@@ -3159,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";
|
||||
@@ -3180,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;
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace cryptonote
|
||||
MAP_JON_RPC_WE("get_output_histogram", on_get_output_histogram, COMMAND_RPC_GET_OUTPUT_HISTOGRAM)
|
||||
MAP_JON_RPC_WE("get_version", on_get_version, COMMAND_RPC_GET_VERSION)
|
||||
MAP_JON_RPC_WE_IF("get_coinbase_tx_sum", on_get_coinbase_tx_sum, COMMAND_RPC_GET_COINBASE_TX_SUM, !m_restricted)
|
||||
MAP_JON_RPC_WE("get_circulating_supply", on_get_circulating_supply, COMMAND_RPC_GET_CIRCULATING_SUPPLY)
|
||||
MAP_JON_RPC_WE("get_supply_info", on_get_supply_info, COMMAND_RPC_GET_SUPPLY_INFO)
|
||||
MAP_JON_RPC_WE("get_yield_info", on_get_yield_info, COMMAND_RPC_GET_YIELD_INFO)
|
||||
MAP_JON_RPC_WE("get_fee_estimate", on_get_base_fee_estimate, COMMAND_RPC_GET_BASE_FEE_ESTIMATE)
|
||||
MAP_JON_RPC_WE_IF("get_alternate_chains",on_get_alternate_chains, COMMAND_RPC_GET_ALTERNATE_CHAINS, !m_restricted)
|
||||
@@ -253,7 +253,7 @@ namespace cryptonote
|
||||
bool on_get_output_histogram(const COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request& req, COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||
bool on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||
bool on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||
bool on_get_circulating_supply(const COMMAND_RPC_GET_CIRCULATING_SUPPLY::request& req, COMMAND_RPC_GET_CIRCULATING_SUPPLY::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||
bool on_get_supply_info(const COMMAND_RPC_GET_SUPPLY_INFO::request& req, COMMAND_RPC_GET_SUPPLY_INFO::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||
bool on_get_yield_info(const COMMAND_RPC_GET_YIELD_INFO::request& req, COMMAND_RPC_GET_YIELD_INFO::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||
bool on_get_base_fee_estimate(const COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request& req, COMMAND_RPC_GET_BASE_FEE_ESTIMATE::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||
bool on_get_alternate_chains(const COMMAND_RPC_GET_ALTERNATE_CHAINS::request& req, COMMAND_RPC_GET_ALTERNATE_CHAINS::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||
|
||||
@@ -1294,10 +1294,12 @@ namespace cryptonote
|
||||
|
||||
struct request_t
|
||||
{
|
||||
bool include_raw_data;
|
||||
uint64_t from_height;
|
||||
uint64_t to_height;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_OPT(include_raw_data, false)
|
||||
KV_SERIALIZE_OPT(from_height, (uint64_t)0)
|
||||
KV_SERIALIZE_OPT(to_height, (uint64_t)0)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
@@ -1308,9 +1310,17 @@ namespace cryptonote
|
||||
struct response_t
|
||||
{
|
||||
std::string status;
|
||||
uint64_t total_burnt;
|
||||
uint64_t total_staked;
|
||||
uint64_t total_yield;
|
||||
uint64_t yield_per_stake;
|
||||
std::vector<COMMAND_RPC_GET_YIELD_INFO::yield_data_t> yield_data;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(status)
|
||||
KV_SERIALIZE(total_burnt)
|
||||
KV_SERIALIZE(total_staked)
|
||||
KV_SERIALIZE(total_yield)
|
||||
KV_SERIALIZE(yield_per_stake)
|
||||
KV_SERIALIZE(yield_data)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
@@ -1440,7 +1450,7 @@ namespace cryptonote
|
||||
typedef epee::misc_utils::struct_init<response_t> response;
|
||||
};
|
||||
|
||||
struct COMMAND_RPC_GET_CIRCULATING_SUPPLY
|
||||
struct COMMAND_RPC_GET_SUPPLY_INFO
|
||||
{
|
||||
struct request_t
|
||||
{
|
||||
|
||||
@@ -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)."), ""})
|
||||
|
||||
+2
-10
@@ -234,16 +234,8 @@ namespace cryptonote
|
||||
|
||||
block = is_current ? info.block : info.previous_block;
|
||||
*(uint32_t*)(hashing_blob.data() + 39) = SWAP32LE(nonce);
|
||||
if (block.major_version >= RX_BLOCK_VERSION)
|
||||
{
|
||||
const crypto::hash &seed_hash = is_current ? info.seed_hash : info.previous_seed_hash;
|
||||
crypto::rx_slow_hash(seed_hash.data, hashing_blob.data(), hashing_blob.size(), hash.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int cn_variant = hashing_blob[0] >= 7 ? hashing_blob[0] - 6 : 0;
|
||||
crypto::cn_slow_hash(hashing_blob.data(), hashing_blob.size(), hash, cn_variant, cryptonote::get_block_height(block));
|
||||
}
|
||||
const crypto::hash &seed_hash = is_current ? info.seed_hash : info.previous_seed_hash;
|
||||
crypto::rx_slow_hash(seed_hash.data, hashing_blob.data(), hashing_blob.size(), hash.data);
|
||||
if (!check_hash(hash, m_diff))
|
||||
{
|
||||
MWARNING("Payment too low");
|
||||
|
||||
@@ -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
|
||||
));
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace
|
||||
const char* USAGE_CHECK_SPEND_PROOF("check_spend_proof <txid> <signature_file> [<message>]");
|
||||
const char* USAGE_GET_RESERVE_PROOF("get_reserve_proof (all|<amount>) [<message>]");
|
||||
const char* USAGE_CHECK_RESERVE_PROOF("check_reserve_proof <address> <signature_file> [<message>]");
|
||||
const char* USAGE_SHOW_TRANSFERS("show_transfers [in|out|all|pending|failed|pool|coinbase] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]]");
|
||||
const char* USAGE_SHOW_TRANSFERS("show_transfers [in|out|all|pending|failed|pool|coinbase|burnt|staked|yield] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]]");
|
||||
const char* USAGE_UNSPENT_OUTPUTS("unspent_outputs [index=<N1>[,<N2>,...]] [<min_amount> [<max_amount>]]");
|
||||
const char* USAGE_RESCAN_BC("rescan_bc [hard|soft|keep_ki] [start_height=0]");
|
||||
const char* USAGE_SET_TX_NOTE("set_tx_note <txid> [free text note]");
|
||||
@@ -2349,7 +2349,7 @@ bool simple_wallet::welcome(const std::vector<std::string> &args)
|
||||
message_writer() << tr("Flaws in Salvium may be discovered in the future, and attacks may be developed to peek under some");
|
||||
message_writer() << tr("of the layers of privacy Salvium provides. Be safe and practice defense in depth.");
|
||||
message_writer() << "";
|
||||
message_writer() << tr("Welcome to Salvium and compliant financial privacy. For more information see https://salvium.network");
|
||||
message_writer() << tr("Welcome to Salvium and compliant financial privacy. For more information see https://salvium.io");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3222,7 +3222,7 @@ bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<st
|
||||
message_writer() << tr("\"price_info\" - Display current pricing information for supported assets.");
|
||||
message_writer() << tr("\"supply_info\" - Display circulating supply information.");
|
||||
message_writer() << tr("\"yield_info\" - Display current stats on Salvium staking / yield.");
|
||||
message_writer() << tr("\"show_transfers [in|out|pending|failed|pool|coinbase|burnt|yield]\" - Show transactions.");
|
||||
message_writer() << tr("\"show_transfers [in|out|pending|failed|pool|coinbase|burnt|staked|yield]\" - Show transactions.");
|
||||
message_writer() << tr("\"sweep_all <address>\" - Send whole balance to another wallet.");
|
||||
message_writer() << tr("\"seed\" - Show secret 25 words that can be used to recover this wallet.");
|
||||
message_writer() << tr("\"refresh\" - Synchronize wallet with the Salvium network.");
|
||||
@@ -3427,7 +3427,7 @@ simple_wallet::simple_wallet()
|
||||
m_cmd_binder.set_handler("donate",
|
||||
boost::bind(&simple_wallet::on_command, this, &simple_wallet::donate, _1),
|
||||
tr(USAGE_DONATE),
|
||||
tr("Donate <amount> to the development team (donate.salvium.network)."));
|
||||
tr("Donate <amount> to the development team (donate.salvium.io)."));
|
||||
m_cmd_binder.set_handler("sign_transfer",
|
||||
boost::bind(&simple_wallet::on_command, this, &simple_wallet::sign_transfer, _1),
|
||||
tr(USAGE_SIGN_TRANSFER),
|
||||
@@ -3606,15 +3606,16 @@ simple_wallet::simple_wallet()
|
||||
// Seemingly broken formatting to compensate for the backslash before the quotes.
|
||||
tr("Show the incoming/outgoing transfers within an optional height range.\n\n"
|
||||
"Output format:\n"
|
||||
"In or Coinbase: Block Number, \"block\"|\"in\", Time, Amount, Transaction Hash, Payment ID, Subaddress Index, \"-\", Note\n"
|
||||
"Out: Block Number, \"out\", Time, Amount*, Transaction Hash, Payment ID, Fee, Destinations, Input addresses**, \"-\", Note\n"
|
||||
"Pool: \"pool\", \"in\", Time, Amount, Transaction Hash, Payment Id, Subaddress Index, \"-\", Note, Double Spend Note\n"
|
||||
"Pending or Failed: \"failed\"|\"pending\", \"out\", Time, Amount*, Transaction Hash, Payment ID, Fee, Input addresses**, \"-\", Note\n\n"
|
||||
"In or Coinbase: Block Number, \"block\"|\"in\", Time, Amount, Asset Type, Transaction Hash, Payment ID, Subaddress Index, \"-\", Note\n"
|
||||
"Out: Block Number, \"out\", Time, Amount*, Asset Type, Transaction Hash, Payment ID, Fee, Destinations, Input addresses**, \"-\", Note\n"
|
||||
"Pool: \"pool\", \"in\", Time, Amount, Asset Type, Transaction Hash, Payment Id, Subaddress Index, \"-\", Note, Double Spend Note\n"
|
||||
"Pending or Failed: \"failed\"|\"pending\", \"out\", Time, Amount*, Transaction Hash, Payment ID, Fee, Input addresses**, \"-\", Note\n"
|
||||
"Staked or Burnt: Block Number, \"out\", Time, Amount*, Asset Type, Transaction Hash, Payment ID, Fee, Input addresses**, \"-\", Note\n\n"
|
||||
"* Excluding change and fee.\n"
|
||||
"** Set of address indices used as inputs in this transfer."));
|
||||
m_cmd_binder.set_handler("export_transfers",
|
||||
boost::bind(&simple_wallet::on_command, this, &simple_wallet::export_transfers, _1),
|
||||
tr("export_transfers [in|out|all|pending|failed|pool|coinbase|burnt|yield] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]] [output=<filepath>] [option=<with_keys>]"),
|
||||
tr("export_transfers [in|out|all|pending|failed|pool|coinbase|burnt|staked|yield] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]] [output=<filepath>] [option=<with_keys>]"),
|
||||
tr("Export to CSV the incoming/outgoing transfers within an optional height range."));
|
||||
m_cmd_binder.set_handler("unspent_outputs",
|
||||
boost::bind(&simple_wallet::on_command, this, &simple_wallet::unspent_outputs, _1),
|
||||
@@ -6591,9 +6592,11 @@ bool simple_wallet::process_ring_members(const std::vector<tools::wallet2::pendi
|
||||
ostr
|
||||
<< tr("\nWarning: Some input keys being spent are from ")
|
||||
<< (are_keys_from_same_tx ? tr("the same transaction") : tr("blocks that are temporally very close"))
|
||||
<< tr(", which can break the anonymity of ring signatures. Make sure this is intentional!");
|
||||
<< tr(", which can break the anonymity of ring signatures. Make sure this is intentional!\n")
|
||||
<< ENDL;
|
||||
}
|
||||
ostr << ENDL;
|
||||
if (verbose)
|
||||
ostr << ENDL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -6962,7 +6965,7 @@ bool simple_wallet::transfer_main(
|
||||
fail_msg_writer() << tr("failed to get blockchain height: ") << err;
|
||||
return false;
|
||||
}
|
||||
unlock_block = bc_height + locked_blocks;
|
||||
unlock_block = locked_blocks;
|
||||
ptx_vector = m_wallet->create_transactions_2(dsts, source_asset, dest_asset, cryptonote::transaction_type::TRANSFER, fake_outs_count, unlock_block /* unlock_time */, priority, extra, m_current_subaddress_account, subaddr_indices, subtract_fee_from_outputs);
|
||||
break;
|
||||
default:
|
||||
@@ -7092,7 +7095,7 @@ bool simple_wallet::transfer_main(
|
||||
if (transfer_type == TransferLocked)
|
||||
{
|
||||
float days = locked_blocks / 720.0f;
|
||||
prompt << boost::format(tr(".\nThis transaction (including %s change) will unlock on block %llu, in approximately %s days (assuming 2 minutes per block)")) % cryptonote::print_money(change) % ((unsigned long long)unlock_block) % days;
|
||||
prompt << boost::format(tr(".\nThis transaction (including %s change) will unlock in %llu blocks, approximately %s days (assuming 2 minutes per block)")) % cryptonote::print_money(change) % ((unsigned long long)unlock_block) % days;
|
||||
}
|
||||
if (!process_ring_members(ptx_vector, prompt, m_wallet->print_ring_members()))
|
||||
return false;
|
||||
@@ -7246,7 +7249,7 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
|
||||
// TODO: add locked versions
|
||||
if (args_.size() < 2)
|
||||
{
|
||||
PRINT_USAGE(USAGE_TRANSFER);
|
||||
PRINT_USAGE(USAGE_LOCKED_TRANSFER);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7272,7 +7275,7 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
|
||||
local_args.pop_back();
|
||||
}
|
||||
|
||||
transfer_main(Transfer, source_asset, source_asset, local_args, false);
|
||||
transfer_main(TransferLocked, source_asset, source_asset, local_args, false);
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@@ -7620,8 +7623,10 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, bool locked, co
|
||||
if (subaddr_indices.size() > 1)
|
||||
prompt << tr("WARNING: Outputs of multiple addresses are being used together, which might potentially compromise your privacy.\n");
|
||||
}
|
||||
|
||||
if (!process_ring_members(ptx_vector, prompt, m_wallet->print_ring_members()))
|
||||
return true;
|
||||
|
||||
if (ptx_vector.size() > 1) {
|
||||
prompt << boost::format(tr("Sweeping %s in %llu transactions for a total fee of %s. Is this okay?")) %
|
||||
print_money(total_sent) %
|
||||
@@ -8038,10 +8043,17 @@ bool simple_wallet::return_payment(const std::vector<std::string> &args_)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Verify we have a valid return_address and tx_pubkey
|
||||
if (td.m_tx.return_address == crypto::null_pkey || td.m_tx.return_pubkey != crypto::null_pkey) {
|
||||
fail_msg_writer() << tr("invalid return_address/return_pubkey for txid ") << args_[0];
|
||||
return true;
|
||||
if (td.m_tx.version >= HF_VERSION_ENABLE_N_OUTS) {
|
||||
if (td.m_tx.return_address_list.empty() || td.m_tx.return_address_change_mask.empty()) {
|
||||
fail_msg_writer() << tr("invalid return_address_list for txid ") << args_[0];
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Verify we have a valid return_address and tx_pubkey
|
||||
if (td.m_tx.return_address == crypto::null_pkey || td.m_tx.return_pubkey != crypto::null_pkey) {
|
||||
fail_msg_writer() << tr("invalid return_address/return_pubkey for txid ") << args_[0];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that we have the key image information, and that it is usable
|
||||
@@ -8370,7 +8382,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
|
||||
@@ -8389,68 +8401,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_yield = 0;
|
||||
for (size_t idx=1; idx<ybi_data.size(); ++idx) {
|
||||
total_yield += ybi_data[idx].slippage_total_this_block;
|
||||
}
|
||||
// Get the chain height
|
||||
const uint64_t blockchain_height = m_wallet->get_blockchain_current_height();
|
||||
|
||||
message_writer(console_color_default, false) << boost::format(tr("\nSTAKED FUNDS:"));
|
||||
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("YIELD INFO:\n\tTotal SAL supply: %d\n\tTotal coins locked: %d\n\tYield accrued over last %s: %d"))
|
||||
% print_money(total_supply_128.convert_to<uint64_t>())
|
||||
% print_money(ybi_data.back().locked_coins_tally)
|
||||
% get_human_readable_timespan((ybi_data.size()-1) * DIFFICULTY_TARGET_V2)
|
||||
% print_money(total_yield);
|
||||
|
||||
// Now summarise our own YIELD TXs that are yet to amture
|
||||
tools::wallet2::transfer_container transfers;
|
||||
m_wallet->get_transfers(transfers);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@@ -8508,7 +8494,7 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
|
||||
if (!payment_id_str.empty())
|
||||
local_args.push_back(payment_id_str);
|
||||
if (m_wallet->nettype() == cryptonote::MAINNET)
|
||||
message_writer() << (boost::format(tr("Donating %s %s to The Salvium Team (donate.salvium.network or %s).")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % SALVIUM_DONATION_ADDR).str();
|
||||
message_writer() << (boost::format(tr("Donating %s %s to The Salvium Team (donate.salvium.io or %s).")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % SALVIUM_DONATION_ADDR).str();
|
||||
else
|
||||
message_writer() << (boost::format(tr("Donating %s %s to %s.")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % address_str).str();
|
||||
transfer(local_args);
|
||||
@@ -9444,19 +9430,9 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
|
||||
if (!unlocked)
|
||||
{
|
||||
locked_msg = "locked";
|
||||
if (pd.m_unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER)
|
||||
{
|
||||
uint64_t bh = std::max(pd.m_unlock_time, pd.m_block_height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE);
|
||||
if (bh >= last_block_height)
|
||||
locked_msg = std::to_string(bh - last_block_height) + " blks";
|
||||
}
|
||||
else
|
||||
{
|
||||
const uint64_t adjusted_time = m_wallet->get_daemon_adjusted_time();
|
||||
uint64_t threshold = adjusted_time + (m_wallet->use_fork_rules(2, 0) ? CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2 : CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1);
|
||||
if (threshold < pd.m_unlock_time)
|
||||
locked_msg = get_human_readable_timespan(std::chrono::seconds(pd.m_unlock_time - threshold));
|
||||
}
|
||||
uint64_t bh = pd.m_block_height + std::max(pd.m_unlock_time, (uint64_t)CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE);
|
||||
if (bh >= last_block_height)
|
||||
locked_msg = std::to_string(bh - last_block_height) + " blks";
|
||||
}
|
||||
transfers.push_back({
|
||||
type,
|
||||
@@ -9465,7 +9441,7 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
|
||||
type,
|
||||
true,
|
||||
pd.m_amount,
|
||||
pd.m_asset_type,
|
||||
pd.m_asset_type,
|
||||
pd.m_tx_hash,
|
||||
payment_id,
|
||||
(pd.m_tx_type == cryptonote::transaction_type::STAKE) ? pd.m_fee : 0,
|
||||
@@ -9618,7 +9594,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
|
||||
std::vector<std::string> local_args = args_;
|
||||
|
||||
if(local_args.size() > 4) {
|
||||
fail_msg_writer() << tr("usage: show_transfers [in|out|all|pending|failed|pool|coinbase] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]]");
|
||||
fail_msg_writer() << tr("usage: show_transfers [in|out|all|pending|failed|pool|coinbase|burnt|staked|yield] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]]");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9677,7 +9653,7 @@ bool simple_wallet::export_transfers(const std::vector<std::string>& args_)
|
||||
std::vector<std::string> local_args = args_;
|
||||
|
||||
if(local_args.size() > 6) {
|
||||
fail_msg_writer() << tr("usage: export_transfers [in|out|all|pending|failed|pool|coinbase] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]] [output=<path>] [option=<with_keys>]");
|
||||
fail_msg_writer() << tr("usage: export_transfers [in|out|all|pending|failed|pool|coinbase|burnt|staked|yield] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]] [output=<path>] [option=<with_keys>]");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
#define DEF_SALVIUM_VERSION_TAG "7f6b8da"
|
||||
#define DEF_SALVIUM_VERSION "0.2.8"
|
||||
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
|
||||
#define DEF_SALVIUM_VERSION_TAG "@VERSIONTAG@"
|
||||
#define DEF_SALVIUM_VERSION "0.5.3-rc2"
|
||||
#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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -149,4 +149,9 @@ uint64_t TransactionInfoImpl::unlockTime() const
|
||||
return m_unlock_time;
|
||||
}
|
||||
|
||||
Monero::transaction_type TransactionInfoImpl::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -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,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
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -487,7 +487,7 @@ bool message_store::get_signer_index_by_monero_address(const cryptonote::account
|
||||
return true;
|
||||
}
|
||||
}
|
||||
MWARNING("No authorized signer with Monero address " << account_address_to_string(monero_address));
|
||||
MWARNING("No authorized signer with Salvium address " << account_address_to_string(monero_address));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+339
-82
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -2223,6 +2223,9 @@ void wallet2::scan_output(const cryptonote::transaction &tx, bool miner_tx, cons
|
||||
{
|
||||
tx_scan_info.money_transfered = tools::decodeRct(tx.rct_signatures, tx_scan_info.received->derivation, i, tx_scan_info.mask, m_account.get_device());
|
||||
}
|
||||
// SRCG: The following "if" block is commented out for a GOOD REASON...
|
||||
// 1. Monero doesn't care about 0 amounts, because they don't have a value or purpose.
|
||||
// 2. Salvium NEEDS to care about 0 amounts, because they are the CHANGE for a TX, and we need the CHANGE to accept RETURN_PAYMENTs.
|
||||
/*
|
||||
if (tx_scan_info.money_transfered == 0)
|
||||
{
|
||||
@@ -2231,6 +2234,9 @@ void wallet2::scan_output(const cryptonote::transaction &tx, bool miner_tx, cons
|
||||
return;
|
||||
}
|
||||
*/
|
||||
// Populate the unlock_time
|
||||
THROW_WALLET_EXCEPTION_IF(!cryptonote::get_output_unlock_time(tx.vout[i], tx_scan_info.unlock_time), error::wallet_internal_error, "failed to get output unlock_time");
|
||||
|
||||
outs.push_back(i);
|
||||
THROW_WALLET_EXCEPTION_IF(tx_money_got_in_outs[tx_scan_info.received->index][tx_scan_info.asset_type] >= std::numeric_limits<uint64_t>::max() - tx_scan_info.money_transfered,
|
||||
error::wallet_internal_error, "Overflow in received amounts");
|
||||
@@ -2323,10 +2329,10 @@ bool wallet2::get_pricing_record(oracle::pricing_record& pr, const uint64_t heig
|
||||
bool wallet2::get_circulating_supply(std::vector<std::pair<std::string, std::string>> &amounts)
|
||||
{
|
||||
// Issue an RPC call to get the block header (and thus the pricing record) at the specified height
|
||||
cryptonote::COMMAND_RPC_GET_CIRCULATING_SUPPLY::request req = AUTO_VAL_INIT(req);
|
||||
cryptonote::COMMAND_RPC_GET_CIRCULATING_SUPPLY::response res = AUTO_VAL_INIT(res);
|
||||
cryptonote::COMMAND_RPC_GET_SUPPLY_INFO::request req = AUTO_VAL_INIT(req);
|
||||
cryptonote::COMMAND_RPC_GET_SUPPLY_INFO::response res = AUTO_VAL_INIT(res);
|
||||
m_daemon_rpc_mutex.lock();
|
||||
bool r = invoke_http_json_rpc("/json_rpc", "get_circulating_supply", req, res, rpc_timeout);
|
||||
bool r = invoke_http_json_rpc("/json_rpc", "get_supply_info", req, res, rpc_timeout);
|
||||
m_daemon_rpc_mutex.unlock();
|
||||
if (r && res.status == CORE_RPC_STATUS_OK)
|
||||
{
|
||||
@@ -2338,7 +2344,7 @@ bool wallet2::get_circulating_supply(std::vector<std::pair<std::string, std::str
|
||||
}
|
||||
else
|
||||
{
|
||||
MERROR("Failed to retrieve circulating supply from daemon");
|
||||
MERROR("Failed to retrieve supply info from daemon");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2349,6 +2355,7 @@ bool wallet2::get_yield_info(std::vector<cryptonote::yield_block_info>& ybi_data
|
||||
cryptonote::COMMAND_RPC_GET_YIELD_INFO::request req = AUTO_VAL_INIT(req);
|
||||
cryptonote::COMMAND_RPC_GET_YIELD_INFO::response res = AUTO_VAL_INIT(res);
|
||||
m_daemon_rpc_mutex.lock();
|
||||
req.include_raw_data = true;
|
||||
bool r = invoke_http_json_rpc("/json_rpc", "get_yield_info", req, res, rpc_timeout);
|
||||
m_daemon_rpc_mutex.unlock();
|
||||
if (r && res.status == CORE_RPC_STATUS_OK)
|
||||
@@ -2373,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);
|
||||
@@ -2381,8 +2523,10 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
if (!miner_tx && !pool)
|
||||
process_unconfirmed(txid, tx, height);
|
||||
|
||||
std::string source_asset = tx.source_asset_type;
|
||||
std::string dest_asset = tx.destination_asset_type;
|
||||
std::string source_asset =
|
||||
(tx.type == cryptonote::transaction_type::MINER) ? "SAL" :
|
||||
(tx.type == cryptonote::transaction_type::PROTOCOL) ? "SAL" :
|
||||
tx.source_asset_type;
|
||||
|
||||
// per receiving subaddress index
|
||||
std::unordered_map<cryptonote::subaddress_index, std::map<std::string, uint64_t>> tx_money_got_in_outs;
|
||||
@@ -2406,7 +2550,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
size_t pk_index = 0;
|
||||
std::vector<tx_scan_info_t> tx_scan_info(tx.vout.size());
|
||||
std::deque<bool> output_found(tx.vout.size(), false);
|
||||
uint64_t total_received_1 = 0;
|
||||
std::map<std::string, uint64_t> total_received_1;
|
||||
uint64_t td_origin_idx = ((uint64_t)-1);
|
||||
while (!tx.vout.empty())
|
||||
{
|
||||
@@ -2542,12 +2686,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)
|
||||
@@ -2563,6 +2701,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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2671,7 +2822,11 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
if (!ignore_callbacks && 0 != m_callback)
|
||||
m_callback->on_money_received(height, txid, tx, td.m_amount, td.asset_type, 0, td.m_subaddr_index, spends_one_of_ours(tx), td.m_tx.unlock_time, td.m_td_origin_idx);
|
||||
}
|
||||
total_received_1 += amount;
|
||||
std::string asset_type = tx_scan_info[o].asset_type;
|
||||
if (total_received_1.count(asset_type))
|
||||
total_received_1[asset_type] += amount;
|
||||
else
|
||||
total_received_1[asset_type] = amount;
|
||||
notify = true;
|
||||
|
||||
if (tx.type == cryptonote::transaction_type::CONVERT || tx.type == cryptonote::transaction_type::STAKE) {
|
||||
@@ -2690,15 +2845,17 @@ 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}});
|
||||
}
|
||||
|
||||
} else if (tx.type == cryptonote::transaction_type::TRANSFER) {
|
||||
|
||||
// We might store garbage entries here occasionally, but they shouldn't impact performance significantly
|
||||
crypto::public_key P_change = crypto::null_pkey;
|
||||
size_t change_idx = m_transfers.back().m_internal_output_index;
|
||||
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});
|
||||
}
|
||||
}
|
||||
@@ -2782,7 +2939,11 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
if (!ignore_callbacks && 0 != m_callback)
|
||||
m_callback->on_money_received(height, txid, tx, td.m_amount, td.asset_type, burnt, td.m_subaddr_index, spends_one_of_ours(tx), td.m_tx.unlock_time, td.m_td_origin_idx);
|
||||
}
|
||||
total_received_1 += extra_amount;
|
||||
std::string asset_type = m_transfers.back().asset_type;
|
||||
if (total_received_1.count(asset_type))
|
||||
total_received_1[asset_type] += extra_amount;
|
||||
else
|
||||
total_received_1[asset_type] = extra_amount;
|
||||
notify = true;
|
||||
}
|
||||
}
|
||||
@@ -2967,51 +3128,84 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t total_received_2 = sub_change;
|
||||
std::map<std::string, uint64_t> total_received_2;
|
||||
for (auto& i : tx_money_got_in_outs)
|
||||
total_received_2 += i.second[source_asset];
|
||||
for (auto& asset: i.second)
|
||||
total_received_2[asset.first] += asset.second;
|
||||
|
||||
// only for regular transfers
|
||||
if (source_asset == dest_asset && !miner_tx) {
|
||||
if (total_received_1 != total_received_2)
|
||||
{
|
||||
const el::Level level = el::Level::Warning;
|
||||
MCLOG_RED(level, "global", "**********************************************************************");
|
||||
MCLOG_RED(level, "global", "Consistency failure in amounts received");
|
||||
MCLOG_RED(level, "global", "Check transaction " << txid);
|
||||
MCLOG_RED(level, "global", "**********************************************************************");
|
||||
exit(1);
|
||||
return;
|
||||
if (!miner_tx) {
|
||||
for (auto& asset: total_received_1) {
|
||||
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)
|
||||
//{
|
||||
const el::Level level = el::Level::Warning;
|
||||
MCLOG_RED(level, "global", "**********************************************************************");
|
||||
MCLOG_RED(level, "global", "Consistency failure in amounts received");
|
||||
MCLOG_RED(level, "global", "Check transaction " << txid);
|
||||
MCLOG_RED(level, "global", "**********************************************************************");
|
||||
exit(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool all_same = true;
|
||||
for (auto& i : tx_money_got_in_outs)
|
||||
{
|
||||
payment_details payment;
|
||||
payment.m_tx_hash = txid;
|
||||
payment.m_fee = fee;
|
||||
std::vector<payment_details> temp_payments;
|
||||
for (auto& tsi : tx_scan_info) {
|
||||
if (!tsi.received) continue;
|
||||
cryptonote::subaddress_index si = tsi.received->index;
|
||||
bool updated_payment = false;
|
||||
for (auto& payment : temp_payments) {
|
||||
if (payment.m_subaddr_index == si && payment.m_unlock_time == tsi.unlock_time) {
|
||||
// Add to existing payment
|
||||
payment.m_amount += tsi.amount;
|
||||
payment.m_amounts.push_back(tsi.amount);
|
||||
updated_payment = true;
|
||||
}
|
||||
if (updated_payment) break;
|
||||
}
|
||||
if (updated_payment) continue;
|
||||
|
||||
// Create a new payment
|
||||
temp_payments.push_back(payment_details{});
|
||||
payment_details& payment = temp_payments.back();
|
||||
payment.m_tx_hash = txid;
|
||||
payment.m_fee = fee;
|
||||
// SRCG - figure out what this needs to be (pretty sure we should never get here with CONVERT!)
|
||||
payment.m_amount = source_asset == dest_asset ? i.second[dest_asset] : tx.amount_burnt;
|
||||
payment.m_asset_type = (tx.type == cryptonote::transaction_type::PROTOCOL) ? "SAL" : dest_asset;
|
||||
payment.m_amounts = tx_amounts_individual_outs[i.first];
|
||||
payment.m_block_height = height;
|
||||
payment.m_unlock_time = tx.unlock_time; // SRCG: this is incorrect - work out which vout entry it is and query that
|
||||
payment.m_timestamp = ts;
|
||||
payment.m_coinbase = miner_tx;
|
||||
payment.m_subaddr_index = i.first;
|
||||
if (tx.type == cryptonote::transaction_type::PROTOCOL) {
|
||||
payment.m_amount = tsi.amount;
|
||||
payment.m_asset_type = tsi.asset_type;
|
||||
payment.m_amounts.push_back(tsi.amount);
|
||||
payment.m_block_height = height;
|
||||
payment.m_unlock_time = tsi.unlock_time;
|
||||
payment.m_timestamp = ts;
|
||||
payment.m_coinbase = miner_tx;
|
||||
payment.m_subaddr_index = si;
|
||||
if (tx.type == cryptonote::transaction_type::MINER) {
|
||||
|
||||
payment.m_unlock_time = CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW; // All protocol_tx payments are coinbase
|
||||
payment.m_tx_type = cryptonote::transaction_type::MINER;
|
||||
|
||||
} else if (tx.type == cryptonote::transaction_type::PROTOCOL) {
|
||||
|
||||
payment.m_unlock_time = CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW; // All protocol_tx payments are coinbase
|
||||
if (td_origin_idx != ((uint64_t)-1)) {
|
||||
// Get the origin TD information
|
||||
payment.m_amount = payment.m_amounts.empty() ? 0 : payment.m_amounts[0];
|
||||
payment.m_tx_type = m_transfers[td_origin_idx].m_tx.type;
|
||||
payment.m_fee = m_transfers[td_origin_idx].m_tx.amount_burnt;
|
||||
payment.m_amount = payment.m_amounts.empty() ? 0 : payment.m_amounts[0];
|
||||
payment.m_tx_type = m_transfers[td_origin_idx].m_tx.type;
|
||||
payment.m_fee = m_transfers[td_origin_idx].m_tx.amount_burnt;
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
payment.m_tx_type = tx.type;
|
||||
payment.m_tx_type = tx.type;
|
||||
}
|
||||
}
|
||||
|
||||
// Now iterate over the temp_payment entries
|
||||
for (auto& payment : temp_payments) {
|
||||
if (pool) {
|
||||
if (emplace_or_replace(m_unconfirmed_payments, payment_id, pool_payment_details{payment, double_spend_seen}))
|
||||
all_same = false;
|
||||
@@ -3022,7 +3216,6 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
m_payments.emplace(payment_id, payment);
|
||||
LOG_PRINT_L2("Payment found in " << (pool ? "pool" : "block") << ": " << payment_id << " / " << payment.m_tx_hash << " / " << payment.m_amount);
|
||||
}
|
||||
|
||||
// if it's a pool tx and we already had it, don't notify again
|
||||
if (pool && all_same)
|
||||
notify = false;
|
||||
@@ -6764,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;
|
||||
@@ -6863,14 +7056,16 @@ std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> wallet2::
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64_t unlock_height = td.m_block_height + std::max<uint64_t>(CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE, CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS);
|
||||
if (td.m_tx.unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER && td.m_tx.unlock_time > unlock_height)
|
||||
unlock_height = td.m_tx.unlock_time;
|
||||
if (td.m_tx.type == cryptonote::transaction_type::MINER)
|
||||
uint64_t unlock_height = 0;
|
||||
if (td.m_tx.type == cryptonote::transaction_type::MINER || td.m_tx.type == cryptonote::transaction_type::PROTOCOL)
|
||||
unlock_height = td.m_block_height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
|
||||
uint64_t unlock_time = td.m_tx.unlock_time >= CRYPTONOTE_MAX_BLOCK_NUMBER ? td.m_tx.unlock_time : 0;
|
||||
blocks_to_unlock = unlock_height > blockchain_height ? unlock_height - blockchain_height : 0;
|
||||
time_to_unlock = unlock_time > now ? unlock_time - now : 0;
|
||||
else {
|
||||
uint64_t unlock_blocks = 0;
|
||||
THROW_WALLET_EXCEPTION_IF(!cryptonote::get_output_unlock_time(td.m_tx.vout[td.m_internal_output_index], unlock_blocks), error::wallet_internal_error, "failed to get unlock_time");
|
||||
unlock_height = td.m_block_height + ((unlock_blocks > CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE) ? unlock_blocks : CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE);
|
||||
}
|
||||
blocks_to_unlock = (unlock_height > blockchain_height) ? unlock_height - blockchain_height : 0;
|
||||
time_to_unlock = 0;
|
||||
amount = 0;
|
||||
}
|
||||
auto found = amount_per_subaddr.find(td.m_subaddr_index.minor);
|
||||
@@ -10433,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));
|
||||
@@ -11102,8 +11298,9 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(uint64_t below
|
||||
|
||||
// gather all dust and non-dust outputs of specified subaddress (if any) and below specified threshold (if any)
|
||||
bool fund_found = false;
|
||||
for (size_t i = 0; i < m_transfers.size(); ++i)
|
||||
for (size_t idx = 0; idx < m_transfers_indices[asset_type].size(); idx++)
|
||||
{
|
||||
size_t i = m_transfers_indices[asset_type][idx];
|
||||
const transfer_details& td = m_transfers[i];
|
||||
if (m_ignore_fractional_outputs && td.amount() < fractional_threshold)
|
||||
{
|
||||
@@ -11187,24 +11384,86 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_return(std::vector
|
||||
uint32_t priority = adjust_priority(0);
|
||||
std::vector<uint8_t> extra; // No need for a TX extra beyond that which will be calculated herein
|
||||
|
||||
// To return a payment, we need to know the y value to process the F value
|
||||
// ...but the y value is calculated differently depending on the original TX
|
||||
ec_scalar y;
|
||||
crypto::public_key return_address = null_pkey;
|
||||
|
||||
// Get P_change from the TX
|
||||
crypto::public_key P_change = crypto::null_pkey;
|
||||
size_t change_index = (td_origin.m_internal_output_index == 0) ? 1 : 0;
|
||||
THROW_WALLET_EXCEPTION_IF(!cryptonote::get_output_public_key(td_origin.m_tx.vout[change_index], P_change), error::wallet_internal_error, "Failed to identify change output");
|
||||
uint8_t change_index;
|
||||
uint32_t hf_version = get_current_hard_fork();
|
||||
if (hf_version >= HF_VERSION_ENABLE_N_OUTS && td_origin.m_tx.version >= TRANSACTION_VERSION_N_OUTS) {
|
||||
|
||||
// Calculate z_i (the shared secret between sender and ourselves for the original TX)
|
||||
crypto::public_key txkey_pub = null_pkey; // R
|
||||
const std::vector<crypto::public_key> in_additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(td_origin.m_tx);
|
||||
if (in_additional_tx_pub_keys.size() != 0) {
|
||||
THROW_WALLET_EXCEPTION_IF(in_additional_tx_pub_keys.size() != td_origin.m_tx.vout.size(),
|
||||
error::wallet_internal_error,
|
||||
tr("at create_transactions_return(): incorrect number of additional TX pubkeys in origin TX for return_payment"));
|
||||
txkey_pub = in_additional_tx_pub_keys[td_origin.m_internal_output_index];
|
||||
} else {
|
||||
txkey_pub = get_tx_pub_key_from_extra(td_origin.m_tx);
|
||||
}
|
||||
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);
|
||||
THROW_WALLET_EXCEPTION_IF(!generate_key_derivation(txkey_pub, m_account.get_keys().m_view_secret_key, derivation),
|
||||
error::wallet_internal_error,
|
||||
tr("at create_transactions_return(): failed to generate_key_derivation"));
|
||||
crypto::secret_key z_i;
|
||||
derivation_to_scalar(derivation, td_origin.m_internal_output_index, z_i);
|
||||
|
||||
// Calculate the y value for return_payment support
|
||||
struct {
|
||||
char domain_separator[8];
|
||||
rct::key amount_key;
|
||||
} buf;
|
||||
std::memset(buf.domain_separator, 0x0, sizeof(buf.domain_separator));
|
||||
std::strncpy(buf.domain_separator, "RETURN", 7);
|
||||
buf.amount_key = rct::sk2rct(z_i);
|
||||
crypto::hash_to_scalar(&buf, sizeof(buf), y);
|
||||
|
||||
// The change_index needs decoding too
|
||||
uint8_t eci_data = td_origin.m_tx.return_address_change_mask[td_origin.m_internal_output_index];
|
||||
|
||||
// Calculate the encrypted_change_index data for this output
|
||||
std::memset(buf.domain_separator, 0x0, sizeof(buf.domain_separator));
|
||||
std::strncpy(buf.domain_separator, "CHG_IDX", 8);
|
||||
crypto::secret_key eci_out;
|
||||
keccak((uint8_t *)&buf, sizeof(buf), (uint8_t*)&eci_out, sizeof(eci_out));
|
||||
change_index = eci_data ^ eci_out.data[0];
|
||||
|
||||
return_address = td_origin.m_tx.return_address_list[td_origin.m_internal_output_index];
|
||||
|
||||
} else {
|
||||
|
||||
// Calculate y
|
||||
struct {
|
||||
char domain_separator[8];
|
||||
crypto::public_key pubkey;
|
||||
} buf;
|
||||
std::memset(buf.domain_separator, 0x0, sizeof(buf.domain_separator));
|
||||
std::strncpy(buf.domain_separator, "RETURN", 6);
|
||||
buf.pubkey = P_change;
|
||||
crypto::hash_to_scalar(&buf, sizeof(buf), y);
|
||||
|
||||
// Change index is the one we didn't receive
|
||||
change_index = (td_origin.m_internal_output_index == 0) ? 1 : 0;
|
||||
|
||||
return_address = td_origin.m_tx.return_address;
|
||||
}
|
||||
|
||||
// Sanity check that we aren't attempting to return our own TX change output to ourselves
|
||||
THROW_WALLET_EXCEPTION_IF(change_index == td_origin.m_internal_output_index, error::wallet_internal_error, tr("Attempting to return change to ourself"));
|
||||
|
||||
// Sanity check that we can obtain the change output from the origin TX
|
||||
THROW_WALLET_EXCEPTION_IF(!cryptonote::get_output_public_key(td_origin.m_tx.vout[change_index], P_change),
|
||||
error::wallet_internal_error,
|
||||
tr("Failed to identify change output"));
|
||||
|
||||
// Calculate yF
|
||||
ec_scalar y;
|
||||
struct {
|
||||
char domain_separator[8];
|
||||
crypto::public_key pubkey;
|
||||
} buf;
|
||||
std::memset(buf.domain_separator, 0x0, sizeof(buf.domain_separator));
|
||||
std::strncpy(buf.domain_separator, "RETURN", 6);
|
||||
buf.pubkey = P_change;
|
||||
crypto::hash_to_scalar(&buf, sizeof(buf), y);
|
||||
|
||||
rct::key key_y = (rct::key&)(y);
|
||||
rct::key key_F = (rct::key&)(td_origin.m_tx.return_address);
|
||||
rct::key key_F = (rct::key&)(return_address);
|
||||
rct::key key_yF = rct::scalarmultKey(key_F, key_y);
|
||||
|
||||
// Build the subaddress to send the return to
|
||||
@@ -12947,18 +13206,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;
|
||||
}
|
||||
@@ -14900,7 +15157,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;
|
||||
}
|
||||
|
||||
+11
-1
@@ -320,12 +320,13 @@ private:
|
||||
rct::key mask;
|
||||
uint64_t amount;
|
||||
std::string asset_type;
|
||||
uint64_t unlock_time;
|
||||
uint64_t money_transfered;
|
||||
uint64_t origin_idx;
|
||||
bool error;
|
||||
boost::optional<cryptonote::subaddress_receive_info> received;
|
||||
|
||||
tx_scan_info_t(): amount(0), asset_type(""), money_transfered(0), origin_idx((uint64_t)-1), error(true) {}
|
||||
tx_scan_info_t(): amount(0), asset_type(""), unlock_time(0), money_transfered(0), origin_idx((uint64_t)-1), error(true) {}
|
||||
};
|
||||
|
||||
struct transfer_details
|
||||
@@ -1746,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:
|
||||
/*!
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -153,15 +153,7 @@ bool wallet2::search_for_rpc_payment(uint64_t credits_target, uint32_t n_threads
|
||||
tpool.submit(&waiter, [&, i] {
|
||||
*(uint32_t*)(hashing_blob.data() + 39) = SWAP32LE(local_nonce-i);
|
||||
const uint8_t major_version = hashing_blob[0];
|
||||
if (major_version >= RX_BLOCK_VERSION)
|
||||
{
|
||||
crypto::rx_slow_hash(seed_hash.data, hashing_blob.data(), hashing_blob.size(), hash[i].data);
|
||||
}
|
||||
else
|
||||
{
|
||||
int cn_variant = hashing_blob[0] >= 7 ? hashing_blob[0] - 6 : 0;
|
||||
crypto::cn_slow_hash(hashing_blob.data(), hashing_blob.size(), hash[i], cn_variant, height);
|
||||
}
|
||||
crypto::rx_slow_hash(seed_hash.data, hashing_blob.data(), hashing_blob.size(), hash[i].data);
|
||||
});
|
||||
}
|
||||
waiter.wait();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -358,6 +358,7 @@ namespace tools
|
||||
entry.timestamp = pd.m_timestamp;
|
||||
entry.amount = pd.m_amount;
|
||||
entry.amounts = pd.m_amounts;
|
||||
entry.asset_type = pd.m_asset_type;
|
||||
entry.unlock_time = pd.m_unlock_time;
|
||||
entry.locked = !m_wallet->is_transfer_unlocked(pd.m_unlock_time, pd.m_block_height);
|
||||
entry.fee = pd.m_fee;
|
||||
@@ -391,6 +392,7 @@ namespace tools
|
||||
td.address = d.address(m_wallet->nettype(), pd.m_payment_id);
|
||||
}
|
||||
|
||||
entry.asset_type = pd.m_tx.source_asset_type;
|
||||
entry.type = "out";
|
||||
entry.subaddr_index = { pd.m_subaddr_account, 0 };
|
||||
for (uint32_t i: pd.m_subaddr_indices)
|
||||
@@ -423,6 +425,7 @@ namespace tools
|
||||
}
|
||||
|
||||
entry.type = is_failed ? "failed" : "pending";
|
||||
entry.asset_type = pd.m_tx.source_asset_type;
|
||||
entry.subaddr_index = { pd.m_subaddr_account, 0 };
|
||||
for (uint32_t i: pd.m_subaddr_indices)
|
||||
entry.subaddr_indices.push_back({pd.m_subaddr_account, i});
|
||||
@@ -461,7 +464,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};
|
||||
@@ -473,7 +476,7 @@ namespace tools
|
||||
balance_info.balance = req.all_accounts ? m_wallet->balance_all(req.strict, asset) : m_wallet->balance(req.account_index, asset, req.strict);
|
||||
if (!balance_info.balance)
|
||||
continue;
|
||||
balance_info.unlocked_balance = req.all_accounts ? m_wallet->unlocked_balance_all(req.strict, asset, &balance_info.blocks_to_unlock, &balance_info.time_to_unlock) : m_wallet->unlocked_balance(req.account_index, "XHV", req.strict, &balance_info.blocks_to_unlock, &balance_info.time_to_unlock);
|
||||
balance_info.unlocked_balance = req.all_accounts ? m_wallet->unlocked_balance_all(req.strict, asset, &balance_info.blocks_to_unlock, &balance_info.time_to_unlock) : m_wallet->unlocked_balance(req.account_index, asset, req.strict, &balance_info.blocks_to_unlock, &balance_info.time_to_unlock);
|
||||
balance_info.multisig_import_needed = m_wallet->multisig() && m_wallet->has_multisig_partial_key_images();
|
||||
std::map<uint32_t, std::map<uint32_t, uint64_t>> balance_per_subaddress_per_account;
|
||||
std::map<uint32_t, std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>>> unlocked_balance_per_subaddress_per_account;
|
||||
@@ -896,7 +899,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;
|
||||
@@ -914,7 +917,7 @@ namespace tools
|
||||
}
|
||||
if (addresses.empty())
|
||||
{
|
||||
er.message = std::string("No Monero address found at ") + url;
|
||||
er.message = std::string("No Salvium address found at ") + url;
|
||||
return {};
|
||||
}
|
||||
return addresses[0];
|
||||
@@ -931,6 +934,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)
|
||||
@@ -1106,8 +1110,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;
|
||||
}
|
||||
@@ -1116,7 +1123,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())
|
||||
{
|
||||
@@ -1160,8 +1167,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;
|
||||
}
|
||||
@@ -1171,7 +1181,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())
|
||||
@@ -1596,13 +1606,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;
|
||||
}
|
||||
@@ -1664,12 +1678,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;
|
||||
}
|
||||
@@ -2223,7 +2242,7 @@ namespace tools
|
||||
}
|
||||
if (addresses.empty())
|
||||
{
|
||||
er.message = std::string("No Monero address found at ") + url;
|
||||
er.message = std::string("No Salvium address found at ") + url;
|
||||
return {};
|
||||
}
|
||||
return addresses[0];
|
||||
@@ -3041,7 +3060,7 @@ namespace tools
|
||||
}
|
||||
if (addresses.empty())
|
||||
{
|
||||
er.message = std::string("No Monero address found at ") + url;
|
||||
er.message = std::string("No Salvium address found at ") + url;
|
||||
return {};
|
||||
}
|
||||
return addresses[0];
|
||||
@@ -3095,7 +3114,7 @@ namespace tools
|
||||
}
|
||||
if (addresses.empty())
|
||||
{
|
||||
er.message = std::string("No Monero address found at ") + url;
|
||||
er.message = std::string("No Salvium address found at ") + url;
|
||||
return {};
|
||||
}
|
||||
return addresses[0];
|
||||
@@ -4403,7 +4422,7 @@ namespace tools
|
||||
}
|
||||
if (addresses.empty())
|
||||
{
|
||||
er.message = std::string("No Monero address found at ") + url;
|
||||
er.message = std::string("No Salvium address found at ") + url;
|
||||
return {};
|
||||
}
|
||||
address = addresses[0];
|
||||
@@ -4780,7 +4799,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; },
|
||||
|
||||
@@ -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;
|
||||
@@ -1439,6 +1443,7 @@ namespace wallet_rpc
|
||||
uint64_t amount;
|
||||
amounts_container amounts;
|
||||
uint64_t fee;
|
||||
std::string asset_type;
|
||||
std::string note;
|
||||
std::list<transfer_destination> destinations;
|
||||
std::string type;
|
||||
@@ -1460,6 +1465,7 @@ namespace wallet_rpc
|
||||
KV_SERIALIZE(amounts);
|
||||
KV_SERIALIZE(fee);
|
||||
KV_SERIALIZE(note);
|
||||
KV_SERIALIZE(asset_type);
|
||||
KV_SERIALIZE(destinations);
|
||||
KV_SERIALIZE(type);
|
||||
KV_SERIALIZE(unlock_time)
|
||||
|
||||
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
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user