Browse Source

Merge branch 'dev'

pull/99/head v3.9.0
Duke Leto 3 years ago
parent
commit
e58b7df834
  1. 8
      .gitignore
  2. 11
      INSTALL-BIN.md
  3. 21
      INSTALL.md
  4. 4
      Makefile.am
  5. 15
      README.md
  6. BIN
      asmap.dat
  7. 14
      configure.ac
  8. 6
      contrib/checkpoints.pl
  9. 32
      doc/developer-notes.md
  10. 35
      doc/hushd-systemd.md
  11. 9
      doc/hushd.service
  12. 2
      doc/man/Makefile.am
  13. 90
      doc/man/komodo-cli.1
  14. 103
      doc/man/komodo-tx.1
  15. 637
      doc/man/komodod.1
  16. 50
      doc/relnotes/README.md
  17. 2
      doc/wallet-backup.md
  18. 66
      src/Makefile.am
  19. 25
      src/Makefile.gtest.include
  20. 5
      src/assetchains_stop
  21. 29
      src/bitcoin-cli.cpp
  22. 9
      src/bitcoind.cpp
  23. 2
      src/cc/CCPrices.h
  24. 32
      src/cc/CC_made_easy.md
  25. 16
      src/cc/CCutils.cpp
  26. 2
      src/cc/betprotocol.cpp
  27. 2
      src/cc/betprotocol.h
  28. 2
      src/cc/cclib.cpp
  29. 16
      src/cc/channels.cpp
  30. 2
      src/cc/customcc.cpp
  31. 2
      src/cc/customcc.h
  32. 6
      src/cc/dapps/dappinc.h
  33. 16
      src/cc/dapps/dappstd.c
  34. 6
      src/cc/dapps/diceloop
  35. 3
      src/cc/dapps/sendmany
  36. 2
      src/cc/dapps/sendmany100
  37. 117
      src/cc/dapps/zmigrate.c
  38. 2
      src/cc/dice.cpp
  39. 2
      src/cc/eval.h
  40. 4
      src/cc/games/prices.c
  41. 2
      src/cc/games/tetris.c
  42. 8
      src/cc/gamescc.cpp
  43. 94
      src/cc/gateways.cpp
  44. 2
      src/cc/import.cpp
  45. 54
      src/cc/importgateway.cpp
  46. 2
      src/cc/importpayout.cpp
  47. 6
      src/cc/makerogue
  48. 28
      src/cc/musig.cpp
  49. 2
      src/cc/payments.cpp
  50. 26
      src/cc/pegs.cpp
  51. 73
      src/cc/rogue/main.c
  52. 2
      src/cc/rogue/rogue.c
  53. 18
      src/cc/rogue_rpc.cpp
  54. 2
      src/cc/sudoku.cpp
  55. 25
      src/chain.cpp
  56. 30
      src/chain.h
  57. 139
      src/chainparams.cpp
  58. 8
      src/chainparamsbase.cpp
  59. 1
      src/chainparamsbase.h
  60. 32
      src/clearassets
  61. 2
      src/clientversion.cpp
  62. 2
      src/clientversion.h
  63. 2
      src/crypto/equihash.h
  64. 6
      src/httprpc.cpp
  65. 26
      src/httpserver.cpp
  66. 4
      src/httpserver.h
  67. 23
      src/hush-cli
  68. 11
      src/hush-cli-testnet
  69. 14
      src/hush-cli.bat
  70. 18
      src/hush-smart-chain
  71. 11
      src/hush-tx
  72. 14
      src/hush-tx.bat
  73. 0
      src/hush-tx.cpp
  74. 126
      src/hush.h
  75. 226
      src/hush_bitcoind.h
  76. 4
      src/hush_cJSON.h
  77. 50
      src/hush_ccdata.h
  78. 6
      src/hush_curve25519.h
  79. 109
      src/hush_defs.h
  80. 44
      src/hush_events.h
  81. 480
      src/hush_gateway.h
  82. 30
      src/hush_globals.h
  83. 36
      src/hush_kv.h
  84. 2
      src/hush_nSPV.h
  85. 4
      src/hush_nSPV_fullnode.h
  86. 8
      src/hush_nSPV_superlite.h
  87. 136
      src/hush_notary.h
  88. 455
      src/hush_pax.h
  89. 12
      src/hush_structs.h
  90. 199
      src/hush_utils.h
  91. 99
      src/hushd
  92. 60
      src/hushd-testnet
  93. 10
      src/hushd.bat
  94. 36
      src/init.cpp
  95. 59
      src/main.cpp
  96. 39
      src/miner.cpp
  97. 17
      src/musigtest.py
  98. 4
      src/net.cpp
  99. 1
      src/netbase.cpp
  100. 12
      src/pow.cpp
  101. 8
      src/purge
  102. 2
      src/revs
  103. 29
      src/rpc/blockchain.cpp
  104. 59
      src/rpc/crosschain.cpp
  105. 2
      src/rpc/mining.cpp
  106. 39
      src/rpc/misc.cpp
  107. 2
      src/rpc/rawtransaction.cpp
  108. 6
      src/rpc/register.h
  109. 16
      src/rpc/server.cpp
  110. 1
      src/rpc/server.h
  111. 39
      src/script/standard.h
  112. 2
      src/smartchains
  113. 2151
      src/stratum.cpp
  114. 21
      src/stratum.h
  115. 3
      src/sync.cpp
  116. 5
      src/test-hush/test_addrman.cpp
  117. 8
      src/test-hush/test_eval_notarization.cpp
  118. 5
      src/test-hush/test_parse_notarization.cpp
  119. 17
      src/tush-cli
  120. 15
      src/tushd
  121. 23
      src/txdb.cpp
  122. 14
      src/txmempool.cpp
  123. 100
      src/util.cpp
  124. 4
      src/util.h
  125. 2
      src/validationinterface.h
  126. 2
      src/version.h
  127. 2
      src/wallet-utility.cpp
  128. 2
      src/wallet/asyncrpcoperation_sendmany.cpp
  129. 11
      src/wallet/crypter.cpp
  130. 8
      src/wallet/db.cpp
  131. 104
      src/wallet/rpcwallet.cpp
  132. 2
      src/wallet/test/wallet_tests.cpp
  133. 11
      src/wallet/wallet.cpp
  134. 2
      src/wallet/walletdb.cpp
  135. 2
      src/zcash/JoinSplit.cpp
  136. 7
      src/zush
  137. 1
      zcutil/build-debian-package.sh

8
.gitignore

@ -118,6 +118,14 @@ src/komodo-cli.exe
src/komodod.exe
src/komodo-tx.exe
src/hush-cli
src/hushd
src/hush-tx
src/hush-test
src/hush-cli.exe
src/hushd.exe
src/hush-tx.exe
#output during builds, symbol tables?
*.dSYM

11
INSTALL-BIN.md

@ -0,0 +1,11 @@
# Installing Hush binaries
1. First [download the release](https://git.hush.is/hush/hush3/releases) you want to install. It will have a .deb file extension.
1. Next install the Debian package (change the version to what you downloaded above):
`dpkg -i hush-3.8.0-amd64.deb`
1. If you want to remove it, then run this to uninstall:
`apt-get remove hush`

21
INSTALL.md

@ -1,14 +1,6 @@
# Installing Hush
## Installing Binaries
To install a Debian package:
dpkg -i hush-3.6.2-amd4.deb
To uninstall:
apt-get remove hush
Instructions to compile Hush yourself.
## Build HUSH dependencies
@ -29,7 +21,6 @@ sudo swapon /swapfile
## Build on Linux:
```sh
# install build dependencies
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib \
@ -42,7 +33,7 @@ cd hush3
./build.sh -j$(nproc)
```
## Building On Ubuntu 16.04 and older systems
### Building On Ubuntu 16.04 and older systems
Some older compilers may not be able to compile modern code, such as gcc 5.4 which comes with Ubuntu 16.04 by default. Here is how to install gcc 7 on Ubuntu 16.04. Run these commands as root:
@ -56,6 +47,8 @@ apt-get install -y gcc-7 g++-7 && \
## Run a HUSH Node
After you have compiled Hush, then you can run it with the following command:
```sh
./src/hushd
```
@ -81,11 +74,7 @@ cd hush
./src/hushd
```
Currently Linux, Windows and Mac OS X are our supported platforms. If you
are interested in porting Hush to a new operating system, we are interested
to talk with you. Experimental FreeBSD support is in progress, thanks to radix42.
We aim to support all platforms, but there is only so much time in the day.
## ARM Architecture
Currently, any ARMv7 machine will not be able to build this repo, because the
underlying tech (zcash and the zksnark library) do not support that instruction

4
Makefile.am

@ -1,3 +1,7 @@
# Copyright 2016-2021 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
ACLOCAL_AMFLAGS = -I build-aux/m4
SUBDIRS = src
if ENABLE_MAN

15
README.md

@ -22,7 +22,7 @@ coin takes over 24 hours to sync their full nodes because of Sprout Transactions
In working on this release, Duke Leto was suspended from Github, which gave Hush developers
the impetus to completely leave that racist and censorship-loving platform.
Hush now has it's own <a href="https://git.hush.is/hush">git.hush.is</a> Gitea instance,
Hush now has it's own [git.hush.is](https://git.hush.is/hush) Gitea instance,
because we will not be silenced by Microsoft.
All Hush software will be released from git.hush.is and hush.is, downloads from any other
@ -32,7 +32,11 @@ domains should be assumed to be backdoored.
## Installing
See [INSTALL.md](https://git.hush.is/hush/hush3/src/branch/master/INSTALL.md)
You can either compile it yourself or you can install a binary which was compiled by us.
Please refer to the instructions which apply to you below:
* See [INSTALL.md](INSTALL.md) to compile from source on Linux and to cross-compile for Windows
* See [INSTALL-BIN.md](INSTALL-BIN.md) to install pre-compiled binary on Linux
### Claiming Funds From Old Hush Wallets
@ -40,11 +44,16 @@ If you have an older wallet, then refer to [OLD_WALLETS.md](OLD_WALLETS.md).
### Official Explorer
The link for the Official Hush explorer is: <a href="https://explorer.hush.is">explorer.hush.is</a>
The link for the Official Hush explorer is: [explorer.hush.is](https://explorer.hush.is)
We are looking for alternate explorers to be run on Tor, i2P and other TLDs, if you are interested
please join Telegram and ask questions.
### For system admins
There is a new systemd user service script so you can easily start/stop/restart your hushd service on your server.
[Try it out today](doc/hushd-systemd.md) and the systemd script is located in the doc directory of the source tree.
## Support and Socials
Please feel free to join us on Telegram for official support:

BIN
asmap.dat

Binary file not shown.

14
configure.ac

@ -1,7 +1,7 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 3)
define(_CLIENT_VERSION_MINOR, 8)
define(_CLIENT_VERSION_MINOR, 9)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 50)
define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
@ -14,9 +14,9 @@ AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])
BITCOIN_DAEMON_NAME=komodod
BITCOIN_CLI_NAME=komodo-cli
BITCOIN_TX_NAME=komodo-tx
BITCOIN_DAEMON_NAME=hushd
BITCOIN_CLI_NAME=hush-cli
BITCOIN_TX_NAME=hush-tx
dnl Unless the user specified ARFLAGS, force it to be cr
AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to <cr> if not set])
@ -231,7 +231,7 @@ CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
AC_ARG_WITH([utils],
[AS_HELP_STRING([--with-utils],
[build komodo-cli komodo-tx wallet-utility (default=yes)])],
[build hush-cli hush-tx wallet-utility (default=yes)])],
[build_bitcoin_utils=$withval],
[build_bitcoin_utils=yes])
@ -766,11 +766,11 @@ AX_CHECK_COMPILE_FLAG([-Wno-builtin-declaration-mismatch],[CXXFLAGS="$CXXFLAGS -
LIBZCASH_LIBS="-lgmp -lgmpxx $BOOST_SYSTEM_LIB -lwolfssl -lsodium $RUST_LIBS"
AC_MSG_CHECKING([whether to build komodod])
AC_MSG_CHECKING([whether to build hushd])
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
AC_MSG_RESULT($build_bitcoind)
AC_MSG_CHECKING([whether to build utils (komodo-cli komodo-tx wallet-utility)])
AC_MSG_CHECKING([whether to build utils (hush-cli hush-tx wallet-utility)])
AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes])
AC_MSG_RESULT($build_bitcoin_utils)

6
contrib/checkpoints.pl

@ -37,9 +37,9 @@ while (1) {
}
my $time = qx{$hush getblock $last |grep time|cut -d: -f2| sed 's/,//g'};
chomp($time);
# TODO: This is Linux-only
my $line1 = qx{grep --text height=$prev ~/.komodo/HUSH3/debug.log};
my $line2 = qx{grep --text height=$blocks ~/.komodo/HUSH3/debug.log};
# TODO: This is Linux-only and assumes new (not legacy) dir
my $line1 = qx{grep --text height=$prev ~/.hush/HUSH3/debug.log};
my $line2 = qx{grep --text height=$blocks ~/.hush/HUSH3/debug.log};
my $txs_per_day = 2 * $perday; # default estimate is 2 txs per block, on average
my $total_txs = 0;
#print "line1: $line1\n";

32
doc/developer-notes.md

@ -9,19 +9,30 @@ A fresh sync preserves peers.dat, so it will always be faster than a "fresh clon
One way to do a fresh sync is:
```
cd ~/.komodo/HUSH3
cd ~/.hush/HUSH3
rm blocks chainstate database notarizations hushstate
```
NOTE: The legacy directory is ~/.komodo/HUSH3 and hushd will use data from either, or ~/.hush/HUSH3 if both exist.
If you are using `zindex=1` then you need to also delete zindex.dat
```
cd ~/.komodo/HUSH3
cd ~/.hush/HUSH3
rm zindex.dat blocks chainstate database notarizations hushstate
```
It's possible to confused hush if you ran old code, stop, restart, and then write out zindex.dat that is incorrect, with later hushds will load from disk and believe.
# Making a new release of Hush
* Update version in configure.ac and src/clientversion.h
* Run ./contrib/devtools/gen-manpages.sh, commit + push results
* Update checkpoints
* Update protocol version in src/version.h if necessary
* Make Gitea release
* Make Git Tag (Gitea can do this)
# Testing a Branch
@ -37,17 +48,17 @@ git checkout zindexdb
# we want to test a fresh sync, so backup current data
TIME=`perl -e "print time"`
mv ~/.komodo/{HUSH3,HUSH3-backup-$TIME}
mkdir ~/.komodo/HUSH3
mv ~/.hush/{HUSH3,HUSH3-backup-$TIME}
mkdir ~/.hush/HUSH3
# Use your previous config as a base
cp ~/.komodo/{HUSH3-backup-$TIME,HUSH3}/HUSH3.conf
cp ~/.hush/{HUSH3-backup-$TIME,HUSH3}/HUSH3.conf
# Add zindex to your node
echo "zindex=1" >> ~/.komodo/HUSH3/HUSH3.conf
echo "zindex=1" >> ~/.hush/HUSH3/HUSH3.conf
# This is optional but will likely speed up sync time greatly
cp ~/.komodo/{HUSH3-backup,HUSH3}/peers.dat
cp ~/.hush/{HUSH3-backup,HUSH3}/peers.dat
# This log file is helpful for debugging more and will contain a history of the
# size of the anonset at every block height
@ -77,7 +88,7 @@ These values should match on all nodes:
We should also check a recent block height to verify it's working correctly. The big "test" for this `zindexdb` branch is:
* If you stop a node, and restart, are the stats from `getchaintxtstats` correct, i.e. the anonset stats? For instance, `shielded_pool_size` should be close to 500000, if it's close to or exactly 0, something is wrong.
* Is there a new file called `zindex.dat` in `~/.komodo/HUSH3/` ?
* Is there a new file called `zindex.dat` in `~/.hush/HUSH3/` ?
* Is `zindex.dat` 149 bytes ?
# Coding
@ -135,8 +146,9 @@ on all categories (and give you a very large debug.log file).
**testnet and regtest modes**
Run with the -testnet option to run with "play zcash" on the test network, if you
are testing multi-machine code that needs to operate across the internet.
Run with the -testnet option to run with "play HUSH" on the test network, if you
are testing multi-machine code that needs to operate across the internet. You can
also make a Hush Smart Chain "testcoin" with a single command: `hushd -ac_name=COIN ...`
If you are testing something that can run on one machine, run with the -regtest option.
In regression test mode, blocks can be created on-demand; see qa/rpc-tests/ for tests

35
doc/hushd-systemd.md

@ -0,0 +1,35 @@
# Systemd script for the Hush daemon
## Set it up
First set it up as follows:
* Copy hushd.service to the systemd user directory, which is /usr/lib/systemd/user directory
## Basic Usage
How to start the script:
`systemctl start --user hushd.service`
How to stop the script:
`systemctl stop --user hushd.service`
How to restart the script:
`systemctl restart --user hushd.service`
## How to watch it as it starts
Use the following on most Linux distros:
`watch systemctl status --user hushd.service`
If you're using Ubuntu 20.04, then try this instead as the above did not work for me on Ubuntu 20.04 server:
`tail -f ~/.hush/HUSH3/debug.log`
## Troubleshooting
* Don't run it with sudo or root, or it won't work with the wallet.
### To-do
* Determine why Ubuntu 20.04 didn't produce the expected outcome with watch and systemctl
* Create the hushd rc.d script
* Create the hushd runit script

9
doc/hushd.service

@ -0,0 +1,9 @@
[Unit]
Description=Hush daemon
After=network.target
[Service]
ExecStart=/usr/bin/hushd
[Install]
WantedBy=default.target

2
doc/man/Makefile.am

@ -1 +1 @@
dist_man1_MANS=komodod.1 komodo-cli.1 komodo-tx.1
dist_man1_MANS=hushd.1 hush-cli.1 hush-tx.1

90
doc/man/komodo-cli.1

@ -1,90 +0,0 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10.
.TH KOMODO-CLI "1" "December 2019" "komodo-cli v3.3.0" "User Commands"
.SH NAME
komodo-cli \- manual page for komodo-cli v3.3.0
.SH DESCRIPTION
Komodo RPC client version v3.3.0\-bde7744d9
.PP
In order to ensure you are adequately protecting your privacy when using Hush,
please see <https://myhush.org/security/>.
.SS "Usage:"
.TP
komodo\-cli [options] <command> [params]
Send command to Komodo
.TP
komodo\-cli [options] help
List commands
.TP
komodo\-cli [options] help <command>
Get help for a command
.SH OPTIONS
.HP
\-?
.IP
This help message
.HP
\fB\-conf=\fR<file>
.IP
Specify configuration file (default: komodo.conf)
.HP
\fB\-datadir=\fR<dir>
.IP
Specify data directory
.HP
\fB\-testnet\fR
.IP
Use the test network
.HP
\fB\-regtest\fR
.IP
Enter regression test mode, which uses a special chain in which blocks
can be solved instantly. This is intended for regression testing tools
and app development.
.HP
\fB\-rpcconnect=\fR<ip>
.IP
Send commands to node running on <ip> (default: 127.0.0.1)
.HP
\fB\-rpcport=\fR<port>
.IP
Connect to JSON\-RPC on <port> (default: 8232 or testnet: 18232)
.HP
\fB\-rpcwait\fR
.IP
Wait for RPC server to start
.HP
\fB\-rpcuser=\fR<user>
.IP
Username for JSON\-RPC connections
.HP
\fB\-rpcpassword=\fR<pw>
.IP
Password for JSON\-RPC connections
.HP
\fB\-rpcclienttimeout=\fR<n>
.IP
Timeout in seconds during HTTP requests, or 0 for no timeout. (default:
900)
.HP
\fB\-stdin\fR
.IP
Read extra arguments from standard input, one per line until EOF/Ctrl\-D
(recommended for sensitive information such as passphrases)
.SH COPYRIGHT
In order to ensure you are adequately protecting your privacy when using Hush,
please see <https://myhush.org/security/>.
Copyright (C) 2009-2019 The Bitcoin Core Developers
Copyright (C) 2015-2019 The Zcash Developers
Copyright (C) 2015-2019 jl777 and SuperNET developers
Copyright (C) 2018-2019 The Hush developers
This is experimental software!!!
Distributed under the MIT software license, see the accompanying file COPYING
or <http://www.opensource.org/licenses/mit-license.php>.
This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written
by Eric Young.

103
doc/man/komodo-tx.1

@ -1,103 +0,0 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10.
.TH KOMODO-TX "1" "December 2019" "komodo-tx v3.3.0" "User Commands"
.SH NAME
komodo-tx \- manual page for komodo-tx v3.3.0
.SH DESCRIPTION
Hush komodo\-tx utility version v3.3.0\-bde7744d9
.SS "Usage:"
.TP
komodo\-tx [options] <hex\-tx> [commands]
Update hex\-encoded zcash transaction
.TP
komodo\-tx [options] \fB\-create\fR [commands]
Create hex\-encoded zcash transaction
.SH OPTIONS
.HP
\-?
.IP
This help message
.HP
\fB\-create\fR
.IP
Create new, empty TX.
.HP
\fB\-json\fR
.IP
Select JSON output
.HP
\fB\-txid\fR
.IP
Output only the hex\-encoded transaction id of the resultant transaction.
.HP
\fB\-regtest\fR
.IP
Enter regression test mode, which uses a special chain in which blocks
can be solved instantly.
.HP
\fB\-testnet\fR
.IP
Use the test network
.PP
Commands:
.IP
delin=N
.IP
Delete input N from TX
.IP
delout=N
.IP
Delete output N from TX
.IP
in=TXID:VOUT(:SEQUENCE_NUMBER)
.IP
Add input to TX
.IP
locktime=N
.IP
Set TX lock time to N
.IP
nversion=N
.IP
Set TX version to N
.IP
outaddr=VALUE:ADDRESS
.IP
Add address\-based output to TX
.IP
outscript=VALUE:SCRIPT
.IP
Add raw script output to TX
.IP
sign=HEIGHT:SIGHASH\-FLAGS
.IP
Add zero or more signatures to transaction. This command requires JSON
registers:prevtxs=JSON object, privatekeys=JSON object. See
signrawtransaction docs for format of sighash flags, JSON objects.
.PP
Register Commands:
.IP
load=NAME:FILENAME
.IP
Load JSON file FILENAME into register NAME
.IP
set=NAME:JSON\-STRING
.IP
Set register NAME to given JSON\-STRING
.SH COPYRIGHT
In order to ensure you are adequately protecting your privacy when using Hush,
please see <https://myhush.org/security/>.
Copyright (C) 2009-2019 The Bitcoin Core Developers
Copyright (C) 2015-2019 The Zcash Developers
Copyright (C) 2015-2019 jl777 and SuperNET developers
Copyright (C) 2018-2019 The Hush developers
This is experimental software!!!
Distributed under the MIT software license, see the accompanying file COPYING
or <http://www.opensource.org/licenses/mit-license.php>.
This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written
by Eric Young.

637
doc/man/komodod.1

@ -1,637 +0,0 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10.
.TH KOMODOD "1" "December 2019" "komodod v3.3.0" "User Commands"
.SH NAME
komodod \- manual page for komodod v3.3.0
.SH DESCRIPTION
Hush Daemon version v3.3.0\-bde7744d9
.PP
In order to ensure you are adequately protecting your privacy when using Hush,
please see <https://myhush.org/security/>.
.SS "Usage:"
.TP
komodod [options]
Start Hush\-flavored Komodo Daemon
.SH OPTIONS
.HP
\-?
.IP
This help message
.HP
\fB\-alerts\fR
.IP
Receive and display P2P network alerts (default: 1)
.HP
\fB\-alertnotify=\fR<cmd>
.IP
Execute command when a relevant alert is received or we see a really
long fork (%s in cmd is replaced by message)
.HP
\fB\-blocknotify=\fR<cmd>
.IP
Execute command when the best block changes (%s in cmd is replaced by
block hash)
.HP
\fB\-checkblocks=\fR<n>
.IP
How many blocks to check at startup (default: 288, 0 = all)
.HP
\fB\-checklevel=\fR<n>
.IP
How thorough the block verification of \fB\-checkblocks\fR is (0\-4, default: 3)
.HP
\fB\-clientname=\fR<SomeName>
.IP
Full node client name, default 'MagicBean'
.HP
\fB\-conf=\fR<file>
.IP
Specify configuration file (default: komodo.conf)
.HP
\fB\-daemon\fR
.IP
Run in the background as a daemon and accept commands
.HP
\fB\-datadir=\fR<dir>
.IP
Specify data directory
.HP
\fB\-exportdir=\fR<dir>
.IP
Specify directory to be used when exporting data
.HP
\fB\-dbcache=\fR<n>
.IP
Set database cache size in megabytes (4 to 16384, default: 450)
.HP
\fB\-loadblock=\fR<file>
.IP
Imports blocks from external blk000??.dat file on startup
.HP
\fB\-maxorphantx=\fR<n>
.IP
Keep at most <n> unconnectable transactions in memory (default: 100)
.HP
\fB\-mempooltxinputlimit=\fR<n>
.IP
[DEPRECATED FROM OVERWINTER] Set the maximum number of transparent
inputs in a transaction that the mempool will accept (default: 0 = no
limit applied)
.HP
\fB\-par=\fR<n>
.IP
Set the number of script verification threads (\fB\-8\fR to 16, 0 = auto, <0 =
leave that many cores free, default: 0)
.HP
\fB\-pid=\fR<file>
.IP
Specify pid file (default: komodod.pid)
.HP
\fB\-prune=\fR<n>
.IP
Reduce storage requirements by pruning (deleting) old blocks. This mode
disables wallet support and is incompatible with \fB\-txindex\fR. Warning:
Reverting this setting requires re\-downloading the entire blockchain.
(default: 0 = disable pruning blocks, >550 = target size in MiB to use
for block files)
.HP
\fB\-reindex\fR
.IP
Rebuild block chain index from current blk000??.dat files on startup
.HP
\fB\-sysperms\fR
.IP
Create new files with system default permissions, instead of umask 077
(only effective with disabled wallet functionality)
.HP
\fB\-txindex\fR
.IP
Maintain a full transaction index, used by the getrawtransaction rpc
call (default: 0)
.HP
\fB\-addressindex\fR
.IP
Maintain a full address index, used to query for the balance, txids and
unspent outputs for addresses (default: 0)
.HP
\fB\-timestampindex\fR
.IP
Maintain a timestamp index for block hashes, used to query blocks hashes
by a range of timestamps (default: 0)
.HP
\fB\-spentindex\fR
.IP
Maintain a full spent index, used to query the spending txid and input
index for an outpoint (default: 0)
.HP
\fB\-zindex\fR
.IP
Maintain extra statistics about shielded transactions and payments
(default: 0)
.PP
Connection options:
.HP
\fB\-addnode=\fR<ip>
.IP
Add a node to connect to and attempt to keep the connection open
.HP
\fB\-banscore=\fR<n>
.IP
Threshold for disconnecting misbehaving peers (default: 100)
.HP
\fB\-bantime=\fR<n>
.IP
Number of seconds to keep misbehaving peers from reconnecting (default:
86400)
.HP
\fB\-bind=\fR<addr>
.IP
Bind to given address and always listen on it. Use [host]:port notation
for IPv6
.HP
\fB\-connect=\fR<ip>
.IP
Connect only to the specified node(s)
.HP
\fB\-discover\fR
.IP
Discover own IP addresses (default: 1 when listening and no \fB\-externalip\fR
or \fB\-proxy\fR)
.HP
\fB\-dns\fR
.IP
Allow DNS lookups for \fB\-addnode\fR, \fB\-seednode\fR and \fB\-connect\fR (default: 1)
.HP
\fB\-dnsseed\fR
.IP
Query for peer addresses via DNS lookup, if low on addresses (default: 1
unless \fB\-connect\fR)
.HP
\fB\-externalip=\fR<ip>
.IP
Specify your own public address
.HP
\fB\-forcednsseed\fR
.IP
Always query for peer addresses via DNS lookup (default: 0)
.HP
\fB\-listen\fR
.IP
Accept connections from outside (default: 1 if no \fB\-proxy\fR or \fB\-connect\fR)
.HP
\fB\-listenonion\fR
.IP
Automatically create Tor hidden service (default: 1)
.HP
\fB\-maxconnections=\fR<n>
.IP
Maintain at most <n> connections to peers (default: 384)
.HP
\fB\-maxreceivebuffer=\fR<n>
.IP
Maximum per\-connection receive buffer, <n>*1000 bytes (default: 5000)
.HP
\fB\-maxsendbuffer=\fR<n>
.IP
Maximum per\-connection send buffer, <n>*1000 bytes (default: 1000)
.HP
\fB\-onion=\fR<ip:port>
.IP
Use separate SOCKS5 proxy to reach peers via Tor hidden services
(default: \fB\-proxy\fR)
.HP
\fB\-onlynet=\fR<net>
.IP
Only connect to nodes in network <net> (ipv4, ipv6 or onion)
.HP
\fB\-permitbaremultisig\fR
.IP
Relay non\-P2SH multisig (default: 1)
.HP
\fB\-peerbloomfilters\fR
.IP
Support filtering of blocks and transaction with Bloom filters (default:
1)
.HP
\fB\-port=\fR<port>
.IP
Listen for connections on <port> (default: 7770 or testnet: 17770)
.HP
\fB\-proxy=\fR<ip:port>
.IP
Connect through SOCKS5 proxy
.HP
\fB\-proxyrandomize\fR
.IP
Randomize credentials for every proxy connection. This enables Tor
stream isolation (default: 1)
.HP
\fB\-seednode=\fR<ip>
.IP
Connect to a node to retrieve peer addresses, and disconnect
.HP
\fB\-timeout=\fR<n>
.IP
Specify connection timeout in milliseconds (minimum: 1, default: 5000)
.HP
\fB\-torcontrol=\fR<ip>:<port>
.IP
Tor control port to use if onion listening enabled (default:
127.0.0.1:9051)
.HP
\fB\-torpassword=\fR<pass>
.IP
Tor control port password (default: empty)
.HP
\fB\-whitebind=\fR<addr>
.IP
Bind to given address and whitelist peers connecting to it. Use
[host]:port notation for IPv6
.HP
\fB\-whitelist=\fR<netmask>
.IP
Whitelist peers connecting from the given netmask or IP address. Can be
specified multiple times. Whitelisted peers cannot be DoS banned and
their transactions are always relayed, even if they are already in the
mempool, useful e.g. for a gateway
.PP
Wallet options:
.HP
\fB\-disablewallet\fR
.IP
Do not load the wallet and disable wallet RPC calls
.HP
\fB\-keypool=\fR<n>
.IP
Set key pool size to <n> (default: 100)
.HP
\fB\-paytxfee=\fR<amt>
.IP
Fee (in KMD/kB) to add to transactions you send (default: 0.00)
.HP
\fB\-rescan\fR
.IP
Rescan the block chain for missing wallet transactions on startup
.HP
\fB\-salvagewallet\fR
.IP
Attempt to recover private keys from a corrupt wallet.dat on startup
.HP
\fB\-sendfreetransactions\fR
.IP
Send transactions as zero\-fee transactions if possible (default: 0)
.HP
\fB\-spendzeroconfchange\fR
.IP
Spend unconfirmed change when sending transactions (default: 1)
.HP
\fB\-txconfirmtarget=\fR<n>
.IP
If paytxfee is not set, include enough fee so transactions begin
confirmation on average within n blocks (default: 2)
.HP
\fB\-txexpirydelta\fR
.IP
Set the number of blocks after which a transaction that has not been
mined will become invalid (default: 200)
.HP
\fB\-maxtxfee=\fR<amt>
.IP
Maximum total fees (in KMD) to use in a single wallet transaction;
setting this too low may abort large transactions (default: 0.10)
.HP
\fB\-upgradewallet\fR
.IP
Upgrade wallet to latest format on startup
.HP
\fB\-wallet=\fR<file>
.IP
Specify wallet file (within data directory) (default: wallet.dat)
.HP
\fB\-walletbroadcast\fR
.IP
Make the wallet broadcast transactions (default: 1)
.HP
\fB\-walletnotify=\fR<cmd>
.IP
Execute command when a wallet transaction changes (%s in cmd is replaced
by TxID)
.HP
\fB\-whitelistaddress=\fR<Raddress>
.IP
Enable the wallet filter for notary nodes and add one Raddress to the
whitelist of the wallet filter. If \fB\-whitelistaddress=\fR is used, then the
wallet filter is automatically activated. Several Raddresses can be
defined using several \fB\-whitelistaddress=\fR (similar to \fB\-addnode\fR). The
wallet filter will filter the utxo to only ones coming from my own
Raddress (derived from pubkey) and each Raddress defined using
\fB\-whitelistaddress=\fR this option is mostly for Notary Nodes).
.HP
\fB\-zapwallettxes=\fR<mode>
.IP
Delete all wallet transactions and only recover those parts of the
blockchain through \fB\-rescan\fR on startup (1 = keep tx meta data e.g.
account owner and payment request information, 2 = drop tx meta data)
.PP
ZeroMQ notification options:
.HP
\fB\-zmqpubhashblock=\fR<address>
.IP
Enable publish hash block in <address>
.HP
\fB\-zmqpubhashtx=\fR<address>
.IP
Enable publish hash transaction in <address>
.HP
\fB\-zmqpubrawblock=\fR<address>
.IP
Enable publish raw block in <address>
.HP
\fB\-zmqpubrawtx=\fR<address>
.IP
Enable publish raw transaction in <address>
.PP
Debugging/Testing options:
.HP
\fB\-debug=\fR<category>
.IP
Output debugging information (default: 0, supplying <category> is
optional). If <category> is not supplied or if <category> = 1, output
all debugging information. <category> can be: addrman, alert, bench,
coindb, db, estimatefee, http, libevent, lock, mempool, net,
partitioncheck, pow, proxy, prune, rand, reindex, rpc, selectcoins, tor,
zmq, zrpc, zrpcunsafe (implies zrpc).
.HP
\fB\-experimentalfeatures\fR
.IP
Enable use of experimental features
.HP
\fB\-help\-debug\fR
.IP
Show all debugging options (usage: \fB\-\-help\fR \fB\-help\-debug\fR)
.HP
\fB\-logips\fR
.IP
Include IP addresses in debug output (default: 0)
.HP
\fB\-logtimestamps\fR
.IP
Prepend debug output with timestamp (default: 1)
.HP
\fB\-minrelaytxfee=\fR<amt>
.IP
Fees (in KMD/kB) smaller than this are considered zero fee for relaying
(default: 0.000001)
.HP
\fB\-printtoconsole\fR
.IP
Send trace/debug info to console instead of debug.log file
.HP
\fB\-shrinkdebugfile\fR
.IP
Shrink debug.log file on client startup (default: 1 when no \fB\-debug\fR)
.HP
\fB\-testnet\fR
.IP
Use the test network
.PP
Node relay options:
.HP
\fB\-datacarrier\fR
.IP
Relay and mine data carrier transactions (default: 1)
.HP
\fB\-datacarriersize\fR
.IP
Maximum size of data in data carrier transactions we relay and mine
(default: 8192)
.PP
Block creation options:
.HP
\fB\-blockminsize=\fR<n>
.IP
Set minimum block size in bytes (default: 0)
.HP
\fB\-blockmaxsize=\fR<n>
.IP
Set maximum block size in bytes (default: 2000000)
.HP
\fB\-blockprioritysize=\fR<n>
.IP
Set maximum size of high\-priority/low\-fee transactions in bytes
(default: 1000000)
.PP
Mining options:
.HP
\fB\-mint\fR
.IP
Mint/stake coins automatically (default: 0)
.HP
\fB\-gen\fR
.IP
Mine/generate coins (default: 0)
.HP
\fB\-genproclimit=\fR<n>
.IP
Set the number of threads for coin mining if enabled (\fB\-1\fR = all cores,
default: 0)
.HP
\fB\-equihashsolver=\fR<name>
.IP
Specify the Equihash solver to be used if enabled (default: "default")
.HP
\fB\-mineraddress=\fR<addr>
.IP
Send mined coins to a specific single address
.HP
\fB\-minetolocalwallet\fR
.IP
Require that mined blocks use a coinbase address in the local wallet
(default: 1)
.PP
RPC server options:
.HP
\fB\-server\fR
.IP
Accept command line and JSON\-RPC commands
.HP
\fB\-rest\fR
.IP
Accept public REST requests (default: 0)
.HP
\fB\-rpcbind=\fR<addr>
.IP
Bind to given address to listen for JSON\-RPC connections. Use
[host]:port notation for IPv6. This option can be specified multiple
times (default: bind to all interfaces)
.HP
\fB\-rpcuser=\fR<user>
.IP
Username for JSON\-RPC connections
.HP
\fB\-rpcpassword=\fR<pw>
.IP
Password for JSON\-RPC connections
.HP
\fB\-rpcport=\fR<port>
.IP
Listen for JSON\-RPC connections on <port> (default: 7771 or testnet:
17771)
.HP
\fB\-rpcallowip=\fR<ip>
.IP
Allow JSON\-RPC connections from specified source. Valid for <ip> are a
single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0)
or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified
multiple times
.HP
\fB\-rpcthreads=\fR<n>
.IP
Set the number of threads to service RPC calls (default: 4)
.PP
Metrics Options (only if \fB\-daemon\fR and \fB\-printtoconsole\fR are not set):
.HP
\fB\-showmetrics\fR
.IP
Show metrics on stdout (default: 1 if running in a console, 0 otherwise)
.HP
\fB\-metricsui\fR
.IP
Set to 1 for a persistent metrics screen, 0 for sequential metrics
output (default: 1 if running in a console, 0 otherwise)
.HP
\fB\-metricsrefreshtime\fR
.IP
Number of seconds between metrics refreshes (default: 1 if running in a
console, 600 otherwise)
.PP
Komodo Asset Chain options:
.HP
\fB\-ac_algo\fR
.IP
Choose PoW mining algorithm, default is Equihash
.HP
\fB\-ac_blocktime\fR
.IP
Block time in seconds, default is 60
.HP
\fB\-ac_cc\fR
.IP
Cryptoconditions, default 0
.HP
\fB\-ac_beam\fR
.IP
BEAM integration
.HP
\fB\-ac_coda\fR
.IP
CODA integration
.HP
\fB\-ac_cclib\fR
.IP
Cryptoconditions dynamicly loadable library
.HP
\fB\-ac_ccenable\fR
.IP
Cryptoconditions to enable
.HP
\fB\-ac_ccactivate\fR
.IP
Block height to enable Cryptoconditions
.HP
\fB\-ac_decay\fR
.IP
Percentage of block reward decrease at each halving
.HP
\fB\-ac_end\fR
.IP
Block height at which block rewards will end
.HP
\fB\-ac_eras\fR
.IP
Block reward eras
.HP
\fB\-ac_founders\fR
.IP
Number of blocks between founders reward payouts
.HP
\fB\-ac_halving\fR
.IP
Number of blocks between each block reward halving
.HP
\fB\-ac_name\fR
.IP
Name of asset chain
.HP
\fB\-ac_notarypay\fR
.IP
Pay notaries, default 0
.HP
\fB\-ac_perc\fR
.IP
Percentage of block rewards paid to the founder
.HP
\fB\-ac_private\fR
.IP
Shielded transactions only (except coinbase + notaries), default is 0
.HP
\fB\-ac_pubkey\fR
.IP
Public key for receiving payments on the network
.HP
\fB\-ac_public\fR
.IP
Transparent transactions only, default 0
.HP
\fB\-ac_reward\fR
.IP
Block reward in satoshis, default is 0
.HP
\fB\-ac_sapling\fR
.IP
Sapling activation block height
.HP
\fB\-ac_script\fR
.IP
P2SH/multisig address to receive founders rewards
.HP
\fB\-ac_staked\fR
.IP
Percentage of blocks that are Proof\-Of\-Stake, default 0
.HP
\fB\-ac_supply\fR
.IP
Starting supply, default is 0
.HP
\fB\-ac_timelockfrom\fR
.IP
Timelocked coinbase start height
.HP
\fB\-ac_timelockgte\fR
.IP
Timelocked coinbase minimum amount to be locked
.HP
\fB\-ac_timelockto\fR
.IP
Timelocked coinbase stop height
.HP
\fB\-ac_txpow\fR
.IP
Enforce transaction\-rate limit, default 0
.SH COPYRIGHT
In order to ensure you are adequately protecting your privacy when using Hush,
please see <https://myhush.org/security/>.
Copyright (C) 2009-2019 The Bitcoin Core Developers
Copyright (C) 2015-2019 The Zcash Developers
Copyright (C) 2015-2019 jl777 and SuperNET developers
Copyright (C) 2018-2019 The Hush developers
This is experimental software!!!
Distributed under the MIT software license, see the accompanying file COPYING
or <http://www.opensource.org/licenses/mit-license.php>.
This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written
by Eric Young.

50
doc/relnotes/README.md

@ -10,6 +10,56 @@ and no longer on Github, since they banned Duke Leto and
also because they censor many people around the world and work with
evil organizations.
# Hush 3.9.0 "Unusual Ursid"
```
136 files changed, 3881 insertions(+), 3156 deletions(-)
```
This is a MANDATORY release, please update as soon as you can! At some point, full nodes older than 3.9.0
will no longer be able to sync the current HUSH network correctly. More details will be given in a future update.
* :rainbow: hushd/hush-cli/hush-tx are now true binaries instead of shell scripts
* This means hushd.bat, hush-cli.bat and hush-tx.bat are no longer needed on Windows
and simplifies the maintenance of internals
* :tada: New official location for full node data is ~/.hush !
* New full nodes will install and use ~/.hush
* Existing full nodes will continue to use the legacy ~/.komodo directory
* If both ~/.hush/HUSH3 and ~/.komodo/HUSH3 exist, the ~/.hush directory will be used
* :kiss: Hush full nodes will now attempt to talk to two more nodes by default:
* node1.hush.land
* node2.hush.land
* :fork_and_knife: New RPCs:
* listaddresses - Show all taddrs in this wallet.dat
* rpcinfo - Shows stats about RPC internals
* :unicorn: These RPCs can now be run during RPC warmup:
* listaddresses
* z\_exportwallet
* signmessage
* decoderawtransaction
* getnetworkinfo
* :sweat_drops: New doc/hushd.service to use hushd with systemd
* Learn more at doc/hushd-systemd.md
* :rocket: Many updates to Hush Smart Chains and Hush internals
* Optimize zaddrs by only building witness caches for blocks that involve our wallet
* When RPC connection fails hush-cli now tells you which port it was trying to connect to
* Calculation of HSC "network magic" has changed as of 3.9.0
* If using or developing an HSC, all nodes must use either 3.8.0 or earlier, or
preferably, all use 3.9.0 code or later. HSC networks using both 3.8.0 and 3.9.0 will not work.
* This was required by internals changes and we do not plan to do this again.
* :hammer: New Stratum API so you can Solo mine with your full node!
* This is an optional feature that defaults to disabled. Enable it with `-stratum=1`
* Example usage: `hushd -stratum=1 -stratumport=31337 -stratumallowip=192.168.0.0/24'
* This allows mining connections from your local network where computers have IPs like 192.168.0.x .
* Your ASICs must be able to connect to the IP and port of your full node. Firewall rules may be needed.
* It offers the highest privacy for miners, since mining pools know your IP and address metadata and can be
hacked or coerced into giving that data. Solo mining with your own full node gives the absolute least metadata
to third parties.
* This is also the cheapest possible way to mine HUSH, since there are NO POOL FEES and NO PAYOUT TRANSACTION FEES! :smile:
* Miners can mine entire HUSH blocks from the privacy of their own server
* As many ASICs as you like can be used with a single Hush full node, just use an address inside a wallet you control,
and set your pool to the IP and port of your Hush full node with Stratum enabled.
* :nerd_face: The hush-smart-chain script is now installed in Debian packages
# Hush 3.8.0 "Chuckling Chupacabra"
```

2
doc/wallet-backup.md

@ -16,7 +16,7 @@ These instructions are specific for the officially supported Hush Linux client.
There are multiple ways to make sure you have at least one other copy of the private keys needed to spend your HUSH and view your shielded HUSH.
For all methods, you will need to include an export directory setting in your config file (`HUSH3.conf` located in the data directory which is `~/.komodo/HUSH3` unless it's been overridden with `datadir=` setting):
For all methods, you will need to include an export directory setting in your config file (`HUSH3.conf` located in the data directory which is `~/.hush/HUSH3` or `~/.komodo/HUSH3` (Legacy Location) unless it's been overridden with `datadir=` setting):
`exportdir=path/to/chosen/export/directory`

66
src/Makefile.am

@ -98,11 +98,11 @@ noinst_PROGRAMS =
TESTS =
#if BUILD_BITCOIND
bin_PROGRAMS += komodod
bin_PROGRAMS += hushd
#endif
if BUILD_BITCOIN_UTILS
bin_PROGRAMS += komodo-cli komodo-tx
bin_PROGRAMS += hush-cli hush-tx
endif
if ENABLE_WALLET
bin_PROGRAMS += wallet-utility
@ -203,6 +203,7 @@ BITCOIN_CORE_H = \
script/standard.h \
serialize.h \
streams.h \
stratum.h \
support/allocators/secure.h \
support/allocators/zeroafterfree.h \
support/cleanse.h \
@ -315,6 +316,7 @@ libbitcoin_server_a_SOURCES = \
rpc/server.cpp \
script/serverchecker.cpp \
script/sigcache.cpp \
stratum.cpp \
timedata.cpp \
torcontrol.cpp \
txdb.cpp \
@ -333,7 +335,7 @@ libbitcoin_zmq_a_SOURCES = \
zmq/zmqpublishnotifier.cpp
endif
# wallet: komodod, but only linked when wallet enabled
# wallet: hushd, but only linked when wallet enabled
libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_wallet_a_SOURCES = \
@ -481,17 +483,17 @@ libbitcoin_cli_a_SOURCES = \
nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h
#
# komodod binary #
komodod_SOURCES = bitcoind.cpp
komodod_CPPFLAGS = -fPIC $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
komodod_CXXFLAGS = -fPIC $(AM_CXXFLAGS) $(PIE_FLAGS)
komodod_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
# hushd binary #
hushd_SOURCES = bitcoind.cpp
hushd_CPPFLAGS = -fPIC $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
hushd_CXXFLAGS = -fPIC $(AM_CXXFLAGS) $(PIE_FLAGS)
hushd_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
if TARGET_WINDOWS
komodod_SOURCES += bitcoind-res.rc
hushd_SOURCES += bitcoind-res.rc
endif
komodod_LDADD = \
hushd_LDADD = \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_COMMON) \
$(LIBUNIVALUE) \
@ -506,10 +508,10 @@ komodod_LDADD = \
$(LIBCRYPTOCONDITIONS)
if ENABLE_WALLET
komodod_LDADD += $(LIBBITCOIN_WALLET)
hushd_LDADD += $(LIBBITCOIN_WALLET)
endif
komodod_LDADD += \
hushd_LDADD += \
$(BOOST_LIBS) \
$(BDB_LIBS) \
$(SSL_LIBS) \
@ -521,27 +523,27 @@ komodod_LDADD += \
$(LIBZCASH_LIBS)
if TARGET_DARWIN
komodod_LDADD += libcc.dylib $(LIBSECP256K1)
hushd_LDADD += libcc.dylib $(LIBSECP256K1)
endif
if TARGET_WINDOWS
komodod_LDADD += libcc.dll $(LIBSECP256K1)
hushd_LDADD += libcc.dll $(LIBSECP256K1)
endif
if TARGET_LINUX
komodod_LDADD += libcc.so $(LIBSECP256K1)
hushd_LDADD += libcc.so $(LIBSECP256K1)
endif
# [+] Decker: use static linking for libstdc++.6.dylib, libgomp.1.dylib, libgcc_s.1.dylib
if TARGET_DARWIN
komodod_LDFLAGS += -static-libgcc
hushd_LDFLAGS += -static-libgcc
endif
# komodo-cli binary #
komodo_cli_SOURCES = bitcoin-cli.cpp
komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS)
komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
# hush-cli binary #
hush_cli_SOURCES = bitcoin-cli.cpp
hush_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS)
hush_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
hush_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
if TARGET_DARWIN
komodo_cli_LDFLAGS += -static-libgcc
hush_cli_LDFLAGS += -static-libgcc
endif
# wallet-utility binary #
@ -553,10 +555,10 @@ wallet_utility_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
endif
if TARGET_WINDOWS
komodo_cli_SOURCES += bitcoin-cli-res.rc
hush_cli_SOURCES += bitcoin-cli-res.rc
endif
komodo_cli_LDADD = \
hush_cli_LDADD = \
$(LIBBITCOIN_CLI) \
$(LIBUNIVALUE) \
$(LIBBITCOIN_UTIL) \
@ -584,17 +586,17 @@ wallet_utility_LDADD = \
$(LIBCRYPTOCONDITIONS)
endif
# komodo-tx binary #
komodo_tx_SOURCES = komodo-tx.cpp
komodo_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
komodo_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
komodo_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
# hush-tx binary #
hush_tx_SOURCES = hush-tx.cpp
hush_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
hush_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
hush_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
if TARGET_WINDOWS
komodo_tx_SOURCES += bitcoin-tx-res.rc
hush_tx_SOURCES += bitcoin-tx-res.rc
endif
komodo_tx_LDADD = \
hush_tx_LDADD = \
$(LIBUNIVALUE) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UTIL) \
@ -605,7 +607,7 @@ komodo_tx_LDADD = \
$(LIBZCASH_LIBS) \
$(LIBCRYPTOCONDITIONS)
komodo_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
hush_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
# Zcash Protocol Primitives
libzcash_a_SOURCES = \

25
src/Makefile.gtest.include

@ -1,10 +1,10 @@
# Copyright (c) 2016-2021 The Hush developers
# Released under the GPLv3
TESTS += komodo-gtest
bin_PROGRAMS += komodo-gtest
TESTS += hush-gtest
bin_PROGRAMS += hush-gtest
# tool for generating our public parameters
komodo_gtest_SOURCES = \
hush_gtest_SOURCES = \
gtest/main.cpp \
gtest/utils.cpp \
gtest/test_checktransaction.cpp \
@ -22,7 +22,6 @@ zcash_gtest_SOURCES += \
gtest/test_deprecation.cpp \
gtest/test_equihash.cpp \
gtest/test_httprpc.cpp \
gtest/test_joinsplit.cpp \
gtest/test_keys.cpp \
gtest/test_keystore.cpp \
gtest/test_noteencryption.cpp \
@ -51,23 +50,23 @@ zcash_gtest_SOURCES += \
wallet/gtest/test_wallet.cpp
endif
komodo_gtest_CPPFLAGS = $(AM_CPPFLAGS) -DMULTICORE -fopenmp -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DSTATIC $(BITCOIN_INCLUDES)
komodo_gtest_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
hush_gtest_CPPFLAGS = $(AM_CPPFLAGS) -DMULTICORE -fopenmp -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DSTATIC $(BITCOIN_INCLUDES)
hush_gtest_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
komodo_gtest_LDADD = -lgtest -lgmock $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
hush_gtest_LDADD = -lgtest -lgmock $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1)
if ENABLE_ZMQ
zcash_gtest_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
if ENABLE_WALLET
komodo_gtest_LDADD += $(LIBBITCOIN_WALLET)
hush_gtest_LDADD += $(LIBBITCOIN_WALLET)
endif
komodo_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS)
hush_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS)
komodo_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
hush_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
komodo_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
hush_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
komodo-gtest-expected-failures: komodo-gtest FORCE
./komodo-gtest --gtest_filter=*DISABLED_* --gtest_also_run_disabled_tests
hush-gtest-expected-failures: hush-gtest FORCE
./hush-gtest --gtest_filter=*DISABLED_* --gtest_also_run_disabled_tests

5
src/assetchains_stop

@ -1,8 +1,9 @@
#!/bin/bash
# Copyright (c) 2016-2021 The Hush developers
set -eo pipefail
komodo_cli='./komodo-cli'
hush_cli='./hush-cli'
./listassetchains | while read chain; do
$komodo_cli --ac_name=$chain stop
$hush_cli --ac_name=$chain stop
done

29
src/bitcoin-cli.cpp

@ -28,9 +28,13 @@
#include <event2/buffer.h>
#include <event2/keyvalq_struct.h>
#include "support/events.h"
uint16_t BITCOIND_RPCPORT = 7771;
uint16_t ASSETCHAINS_RPCPORT = 18031;
uint16_t BITCOIND_RPCPORT = 18031;
char SMART_CHAIN_SYMBOL[65];
extern uint16_t ASSETCHAINS_RPCPORT;
#include <univalue.h>
using namespace std;
@ -43,13 +47,13 @@ std::string HelpMessageCli()
std::string strUsage;
strUsage += HelpMessageGroup(_("Options:"));
strUsage += HelpMessageOpt("-?", _("This help message"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "komodo.conf"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "HUSH3.conf"));
strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory"));
strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be "
"solved instantly. This is intended for regression testing tools and app development."));
strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), "127.0.0.1"));
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), 8232, 18232));
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u )"), 18030));
strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start"));
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
@ -82,7 +86,10 @@ static int AppInitRPC(int argc, char* argv[])
// Parameters
ParseParameters(argc, argv);
std:string name;
name = GetArg("-ac_name","");
// default HSC is HUSH3 itself, which to the internals, is also an HSC
name = GetArg("-ac_name","HUSH3");
if ( !name.empty() )
strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1);
@ -249,14 +256,16 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
event_base_dispatch(base.get());
if (response.status == 0)
throw CConnectionFailed(strprintf("couldn't connect to server: %s (code %d)\n(make sure server is running and you are connecting to the correct RPC port)", http_errorstring(response.error), response.error));
else if (response.status == HTTP_UNAUTHORIZED)
if (response.status == 0) {
throw CConnectionFailed(strprintf("couldn't connect to server at port %d : %s (code %d)\n(make sure server is running and you are connecting to the correct RPC port)",
ASSETCHAINS_RPCPORT, http_errorstring(response.error), response.error));
} else if (response.status == HTTP_UNAUTHORIZED) {
throw std::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR)
} else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR) {
throw std::runtime_error(strprintf("server returned HTTP error %d", response.status));
else if (response.body.empty())
throw std::runtime_error("no response from server");
} else if (response.body.empty()) {
throw std::runtime_error(strprintf("no response from server at port %d", ASSETCHAINS_RPCPORT ));
}
// Parse reply
UniValue valReply(UniValue::VSTR);

9
src/bitcoind.cpp

@ -69,7 +69,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
// Tell the main threads to shutdown.
if ( ASSETCHAINS_CBOPRET != 0 ) {
komodo_pricesinit();
hush_pricesinit();
}
while (!fShutdown)
@ -109,14 +109,11 @@ void WaitForShutdown(boost::thread_group* threadGroup)
}
}
//////////////////////////////////////////////////////////////////////////////
//
// Start
//
extern int32_t IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY;
extern uint32_t ASSETCHAIN_INIT;
extern std::string NOTARY_PUBKEY;
int32_t komodo_is_issuer();
int32_t hush_is_issuer();
void hush_passport_iteration();
bool AppInit(int argc, char* argv[])
@ -172,7 +169,7 @@ bool AppInit(int argc, char* argv[])
{
fprintf(stderr, "%s reading config file\n", __FUNCTION__);
ReadConfigFile(mapArgs, mapMultiArgs);
} catch (const missing_zcash_conf& e) {
} catch (const missing_hush_conf& e) {
fprintf(stderr,
(_("Before starting hushd, you need to create a configuration file:\n"
"%s\n"

2
src/cc/CCPrices.h

@ -23,7 +23,7 @@
#include "hush_defs.h"
#include "CCinclude.h"
int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
int32_t hush_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
extern void GetHushEarlytxidScriptPub();
extern CScript HUSH_EARLYTXID_SCRIPTPUB;

32
src/cc/CC_made_easy.md

@ -1,3 +1,4 @@
// Copyright (c) 2016-2021 The Hush developers
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -13,18 +14,18 @@
* *
******************************************************************************/
How to write utxo based CryptoConditions contracts for KMD chains
How to write utxo based CryptoConditions contracts for HUSH chains
by jl777
This is not the only smart contracts methodology that is possible to build on top of OP_CHECKCRYPTOCONDITION, just the first one. All the credit for getting OP_CHECKCRYPTOCONDITION working in the Komodo codebase goes to @libscott. I am just hooking into the code that he made and tried to make it just a little easier to make new contracts.
This is not the only smart contracts methodology that is possible to build on top of OP_CHECKCRYPTOCONDITION, just the first one. All the credit for getting OP_CHECKCRYPTOCONDITION working in the Hush codebase goes to @libscott. I am just hooking into the code that he made and tried to make it just a little easier to make new contracts.
There is probably some fancy marketing name to use, but for now, I will just call it "CC contract" for short, knowing that it is not 100% technically accurate as the CryptoConditions aspect is not really the main attribute. However, the KMD contracts were built to make the CryptoConditions codebase that was integrated into it to be more accessible.
There is probably some fancy marketing name to use, but for now, I will just call it "CC contract" for short, knowing that it is not 100% technically accurate as the CryptoConditions aspect is not really the main attribute. However, the HUSH contracts were built to make the CryptoConditions codebase that was integrated into it to be more accessible.
Since CC contracts run native C/C++ code, it is turing complete and that means that any contract that is possible to do on any other platform will be possible to create via CC contract.
utxo based contracts are a bit harder to start writing than for balance based contracts. However, they are much more secure as they leverage the existing bitcoin utxo system. That makes it much harder to have bugs that issue a zillion new coins from a bug, since all the CC contract operations needs to also obey the existing bitcoin utxo protocol.
This document will be heavily example based so it will utilize many of the existing reference CC contracts. After understanding this document, you should be in a good position to start creating either a new CC contract to be integrated into komodod or to make rpc based dapps directly.
This document will be heavily example based so it will utilize many of the existing reference CC contracts. After understanding this document, you should be in a good position to start creating either a new CC contract to be integrated into hushd or to make rpc based dapps directly.
Chapter 0 - Bitcoin Protocol Basics
There are many aspects of the bitcoin protocol that isnt needed to understand the CC contracts dependence on it. Such details will not be discussed. The primary aspect is the utxo, unspent transaction output. Just a fancy name for txid/vout, so when you sendtoaddress some coins, it creates a txid and the first output is vout.0, combine it and txid/0 is a specific utxo.
@ -83,7 +84,7 @@ However, this is the CC contract basics chapter, so let us ignore mempool issues
That means to just follow a known working template and only changing the things where the existing templates are not sufficient, ie. the core differentiator of your CC contract.
In the ~/komodo/src/cc/eval.h file all the eval codes are defined, currently:
In the hush3/src/cc/eval.h file all the eval codes are defined, currently:
#define FOREACH_EVAL(EVAL) \
EVAL(EVAL_IMPORTPAYOUT, 0xe1) \
@ -151,7 +152,7 @@ Ultimately the CC contract is all about how it constrains its inputs, but before
Chapter 4 - CC rpc extensions
Currently, CC contracts need to be integrated at the source level. This limits who is able to create and add new CC contracts, which at first is good, but eventually will be a too strict limitation. The runtime bindings chapter will touch on how to break out of the source based limitation, but there is another key interface level, the RPC.
By convention, each CC contract adds an associated set of rpc calls to the komodo-cli. This not only simplifies the creation of the CC contract transactions, it further will allow dapps to be created just via rpc calls. That will require there being enough foundational CC contracts already in place. As we find new usecases that cannot be implemented via rpc, then a new CC contract is made that can handle that (and more) and the power of the rpc level increases. This is a long term process.
By convention, each CC contract adds an associated set of rpc calls to the hush-cli. This not only simplifies the creation of the CC contract transactions, it further will allow dapps to be created just via rpc calls. That will require there being enough foundational CC contracts already in place. As we find new usecases that cannot be implemented via rpc, then a new CC contract is made that can handle that (and more) and the power of the rpc level increases. This is a long term process.
The typical rpc calls that are added <CC>address, <CClist>, <CCinfo> return the various special CC addresses, the list of CC contract instances and info about each CC contract instance. Along with an rpc that creates a CC instance and of course the calls to invoke a CC instance.
@ -200,7 +201,7 @@ You do need to be careful not to cause a deadlock as the CC validation code is c
Chapter 6 - faucet example
Finally, we are ready for the first actual example of a CC contract. The faucet. This is a very simple contract and it ran into some interesting bugs in the first incarnation.
The code in ~/komodo/src/cc/faucet.cpp is the ultimate documentation for it with all the details, so I will just address the conceptual issues here.
The code in hush3/src/cc/faucet.cpp is the ultimate documentation for it with all the details, so I will just address the conceptual issues here.
The idea is that people send funds to the faucet by locking it in faucet's global CC address and anybody is allowed to create a faucetget transaction that spends it.
@ -227,9 +228,9 @@ faucetfund calls FaucetFund
faucetget calls FaucetGet
faucetinfo calls FaucetInfo
Now you might not be a programmer, but I hope you are able to understand the above sequence. user types in a cli call, komodo-cli processes it by calling the rpc function, which in turn calls the function inside faucet.cpp
Now you might not be a programmer, but I hope you are able to understand the above sequence. user types in a cli call, hush-cli processes it by calling the rpc function, which in turn calls the function inside faucet.cpp
No magic, just simple conversion of a user command line call that runs code inside the komodod. Both the faucetfund and faucetget create properly signed rawtransaction that is ready to be broadcast to the network using the standard sendrawtransaction rpc. It doesnt automatically do this to allow the GUI to have a confirmation step with all the details before doing an irrevocable CC contract transaction.
No magic, just simple conversion of a user command line call that runs code inside the hushd. Both the faucetfund and faucetget create properly signed rawtransaction that is ready to be broadcast to the network using the standard sendrawtransaction rpc. It doesnt automatically do this to allow the GUI to have a confirmation step with all the details before doing an irrevocable CC contract transaction.
faucetfund allows anybody to add funds to the faucet
faucetget allows anybody to get 0.1 coins from the faucet as long as they dont violate the rules.
@ -238,7 +239,7 @@ And we come to what it is all about. The rules of the faucet. Initially it was m
To make it much harder to leech, it was made so each faucetget returned only 0.1 coins (down from 1.0) so it was worth 90% less. It was also made so that it had to be to a fresh address with less than 3 transactions. Finally each txid was constrained to start and end with 00! This is a cool trick to force usage of precious CPU time (20 to 60 seconds depending on system) to generate a valid txid. Like PoW mining for the txid and I expect other CC contracts to use a similar mechanism if they want to rate limit usage.
Combined, it became such a pain to get 0.1 coins, the faucet leeching problem was solved. It might not seem like too much trouble to change an address to get another 0.1 coins, but the way things are setup you need to launch the komodod -pubkey=<your pubkey> to change the pubkey that is active for a node. That means to change the pubkey being used, the komodod needs to be restarted and this creates a lot of issues for any automation trying to do this. Combined with the PoW required, only when 0.1 coins becomes worth a significant effort will faucet leeching return. In that case, the PoW requirement can be increased and coin amount decreased, likely with a faucet2 CC contract as I dont expect many such variations to be needed.
Combined, it became such a pain to get 0.1 coins, the faucet leeching problem was solved. It might not seem like too much trouble to change an address to get another 0.1 coins, but the way things are setup you need to launch the hushd -pubkey=<your pubkey> to change the pubkey that is active for a node. That means to change the pubkey being used, the hushd needs to be restarted and this creates a lot of issues for any automation trying to do this. Combined with the PoW required, only when 0.1 coins becomes worth a significant effort will faucet leeching return. In that case, the PoW requirement can be increased and coin amount decreased, likely with a faucet2 CC contract as I dont expect many such variations to be needed.
Chapter 7 - rewards example
The next CC contract in complexity is the rewards CC contract. This is designed to capture what most people like about masternodes, without anything else, ie. the rewards!
@ -652,9 +653,9 @@ Our testing cycle went a lot faster than expected as the bugs found were few and
Yes, blockchains are complicated.
Chapter 13 - different languages
The current codebase is integrated into the komodod codebase, which is C/C++. However, it is possible to use different languages and integrate into the C/C++ as zcash has shown by using the rust language for some parts of the zcashd.
The current codebase is integrated into the hushd codebase, which is C/C++. However, it is possible to use different languages and integrate into the C/C++ as zcash has shown by using the rust language for some parts of the zcashd.
I think any language that is compiled and can create a linkable library while being able to call and be called by C/C++ functions can be used. If you are able to make such a language binding for a simple CC contract like faucet, this will be good for a 777 KMD bounty. Of course, you need to be the first to submit a properly working pull request.
I think any language that is compiled and can create a linkable library while being able to call and be called by C/C++ functions can be used. If you are able to make such a language binding for a simple CC contract like faucet, this will be good for a 777 HUSH bounty. Of course, you need to be the first to submit a properly working pull request.
Chapter 14 - runtime bindings
@ -676,7 +677,7 @@ This codebase and tools in between the GUI and the rpc level will be a very good
##########
Conclusion
I hope this document has helped you understand what a Komodo utxo based CC contract is and how it is different from the other smart contracts. If you are now able to dive into the cc directory and start making your own CC contract, then I am very happy!
I hope this document has helped you understand what a Hush utxo based CC contract is and how it is different from the other smart contracts. If you are now able to dive into the cc directory and start making your own CC contract, then I am very happy!
gateways CC
@ -712,8 +713,3 @@ gatewayswithdraw bindtxid coin withdrawpub amount
And with a bit more magic in the oraclefeed, this is achieved. To be continued...

16
src/cc/CCutils.cpp

@ -675,7 +675,7 @@ int32_t hush_get_current_height()
else return chainActive.LastTip()->GetHeight();
}
bool komodo_txnotarizedconfirmed(uint256 txid)
bool hush_txnotarizedconfirmed(uint256 txid)
{
char str[65];
int32_t confirms,notarized=0,txheight=0,currentheight=0;;
@ -688,17 +688,17 @@ bool komodo_txnotarizedconfirmed(uint256 txid)
{
if ( NSPV_myGetTransaction(txid,tx,hashBlock,txheight,currentheight) == 0 )
{
fprintf(stderr,"komodo_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str());
fprintf(stderr,"hush_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str());
return(0);
}
else if (txheight<=0)
{
fprintf(stderr,"komodo_txnotarizedconfirmed no txheight.%d for txid %s\n",txheight,txid.ToString().c_str());
fprintf(stderr,"hush_txnotarizedconfirmed no txheight.%d for txid %s\n",txheight,txid.ToString().c_str());
return(0);
}
else if (txheight>currentheight)
{
fprintf(stderr,"komodo_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,currentheight);
fprintf(stderr,"hush_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,currentheight);
return(0);
}
confirms=1 + currentheight - txheight;
@ -707,22 +707,22 @@ bool komodo_txnotarizedconfirmed(uint256 txid)
{
if ( myGetTransaction(txid,tx,hashBlock) == 0 )
{
fprintf(stderr,"komodo_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str());
fprintf(stderr,"hush_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str());
return(0);
}
else if ( hashBlock == zeroid )
{
fprintf(stderr,"komodo_txnotarizedconfirmed no hashBlock for txid %s\n",txid.ToString().c_str());
fprintf(stderr,"hush_txnotarizedconfirmed no hashBlock for txid %s\n",txid.ToString().c_str());
return(0);
}
else if ( (pindex= hush_blockindex(hashBlock)) == 0 || (txheight= pindex->GetHeight()) <= 0 )
{
fprintf(stderr,"komodo_txnotarizedconfirmed no txheight.%d %p for txid %s\n",txheight,pindex,txid.ToString().c_str());
fprintf(stderr,"hush_txnotarizedconfirmed no txheight.%d %p for txid %s\n",txheight,pindex,txid.ToString().c_str());
return(0);
}
else if ( (pindex= chainActive.LastTip()) == 0 || pindex->GetHeight() < txheight )
{
fprintf(stderr,"komodo_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,(int32_t)pindex->GetHeight());
fprintf(stderr,"hush_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,(int32_t)pindex->GetHeight());
return(0);
}
confirms=1 + pindex->GetHeight() - txheight;

2
src/cc/betprotocol.cpp

@ -167,7 +167,7 @@ bool GetOpReturnHash(CScript script, uint256 &hash)
* notarised on another chain.
*
* IN: params - condition params
* IN: importTx - Payout transaction on value chain (KMD)
* IN: importTx - Payout transaction on value chain (HUSH)
* IN: nIn - index of input of stake
*
* importTx: Spends stakeTx with payouts from asset chain

2
src/cc/betprotocol.h

@ -62,7 +62,7 @@ public:
CMutableTransaction MakePostEvidenceTx(uint256 signedSessionTxHash,
int playerIndex, std::vector<unsigned char> state);
// on KMD
// on HUSH
CC* MakePayoutCond(uint256 signedSessionTxHash);
CMutableTransaction MakeStakeTx(CAmount totalPayout, uint256 signedSessionTx);
CMutableTransaction MakeAgreePayoutTx(std::vector<CTxOut> payouts, uint256 signedStakeTxHash);

2
src/cc/cclib.cpp

@ -47,7 +47,7 @@ std::string MYCCLIBNAME = (char *)"sudoku";
#endif
#ifndef BUILD_GAMESCC
void komodo_netevent(std::vector<uint8_t> payload) {}
void hush_netevent(std::vector<uint8_t> payload) {}
#endif
extern std::string MYCCLIBNAME;

16
src/cc/channels.cpp

@ -249,7 +249,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!");
else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 )
return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!");
else if (komodo_txnotarizedconfirmed(opentxid) == 0)
else if (hush_txnotarizedconfirmed(opentxid) == 0)
return eval->Invalid("channelopen is not yet confirmed(notarised)!");
else if ( IsCCInput(tx.vin[0].scriptSig) != 0 )
return eval->Invalid("vin.0 is normal for channelpayment!");
@ -310,7 +310,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!");
else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 )
return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!");
else if (komodo_txnotarizedconfirmed(opentxid) == 0)
else if (hush_txnotarizedconfirmed(opentxid) == 0)
return eval->Invalid("channelopen is not yet confirmed(notarised)!");
else if ( IsCCInput(tx.vin[0].scriptSig) != 0 )
return eval->Invalid("vin.0 is normal for channelclose!");
@ -351,9 +351,9 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!");
else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 )
return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!");
else if (komodo_txnotarizedconfirmed(opentxid) == 0)
else if (hush_txnotarizedconfirmed(opentxid) == 0)
return eval->Invalid("channelopen is not yet confirmed(notarised)!");
else if (komodo_txnotarizedconfirmed(param3) == 0)
else if (hush_txnotarizedconfirmed(param3) == 0)
return eval->Invalid("channelClose is not yet confirmed(notarised)!");
else if ( IsCCInput(tx.vin[0].scriptSig) != 0 )
return eval->Invalid("vin.0 is normal for channelrefund!");
@ -537,7 +537,7 @@ UniValue ChannelPayment(const CPubKey& pk, uint64_t txfee,uint256 opentxid,int64
}
else
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open tx");
if (komodo_txnotarizedconfirmed(opentxid)==false) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "channelsopen tx not yet confirmed/notarized");
if (hush_txnotarizedconfirmed(opentxid)==false) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "channelsopen tx not yet confirmed/notarized");
if (AddNormalinputs(mtx,mypk,txfee+CC_MARKER_VALUE,3,pk.IsValid()) > 0)
{
if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount)>=0)
@ -612,7 +612,7 @@ UniValue ChannelClose(const CPubKey& pk, uint64_t txfee,uint256 opentxid)
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open txid");
if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain)!='O')
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open tx");
if (komodo_txnotarizedconfirmed(opentxid)==false)
if (hush_txnotarizedconfirmed(opentxid)==false)
CCERR_RESULT("channelscc",CCLOG_INFO, stream <<"channelsopen tx not yet confirmed/notarized");
if (mypk != srcpub)
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "cannot close, you are not channel owner");
@ -650,13 +650,13 @@ UniValue ChannelRefund(const CPubKey& pk, uint64_t txfee,uint256 opentxid,uint25
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel close txid");
if ((numvouts=channelCloseTx.vout.size()) < 1 || DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,param1,param2,param3)!='C')
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel close tx");
if (komodo_txnotarizedconfirmed(closetxid)==false)
if (hush_txnotarizedconfirmed(closetxid)==false)
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "channelsclose tx not yet confirmed/notarized");
if (txid!=opentxid)
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "open and close txid are not from same channel");
if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0)
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open txid");
if (komodo_txnotarizedconfirmed(opentxid)==false)
if (hush_txnotarizedconfirmed(opentxid)==false)
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "channelsopen tx not yet confirmed/notarized");
if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,numpayments,payment,hashchain)!='O')
CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open tx");

2
src/cc/customcc.cpp

@ -10,7 +10,7 @@
./makecustom
../hush-smart-chain -ac_name=CUSTOM -ac_cclib=custom -ac_cc=2 ...
The above will rebuild komodod and get it running again
The above will rebuild hushd and get it running again
*/
CScript custom_opret(uint8_t funcid,CPubKey pk)

2
src/cc/customcc.h

@ -10,7 +10,7 @@
3. write the actual custom_func0, custom_func1 and custom_validate in customcc.cpp
4. ./makecustom, which builds cclib.cpp with -DBUILD_CUSTOMCC and puts the libcc.so in ~/komodo/src and rebuilds komodod
4. ./makecustom, which builds cclib.cpp with -DBUILD_CUSTOMCC and puts the libcc.so in ~/hush3/src and rebuilds hushd
5. launch your chain with -ac_cclib=customcc -ac_cc=2

6
src/cc/dapps/dappinc.h

@ -384,7 +384,7 @@ cJSON *hushdex_cli(char *clistr,char **retstrp,char *method,char *arg0,char *arg
return(retjson);
}
bits256 komodobroadcast(char *refcoin,char *acname,cJSON *hexjson)
bits256 hushbroadcast(char *refcoin,char *acname,cJSON *hexjson)
{
char *hexstr,*retstr,str[65]; cJSON *retjson; bits256 txid;
memset(txid.bytes,0,sizeof(txid));
@ -439,7 +439,7 @@ bits256 tokentransfer(char *refcoin,char *acname,char *tokenid,char *destpub,int
sprintf(numstr,"%llu",(long long)units);
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"tokentransfer",tokenid,destpub,numstr,"","","","")) != 0 )
{
txid = komodobroadcast(refcoin,acname,retjson);
txid = hushbroadcast(refcoin,acname,retjson);
fprintf(stderr,"tokentransfer returned (%s)\n",jprint(retjson,0));
free_json(retjson);
}
@ -639,7 +639,7 @@ cJSON *get_rawmempool(char *refcoin,char *acname)
cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr)
{
cJSON *retjson; char *retstr,jsonbuf[256];
if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 )
if ( refcoin[0] != 0 && strcmp(refcoin,"HUSH3") != 0 )
printf("warning: assumes %s has addressindex enabled\n",refcoin);
sprintf(jsonbuf,"{\\\"addresses\\\":[\\\"%s\\\"]}",coinaddr);
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","","","","")) != 0 )

16
src/cc/dapps/dappstd.c

@ -246,9 +246,9 @@ int32_t safecopy(char *dest,char *src,long len)
#define true 1
#define false 0
//#ifdef STANDALONE
//#include "../komodo/src/komodo_cJSON.c"
//#include "../hush3/src/hush_cJSON.c"
//#else
#include "../komodo_cJSON.c"
#include "../hush_cJSON.c"
//#endif
int32_t games_replay(uint64_t seed,int32_t sleeptime);
@ -669,7 +669,7 @@ uint16_t hush_userpass(char *userpass,char *symbol)
#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port)
{
//static void *cHandle;
char url[512],*retstr=0,*retstr2=0,postdata[8192];
@ -691,7 +691,7 @@ int32_t games_sendrawtransaction(char *rawtx)
char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1;
params = (char *)malloc(strlen(rawtx) + 16);
sprintf(params,"[\"%s\"]",rawtx);
if ( (retstr= komodo_issuemethod(USERPASS,(char *)"sendrawtransaction",params,GAMES_PORT)) != 0 )
if ( (retstr= hush_issuemethod(USERPASS,(char *)"sendrawtransaction",params,GAMES_PORT)) != 0 )
{
if ( 0 ) // causes 4th level crash
{
@ -768,7 +768,7 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,gam
if ( fp == 0 )
fp = fopen("keystrokes.log","a");
sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr);
if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 )
if ( (retstr= hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 )
{
if ( fp != 0 )
{
@ -970,7 +970,7 @@ int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr)
if ( 0 )
{
sprintf(fname,"%s.gameinfo",gametxidstr);
sprintf(cmd,"./komodo-cli -ac_name=%s cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",ASSETCHAINS_SYMBOL,gametxidstr,fname);
sprintf(cmd,"./hush-cli -ac_name=%s cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",ASSETCHAINS_SYMBOL,gametxidstr,fname);
if ( system(cmd) != 0 )
fprintf(stderr,"error issuing (%s)\n",cmd);
else filestr = (char *)OS_fileptr(&allocsize,fname);
@ -978,7 +978,7 @@ int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr)
else
{
sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr);
filestr = komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT);
filestr = hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT);
}
if ( filestr != 0 )
{
@ -1105,7 +1105,7 @@ int main(int argc, char **argv)
fclose(fp);
if ( GAMES_PORT == 0 )
{
printf("you must copy %s.conf from ~/.komodo/%s/%s.conf (or equivalent location) to current dir\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_SYMBOL,ASSETCHAINS_SYMBOL);
printf("you must copy %s.conf from ~/.hush/%s/%s.conf (or equivalent location) to current dir\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_SYMBOL,ASSETCHAINS_SYMBOL);
return(-1);
}
return(GAMEMAIN(argc,argv));

6
src/cc/dapps/diceloop

@ -1,6 +0,0 @@
while true
do
./c dicestatus KMDICE 5be49570c56d036abb08b6d084da93a8a86f58fc48db4a1086be95540d752d6f
sleep 10
done

3
src/cc/dapps/sendmany

@ -1,3 +0,0 @@
export addr="RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo"
./komodo-cli -ac_name=KMDICE sendmany "" "{\"$addr\":0.023,\"$addr\":0.023,\"$addr\":0.023,\"$addr\":0.023,\"$addr\":0.023,\"$addr\":0.023,\"$addr\":0.023,\"$addr\":0.023,\"$addr\":0.023,\"$addr\":0.023}"

2
src/cc/dapps/sendmany100

@ -1,2 +0,0 @@
./komodo-cli -ac_name=KMDICE sendmany "" "{\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002}"

117
src/cc/dapps/zmigrate.c

@ -23,6 +23,8 @@
#include "cJSON.c"
/*
NOTE: HUSH nor any Hush Smart Chain has any sprout outputs. This code is kept for historical and educational purposes.
z_migrate: the purpose of z_migrate is to make converting of all sprout outputs into sapling. the usage would be for the user to specify a sapling address and call z_migrate zsaddr, until it returns that there is nothing left to be done.
its main functionality is quite similar to a z_mergetoaddress ANY_ZADDR -> onetime_taddr followed by a z_sendmany onetime_taddr -> zsaddr
@ -314,20 +316,18 @@ cJSON *get_urljson(char *url,char *fname)
char *REFCOIN_CLI;
cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char *arg0,char *arg1,char *arg2,char *arg3)
cJSON *get_hushcli(char *refcoin,char **retstrp,char *acname,char *method,char *arg0,char *arg1,char *arg2,char *arg3)
{
long fsize; cJSON *retjson = 0; char cmdstr[32768],*jsonstr,fname[256];
sprintf(fname,"/tmp/zmigrate.%s",method);
//if ( (acname == 0 || acname[0] == 0) && strcmp(refcoin,"KMD") != 0 )
// acname = refcoin;
if ( acname[0] != 0 )
{
if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 )
if ( refcoin[0] != 0 && strcmp(refcoin,"HUSH3") != 0 )
printf("unexpected: refcoin.(%s) acname.(%s)\n",refcoin,acname);
sprintf(cmdstr,"./komodo-cli -ac_name=%s %s %s %s %s %s > %s\n",acname,method,arg0,arg1,arg2,arg3,fname);
sprintf(cmdstr,"./hush-cli -ac_name=%s %s %s %s %s %s > %s\n",acname,method,arg0,arg1,arg2,arg3,fname);
}
else if ( strcmp(refcoin,"KMD") == 0 )
sprintf(cmdstr,"./komodo-cli %s %s %s %s %s > %s\n",method,arg0,arg1,arg2,arg3,fname);
else if ( strcmp(refcoin,"HUSH3") == 0 )
sprintf(cmdstr,"./hush-cli %s %s %s %s %s > %s\n",method,arg0,arg1,arg2,arg3,fname);
else if ( REFCOIN_CLI != 0 && REFCOIN_CLI[0] != 0 )
{
sprintf(cmdstr,"%s %s %s %s %s %s > %s\n",REFCOIN_CLI,method,arg0,arg1,arg2,arg3,fname);
@ -346,37 +346,12 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char
return(retjson);
}
bits256 komodobroadcast(char *refcoin,char *acname,cJSON *hexjson)
{
char *hexstr,*retstr,str[65]; cJSON *retjson; bits256 txid;
memset(txid.bytes,0,sizeof(txid));
if ( (hexstr= jstr(hexjson,"hex")) != 0 )
{
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendrawtransaction",hexstr,"","","")) != 0 )
{
//fprintf(stderr,"broadcast.(%s)\n",jprint(retjson,0));
free_json(retjson);
}
else if ( retstr != 0 )
{
if ( strlen(retstr) >= 64 )
{
retstr[64] = 0;
decode_hex(txid.bytes,32,retstr);
}
fprintf(stderr,"broadcast %s txid.(%s)\n",strlen(acname)>0?acname:refcoin,bits256_str(str,txid));
free(retstr);
}
}
return(txid);
}
bits256 sendtoaddress(char *refcoin,char *acname,char *destaddr,int64_t satoshis)
{
char numstr[32],*retstr,str[65]; cJSON *retjson; bits256 txid;
memset(txid.bytes,0,sizeof(txid));
sprintf(numstr,"%.8f",(double)satoshis/SATOSHIDEN);
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendtoaddress",destaddr,numstr,"","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"sendtoaddress",destaddr,numstr,"","")) != 0 )
{
fprintf(stderr,"unexpected sendrawtransaction json.(%s)\n",jprint(retjson,0));
free_json(retjson);
@ -397,7 +372,7 @@ bits256 sendtoaddress(char *refcoin,char *acname,char *destaddr,int64_t satoshis
int32_t get_coinheight(char *refcoin,char *acname)
{
cJSON *retjson; char *retstr; int32_t height=0;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockchaininfo","","","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getblockchaininfo","","","","")) != 0 )
{
height = jint(retjson,"blocks");
free_json(retjson);
@ -415,7 +390,7 @@ bits256 get_coinblockhash(char *refcoin,char *acname,int32_t height)
cJSON *retjson; char *retstr,heightstr[32]; bits256 hash;
memset(hash.bytes,0,sizeof(hash));
sprintf(heightstr,"%d",height);
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockhash",heightstr,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getblockhash",heightstr,"","","")) != 0 )
{
fprintf(stderr,"unexpected blockhash json.(%s)\n",jprint(retjson,0));
free_json(retjson);
@ -436,7 +411,7 @@ bits256 get_coinmerkleroot(char *refcoin,char *acname,bits256 blockhash)
{
cJSON *retjson; char *retstr,str[65]; bits256 merkleroot;
memset(merkleroot.bytes,0,sizeof(merkleroot));
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockheader",bits256_str(str,blockhash),"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getblockheader",bits256_str(str,blockhash),"","","")) != 0 )
{
merkleroot = jbits256(retjson,"merkleroot");
//fprintf(stderr,"got merkleroot.(%s)\n",bits256_str(str,merkleroot));
@ -474,7 +449,7 @@ int32_t get_coinheader(char *refcoin,char *acname,bits256 *blockhashp,bits256 *m
cJSON *get_rawmempool(char *refcoin,char *acname)
{
cJSON *retjson; char *retstr;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getrawmempool","","","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getrawmempool","","","","")) != 0 )
{
//printf("mempool.(%s)\n",jprint(retjson,0));
return(retjson);
@ -490,10 +465,10 @@ cJSON *get_rawmempool(char *refcoin,char *acname)
cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr)
{
cJSON *retjson; char *retstr,jsonbuf[256];
if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 )
if ( refcoin[0] != 0 && strcmp(refcoin,"HUSH3") != 0 )
printf("warning: assumes %s has addressindex enabled\n",refcoin);
sprintf(jsonbuf,"{\\\"addresses\\\":[\\\"%s\\\"]}",coinaddr);
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","")) != 0 )
{
//printf("addressutxos.(%s)\n",jprint(retjson,0));
return(retjson);
@ -509,7 +484,7 @@ cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr)
cJSON *get_rawtransaction(char *refcoin,char *acname,bits256 txid)
{
cJSON *retjson; char *retstr,str[65];
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getrawtransaction",bits256_str(str,txid),"1","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getrawtransaction",bits256_str(str,txid),"1","","")) != 0 )
{
return(retjson);
}
@ -524,7 +499,7 @@ cJSON *get_rawtransaction(char *refcoin,char *acname,bits256 txid)
cJSON *get_listunspent(char *refcoin,char *acname)
{
cJSON *retjson; char *retstr,str[65];
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"listunspent","","","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"listunspent","","","","")) != 0 )
{
return(retjson);
}
@ -539,7 +514,7 @@ cJSON *get_listunspent(char *refcoin,char *acname)
cJSON *z_listunspent(char *refcoin,char *acname)
{
cJSON *retjson; char *retstr,str[65];
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_listunspent","","","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_listunspent","","","","")) != 0 )
{
return(retjson);
}
@ -554,7 +529,7 @@ cJSON *z_listunspent(char *refcoin,char *acname)
cJSON *z_listoperationids(char *refcoin,char *acname)
{
cJSON *retjson; char *retstr,str[65];
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_listoperationids","","","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_listoperationids","","","","")) != 0 )
{
return(retjson);
}
@ -570,7 +545,7 @@ cJSON *z_getoperationstatus(char *refcoin,char *acname,char *opid)
{
cJSON *retjson; char *retstr,str[65],params[512];
sprintf(params,"'[\"%s\"]'",opid);
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getoperationstatus",params,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_getoperationstatus",params,"","","")) != 0 )
{
//printf("got status (%s)\n",jprint(retjson,0));
return(retjson);
@ -587,7 +562,7 @@ cJSON *z_getoperationresult(char *refcoin,char *acname,char *opid)
{
cJSON *retjson; char *retstr,str[65],params[512];
sprintf(params,"'[\"%s\"]'",opid);
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getoperationresult",params,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_getoperationresult",params,"","","")) != 0 )
{
return(retjson);
}
@ -602,7 +577,7 @@ cJSON *z_getoperationresult(char *refcoin,char *acname,char *opid)
int32_t validateaddress(char *refcoin,char *acname,char *depositaddr, char* compare)
{
cJSON *retjson; char *retstr; int32_t res=0;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","")) != 0 )
{
if (is_cJSON_True(jobj(retjson,compare)) != 0 ) res=1;
free_json(retjson);
@ -618,7 +593,7 @@ int32_t validateaddress(char *refcoin,char *acname,char *depositaddr, char* comp
int32_t z_validateaddress(char *refcoin,char *acname,char *depositaddr, char *compare)
{
cJSON *retjson; char *retstr; int32_t res=0;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_validateaddress",depositaddr,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_validateaddress",depositaddr,"","","")) != 0 )
{
if (is_cJSON_True(jobj(retjson,compare)) != 0 )
res=1;
@ -635,7 +610,7 @@ int32_t z_validateaddress(char *refcoin,char *acname,char *depositaddr, char *co
int64_t z_getbalance(char *refcoin,char *acname,char *coinaddr)
{
cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getbalance",coinaddr,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_getbalance",coinaddr,"","","")) != 0 )
{
fprintf(stderr,"z_getbalance.(%s) %s returned json!\n",refcoin,acname);
free_json(retjson);
@ -656,7 +631,7 @@ int32_t z_exportkey(char *privkey,char *refcoin,char *acname,char *zaddr)
{
cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0;
privkey[0] = 0;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_exportkey",zaddr,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_exportkey",zaddr,"","","")) != 0 )
{
fprintf(stderr,"z_exportkey.(%s) %s returned json!\n",refcoin,acname);
free_json(retjson);
@ -675,7 +650,7 @@ int32_t z_exportkey(char *privkey,char *refcoin,char *acname,char *zaddr)
int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname)
{
cJSON *retjson; char *retstr; int64_t amount=0; int32_t retval = -1;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getnewaddress","","","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getnewaddress","","","","")) != 0 )
{
fprintf(stderr,"getnewaddress.(%s) %s returned json!\n",refcoin,acname);
free_json(retjson);
@ -692,7 +667,7 @@ int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname)
int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname,char *typestr)
{
cJSON *retjson; char *retstr; int64_t amount=0; int32_t retval = -1;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getnewaddress",typestr,"","","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_getnewaddress",typestr,"","","")) != 0 )
{
fprintf(stderr,"z_getnewaddress.(%s) %s returned json!\n",refcoin,acname);
free_json(retjson);
@ -764,7 +739,7 @@ int64_t find_sprout_amount(char *coinstr,char *zcaddr)
void importaddress(char *refcoin,char *acname,char *depositaddr)
{
cJSON *retjson; char *retstr;
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"importaddress",depositaddr,"","true","")) != 0 )
if ( (retjson= get_hushcli(refcoin,&retstr,acname,"importaddress",depositaddr,"","true","")) != 0 )
{
printf("importaddress.(%s)\n",jprint(retjson,0));
free_json(retjson);
@ -782,7 +757,7 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char *
sprintf(params,"'[{\"address\":\"%s\",\"amount\":%.8f}]'",destaddr,dstr(amount));
sprintf(addr,"\"%s\"",srcaddr);
printf("z_sendmany from.(%s) -> %s\n",srcaddr,params);
if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 )
if ( (retjson= get_hushcli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 )
{
printf("unexpected json z_sendmany.(%s)\n",jprint(retjson,0));
free_json(retjson);
@ -801,7 +776,7 @@ int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr
{
cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1;
sprintf(addr,"[\\\"ANY_SPROUT\\\"]");
if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 )
if ( (retjson= get_hushcli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 )
{
if ( (opstr= jstr(retjson,"opid")) != 0 )
strcpy(opidstr,opstr);
@ -1044,8 +1019,8 @@ int32_t itemvalid(char *refcoin,int64_t *refundedp,int64_t *waitingp,struct clai
*refundedp = *waitingp = 0;
if ( item->refundvalue < 0 )
return(-1);
// change "kmd" -> %s, tolowerstr(refcoin)
sprintf(url,"https://kmd.explorer.dexstats.info/insight-api-komodo/addr/%s",item->destaddr);
sprintf(url,"https://explorer.hush.is/api/addr/%s",item->destaddr);
if ( (retstr= send_curl(url,"/tmp/itemvalid")) != 0 )
{
if ( (curljson= cJSON_Parse(retstr)) != 0 )
@ -1294,7 +1269,7 @@ void reconcile_claims(char *refcoin,char *fname)
else fields[n][i++] = *str++;
}
printf("%s\n",fields[1]);
total += update_claimstats(fields[1],fields[3],fields[5 + (strcmp("KMD",refcoin)==0)],atof(fields[4])*SATOSHIDEN + 0.0000000049);
total += update_claimstats(fields[1],fields[3],fields[5 + (strcmp("HUSH3",refcoin)==0)],atof(fields[4])*SATOSHIDEN + 0.0000000049);
numlines++;
}
fclose(fp);
@ -1310,26 +1285,20 @@ int32_t main(int32_t argc,char **argv)
printf("argc needs to be 2: <prog> coin\n");
return(-1);
}
if ( strcmp(argv[1],"KMD") == 0 )
{
REFCOIN_CLI = "./komodo-cli";
coinstr = clonestr("KMD");
acstr = "";
}
else if ( strcmp(argv[1],"CHIPS") == 0 )
if ( strcmp(argv[1],"HUSH3") == 0 )
{
REFCOIN_CLI = "./chips-cli";
coinstr = clonestr("CHIPS");
REFCOIN_CLI = "./hush-cli";
coinstr = clonestr("HUSH3");
acstr = "";
}
else
{
sprintf(buf,"./komodo-cli -ac_name=%s",argv[1]);
sprintf(buf,"./hush-cli -ac_name=%s",argv[1]);
REFCOIN_CLI = clonestr(buf);
coinstr = clonestr(argv[1]);
acstr = coinstr;
}
if ( 1 )//strcmp(coinstr,"KMD") == 0 )
if ( 1 )
{
sprintf(buf,"%s-Claims.csv",coinstr);
reconcile_claims(coinstr,buf);
@ -1364,12 +1333,12 @@ int32_t main(int32_t argc,char **argv)
}
continue;
}
if ( strcmp(coinstr,"KMD") == 0 && verify_vin(coinstr,jbits256(item,"txid"),0,"R9JCEd6xnCxNUSpLrHEWvzPSh7CNXm7z75") < 0 )
if ( strcmp(coinstr,"HUSH3") == 0 && verify_vin(coinstr,jbits256(item,"txid"),0,"R9JCEd6xnCxNUSpLrHEWvzPSh7CNXm7z75") < 0 )
{
printf("WARNING: imposter dust detected! %s\n",bits256_str(str,jbits256(item,"txid")));
continue;
}
else if ( strcmp(coinstr,"KMD") != 0 && verify_vin(coinstr,jbits256(item,"txid"),0,"R9MUnxXijovvSeT9sFuUX23TiFtVvZEGjT") < 0 )
else if ( strcmp(coinstr,"HUSH3") != 0 && verify_vin(coinstr,jbits256(item,"txid"),0,"R9MUnxXijovvSeT9sFuUX23TiFtVvZEGjT") < 0 )
{
printf("WARNING: imposter dust detected! %s\n",bits256_str(str,jbits256(item,"txid")));
continue;
@ -1452,14 +1421,14 @@ int32_t zmigratemain(int32_t argc,char **argv)
printf("argc needs to be 3\n");
return(-1);
}
if ( strcmp(argv[1],"KMD") == 0 )
if ( strcmp(argv[1],"HUSH3") == 0 )
{
REFCOIN_CLI = "./komodo-cli";
coinstr = clonestr("KMD");
REFCOIN_CLI = "./hush-cli";
coinstr = clonestr("HUSH3");
}
else
{
sprintf(buf,"./komodo-cli -ac_name=%s",argv[1]);
sprintf(buf,"./hush-cli -ac_name=%s",argv[1]);
REFCOIN_CLI = clonestr(buf);
coinstr = clonestr(argv[1]);
}

2
src/cc/dice.cpp

@ -1732,7 +1732,7 @@ void *dealer0_loop(void *_arg)
if ( num < DICE_MINUTXOS ) // this deadlocks, need to put it in a different thread
{
char *cmd = (char *)malloc(100 * 128);
sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",SMART_CHAIN_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr);
sprintf(cmd,"./hush-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",SMART_CHAIN_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr);
n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1;
fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n);
for (i=0; i<n; i++)

2
src/cc/eval.h

@ -224,7 +224,7 @@ public:
if (SMART_CHAIN_SYMBOL[0]) return 1;
if (s.size() >= 72) {
if (strcmp("BTC", &s[68]) == 0) return 1;
if (strcmp("KMD", &s[68]) == 0) return 1;
if (strcmp("HUSH3", &s[68]) == 0) return 1;
}
return 0;
}

4
src/cc/games/prices.c

@ -206,7 +206,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve
sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",(uint32_t)c&0xffffffff,gametxidstr,eventid);
else if ( sizeof(c) == 8 )
sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid);
if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 )
if ( (retstr= hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
@ -237,7 +237,7 @@ int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize)
x >>= 8;
}
sprintf(params,"[\"bet\",\"17\",\"[%.8f,%%22%s%%22]\"]",dstr(betsize),hexstr);
if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 )
if ( (retstr= hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{

2
src/cc/games/tetris.c

@ -822,7 +822,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve
sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",(uint32_t)c&0xffffffff,gametxidstr,eventid);
else if ( sizeof(c) == 8 )
sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid);
if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 )
if ( (retstr= hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{

8
src/cc/gamescc.cpp

@ -479,7 +479,7 @@ int32_t games_event(uint32_t timestamp,uint256 gametxid,int32_t eventid,std::vec
{
GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret);
games_payloadrecv(mypk,timestamp,payload);
komodo_sendmessage(4,8,"events",vopret);
hush_sendmessage(4,8,"events",vopret);
return(0);
}
fprintf(stderr,"games_eventsign error\n");
@ -539,7 +539,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
return(result);
}
void komodo_netevent(std::vector<uint8_t> message)
void hush_netevent(std::vector<uint8_t> message)
{
int32_t i,retval,lag,lagerr=0; uint32_t timestamp,now; CPubKey pk; std::vector<uint8_t> sig,payload; char str[67];
if ( games_eventdecode(timestamp,pk,sig,payload,message) == 'E' )
@ -560,7 +560,7 @@ void komodo_netevent(std::vector<uint8_t> message)
if ( (rand() % 10) == 0 )
{
//fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size());
komodo_sendmessage(2,2,"events",message);
hush_sendmessage(2,2,"events",message);
}
}
}
@ -874,7 +874,7 @@ uint64_t games_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256
obj.push_back(Pair("seed",(int64_t)seed));
if ( games_iamregistered(maxplayers,gametxid,tx,mygamesaddr) > 0 )
sprintf(cmd,"cc/%s %llu %s",GAMENAME,(long long)seed,gametxid.ToString().c_str());
else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",SMART_CHAIN_SYMBOL,EVAL_GAMES,gametxid.ToString().c_str());
else sprintf(cmd,"./hush-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",SMART_CHAIN_SYMBOL,EVAL_GAMES,gametxid.ToString().c_str());
obj.push_back(Pair("run",cmd));
}
}

94
src/cc/gateways.cpp

@ -33,8 +33,8 @@
the potential pubkeys to be used would be based on active oracle data providers with recent activity.
bind asset <-> KMD gateway deposit address
KMD deposit -> globally spendable marker utxo
bind asset <-> HUSH gateway deposit address
HUSH deposit -> globally spendable marker utxo
spend marker utxo and spend linked/locked asset to user's CC address
redeem -> asset to global CC address with withdraw address -> gateway spendable marker utxo
@ -57,19 +57,19 @@
In order to create a new gateway it is necessary to follow some strict steps.
1. create a token with the max possible supply that will be issued
2. transfer 100% of them to the gateways CC's global pubkey's asset CC address. (yes it is a bit confusing)
3. create an oracle with the identical name, ie. KMD and format must start with Ihh (height, blockhash, merkleroot)
3. create an oracle with the identical name, ie. HUSH and format must start with Ihh (height, blockhash, merkleroot)
4. register a publisher and fund it with a subscribe. there will be a special client app that will automatically publish the merkleroots.
5. Now a gatewaysbind can bind an external coin to an asset, along with the oracle for the merkleroots. the txid from the bind is used in most of the other gateways CC calls
usage:
./c tokencreate KMD 1000000 KMD_equivalent_token_for_gatewaysCC
./c tokencreate HUSH 1000000 HUSH_equivalent_token_for_gatewaysCC
a7398a8748354dd0a3f8d07d70e65294928ecc3674674bb2d9483011ccaa9a7a
transfer to gateways pubkey: 03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40 RDMqGyREkP1Gwub1Nr5Ye8a325LGZsWBCb
./c tokentransfer a7398a8748354dd0a3f8d07d70e65294928ecc3674674bb2d9483011ccaa9a7a 03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40 100000000000000
2206fc39c0f384ca79819eb491ddbf889642cbfe4d0796bb6a8010ed53064a56
./c oraclescreate KMD blockheaders Ihh
./c oraclescreate HUSH blockheaders Ihh
1f1aefcca2bdea8196cfd77337fb21de22d200ddea977c2f9e8742c55829d808
./c oraclesregister 1f1aefcca2bdea8196cfd77337fb21de22d200ddea977c2f9e8742c55829d808 1000000
@ -79,7 +79,7 @@
f9499d8bb04ffb511fcec4838d72e642ec832558824a2ce5aed87f1f686f8102
gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s)
./c gatewaysbind a7398a8748354dd0a3f8d07d70e65294928ecc3674674bb2d9483011ccaa9a7a 1f1aefcca2bdea8196cfd77337fb21de22d200ddea977c2f9e8742c55829d808 KMD 100000000000000 1 1 02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92
./c gatewaysbind a7398a8748354dd0a3f8d07d70e65294928ecc3674674bb2d9483011ccaa9a7a 1f1aefcca2bdea8196cfd77337fb21de22d200ddea977c2f9e8742c55829d808 HUSH 100000000000000 1 1 02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92
e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e
./c gatewaysinfo e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e
@ -87,7 +87,7 @@
"result": "success",
"name": "Gateways",
"pubkey": "02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92",
"coin": "KMD",
"coin": "HUSH",
"oracletxid": "1f1aefcca2bdea8196cfd77337fb21de22d200ddea977c2f9e8742c55829d808",
"taddr": 0,
"prefix": 60,
@ -99,40 +99,40 @@
"issued": "0.00000000"
}
To make a gateway deposit, send the funds to the "deposit" address, along with any amount to the same pubkey address you want to get the assetized KMD to appear in.
To make a gateway deposit, send the funds to the "deposit" address, along with any amount to the same pubkey address you want to get the assetized HUSH to appear in.
0223d114dededb04f253816d6ad0ce78dd08c617c94ce3c53bf50dc74a5157bef8 pubkey for RFpxgqff7FDHFuHa3jSX5NzqqWCcELz8ha
./komodo-cli z_sendmany "<funding addr>" '[{"address":"RFpxgqff7FDHFuHa3jSX5NzqqWCcELz8ha","amount":0.0001},{"address":"RHV2As4rox97BuE3LK96vMeNY8VsGRTmBj","amount":7.6999}]'
./hush-cli z_sendmany "<funding addr>" '[{"address":"RFpxgqff7FDHFuHa3jSX5NzqqWCcELz8ha","amount":0.0001},{"address":"RHV2As4rox97BuE3LK96vMeNY8VsGRTmBj","amount":7.6999}]'
bc41a00e429db741c3199f17546a48012fd3b7eea45dfc6bc2f5228278133009 height.1003776 merkle.90aedc2f19200afc9aca2e351438d011ebae8264a58469bf225883045f61917f
./komodo-cli gettxoutproof '["bc41a00e429db741c3199f17546a48012fd3b7eea45dfc6bc2f5228278133009"]'
./hush-cli gettxoutproof '["bc41a00e429db741c3199f17546a48012fd3b7eea45dfc6bc2f5228278133009"]'
04000000232524ea04b54489eb222f8b3f566ed35504e3050488a63f0ab7b1c2030000007f91615f04835822bf6984a56482aeeb11d03814352eca9afc0a20192fdcae900000000000000000000000000000000000000000000000000000000000000000268e965ba608071d0800038e16762900000000000000000000000000000000000000000042008dd6fd4005016b4292b05df6dfd316c458c53e28fb2befb96e4870a40c6c04e733d75d8a7a18cce34fe326005efdc403bfa4644e30eeafdaeff34419edc591299e6cc5933cb2eeecbab5c4dfe97cd413b75215999a3dd02b540373581e81d8512bff1640590a6b4da4aaa9b8adc0102c38ca0022daed997b53ed192ba326e212fba5e505ce29e3ad149cef7f48d0e00948a1acd81731d84008760759211eb4abbc7b037939a7964182edb59cf9065357e864188ee5fc7316e8796963036bb99eeb9f06c95d64f78749ecec7181c12eb5d83a3b9b1c1e8a0aae9a20ce04a250b28216620bfc99bb81a6de4db80b93a5aea916de97c1a272e26644abdd683f19c5e3174a2e4513ed767d8f11a4c3074295f697839c5d9139676a813451cc7da38f68cbae5d990a79075f98903233ca04fe1b4b099e433585e5adcc45d41d54a9c648179297359c75950a5e574f13f70b728bbbf552770256315cd0a00139d6ab6934cb5ed70a4fc01a92611b096dd0028f17f4cc687b75f37dca530aa47a18321c50528dbd9272eabb3e13a87021a05918a6d2627e2caba6d7cf1a9f0b831ea3337b9a6af92746d83140078d60c72b6beacf91c9e68a34cee209e08670be1d17ff8d80b7a2285b1325461a2e33f2ee675593f1900e066a5d212615cd8da18749b0e684eee73edcc9031709be715b889c6d015cf4bd4ad5ab7e21bd3492c208930a54d353ef36a437f507ead38855633c1b88d060d9e4221ca8ce2f698e8a6ae0d41e9ace3cbd401f1e0f07650e9c126d4ef20278c8be6e85c7637513643f8d02d7ad64c09da11c16429d60e5160c345844b8158ece62794e8ad280d4e4664150e74978609ece431e51a9f9e1ce8aa49c16f36c7fd12b71acc42d893e18476b8b1e144a8175519612efc93e0aecc61f3b21212c958b0e2331d76aaa62faf11a58fe2bd91ab9ab01b906406c9bbc02df2a106e67182aae0a20b538bf19f09c57f9de5e198ba254580fb1b11e22ad526550093420cb7c68628d4c3ad329c8acc6e219093d277810ed016b6099b7e3781de412a22dacedaa2acf29e8062debcd85c7b9529a20b2782a2470763ac27cf89611a527d43ac89b8063ffb93b6ed993425194f8ee821a8493a563072c896f9584f95db28e3f2fc5fb4a6f3c39d615cd563641717cd50afb73ed3989cbf504b2043882993ce9575f56402534173b1396fbc13df80920b46788ae340ad5a91f25177cc74aa69024d76f56166199d2e4d50a053555256c4e3137ea1cee1130e916a88b6ee5cf2c85652fb8824d5dacfa485e3ef6190591ac0c2fcacc4fc7deb65aca4b0b89b76e35a46b0627e2e967cc63a5d606a984c8e63eabb98fde3e69114340ae524c974cb936e57690e98a7a74533f6f7d1d0496976496b54d14a8163efb32b70dfbb79d80a3022c4f53571c08bf044270565716b435084376714b224ab23e9817c05af8223723afc0577af5c8fc28f71036ca82528aaa4ca9bcd18a50e25d2a528f183d3a2074d968d170876d8dce434c5937261b55173ab87e03d5632ca0834fdc5387c15ab3a17d75c0f274004f289ff1bf7d14e97fdf4172eb49adfb418cc2f4794806ae7c0111c97df4d65d38679ec93fea3ef738ed565e8906a8fe1861cafe3938c772fedcfab40159938e06ef414fd299f2355c6d3369bc1bd3c4db64ce205f0a1b70a40030f505b736e28230de82e97776b5ee7b10708bb3020d28cec7a8e124549ec80c547ac4e7b52bf397c72bcfce30820554ab8fb4d1f73b209bc32a0e7e878843cdbf5f01222728ccea7e6ab7cb5e3fee3234f5b85d1985f91492f6ceaa6454a658dab5074f163ce26ed753137fa61c940679de13bd7b212cd3cf2b334f5201cecbc7473342bd7a239e09169bccd56d03000000037a9068df0625e548e71263c8361b4e904c998378f6b9e32729c3f19b10ad752e093013788222f5c26bfc5da4eeb7d32f01486a54179f19c341b79d420ea041bc8878d22fad4692b2d609c3cf190903874d3682a714c7483518c9392e07c25035010b
./komodo-cli getrawtransaction bc41a00e429db741c3199f17546a48012fd3b7eea45dfc6bc2f5228278133009
./hush-cli getrawtransaction bc41a00e429db741c3199f17546a48012fd3b7eea45dfc6bc2f5228278133009
010000000149964cdcd17fe9b1cae4d0f3b5f5db301d9b4f54099fdf4d34498df281757094010000006a4730440220594f3a630dd73c123f44621aa8bb9968ab86734833453dd479af6d79ae6f584202207bb5e35f13b337ccc8a88d9a006c8c5ddb016c0a6f4f2dc44357a8128623d85d01210223154bf53cd3a75e64d86697070d6437c8f0010a09c1df35b659e31ce3d79b5dffffffff0310270000000000001976a91447d2e323a14b0c3be08698aa46a9b91489b189d688ac701de52d000000001976a91459fdba29ea85c65ad90f6d38f7a6646476b26b1688acb0a86a00000000001976a914f9a9daf5519dae38b8b61d945f075da895df441d88ace18d965b
gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof destpub amount
./komodo-cli -ac_name=AT5 gatewaysdeposit e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e 1003776 KMD bc41a00e429db741c3199f17546a48012fd3b7eea45dfc6bc2f5228278133009 0 010000000149964cdcd17fe9b1cae4d0f3b5f5db301d9b4f54099fdf4d34498df281757094010000006a4730440220594f3a630dd73c123f44621aa8bb9968ab86734833453dd479af6d79ae6f584202207bb5e35f13b337ccc8a88d9a006c8c5ddb016c0a6f4f2dc44357a8128623d85d01210223154bf53cd3a75e64d86697070d6437c8f0010a09c1df35b659e31ce3d79b5dffffffff0310270000000000001976a91447d2e323a14b0c3be08698aa46a9b91489b189d688ac701de52d000000001976a91459fdba29ea85c65ad90f6d38f7a6646476b26b1688acb0a86a00000000001976a914f9a9daf5519dae38b8b61d945f075da895df441d88ace18d965b 04000000232524ea04b54489eb222f8b3f566ed35504e3050488a63f0ab7b1c2030000007f91615f04835822bf6984a56482aeeb11d03814352eca9afc0a20192fdcae900000000000000000000000000000000000000000000000000000000000000000268e965ba608071d0800038e16762900000000000000000000000000000000000000000042008dd6fd4005016b4292b05df6dfd316c458c53e28fb2befb96e4870a40c6c04e733d75d8a7a18cce34fe326005efdc403bfa4644e30eeafdaeff34419edc591299e6cc5933cb2eeecbab5c4dfe97cd413b75215999a3dd02b540373581e81d8512bff1640590a6b4da4aaa9b8adc0102c38ca0022daed997b53ed192ba326e212fba5e505ce29e3ad149cef7f48d0e00948a1acd81731d84008760759211eb4abbc7b037939a7964182edb59cf9065357e864188ee5fc7316e8796963036bb99eeb9f06c95d64f78749ecec7181c12eb5d83a3b9b1c1e8a0aae9a20ce04a250b28216620bfc99bb81a6de4db80b93a5aea916de97c1a272e26644abdd683f19c5e3174a2e4513ed767d8f11a4c3074295f697839c5d9139676a813451cc7da38f68cbae5d990a79075f98903233ca04fe1b4b099e433585e5adcc45d41d54a9c648179297359c75950a5e574f13f70b728bbbf552770256315cd0a00139d6ab6934cb5ed70a4fc01a92611b096dd0028f17f4cc687b75f37dca530aa47a18321c50528dbd9272eabb3e13a87021a05918a6d2627e2caba6d7cf1a9f0b831ea3337b9a6af92746d83140078d60c72b6beacf91c9e68a34cee209e08670be1d17ff8d80b7a2285b1325461a2e33f2ee675593f1900e066a5d212615cd8da18749b0e684eee73edcc9031709be715b889c6d015cf4bd4ad5ab7e21bd3492c208930a54d353ef36a437f507ead38855633c1b88d060d9e4221ca8ce2f698e8a6ae0d41e9ace3cbd401f1e0f07650e9c126d4ef20278c8be6e85c7637513643f8d02d7ad64c09da11c16429d60e5160c345844b8158ece62794e8ad280d4e4664150e74978609ece431e51a9f9e1ce8aa49c16f36c7fd12b71acc42d893e18476b8b1e144a8175519612efc93e0aecc61f3b21212c958b0e2331d76aaa62faf11a58fe2bd91ab9ab01b906406c9bbc02df2a106e67182aae0a20b538bf19f09c57f9de5e198ba254580fb1b11e22ad526550093420cb7c68628d4c3ad329c8acc6e219093d277810ed016b6099b7e3781de412a22dacedaa2acf29e8062debcd85c7b9529a20b2782a2470763ac27cf89611a527d43ac89b8063ffb93b6ed993425194f8ee821a8493a563072c896f9584f95db28e3f2fc5fb4a6f3c39d615cd563641717cd50afb73ed3989cbf504b2043882993ce9575f56402534173b1396fbc13df80920b46788ae340ad5a91f25177cc74aa69024d76f56166199d2e4d50a053555256c4e3137ea1cee1130e916a88b6ee5cf2c85652fb8824d5dacfa485e3ef6190591ac0c2fcacc4fc7deb65aca4b0b89b76e35a46b0627e2e967cc63a5d606a984c8e63eabb98fde3e69114340ae524c974cb936e57690e98a7a74533f6f7d1d0496976496b54d14a8163efb32b70dfbb79d80a3022c4f53571c08bf044270565716b435084376714b224ab23e9817c05af8223723afc0577af5c8fc28f71036ca82528aaa4ca9bcd18a50e25d2a528f183d3a2074d968d170876d8dce434c5937261b55173ab87e03d5632ca0834fdc5387c15ab3a17d75c0f274004f289ff1bf7d14e97fdf4172eb49adfb418cc2f4794806ae7c0111c97df4d65d38679ec93fea3ef738ed565e8906a8fe1861cafe3938c772fedcfab40159938e06ef414fd299f2355c6d3369bc1bd3c4db64ce205f0a1b70a40030f505b736e28230de82e97776b5ee7b10708bb3020d28cec7a8e124549ec80c547ac4e7b52bf397c72bcfce30820554ab8fb4d1f73b209bc32a0e7e878843cdbf5f01222728ccea7e6ab7cb5e3fee3234f5b85d1985f91492f6ceaa6454a658dab5074f163ce26ed753137fa61c940679de13bd7b212cd3cf2b334f5201cecbc7473342bd7a239e09169bccd56d03000000037a9068df0625e548e71263c8361b4e904c998378f6b9e32729c3f19b10ad752e093013788222f5c26bfc5da4eeb7d32f01486a54179f19c341b79d420ea041bc8878d22fad4692b2d609c3cf190903874d3682a714c7483518c9392e07c25035010b 0223d114dededb04f253816d6ad0ce78dd08c617c94ce3c53bf50dc74a5157bef8 7.6999
./hush-cli -ac_name=AT5 gatewaysdeposit e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e 1003776 HUSH bc41a00e429db741c3199f17546a48012fd3b7eea45dfc6bc2f5228278133009 0 010000000149964cdcd17fe9b1cae4d0f3b5f5db301d9b4f54099fdf4d34498df281757094010000006a4730440220594f3a630dd73c123f44621aa8bb9968ab86734833453dd479af6d79ae6f584202207bb5e35f13b337ccc8a88d9a006c8c5ddb016c0a6f4f2dc44357a8128623d85d01210223154bf53cd3a75e64d86697070d6437c8f0010a09c1df35b659e31ce3d79b5dffffffff0310270000000000001976a91447d2e323a14b0c3be08698aa46a9b91489b189d688ac701de52d000000001976a91459fdba29ea85c65ad90f6d38f7a6646476b26b1688acb0a86a00000000001976a914f9a9daf5519dae38b8b61d945f075da895df441d88ace18d965b 04000000232524ea04b54489eb222f8b3f566ed35504e3050488a63f0ab7b1c2030000007f91615f04835822bf6984a56482aeeb11d03814352eca9afc0a20192fdcae900000000000000000000000000000000000000000000000000000000000000000268e965ba608071d0800038e16762900000000000000000000000000000000000000000042008dd6fd4005016b4292b05df6dfd316c458c53e28fb2befb96e4870a40c6c04e733d75d8a7a18cce34fe326005efdc403bfa4644e30eeafdaeff34419edc591299e6cc5933cb2eeecbab5c4dfe97cd413b75215999a3dd02b540373581e81d8512bff1640590a6b4da4aaa9b8adc0102c38ca0022daed997b53ed192ba326e212fba5e505ce29e3ad149cef7f48d0e00948a1acd81731d84008760759211eb4abbc7b037939a7964182edb59cf9065357e864188ee5fc7316e8796963036bb99eeb9f06c95d64f78749ecec7181c12eb5d83a3b9b1c1e8a0aae9a20ce04a250b28216620bfc99bb81a6de4db80b93a5aea916de97c1a272e26644abdd683f19c5e3174a2e4513ed767d8f11a4c3074295f697839c5d9139676a813451cc7da38f68cbae5d990a79075f98903233ca04fe1b4b099e433585e5adcc45d41d54a9c648179297359c75950a5e574f13f70b728bbbf552770256315cd0a00139d6ab6934cb5ed70a4fc01a92611b096dd0028f17f4cc687b75f37dca530aa47a18321c50528dbd9272eabb3e13a87021a05918a6d2627e2caba6d7cf1a9f0b831ea3337b9a6af92746d83140078d60c72b6beacf91c9e68a34cee209e08670be1d17ff8d80b7a2285b1325461a2e33f2ee675593f1900e066a5d212615cd8da18749b0e684eee73edcc9031709be715b889c6d015cf4bd4ad5ab7e21bd3492c208930a54d353ef36a437f507ead38855633c1b88d060d9e4221ca8ce2f698e8a6ae0d41e9ace3cbd401f1e0f07650e9c126d4ef20278c8be6e85c7637513643f8d02d7ad64c09da11c16429d60e5160c345844b8158ece62794e8ad280d4e4664150e74978609ece431e51a9f9e1ce8aa49c16f36c7fd12b71acc42d893e18476b8b1e144a8175519612efc93e0aecc61f3b21212c958b0e2331d76aaa62faf11a58fe2bd91ab9ab01b906406c9bbc02df2a106e67182aae0a20b538bf19f09c57f9de5e198ba254580fb1b11e22ad526550093420cb7c68628d4c3ad329c8acc6e219093d277810ed016b6099b7e3781de412a22dacedaa2acf29e8062debcd85c7b9529a20b2782a2470763ac27cf89611a527d43ac89b8063ffb93b6ed993425194f8ee821a8493a563072c896f9584f95db28e3f2fc5fb4a6f3c39d615cd563641717cd50afb73ed3989cbf504b2043882993ce9575f56402534173b1396fbc13df80920b46788ae340ad5a91f25177cc74aa69024d76f56166199d2e4d50a053555256c4e3137ea1cee1130e916a88b6ee5cf2c85652fb8824d5dacfa485e3ef6190591ac0c2fcacc4fc7deb65aca4b0b89b76e35a46b0627e2e967cc63a5d606a984c8e63eabb98fde3e69114340ae524c974cb936e57690e98a7a74533f6f7d1d0496976496b54d14a8163efb32b70dfbb79d80a3022c4f53571c08bf044270565716b435084376714b224ab23e9817c05af8223723afc0577af5c8fc28f71036ca82528aaa4ca9bcd18a50e25d2a528f183d3a2074d968d170876d8dce434c5937261b55173ab87e03d5632ca0834fdc5387c15ab3a17d75c0f274004f289ff1bf7d14e97fdf4172eb49adfb418cc2f4794806ae7c0111c97df4d65d38679ec93fea3ef738ed565e8906a8fe1861cafe3938c772fedcfab40159938e06ef414fd299f2355c6d3369bc1bd3c4db64ce205f0a1b70a40030f505b736e28230de82e97776b5ee7b10708bb3020d28cec7a8e124549ec80c547ac4e7b52bf397c72bcfce30820554ab8fb4d1f73b209bc32a0e7e878843cdbf5f01222728ccea7e6ab7cb5e3fee3234f5b85d1985f91492f6ceaa6454a658dab5074f163ce26ed753137fa61c940679de13bd7b212cd3cf2b334f5201cecbc7473342bd7a239e09169bccd56d03000000037a9068df0625e548e71263c8361b4e904c998378f6b9e32729c3f19b10ad752e093013788222f5c26bfc5da4eeb7d32f01486a54179f19c341b79d420ea041bc8878d22fad4692b2d609c3cf190903874d3682a714c7483518c9392e07c25035010b 0223d114dededb04f253816d6ad0ce78dd08c617c94ce3c53bf50dc74a5157bef8 7.6999
-> 9d80ea79a65aaa0d464f8b762356fa01047e16e9793505a22ca04559f81a6eb6
to get the merkleroots onchain, from the multisig signers nodes run the oraclefeed program with acname oracletxid pubkey Ihh
./oraclefeed AT5 1f1aefcca2bdea8196cfd77337fb21de22d200ddea977c2f9e8742c55829d808 02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92 Ihh
gatewaysclaim bindtxid coin deposittxid destpub amount
./c gatewaysclaim e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e KMD 9d80ea79a65aaa0d464f8b762356fa01047e16e9793505a22ca04559f81a6eb6 0223d114dededb04f253816d6ad0ce78dd08c617c94ce3c53bf50dc74a5157bef8 7.6999
./c gatewaysclaim e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e HUSH 9d80ea79a65aaa0d464f8b762356fa01047e16e9793505a22ca04559f81a6eb6 0223d114dededb04f253816d6ad0ce78dd08c617c94ce3c53bf50dc74a5157bef8 7.6999
now the asset is in the pubkey's asset address!
it can be used, traded freely and any node who has the asset can do a gatewayswithdraw
gatewayswithdraw bindtxid coin withdrawpub amount
./c gatewayswithdraw e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e KMD 03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828 1
./c gatewayswithdraw e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e HUSH 03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828 1
ef3cc452da006eb2edda6b6ed3d3347664be51260f3e91f59ec44ec9701367f0
Now there is a withdraw pending, so it needs to be processed by the signing nodes on the KMD side
Now there is a withdraw pending, so it needs to be processed by the signing nodes on the HUSH side
gatewayspending bindtxid coin
gatewayspending will display all pending withdraws and if it is done on one of the msigpubkeys, then it will queue it for processing
./c gatewayspending e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e KMD
./c gatewayspending e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e HUSH
Implementation Issues:
@ -151,10 +151,10 @@
*/
// start of consensus code
#define KMD_PUBTYPE 60
#define KMD_P2SHTYPE 85
#define KMD_WIFTYPE 188
#define KMD_TADDR 0
#define HUSH_PUBTYPE 60
#define HUSH_P2SHTYPE 85
#define HUSH_WIFTYPE 188
#define HUSH_TADDR 0
#define CC_MARKER_VALUE 10000
CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector<CPubKey> gatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2,uint8_t wiftype)
@ -184,7 +184,7 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui
depositaddr[0] = 0;
if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> totalsupply; ss >> oracletxid; ss >> M; ss >> N; ss >> gatewaypubkeys; ss >> taddr; ss >> prefix; ss >> prefix2; ss >> wiftype) != 0 )
{
if ( prefix == KMD_PUBTYPE && prefix2 == KMD_P2SHTYPE )
if ( prefix == HUSH_PUBTYPE && prefix2 == HUSH_P2SHTYPE )
{
if ( N > 1 )
{
@ -612,7 +612,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
sprintf(validationError,"illegal format %s != Ihh\n",format.c_str());
return eval->Invalid(validationError);
}
else if (komodo_txnotarizedconfirmed(bindtxid) == false)
else if (hush_txnotarizedconfirmed(bindtxid) == false)
return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!");
else if (myGetTransaction(deposittxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid gatewaysdeposittxid!");
@ -630,7 +630,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("bindtxid does not match to bindtxid from gatewaysdeposit");
else if (tmpamount>totalsupply)
return eval->Invalid("deposit amount greater then bind total supply");
else if (komodo_txnotarizedconfirmed(deposittxid) == false)
else if (hush_txnotarizedconfirmed(deposittxid) == false)
return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!");
else if (tx.vin.size()>0)
{
@ -704,7 +704,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("invalid marker vout for gatewaysWithdraw!");
else if ( ConstrainVout(tmptx.vout[1],1,gatewaystokensaddr,amount)==0)
return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!");
else if (komodo_txnotarizedconfirmed(withdrawtxid) == false)
else if (hush_txnotarizedconfirmed(withdrawtxid) == false)
return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!");
else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid gatewaysbind txid!");
@ -714,7 +714,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("refcoin different than in bind tx");
else if (tmptokenid!=tokenid)
return eval->Invalid("tokenid does not match tokenid from gatewaysbind");
else if (komodo_txnotarizedconfirmed(bindtxid) == false)
else if (hush_txnotarizedconfirmed(bindtxid) == false)
return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!");
else if (IsCCInput(tx.vin[0].scriptSig) != 0)
return eval->Invalid("vin.0 is normal for gatewayspartialsign!");
@ -746,7 +746,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!");
else if (tmptx.vout[1].nValue!=amount)
return eval->Invalid("amount in opret not matching tx tokens amount!");
else if (komodo_txnotarizedconfirmed(withdrawtxid) == false)
else if (hush_txnotarizedconfirmed(withdrawtxid) == false)
return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!");
else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid gatewaysbind txid!");
@ -756,7 +756,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("refcoin different than in bind tx");
else if (tmptokenid!=tokenid)
return eval->Invalid("tokenid does not match tokenid from gatewaysbind");
else if (komodo_txnotarizedconfirmed(bindtxid) == false)
else if (hush_txnotarizedconfirmed(bindtxid) == false)
return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!");
else if (IsCCInput(tx.vin[0].scriptSig) != 0)
return eval->Invalid("vin.0 is normal for gatewayscompletesigning!");
@ -777,7 +777,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("invalid gatewayscompletesigning txid!");
else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysCompleteSigningOpRet(tmptx.vout[numvouts-1].scriptPubKey,withdrawtxid,tmprefcoin,K,hex)!='S')
return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!");
else if (komodo_txnotarizedconfirmed(completetxid) == false)
else if (hush_txnotarizedconfirmed(completetxid) == false)
return eval->Invalid("gatewayscompletesigning tx is not yet confirmed(notarised)!");
else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid withdraw txid!");
@ -785,7 +785,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!");
else if (tmprefcoin!=refcoin)
return eval->Invalid("refcoin different than in bind tx");
else if (komodo_txnotarizedconfirmed(withdrawtxid) == false)
else if (hush_txnotarizedconfirmed(withdrawtxid) == false)
return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!");
else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid gatewaysbind txid!");
@ -795,7 +795,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("refcoin different than in bind tx");
else if (tmptokenid!=tokenid)
return eval->Invalid("tokenid does not match tokenid from gatewaysbind");
else if (komodo_txnotarizedconfirmed(bindtxid) == false)
else if (hush_txnotarizedconfirmed(bindtxid) == false)
return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!");
else if ( IsCCInput(tx.vin[0].scriptSig) != 0 )
return eval->Invalid("vin.0 is normal for gatewaysmarkdone!");
@ -874,12 +874,12 @@ UniValue GatewaysBind(const CPubKey& pk, uint64_t txfee,std::string coin,uint256
cp = CCinit(&C,EVAL_GATEWAYS);
cpTokens = CCinit(&CTokens,EVAL_TOKENS);
if (coin=="KMD")
if (coin=="HUSH")
{
prefix = KMD_PUBTYPE;
prefix2 = KMD_P2SHTYPE;
wiftype = KMD_WIFTYPE;
taddr = KMD_TADDR;
prefix = HUSH_PUBTYPE;
prefix2 = HUSH_P2SHTYPE;
wiftype = HUSH_WIFTYPE;
taddr = HUSH_TADDR;
}
else
{
@ -946,7 +946,7 @@ UniValue GatewaysDeposit(const CPubKey& pk, uint64_t txfee,uint256 bindtxid,int3
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cant find bindtxid " << bindtxid.GetHex());
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin )
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid coin - bindtxid " << bindtxid.GetHex() << " coin." << coin);
if (komodo_txnotarizedconfirmed(bindtxid)==false)
if (hush_txnotarizedconfirmed(bindtxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewaysbind tx not yet confirmed/notarized");
n = (int32_t)pubkeys.size();
merkleroot = zeroid;
@ -997,13 +997,13 @@ UniValue GatewaysClaim(const CPubKey& pk, uint64_t txfee,uint256 bindtxid,std::s
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cant find bindtxid " << bindtxid.GetHex());
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin )
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid coin - bindtxid " << bindtxid.GetHex() << " coin." << coin);
if (komodo_txnotarizedconfirmed(bindtxid)==false)
if (hush_txnotarizedconfirmed(bindtxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewaysbind tx not yet confirmed/notarized");
if ( myGetTransaction(deposittxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cant find deposittxid " << bindtxid.GetHex());
if (DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmptxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D' || coin != refcoin)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid coin - deposittxid " << bindtxid.GetHex() << " coin." << coin);
if (komodo_txnotarizedconfirmed(deposittxid)==false)
if (hush_txnotarizedconfirmed(deposittxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewaysdeposit tx not yet confirmed/notarized");
if (tmpdestpub!=destpub)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "different destination pubkey from desdeposit tx");
@ -1038,7 +1038,7 @@ UniValue GatewaysWithdraw(const CPubKey& pk, uint64_t txfee,uint256 bindtxid,std
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cant find bindtxid " << bindtxid.GetHex());
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin )
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid coin - bindtxid " << bindtxid.GetHex() << " coin." << coin);
if (komodo_txnotarizedconfirmed(bindtxid)==false)
if (hush_txnotarizedconfirmed(bindtxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewaysbind tx not yet confirmed/notarized");
_GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk);
SetCCunspents(unspentOutputs,coinaddr,true);
@ -1097,7 +1097,7 @@ UniValue GatewaysPartialSign(const CPubKey& pk, uint64_t txfee,uint256 lasttxid,
withdrawtxid=lasttxid;
if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw tx " << lasttxid.GetHex());
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
else if (hush_txnotarizedconfirmed(withdrawtxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayswithdraw tx not yet confirmed/notarized");
else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "can't find bind tx " << bindtxid.GetHex());
@ -1114,7 +1114,7 @@ UniValue GatewaysPartialSign(const CPubKey& pk, uint64_t txfee,uint256 lasttxid,
else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W'
|| refcoin!=coin)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw tx " << withdrawtxid.GetHex());
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
else if (hush_txnotarizedconfirmed(withdrawtxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayswithdraw tx not yet confirmed/notarized");
else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "can't find bind tx " << bindtxid.GetHex());
@ -1151,7 +1151,7 @@ UniValue GatewaysCompleteSigning(const CPubKey& pk, uint64_t txfee,uint256 lastt
withdrawtxid=lasttxid;
if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw tx " << lasttxid.GetHex());
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
else if (hush_txnotarizedconfirmed(withdrawtxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayswithdraw tx not yet confirmed/notarized");
else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "can't find bind tx " << bindtxid.GetHex());
@ -1168,7 +1168,7 @@ UniValue GatewaysCompleteSigning(const CPubKey& pk, uint64_t txfee,uint256 lastt
else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W'
|| refcoin!=coin)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw tx " << withdrawtxid.GetHex());
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
else if (hush_txnotarizedconfirmed(withdrawtxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayswithdraw tx not yet confirmed/notarized");
else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "can't find bind tx " << bindtxid.GetHex());
@ -1200,7 +1200,7 @@ UniValue GatewaysMarkDone(const CPubKey& pk, uint64_t txfee,uint256 completetxid
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid completesigning txid " << completetxid.GetHex());
else if (DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex)!='S' || refcoin!=coin)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cannot decode completesigning tx opret " << completetxid.GetHex());
if (komodo_txnotarizedconfirmed(completetxid)==false)
if (hush_txnotarizedconfirmed(completetxid)==false)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayscompletesigning tx not yet confirmed/notarized");
else if (myGetTransaction(withdrawtxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())==0)
CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw txid " << withdrawtxid.GetHex());
@ -1266,7 +1266,7 @@ UniValue GatewaysPendingDeposits(const CPubKey& pk, uint256 bindtxid,std::string
pub=HexStr(destpub);
obj.push_back(Pair("claim_pubkey",pub));
obj.push_back(Pair("amount",(double)amount/COIN));
obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid)));
obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(txid)));
pending.push_back(obj);
}
}
@ -1340,7 +1340,7 @@ UniValue GatewaysPendingWithdraws(const CPubKey& pk, uint256 bindtxid,std::strin
obj.push_back(Pair("withdrawaddr",withaddr));
sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN);
obj.push_back(Pair("amount",numstr));
obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(tx.GetHash())));
obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(tx.GetHash())));
if ( queueflag != 0 )
{
obj.push_back(Pair("depositaddr",depositaddr));
@ -1415,7 +1415,7 @@ UniValue GatewaysProcessedWithdraws(const CPubKey& pk, uint256 bindtxid,std::str
obj.push_back(Pair("withdrawtxidaddr",txidaddr));
GetCustomscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG,taddr,prefix,prefix2);
obj.push_back(Pair("withdrawaddr",withaddr));
obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid)));
obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(txid)));
sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN);
obj.push_back(Pair("amount",numstr));
obj.push_back(Pair("hex",hex));

2
src/cc/import.cpp

@ -395,7 +395,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string
LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport not enough pubkeys for given N " << std::endl);
return(-1);
}
else if (komodo_txnotarizedconfirmed(bindtxid) == false)
else if (hush_txnotarizedconfirmed(bindtxid) == false)
{
LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport bindtx not yet confirmed/notarized" << std::endl);
return(-1);

54
src/cc/importgateway.cpp

@ -19,13 +19,11 @@
#include "CCImportGateway.h"
#include "key_io.h"
#include "../importcoin.h"
// start of consensus code
#define KMD_PUBTYPE 60
#define KMD_P2SHTYPE 85
#define KMD_WIFTYPE 188
#define KMD_TADDR 0
#define HUSH_PUBTYPE 60
#define HUSH_P2SHTYPE 85
#define HUSH_WIFTYPE 188
#define HUSH_TADDR 0
#define CC_MARKER_VALUE 10000
extern uint256 HUSH_EARLYTXID;
@ -46,7 +44,7 @@ uint8_t DecodeImportGatewayBindOpRet(char *burnaddr,const CScript &scriptPubKey,
burnaddr[0] = 0;
if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> coin; ss >> oracletxid; ss >> M; ss >> N; ss >> importgatewaypubkeys; ss >> taddr; ss >> prefix; ss >> prefix2; ss >> wiftype) != 0 )
{
if ( prefix == KMD_PUBTYPE && prefix2 == KMD_P2SHTYPE )
if ( prefix == HUSH_PUBTYPE && prefix2 == HUSH_P2SHTYPE )
{
if ( N > 1 )
{
@ -362,7 +360,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact
return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!");
else if (tmptx.vout[1].nValue!=amount)
return eval->Invalid("amount in opret not matching tx tokens amount!");
else if (komodo_txnotarizedconfirmed(withdrawtxid) == false)
else if (hush_txnotarizedconfirmed(withdrawtxid) == false)
return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!");
else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid gatewaysbind txid!");
@ -370,7 +368,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact
return eval->Invalid("invalid gatewaysbind OP_RETURN data!");
else if (tmprefcoin!=refcoin)
return eval->Invalid("refcoin different than in bind tx");
else if (komodo_txnotarizedconfirmed(bindtxid) == false)
else if (hush_txnotarizedconfirmed(bindtxid) == false)
return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!");
else if (IsCCInput(tx.vin[0].scriptSig) != 0)
return eval->Invalid("vin.0 is normal for gatewayspartialsign!");
@ -404,7 +402,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact
return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!");
else if (tmptx.vout[1].nValue!=amount)
return eval->Invalid("amount in opret not matching tx tokens amount!");
else if (komodo_txnotarizedconfirmed(withdrawtxid) == false)
else if (hush_txnotarizedconfirmed(withdrawtxid) == false)
return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!");
else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid gatewaysbind txid!");
@ -412,7 +410,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact
return eval->Invalid("invalid gatewaysbind OP_RETURN data!");
else if (tmprefcoin!=refcoin)
return eval->Invalid("refcoin different than in bind tx");
else if (komodo_txnotarizedconfirmed(bindtxid) == false)
else if (hush_txnotarizedconfirmed(bindtxid) == false)
return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!");
else if (IsCCInput(tx.vin[0].scriptSig) != 0)
return eval->Invalid("vin.0 is normal for gatewayscompletesigning!");
@ -433,7 +431,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact
return eval->Invalid("invalid gatewayscompletesigning txid!");
else if ((numvouts=tmptx.vout.size()) > 0 && DecodeImportGatewayCompleteSigningOpRet(tmptx.vout[numvouts-1].scriptPubKey,withdrawtxid,tmprefcoin,K,hex)!='S')
return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!");
else if (komodo_txnotarizedconfirmed(completetxid) == false)
else if (hush_txnotarizedconfirmed(completetxid) == false)
return eval->Invalid("gatewayscompletesigning tx is not yet confirmed(notarised)!");
else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid withdraw txid!");
@ -441,7 +439,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact
return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!");
else if (tmprefcoin!=refcoin)
return eval->Invalid("refcoin different than in bind tx");
else if (komodo_txnotarizedconfirmed(withdrawtxid) == false)
else if (hush_txnotarizedconfirmed(withdrawtxid) == false)
return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!");
else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0)
return eval->Invalid("invalid gatewaysbind txid!");
@ -449,7 +447,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact
return eval->Invalid("invalid gatewaysbind OP_RETURN data!");
else if (tmprefcoin!=refcoin)
return eval->Invalid("refcoin different than in bind tx");
else if (komodo_txnotarizedconfirmed(bindtxid) == false)
else if (hush_txnotarizedconfirmed(bindtxid) == false)
return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!");
else if ( IsCCInput(tx.vin[0].scriptSig) != 0 )
return eval->Invalid("vin.0 is normal for gatewaysmarkdone!");
@ -481,12 +479,12 @@ std::string ImportGatewayBind(uint64_t txfee,std::string coin,uint256 oracletxid
cp = CCinit(&C,EVAL_IMPORTGATEWAY);
cpTokens = CCinit(&CTokens,EVAL_TOKENS);
if (coin=="KMD")
if (coin=="HUSH")
{
prefix = KMD_PUBTYPE;
prefix2 = KMD_P2SHTYPE;
wiftype = KMD_WIFTYPE;
taddr = KMD_TADDR;
prefix = HUSH_PUBTYPE;
prefix2 = HUSH_P2SHTYPE;
wiftype = HUSH_WIFTYPE;
taddr = HUSH_TADDR;
}
else
{
@ -597,7 +595,7 @@ std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (komodo_txnotarizedconfirmed(bindtxid)==false)
if (hush_txnotarizedconfirmed(bindtxid)==false)
{
CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized");
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@ -673,7 +671,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (komodo_txnotarizedconfirmed(bindtxid)==false)
if (hush_txnotarizedconfirmed(bindtxid)==false)
{
CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized");
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@ -754,7 +752,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
else if (hush_txnotarizedconfirmed(withdrawtxid)==false)
{
CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized");
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@ -801,7 +799,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
else if (hush_txnotarizedconfirmed(withdrawtxid)==false)
{
CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized");
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@ -872,7 +870,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
else if (hush_txnotarizedconfirmed(withdrawtxid)==false)
{
CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized");
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@ -918,7 +916,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
else if (hush_txnotarizedconfirmed(withdrawtxid)==false)
{
CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized");
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@ -972,7 +970,7 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (komodo_txnotarizedconfirmed(completetxid)==false)
if (hush_txnotarizedconfirmed(completetxid)==false)
{
CCerror = strprintf("gatewayscompletesigning tx not yet confirmed/notarized");
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@ -1084,7 +1082,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin)
obj.push_back(Pair("withdrawaddr",withaddr));
sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN);
obj.push_back(Pair("amount",numstr));
obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(tx.GetHash())));
obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(tx.GetHash())));
if ( queueflag != 0 )
{
obj.push_back(Pair("depositaddr",burnaddr));
@ -1159,7 +1157,7 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin)
obj.push_back(Pair("withdrawtxidaddr",txidaddr));
GetCustomscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG,taddr,prefix,prefix2);
obj.push_back(Pair("withdrawaddr",withaddr));
obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid)));
obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(txid)));
sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN);
obj.push_back(Pair("amount",numstr));
obj.push_back(Pair("hex",hex));

2
src/cc/importpayout.cpp

@ -31,7 +31,7 @@
* notarised on another chain.
*
* IN: params - condition params
* IN: importTx - Payout transaction on value chain (KMD)
* IN: importTx - Payout transaction on value chain (HUSH)
* IN: nIn - index of input of stake
*
* importTx: Spends stakeTx with payouts from asset chain

6
src/cc/makerogue

@ -1,12 +1,14 @@
#!/bin/sh
# Copyright 2016-2021 The Hush developers
cd rogue;
make clean;
if [ "$HOST" = "x86_64-w64-mingw32" ]; then
echo building rogue.exe...
echo "Not supported"
exit 1
./configure --host=x86_64-w64-mingw32
echo $PWD
wget https://github.com/KomodoPlatform/rogue/releases/download/0.3.3b-01/x86_64-w64-mingw32.tar.gz
# wget ...
tar xvfz x86_64-w64-mingw32.tar.gz && rm x86_64-w64-mingw32.tar.gz
echo lib archive cleaned
echo $PWD

28
src/cc/musig.cpp

@ -18,7 +18,7 @@
/* first make a combined pk:
./komodo-cli -ac_name=MUSIG cclib combine 18 '["02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28","0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4"]'
./hush-cli -ac_name=MUSIG cclib combine 18 '["02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28","0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4"]'
{
"pkhash": "5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",
"combined_pk": "03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b",
@ -28,7 +28,7 @@
the combined_pk and pkhash will be needed for various other rpc calls
second, send 1 coin to the combined_pk
./komodo-cli -ac_name=MUSIG cclib send 18 '["03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b",1]'
./hush-cli -ac_name=MUSIG cclib send 18 '["03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b",1]'
{
"hex": "0400008085202f8901a980664dffc810725a79ffb89ac48be4c7b6bade9b789732fcf871acf8e81a2e010000006a47304402207e52763661ecd2c34a65d6623950be11794825db71576dc11894c606ddc317800220028fef46dc20630d0fdf22647b5d4ff0f1c47cf75f48702d0a91d5589eff99d001210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ffffffff031008f60500000000302ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cce09aa4350000000023210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac0000000000000000266a2412782103f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b00000000920500000000000000000000000000",
"txid": "5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c",
@ -36,7 +36,7 @@
}
sendrawtransaction of the above hex.
./komodo-cli -ac_name=MUSIG getrawtransaction 5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c 1
./hush-cli -ac_name=MUSIG getrawtransaction 5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c 1
"vout": [
{
"value": 1.00010000,
@ -72,7 +72,7 @@
get the msg we need to sign:
./komodo-cli -ac_name=MUSIG cclib calcmsg 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac"]'
./hush-cli -ac_name=MUSIG cclib calcmsg 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac"]'
{
"msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75",
@ -85,7 +85,7 @@ the "msg" is what needs to be signed to create a valid spend
5 args: ind, numsigners, combined_pk, pkhash, message to be signed
on node with pubkey: 02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28
./komodo-cli -ac_name=MUSIG cclib session 18 '[0,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]'
./hush-cli -ac_name=MUSIG cclib session 18 '[0,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]'
{
"myind": 0,
"numsigners": 2,
@ -94,7 +94,7 @@ the "msg" is what needs to be signed to create a valid spend
}
on node with pubkey: 0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4
./komodo-cli -ac_name=MUSIG cclib session 18 '[1,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]'
./hush-cli -ac_name=MUSIG cclib session 18 '[1,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]'
{
"myind": 1,
"numsigners": 2,
@ -103,7 +103,7 @@ the "msg" is what needs to be signed to create a valid spend
}
now we need to get the commitment from each node to the other one. the session already put the commitment for each node into the global struct. Keep in mind there is a single global struct with session unique to each cclib session call. that means no restarting any deamon in the middle of the process on any of the nodes and only call cclib session a single time. this is an artificial restriction just to simplify the initial implementation of musig
./komodo-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","c2291acb747a75b1a40014d8eb0cc90a1360f74d413f65f78e20a7de45eda851"]'
./hush-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","c2291acb747a75b1a40014d8eb0cc90a1360f74d413f65f78e20a7de45eda851"]'
{
"added_index": 1,
"myind": 0,
@ -111,7 +111,7 @@ the "msg" is what needs to be signed to create a valid spend
"result": "success"
}
./komodo-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"d242cff13fa8c9b83248e4219fda459ada146b885f2171481f1b0f66c66d94ad"]'
./hush-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"d242cff13fa8c9b83248e4219fda459ada146b885f2171481f1b0f66c66d94ad"]'
{
"added_index": 0,
"myind": 1,
@ -120,7 +120,7 @@ the "msg" is what needs to be signed to create a valid spend
}
Now exchange the revealed nonces to each node:
./komodo-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","039365deaaaea089d509ba4c9f846de2baf4aa04cf6b26fa2c1cd818553e47f80c"]'
./hush-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","039365deaaaea089d509ba4c9f846de2baf4aa04cf6b26fa2c1cd818553e47f80c"]'
{
"added_index": 1,
"myind": 0,
@ -128,7 +128,7 @@ the "msg" is what needs to be signed to create a valid spend
"result": "success"
}
./komodo-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"02fec7a9310c959a0a97b86bc3f8c30d392d1fb51793915898c568f73f1f70476b"]'
./hush-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"02fec7a9310c959a0a97b86bc3f8c30d392d1fb51793915898c568f73f1f70476b"]'
{
"added_index": 0,
"myind": 1,
@ -137,14 +137,14 @@ the "msg" is what needs to be signed to create a valid spend
}
Almost there! final step is to exchange the partial sigs between signers
./komodo-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","4a3795e6801b355102c617390cf5a462061e082e35dc2ed8f8b1fab54cc0769e"]'
./hush-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","4a3795e6801b355102c617390cf5a462061e082e35dc2ed8f8b1fab54cc0769e"]'
{
"added_index": 1,
"result": "success",
"combinedsig": "a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"
}
./komodo-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"1d65c09cd9bffe4f0604227e66cd7cd221480bbb08262fe885563a9df7cf8f5b"]'
./hush-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"1d65c09cd9bffe4f0604227e66cd7cd221480bbb08262fe885563a9df7cf8f5b"]'
{
"added_index": 0,
"result": "success",
@ -155,7 +155,7 @@ the "msg" is what needs to be signed to create a valid spend
Now for a sanity test, we can use the verify call to make sure this sig will work with the msg needed for the spend:
./komodo-cli -ac_name=MUSIG cclib verify 18 '["f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75","03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]'
./hush-cli -ac_name=MUSIG cclib verify 18 '["f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75","03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]'
{
"msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75",
"combined_pk": "03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b",
@ -165,7 +165,7 @@ the "msg" is what needs to be signed to create a valid spend
and finally the spend: sendtxid, scriptPubKey, musig
./komodo-cli -ac_name=MUSIG cclib spend 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]'
./hush-cli -ac_name=MUSIG cclib spend 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]'
{
"scriptpubkey": "210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac",
"msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75",

2
src/cc/payments.cpp

@ -31,7 +31,7 @@
First step is to create txids with the info needed in their opreturns. this info is the weight, scriptPubKey and opret if needed. To do that txidopret is used:
./c is a script that invokes komodo-cli with the correct -ac_name
./c is a script that invokes hush-cli with the correct -ac_name
./c paymentstxidopret \"[9,%222102d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388dac%22]\" -> rawhex with txid 95d9fc8d8a3ef63693c7427e59ff5e177ef63b7345d5f6d6497ac262699a8def

26
src/cc/pegs.cpp

@ -31,45 +31,45 @@ pegs CC is able to create a coin backed (by any supported coin with gateways CC
<one hour later...>
OK, now we are ready to describe the pegs CC. Let us imagine an -ac_import sidechain with KMD gateways CC. Now we have each native coin fungible with the real KMD via the gateways deposit/withdraw mechanism. Let us start with that and make a pegged and backed USD chain.
OK, now we are ready to describe the pegs CC. Let us imagine an -ac_import sidechain with HUSH gateways CC. Now we have each native coin fungible with the real HUSH via the gateways deposit/withdraw mechanism. Let us start with that and make a pegged and backed USD chain.
<alternatively we can start from a CC enabled chain with external value>
Here the native coin is KMD, but we want USD, so there needs to be a way to convert the KMD amounts into USD amounts. Something like "KMDBTC, BTCUSD, *, 1" which is the prices CC syntax to calculate KMD/USD, which is exactly what we need. So now we can assume that we have a block by block usable KMD/USD price. implementationwise, there can be an -ac option like -ac_peg="KMDBTC, BTCUSD, *, 1" and in conjunction with -ac_import=KMD gateways CC sidechain, we now have a chain where deposit of KMD issues the correct USD coins and redeem of USD coins releases the correct number of KMD coins.
Here the native coin is HUSH, but we want USD, so there needs to be a way to convert the HUSH amounts into USD amounts. Something like "HUSHBTC, BTCUSD, *, 1" which is the prices CC syntax to calculate HUSH/USD, which is exactly what we need. So now we can assume that we have a block by block usable HUSH/USD price. implementationwise, there can be an -ac option like -ac_peg="HUSHBTC, BTCUSD, *, 1" and in conjunction with -ac_import=HUSH gateways CC sidechain, we now have a chain where deposit of HUSH issues the correct USD coins and redeem of USD coins releases the correct number of HUSH coins.
Are we done yet?
Not quite, as the prices of KMD will be quite volatile relative to USD, which is good during bull markets, not so happy during bear markets. There are 2 halves to this problem, how to deal with massive price increase (easy to solve), how to solve 90% price drop (a lot harder).
Not quite, as the prices of HUSH will be quite volatile relative to USD, which is good during bull markets, not so happy during bear markets. There are 2 halves to this problem, how to deal with massive price increase (easy to solve), how to solve 90% price drop (a lot harder).
In order to solve both, what is needed is an "account" based tracking which updates based on both price change, coins issued, payments made. So let us create an account that is based on a specific pubkey, where all relevant deposits, issuances, withdraws are tracked via appropriate vin/vout markers.
Let us modify the USD chain above so that only 80% of the possible USD is issued and 20% held in reserve. This 80% should be at least some easily changeable #define, or even an -ac parameter. We want the issued coins to be released without any encumberances, but the residual 20% value is still controlled (owned) but the depositor. This account has the amount of KMD deposited and USD issued. At the moment of deposit, there will still be 20% equity left. Let us start with 1000 KMD deposit, $1.5 per KMD -> 800 KMD converted to 1200 USD into depositor pubkey and the account of (1000 KMD, -1200 USD) = 200 KMD or $300 equity.
Let us modify the USD chain above so that only 80% of the possible USD is issued and 20% held in reserve. This 80% should be at least some easily changeable #define, or even an -ac parameter. We want the issued coins to be released without any encumberances, but the residual 20% value is still controlled (owned) but the depositor. This account has the amount of HUSH deposited and USD issued. At the moment of deposit, there will still be 20% equity left. Let us start with 1000 HUSH deposit, $1.5 per HUSH -> 800 HUSH converted to 1200 USD into depositor pubkey and the account of (1000 HUSH, -1200 USD) = 200 HUSH or $300 equity.
Now it becomes easy for the bull market case, which is to allow (for a fee like 1%) issuance of more USD as the equity increases, so let us imagine KMD at $10:
Now it becomes easy for the bull market case, which is to allow (for a fee like 1%) issuance of more USD as the equity increases, so let us imagine HUSH at $10:
(1000 KMD, -1200 USD, 200KMD reserve) -> $2000 equity, issue 80% -> $1600 using 160 KMD
(1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve)
(1000 HUSH, -1200 USD, 200HUSH reserve) -> $2000 equity, issue 80% -> $1600 using 160 HUSH
(1000 HUSH, -1200 USD, 200HUSH reserve, -160HUSH, issue $1600 USD, 40 HUSH reserve)
we have $2800 USD in circulation, 40 KMD reserve left against $10000 marketcap of the original deposit. It it easy to see that there are never any problems with lack of KMD to redeem the issued USD in a world where prices only go up. Total USD issuance can be limited by using a decentralized account tracking based on each deposit.
we have $2800 USD in circulation, 40 HUSH reserve left against $10000 marketcap of the original deposit. It it easy to see that there are never any problems with lack of HUSH to redeem the issued USD in a world where prices only go up. Total USD issuance can be limited by using a decentralized account tracking based on each deposit.
What is evident though is that with the constantly changing price and the various times that all the various deposits issue USD, the global reserves are something that will be hard to predict and in fact needs to be specifically tracked. Let us combine all accounts exposure in to a global reserves factor. This factor will control various max/min/ allowed and fee percentages.
Now we are prepared to handle the price goes down scenario. We can rely on the global equity/reserve ratio to be changing relatively slowly as the reference price is the smooted trustless oracles price. This means there will be enough blocks to adjust the global reserves percentage. What we need to do is liquidate specific positions that have the least reserves.
What does liquidation mean? It means a specific account will be purchased at below its current value and the KMD withdrawn. Let us assume the price drops to $5:
What does liquidation mean? It means a specific account will be purchased at below its current value and the HUSH withdrawn. Let us assume the price drops to $5:
(1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve) 1000 KMD with 2800 USD issued so $2200 reserves. Let us assume it can be liquidated at a 10% discount, so for $2000 in addition to the $2800, the 5000 KMD is able to be withdrawn. This removes 4800 USD coins for 1000 KMD, which is a very low reserve amount of 4%. If a low reserve amount is removed from the system, then the global reserve amount must be improved.
(1000 HUSH, -1200 USD, 200HUSH reserve, -160HUSH, issue $1600 USD, 40 HUSH reserve) 1000 HUSH with 2800 USD issued so $2200 reserves. Let us assume it can be liquidated at a 10% discount, so for $2000 in addition to the $2800, the 5000 HUSH is able to be withdrawn. This removes 4800 USD coins for 1000 HUSH, which is a very low reserve amount of 4%. If a low reserve amount is removed from the system, then the global reserve amount must be improved.
In addition to the global reserves calculation, there needs to be a trigger percentage that enables positions to be liquidated. We also want to liquidate the worst positions, so in addition to the trigger percentage, there should be a liquidation threshold, and the liquidator would need to find 3 or more better positions that are beyond the liquidation threshold, to be able to liquidate. This will get us to at most 3 accounts that could be liquidated but are not able to, so some method to allow those to also be liquidated. The liquidating nodes are making instant profits, so they should be expected to do whatever blockchain scanning and proving to make things easy for the rest of the nodes.
One last issue is the normal redemption case where we are not liquidating. In this case, it should be done at the current marketprice, should improve the global reserves metrics and not cause anybody whose position was modified to have cause for complaint. Ideally, there would be an account that has the identical to the global reserve percentage and also at the same price as current marketprice, but this is not realistic, so we need to identify classes of accounts and consider which ones can be fully or partially liquidated to satisfy the constraints.
looking at our example account:
(1000 KMD, -1200 USD, 200KMD reserve, -160KMD, issue $1600 USD, 40 KMD reserve)
(1000 HUSH, -1200 USD, 200HUSH reserve, -160HUSH, issue $1600 USD, 40 HUSH reserve)
what sort of non-liquidation withdraw would be acceptable? if the base amount 1000 KMD is reduced along with USD owed, then the reserve status will go up for the account. but that would seem to allow extra USD to be able to be issued. there should be no disadvantage from funding a withdraw, but also not any large advantage. it needs to be a neutral event....
what sort of non-liquidation withdraw would be acceptable? if the base amount 1000 HUSH is reduced along with USD owed, then the reserve status will go up for the account. but that would seem to allow extra USD to be able to be issued. there should be no disadvantage from funding a withdraw, but also not any large advantage. it needs to be a neutral event....
One solution is to allow for the chance for any account to be liquidated, but the equity compensated for with a premium based on the account reserves. So in the above case, a premium of 5% on the 40KMD reserve is paid to liquidate its account. Instead of 5% premium, a lower 1% can be done if based on the MAX(correlated[daywindow],smoothed) so we get something that is close to the current marketprice. To prevent people taking advantage of the slowness of the smoothed price to adjust, there would need to be a one day delay in the withdraw.
One solution is to allow for the chance for any account to be liquidated, but the equity compensated for with a premium based on the account reserves. So in the above case, a premium of 5% on the 40HUSH reserve is paid to liquidate its account. Instead of 5% premium, a lower 1% can be done if based on the MAX(correlated[daywindow],smoothed) so we get something that is close to the current marketprice. To prevent people taking advantage of the slowness of the smoothed price to adjust, there would need to be a one day delay in the withdraw.
From a practical sense, it seems a day is a long time, so maybe having a way to pay a premium like 10%, or wait a day to get the MAX(correlated[daywindow],smoothed) price. This price "jumping" might also be taken advantage of in the deposit side, so similar to prices CC it seems good to have the MAX(correlated[daywindow],smoothed) method.

73
src/cc/rogue/main.c

@ -620,7 +620,7 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *
return(chunk.memory);
}
uint16_t _komodo_userpass(char *username, char *password, FILE *fp)
uint16_t _hush_userpass(char *username, char *password, FILE *fp)
{
char *rpcuser,*rpcpassword,*str,*ipaddress,line[8192]; uint16_t port = 0;
rpcuser = rpcpassword = 0;
@ -658,60 +658,17 @@ uint16_t _komodo_userpass(char *username, char *password, FILE *fp)
return(port);
}
/*void hush_statefname(char *fname,char *symbol,char *str)
{
int32_t n,len;
sprintf(fname,"%s",getDataDir());
if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 )
{
len = (int32_t)strlen(fname);
if ( strcmp(ASSETCHAINS_SYMBOL,&fname[len - n]) == 0 )
fname[len - n] = 0;
else
{
printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,ASSETCHAINS_SYMBOL,n,len,&fname[len - n]);
return;
}
}
else
{
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
#endif
}
if ( symbol != 0 && symbol[0] != 0 && strcmp("KMD",symbol) != 0 )
{
strcat(fname,symbol);
//printf("statefname.(%s) -> (%s)\n",symbol,fname);
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
#endif
}
strcat(fname,str);
//printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname);
}*/
uint16_t komodo_userpass(char *userpass,char *symbol)
uint16_t hush_userpass(char *userpass,char *symbol)
{
FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[HUSH_SMART_CHAIN_MAXLEN];
userpass[0] = 0;
if ( strcmp("KMD",symbol) == 0 )
{
#ifdef __APPLE__
sprintf(confname,"Komodo.conf");
#else
sprintf(confname,"komodo.conf");
#endif
}
else sprintf(confname,"%s.conf",symbol);
sprintf(confname,"%s.conf",symbol);
//hush_statefname(fname,symbol,confname);
if ( (fp= fopen(confname,"rb")) != 0 )
{
port = _komodo_userpass(username,password,fp);
port = _hush_userpass(username,password,fp);
sprintf(userpass,"%s:%s",username,password);
if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 )
strcpy(USERPASS,userpass);
@ -722,7 +679,7 @@ uint16_t komodo_userpass(char *userpass,char *symbol)
#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port)
{
//static void *cHandle;
char url[512],*retstr=0,*retstr2=0,postdata[8192];
@ -746,7 +703,7 @@ int32_t rogue_sendrawtransaction(char *rawtx)
char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1;
params = (char *)malloc(strlen(rawtx) + 16);
sprintf(params,"[\"%s\"]",rawtx);
if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 )
if ( (retstr= hush_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 )
{
if ( 0 ) // causes 4th level crash
{
@ -811,7 +768,7 @@ int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,cha
if ( 0 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 )
{
sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr);
if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 )
if ( (retstr= hush_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
@ -843,7 +800,7 @@ int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,cha
hexstr[i<<1] = 0;
if ( 0 )
{
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr);
sprintf(cmd,"./hush-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr);
if ( system(cmd) != 0 )
fprintf(stderr,"error issuing (%s)\n",cmd);
}
@ -853,7 +810,7 @@ int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,cha
if ( fp == 0 )
fp = fopen("keystrokes.log","a");
sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr);
if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 )
if ( (retstr= hush_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 )
{
if ( fp != 0 )
{
@ -903,7 +860,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
if ( 0 )
{
sprintf(fname,"%s.gameinfo",gametxidstr);
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname);
sprintf(cmd,"./hush-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname);
if ( system(cmd) != 0 )
fprintf(stderr,"error issuing (%s)\n",cmd);
else filestr = (char *)OS_fileptr(&allocsize,fname);
@ -911,7 +868,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
else
{
sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr);
filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT);
filestr = hush_issuemethod(USERPASS,"cclib",params,ROGUE_PORT);
}
if ( filestr != 0 )
{
@ -1007,7 +964,7 @@ int main(int argc, char **argv, char **envp)
#endif
#endif
ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL);
ROGUE_PORT = hush_userpass(userpass,ASSETCHAINS_SYMBOL);
if ( IPADDRESS[0] == 0 )
strcpy(IPADDRESS,"127.0.0.1");
printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s) IPADDRESS.%s \n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS,IPADDRESS); sleep(1);
@ -1035,7 +992,7 @@ int main(int argc, char **argv, char **envp)
fclose(fp);
if ( ROGUE_PORT == 0 )
{
printf("you must copy ROGUE.conf from ~/.komodo/ROGUE/ROGUE.conf (or equivalent location) to current dir\n");
printf("you must copy ROGUE.conf from ~/.hush/ROGUE/ROGUE.conf (or equivalent location) to current dir\n");
return(-1);
}
return(rogue(argc,argv,envp));

2
src/cc/rogue/rogue.c

@ -191,7 +191,7 @@ void rogue_bailout(struct rogue_state *rs)
//sleep(5);
return;
/*fprintf(stderr,"bailing out\n");
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr);
sprintf(cmd,"./hush-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr);
if ( system(cmd) != 0 )
fprintf(stderr,"error issuing (%s)\n",cmd);*/
}

18
src/cc/rogue_rpc.cpp

@ -52,29 +52,29 @@ std::string Rogue_pname = "";
Here is how to play:
./komodo-cli -ac_name=ROGUE cclib newgame 17 \"[3,10]\" -> this will create a hex transaction that when broadcast with sendrawtransaction will get a gametxid onto the blockchain. This specific command was for 3 players and a buyin of 10 ROGUE. Lets assume the gametxid is 4fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a, most all the other commands will need the gametxid.
./hush-cli -ac_name=ROGUE cclib newgame 17 \"[3,10]\" -> this will create a hex transaction that when broadcast with sendrawtransaction will get a gametxid onto the blockchain. This specific command was for 3 players and a buyin of 10 ROGUE. Lets assume the gametxid is 4fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a, most all the other commands will need the gametxid.
you can always find all the existing games with:
./komodo-cli -ac_name=ROGUE cclib pending 17
./hush-cli -ac_name=ROGUE cclib pending 17
and info about a specific game with:
./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\"
./hush-cli -ac_name=ROGUE cclib gameinfo 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\"
due to quirks of various parsing at the shell, rpc and internal level, the above convention is used where %22 is added where " should be. also all fields are separated by , without any space.
When you do a gameinfo command it will show a "run" field and that will tell you if you are registered for the game or not. If not, the "run" field shows the register syntax you need to do, if you are registered, it will show the command line to start the rogue game that is playing the registered game.
./komodo-cli -ac_name=ROGUE cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22playerdata_txid%22]\"
./hush-cli -ac_name=ROGUE cclib register 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22,%22playerdata_txid%22]\"
If you want to cash in your ingame gold and preserve your character for another battle, do the bailout:
./komodo-cli -ac_name=ROGUE cclib bailout 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\"
./hush-cli -ac_name=ROGUE cclib bailout 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\"
If you won your game before anybody else did or if you are the last one left who didnt bailout, you can claim the prize:
./komodo-cli -ac_name=ROGUE cclib highlander 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\"
./hush-cli -ac_name=ROGUE cclib highlander 17 \"[%224fd6f5cad0fac455e5989ca6eef111b00292845447075a802e9335879146ad5a%22]\"
The txid you get from the bailout or highlander transactions is the "playerdata_txid" that you can use in future games.
@ -129,7 +129,7 @@ std::string Rogue_pname = "";
// keystrokes retry
//////////////////////// start of CClib interface
//./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null &
//./hushd -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null &
// cclib newgame 17 \"[3,10]\"
// cclib pending 17
@ -138,7 +138,7 @@ std::string Rogue_pname = "";
// ./rogue <seed> gui -> creates keystroke files
// ./c cclib register 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22,%222475182f9d5169d8a3249d17640e4eccd90f4ee43ab04791129b0fa3f177b14a%22]\"
// ./c cclib bailout 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22]\"
// ./komodo-cli -ac_name=ROGUE cclib register 17 \"[%22a898f4ceef7647ba113b9f3c24ef045f5d134935a3b09bdd1a997b9d474f4c1b%22,%22f11d0cb4e2e4c21f029a1146f8e5926f11456885b7ab7d665096f5efedec8ea0%22]\"
// ./hush-cli -ac_name=ROGUE cclib register 17 \"[%22a898f4ceef7647ba113b9f3c24ef045f5d134935a3b09bdd1a997b9d474f4c1b%22,%22f11d0cb4e2e4c21f029a1146f8e5926f11456885b7ab7d665096f5efedec8ea0%22]\"
CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers)
@ -704,7 +704,7 @@ uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256
obj.push_back(Pair("seed",(int64_t)seed));
if ( rogue_iamregistered(maxplayers,gametxid,tx,myrogueaddr) > 0 )
sprintf(cmd,"cc/rogue/rogue %llu %s",(long long)seed,gametxid.ToString().c_str());
else sprintf(cmd,"./komodo-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",SMART_CHAIN_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str());
else sprintf(cmd,"./hush-cli -ac_name=%s cclib register %d \"[%%22%s%%22]\"",SMART_CHAIN_SYMBOL,EVAL_ROGUE,gametxid.ToString().c_str());
obj.push_back(Pair("run",cmd));
}
}

2
src/cc/sudoku.cpp

@ -2480,7 +2480,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi)
}
//////////////////////// start of CClib interface
// ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey=<yourpubkey> -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc &
// ./hushd -ac_name=SUDOKU -ac_supply=1000000 -pubkey=<yourpubkey> -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc &
/* cclib "gen" 17 \"10\"
5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432
*/

25
src/chain.cpp

@ -1,10 +1,8 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2016-2021 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -80,15 +78,13 @@ const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const {
CChainPower::CChainPower(CBlockIndex *pblockIndex)
{
nHeight = pblockIndex->GetHeight();
chainStake = arith_uint256(0);
nHeight = pblockIndex->GetHeight();
chainWork = arith_uint256(0);
}
CChainPower::CChainPower(CBlockIndex *pblockIndex, const arith_uint256 &stake, const arith_uint256 &work)
CChainPower::CChainPower(CBlockIndex *pblockIndex, const arith_uint256 &work)
{
nHeight = pblockIndex->GetHeight();
chainStake = stake;
nHeight = pblockIndex->GetHeight();
chainWork = work;
}
@ -96,38 +92,29 @@ bool operator==(const CChainPower &p1, const CChainPower &p2)
{
arith_uint256 bigZero = arith_uint256(0);
arith_uint256 workDivisor = p1.chainWork > p2.chainWork ? p1.chainWork : (p2.chainWork != bigZero ? p2.chainWork : 1);
arith_uint256 stakeDivisor = p1.chainStake > p2.chainStake ? p1.chainStake : (p2.chainStake != bigZero ? p2.chainStake : 1);
// use up 16 bits for precision
return ((p1.chainWork << 16) / workDivisor + (p1.chainStake << 16) / stakeDivisor) ==
((p2.chainWork << 16) / workDivisor + (p2.chainStake << 16) / stakeDivisor);
return ((p1.chainWork << 16) / workDivisor == ((p2.chainWork << 16) / workDivisor));
}
bool operator<(const CChainPower &p1, const CChainPower &p2)
{
arith_uint256 bigZero = arith_uint256(0);
arith_uint256 workDivisor = p1.chainWork > p2.chainWork ? p1.chainWork : (p2.chainWork != bigZero ? p2.chainWork : 1);
arith_uint256 stakeDivisor = p1.chainStake > p2.chainStake ? p1.chainStake : (p2.chainStake != bigZero ? p2.chainStake : 1);
// use up 16 bits for precision
return ((p1.chainWork << 16) / workDivisor + (p1.chainStake << 16) / stakeDivisor) <
((p2.chainWork << 16) / workDivisor + (p2.chainStake << 16) / stakeDivisor);
return ((p1.chainWork << 16) / workDivisor < ((p2.chainWork << 16) / workDivisor));
}
bool operator<=(const CChainPower &p1, const CChainPower &p2)
{
arith_uint256 bigZero = arith_uint256(0);
arith_uint256 workDivisor = p1.chainWork > p2.chainWork ? p1.chainWork : (p2.chainWork != bigZero ? p2.chainWork : 1);
arith_uint256 stakeDivisor = p1.chainStake > p2.chainStake ? p1.chainStake : (p2.chainStake != bigZero ? p2.chainStake : 1);
// use up 16 bits for precision
return ((p1.chainWork << 16) / workDivisor + (p1.chainStake << 16) / stakeDivisor) <=
((p2.chainWork << 16) / workDivisor + (p2.chainStake << 16) / stakeDivisor);
return ((p1.chainWork << 16) / workDivisor <= ((p2.chainWork << 16) / workDivisor));
}
/** Turn the lowest '1' bit in the binary representation of a number into a '0'. */
int static inline InvertLowestOne(int n) { return n & (n - 1); }

30
src/chain.h

@ -127,31 +127,23 @@ static const BlockStatus BLOCK_VALID_CONSENSUS = BLOCK_VALID_SCRIPTS;
class CBlockIndex;
// This class provides an accumulator for both the chainwork and the chainPOS value
// CChainPower's can be compared, and the comparison ensures that work and proof of stake power
// are both used equally to determine which chain has the most work. This makes an attack
// that involves mining in secret completely ineffective, even before dPOW, unless a large part
// of the staking supply is also controlled. It also enables a faster deterministic convergence,
// aided by both POS and POW.
// TODO: delete this junk
// This class provides an accumulator for chainwork
class CChainPower
{
public:
arith_uint256 chainWork;
arith_uint256 chainStake;
int32_t nHeight;
CChainPower() : nHeight(0), chainStake(0), chainWork(0) {}
CChainPower() : nHeight(0), chainWork(0) {}
CChainPower(CBlockIndex *pblockIndex);
CChainPower(CBlockIndex *pblockIndex, const arith_uint256 &stake, const arith_uint256 &work);
CChainPower(int32_t height) : nHeight(height), chainStake(0), chainWork(0) {}
CChainPower(int32_t height, const arith_uint256 &stake, const arith_uint256 &work) :
nHeight(height), chainStake(stake), chainWork(work) {}
CChainPower(CBlockIndex *pblockIndex, const arith_uint256 &work);
CChainPower(int32_t height) : nHeight(height), chainWork(0) {}
CChainPower(int32_t height, const arith_uint256 &work) :
nHeight(height), chainWork(work) {}
CChainPower &operator=(const CChainPower &chainPower)
{
chainWork = chainPower.chainWork;
chainStake = chainPower.chainStake;
nHeight = chainPower.nHeight;
return *this;
}
@ -159,7 +151,6 @@ class CChainPower
CChainPower &operator+=(const CChainPower &chainPower)
{
this->chainWork += chainPower.chainWork;
this->chainStake += chainPower.chainStake;
return *this;
}
@ -167,7 +158,6 @@ class CChainPower
{
CChainPower result = CChainPower(chainPowerA);
result.chainWork += chainPowerB.chainWork;
result.chainStake += chainPowerB.chainStake;
return result;
}
@ -175,7 +165,6 @@ class CChainPower
{
CChainPower result = CChainPower(chainPowerA);
result.chainWork -= chainPowerB.chainWork;
result.chainStake -= chainPowerB.chainStake;
return result;
}
@ -183,16 +172,9 @@ class CChainPower
{
CChainPower result = CChainPower(chainPower);
result.chainWork *= x;
result.chainStake *= x;
return result;
}
CChainPower &addStake(const arith_uint256 &nChainStake)
{
chainStake += nChainStake;
return *this;
}
CChainPower &addWork(const arith_uint256 &nChainWork)
{
chainWork += nChainWork;

139
src/chainparams.cpp

@ -521,11 +521,15 @@ void hush_setactivation(int32_t height)
void *chainparams_commandline() {
CChainParams::CCheckpointData checkpointData;
if(fDebug) {
//if(fDebug) {
fprintf(stderr,"chainparams_commandline called with port=%u\n", ASSETCHAINS_P2PPORT);
}
//}
if ( SMART_CHAIN_SYMBOL[0] != 0 )
{
if (strcmp(SMART_CHAIN_SYMBOL,"HUSH3") == 0) {
ASSETCHAINS_P2PPORT = 18030;
}
if ( ASSETCHAINS_BLOCKTIME != 60 )
{
pCurrentParams->consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks
@ -538,8 +542,11 @@ void *chainparams_commandline() {
pCurrentParams->SetNValue(ASSETCHAINS_NK[0]);
pCurrentParams->SetKValue(ASSETCHAINS_NK[1]);
}
if ( HUSH_TESTNODE != 0 )
if ( HUSH_TESTNODE != 0 ) {
fprintf(stderr,"%s: This is a test node, mining will not require peers!\n", __func__);
pCurrentParams->SetMiningRequiresPeers(false);
}
if ( ASSETCHAINS_RPCPORT == 0 )
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
pCurrentParams->pchMessageStart[0] = ASSETCHAINS_MAGIC & 0xff;
@ -875,10 +882,128 @@ void *chainparams_commandline() {
(584000, uint256S("0x0000000720f29b0d72469739e9d94607e67b48eb9957b45c2fd5a34b86df039a"))
(585000, uint256S("0x00000001409c395b2e37e2b88110b320996996241bfb489103db9e17aaf2ddc7"))
(586000, uint256S("0x00000006ff6509d260f66af2fc4fc1769d56394333f3ad5a19bbd10c8c26742b"))
(587000, uint256S("0x00000003866d330ac5448e07eb5e95d2e1860203f2e0ca568161d04ea5c5deb8")),
(int64_t) 1625849524, // time of last checkpointed block
(int64_t) 0, // total txs
(double) 2304 // txs in the last day before block 587157
(587000, uint256S("0x00000003866d330ac5448e07eb5e95d2e1860203f2e0ca568161d04ea5c5deb8"))
(588000, uint256S("0x0000000247f3b1c8f60b82a1dc5b86ead3adb023a6e3508d1c732c88bceae666"))
(589000, uint256S("0x00000000d9108a0e811622919777fb929986966034bb53678d431dd50f0b3640"))
(590000, uint256S("0x00000006a7699d8fb948cc67dd2427ee25fbfa2a8e02517aad45880658eab983"))
(591000, uint256S("0x00000004f6746a57c60ab45b5d0a30375e635bb8b564c85b92e8b34afbb82077"))
(592000, uint256S("0x000000023987ca4c3454b0fd17fe64febcc2c1b75d2820e0368084c59d71cbb3"))
(593000, uint256S("0x00000006e05b247fa1a4b99e5292d4c696e2627ed5b64263ceb2a985d98cb446"))
(594000, uint256S("0x000000010f20489639e7ec3a3694b2c1def345f2bf7804fadbd1ee92813a020d"))
(595000, uint256S("0x00000008fda549361df97ddac7f495fdb629c4c6a646c91e5535f96d12d98dee"))
(596000, uint256S("0x0000000512d08ea2cd501bb2132dec8dd997e0332e5d0a51bf9d0992451030da"))
(597000, uint256S("0x00000006384749ab79ee12dd46e068634254354c511f535278d54b8efd41e29e"))
(598000, uint256S("0x000000031ba9be6704d352002cfb763dc7123e93911796159ef8d2d0328da348"))
(599000, uint256S("0x00000005bf47be7b949ff5217ae980fcea48d9d25e824c68367ce934447ef0bd"))
(600000, uint256S("0x00000000a721ce253a2c130fec44c581810dfb9448a46ef524a16f1ef3920bec"))
(601000, uint256S("0x00000007cdbdfd7f1c9bf8c20ff4f35c2c25a21558a5e70ea139bd50d2421fab"))
(602000, uint256S("0x0000000708ba8ec93c022184d3258cd4956f82e2edd0b67c2493f74a3bf6afef"))
(603000, uint256S("0x00000005a7b51fd94b80f51ae2b0d0dc8f7285eb418914bd177f6f2fcc68e745"))
(604000, uint256S("0x00000010bd1bce0ed2c83f8860b5201a700c535dfc6d6af2c15ee7de4e2e0cba"))
(605000, uint256S("0x00000002cac498bb995a395d52a41a48372e57b494de023cd4e2eb70c5616b1b"))
(606000, uint256S("0x0000000269e7256e93648c29f72e169767af626c7db95fa8ac853be6072a7942"))
(607000, uint256S("0x000000073e07d2a4757b93641c318dbdc784067b02d4cc9f0be4747c80319f3b"))
(608000, uint256S("0x00000001613776b53c2060529996e64d24fa5874879b7457aee20430ab2bc87f"))
(609000, uint256S("0x0000000acd03e99bfe60d8a5d5023b373aa13f71a5d577c813141b3b714cc95a"))
(610000, uint256S("0x0000000aa64b831908eb621b6e2c548620d29146b0c8dae951dd84daef0e63d1"))
(611000, uint256S("0x0000000736b273fdf7d8df9bddba568e71547a79e0b14c71027e61dae6a83443"))
(612000, uint256S("0x00000012a5b000bcb8606acb628c46d49157bc97189fc8e37dfaaf280b05f8a1"))
(613000, uint256S("0x00000006bb698faba83d28b958cd9a242fa9baadb2efa510e2e27b1eebedb951"))
(614000, uint256S("0x000000007c66271651afb1468d0546f3ea1b9720d42e3597c9277429d43765f1"))
(615000, uint256S("0x00000015a141ae1feec020f529a3e5dea51d29efdef8d0425677e5126c850f73"))
(616000, uint256S("0x0000000967c92b77c884fc58d7973a8d78ea47c2ec8e68e1619f6b92f3db2c05"))
(617000, uint256S("0x0000000a7eb3e594474d545752f35a70965c17e497c2201fa8f38943bebb8756"))
(618000, uint256S("0x0000000ca0f1eb16ed72e5ea4e77cb165fb87384e4c3e0064d5faac7f49c91b9"))
(619000, uint256S("0x00000006da3e4a2e36342593090efb0fdf19e77d4ce8663a54df0dd7109b178b"))
(620000, uint256S("0x0000000d7c987adbdbf3742c6cebd55b7c8fe213362385f1e24e6eecf7dd4ea0"))
(621000, uint256S("0x00000003009cf1ac25864d6997dd9c9ce76cf6cb58f0e61700bb52ec72f54cc6"))
(622000, uint256S("0x0000000cf25b9a537ea61d548979003dde28155b73b26d53cf2a7b69036926cb"))
(623000, uint256S("0x00000007da399943d00f84c9e190e9968f3f456de70060ad17b6b63606287db0"))
(624000, uint256S("0x0000000cab9f7f9e6e5223eda1bee8de7384b6dbed3bfe807818871d78f9594f"))
(625000, uint256S("0x0000000266b471c7ee107a85080792531d7dc91c23d7b42b46e44728c3d9ea8c"))
(626000, uint256S("0x00000003fe1af9fffd32fae9b809c916d7484024021053c09286c763fd2fc1e6"))
(627000, uint256S("0x00000006f9bbef0362e0e99bb4061b4d386c82477d64d84850e4a1b6fce85093"))
(628000, uint256S("0x0000000d9afb9e78eac960bc5b7aaa8356ac6660e5147175117ed53f6d41215e"))
(629000, uint256S("0x000000071ee3b95304b4df78e66c56f8f1deb557b57ed7716c389b0e04344d87"))
(630000, uint256S("0x00000002ed362482e0bc5d03d07e406748590d01871f91e03ed86d15737d1e2f"))
(631000, uint256S("0x0000000e55845a96afa1359c6aaac5e66c84daf56ccea33d9127a66e6162736d"))
(632000, uint256S("0x0000000fb180307499ce6d21f2308ffdf20b0d03ed45ba0de3420fac71434b95"))
(633000, uint256S("0x00000010ddf5569109d8a405eedac88f2ae9f56838dcf279cd9ca32185cf5d55"))
(634000, uint256S("0x0000000781805d9c573380c22215cf83280c4d0688bbd730adb0821c89b2a3d0"))
(635000, uint256S("0x0000000fa1d7aba218223517de8ceeecfcda087b7e549b0537a986465520e040"))
(636000, uint256S("0x00000010eb125169e1e9cbe061564c9c663389b6a68a06445d18c4346601ce78"))
(637000, uint256S("0x0000000c85df82c1ade3c311e5673c294d97858ea23dac5d5f03aaf32b374b1b"))
(638000, uint256S("0x00000002aa16a3abc3ae9739609eddaf805fce5d0f7b0ae8d9494381843ab5a2"))
(639000, uint256S("0x00000012eb63468724acc222e45889a9bf54c1a5e0152ad1fc9c57cdb7bcb460"))
(640000, uint256S("0x0000000bf6a31eec79a36c5423f52069e5d6858bfc566081556ba9487a5ef36f"))
(641000, uint256S("0x000000065414f1d2a543687ee4c0137ca5d66d5d35f9dbf9b4fe73e59ecc5af7"))
(642000, uint256S("0x00000005fe35f60661760b7ca027a73e6915f6add12e736018357a1e782310a4"))
(643000, uint256S("0x000000076e77c3e0a2a1890a5bea2d92aa720a08bb4e5571e76bb05c93f40c98"))
(644000, uint256S("0x0000001054093374a3a414047113ab882d092f012c1c17cf3d98ca8006b8e8bc"))
(645000, uint256S("0x0000000cb0c07c2325e8162e58f3fcc14323450274a1d69aff06ac799cf72f53"))
(646000, uint256S("0x0000000252d31029d2e96406697ada40ca3afb3d9fe2a2f67cdad2462e8fe00d"))
(647000, uint256S("0x0000001155755f0718b6cc3474e44748358e5328c2c0c32c97cfd3842bf22510"))
(648000, uint256S("0x000000173c2e63d658263c1c28e1e0a1b2ce30f2d3d4eba2f540836315a9d5ea"))
(649000, uint256S("0x00000002044331ebe095ea838da367fed1495be4ad69b0c655df653ccb1923dd"))
(650000, uint256S("0x00000010afad2d800c397557a9cbe501f32cd09f18f89c2f3f11e0e38ae45843"))
(651000, uint256S("0x0000000b6a9630f3a2334d4529ba013480104e54fc59dc4cabc3a8869ad17a01"))
(652000, uint256S("0x00000004d22aa00fb4c8266b0304f43bc7bec8e18850e764a431438a9fdfd141"))
(653000, uint256S("0x0000000a248721cef01783838a5b53547b12273ddf57a2bc3ba708ea987f8937"))
(654000, uint256S("0x00000004c95adc9e17e429c35cc4c8ffd130e23228245e29f150896ab66ffdfd"))
(655000, uint256S("0x0000001428523dbe3cf9338753a42c579a669df7bbd8d6fa667f4daf2c4c749f"))
(656000, uint256S("0x0000001704429a9b902d4cddee708bd0ae7b758c6bd9ed634c143931e15ac337"))
(657000, uint256S("0x00000007b376e2c197b21a2eacac81847f401f92ed50213e845e039d3516458c"))
(658000, uint256S("0x00000026e751010b1135052b105f2be464702b040d76610bfeae1b1a2bcab15c"))
(659000, uint256S("0x00000005d784a9cf7b60bc6908234052c29a555dcf1d4f8a82663aabbc2e0c83"))
(660000, uint256S("0x00000015cdf576c284ad93912955194f6764a16d562308bb82bcfdc7a27ad20b"))
(661000, uint256S("0x0000000af126a5261626bc10a6cf2a8a07ea145f6aa33539e4d434033411c4db"))
(662000, uint256S("0x00000011c4659f0bbe3559c32ff24588d78a3822e8b0e31bb9298a16213fe154"))
(663000, uint256S("0x000000076756708535e3daeaca6bc32aa1dc360228af6a0c5e5e07b5d9f5f00b"))
(664000, uint256S("0x000000181806c17b47bb843537cc91c95ca1e3596bb9e049d18c2e73c1026258"))
(665000, uint256S("0x0000001e966c9edae76c40262e65a6c9ab764a09154eb802fb892ceebc2d1935"))
(666000, uint256S("0x0000000b7594c1e8f6ccdf1559e230fdc6c276e8df0a800b7f7c82a237a6c14e"))
(667000, uint256S("0x000000101801a801c21a2e50d4a5173e494f2e9ee604cec5886a8547680accaa"))
(668000, uint256S("0x00000001ee22e21a6d5a5b322ea1ec69231b35d72d54f9fbdfa5dfdc5c7e2f4a"))
(669000, uint256S("0x0000000f8fa48f7244099f17c8dbf79982f5dec586b5b32d0fa30f18540081ca"))
(670000, uint256S("0x00000008d3b0a1f5286574ba5fe05c3151144cd7f330f2f1ec3f2009d4b82687"))
(671000, uint256S("0x0000000dd430c9a8e3d83f123f0bc6b6ba11e774ec6bdcf1a13c216b8e071d3e"))
(672000, uint256S("0x0000000326bd2c2465754ee03f2a9d82d902a19e7d92aef3c9967cbbbdd37da9"))
(673000, uint256S("0x000000053e15e2ee0f6fdb5d6a096fb3b785f82165f5126805fb785d884bef7c"))
(674000, uint256S("0x0000000472c24f87b24de8e091ae9b191d0a114ecaecf7487c5ccd88680b4799"))
(675000, uint256S("0x00000007bc716ae47620f86f7f38010b43a92560b4d901cd4fa945c20ffeee4a"))
(676000, uint256S("0x00000011506c87f327448ff75a37168ee0a31f199dc8f42499247f4af5f84a71"))
(677000, uint256S("0x00000007e26fe6537984fc6f7d9164a6edcd9fa1c92a0ba1f2bafed491c50976"))
(678000, uint256S("0x00000013a790e855c1722c648e930302366b15c78f6f2a9d0bc01ce0c8faec69"))
(679000, uint256S("0x0000000f8519548ca86c8689fc4282e1ce7ab34a39680c7dde40846e49235299"))
(680000, uint256S("0x000000060f172b876390a65c27ad87360e16b8710a4b184b11ed09844b5327fd"))
(681000, uint256S("0x00000001a43cafd9c0858e23c62e629609f9e73905fe8f6de14b0db5c8811f31"))
(682000, uint256S("0x0000000b8330e95dc616e2b455de087d541e4ab8f17bff162b08d66b113ccee0"))
(683000, uint256S("0x000000082fdac13fff52ef28e0b288963b091b991be5fec2684092664340d05b"))
(684000, uint256S("0x00000037cde1f403c7fadb6042d63bec2b04de94d6a9c6202dc371146d4c4745"))
(685000, uint256S("0x00000010795f12db65a60d307bedf42692c1b09a909cc0963bf73df8960c6d3d"))
(686000, uint256S("0x0000000b1aec6e706333d02892de401375820a71a307b49671667b10738f92fb"))
(687000, uint256S("0x00000014ba8dc2c0e5a40a4787ca257a220627ebc183ee460d8ae7fb6ddd3ce0"))
(688000, uint256S("0x0000000edade4f635276a397c9704ea83bdf006d6ee8c8a2fe0f2a41b1e1a2c7"))
(689000, uint256S("0x0000001834d62f37506d7729df7784ff6aa082f227a8c248bfc7d646856cfb2d"))
(690000, uint256S("0x00000007f1fc92391ef45142f537991b974151eff532aa3832adadf3b46bcb95"))
(691000, uint256S("0x0000000ef2ee7f7801125026414f2e1b98571f8a5f74615447ba2f62c24b4a22"))
(692000, uint256S("0x0000000b4640658900c7265b94dae90370de8d1673a909239629b26bd2fd5b06"))
(693000, uint256S("0x00000012c16de95e8a827c6337de6ab2e04c94eb12a97aa20fac3acc479bd703"))
(694000, uint256S("0x0000000a6ccfa9999373584068cab8a9670b287905d7f095d8144ca03694bbf8"))
(695000, uint256S("0x000000132069bbd8a9dd0cec996879b949b2a9862fdfa907c3559929865372ce"))
(696000, uint256S("0x00000005dc30a87aafed1a5703403573234529a8fc0e7f4cb789d3b22406476e"))
(697000, uint256S("0x00000004f7fc3367c3483d0ac17ef6c30148c31d0dd7ec14503c69e79212aaf2"))
(698000, uint256S("0x000000116f56e8cf6e7ed759f8095f0b7bd48c5aec6d35615bfd479a042cf094"))
(699000, uint256S("0x000000096cc740eada81deca2d6a2f2fb30e5a5f15bce44f206e9a15c374ee84"))
(700000, uint256S("0x0000000ebb5da3d51a7897c9224fc236bd8085fbd0e1ac4eb08063eef04c1326"))
(701000, uint256S("0x000000032acf386d4ac320303d8d3d5e6885dd384417a5d0b994c8fe101405c5"))
(702000, uint256S("0x00000000f135d58892ddb7f17a7d1d34d108b177152bce2adde48d58a72480cd"))
(703000, uint256S("0x0000000a469db4ff74c9bdf7903981a3247cb11cbc6ece12fb0e8d34206ba583"))
(704000, uint256S("0x000000024f09cabdd6fbdd379b74d4535c20d5bc78f78725f2d87b257ab3a64d"))
(705000, uint256S("0x0000000c122244118777ca474fe3f30151849ff253ae730dc433900aea5616c5")),
(int64_t) 1634769309, // time of last checkpointed block
(int64_t) 1119376, // total txs
(double) 1529 // txs in the last day before block 705072
};
} else {
checkpointData = //(Checkpoints::CCheckpointData)

8
src/chainparamsbase.cpp

@ -1,8 +1,8 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2016-2021 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -19,9 +19,7 @@
******************************************************************************/
#include "chainparamsbase.h"
#include "util.h"
#include <assert.h>
/**
@ -32,7 +30,7 @@ class CBaseMainParams : public CBaseChainParams
public:
CBaseMainParams()
{
nRPCPort = 7771;
nRPCPort = 18031;
}
};
static CBaseMainParams mainParams;
@ -45,7 +43,7 @@ class CBaseTestNetParams : public CBaseChainParams
public:
CBaseTestNetParams()
{
nRPCPort = 17771;
nRPCPort = 28031;
strDataDir = "testnet3";
}
};

1
src/chainparamsbase.h

@ -40,6 +40,7 @@ public:
const std::string& DataDir() const { return strDataDir; }
int RPCPort() const { return nRPCPort; }
int StratumPort() const { return (RPCPort() + 1000); }
protected:
CBaseChainParams() {}

32
src/clearassets

@ -1,32 +0,0 @@
rm -rf ~/.komodo/USD
rm -rf ~/.komodo/EUR
rm -rf ~/.komodo/JPY
rm -rf ~/.komodo/GBP
rm -rf ~/.komodo/AUD
rm -rf ~/.komodo/CAD
rm -rf ~/.komodo/CHF
rm -rf ~/.komodo/NZD
rm -rf ~/.komodo/CNY
rm -rf ~/.komodo/RUB
rm -rf ~/.komodo/MXN
rm -rf ~/.komodo/BRL
rm -rf ~/.komodo/INR
rm -rf ~/.komodo/HKD
rm -rf ~/.komodo/TRY
rm -rf ~/.komodo/ZAR
rm -rf ~/.komodo/PLN
rm -rf ~/.komodo/NOK
rm -rf ~/.komodo/SEK
rm -rf ~/.komodo/DKK
rm -rf ~/.komodo/CZK
rm -rf ~/.komodo/HUF
rm -rf ~/.komodo/ILS
rm -rf ~/.komodo/KRW
rm -rf ~/.komodo/MYR
rm -rf ~/.komodo/PHP
rm -rf ~/.komodo/RON
rm -rf ~/.komodo/SGD
rm -rf ~/.komodo/THB
rm -rf ~/.komodo/BGN
rm -rf ~/.komodo/IDR
rm -rf ~/.komodo/HRK

2
src/clientversion.cpp

@ -32,7 +32,7 @@
* for both bitcoind and bitcoin-core, to make it harder for attackers to
* target servers or GUI users specifically.
*/
const std::string CLIENT_NAME = GetArg("-clientname", "jl777sRemorse");
const std::string CLIENT_NAME = GetArg("-clientname", "GoldenSandtrout");
/**
* Client version number

2
src/clientversion.h

@ -29,7 +29,7 @@
//! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it
// Must be kept in sync with configure.ac , ugh!
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 8
#define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 50

2
src/crypto/equihash.h

@ -204,7 +204,7 @@ public:
#include "equihash.tcc"
/*
* Equihash 200,9 (KMD/Zcash)
* Equihash 200,9 (HUSH/ZEC and other ASIC coins)
* Equihash 150,5 (beam)
* Equihash 144,5 (SnowGem)
* Equihash 96,5 (Minex)

6
src/httprpc.cpp

@ -1,3 +1,6 @@
// Copyright (c) 2016-2021 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -12,9 +15,7 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#include "httprpc.h"
#include "chainparams.h"
#include "httpserver.h"
#include "key_io.h"
@ -25,7 +26,6 @@
#include "util.h"
#include "utilstrencodings.h"
#include "ui_interface.h"
#include <boost/algorithm/string.hpp> // boost::trim
// WWW-Authenticate to present with 401 Unauthorized response

26
src/httpserver.cpp

@ -157,6 +157,16 @@ public:
boost::unique_lock<boost::mutex> lock(cs);
return queue.size();
}
size_t MaxDepth()
{
boost::unique_lock<boost::mutex> lock(cs);
return maxDepth;
}
int NumThreads()
{
boost::unique_lock<boost::mutex> lock(cs);
return numThreads;
}
};
struct HTTPPathHandler
@ -186,6 +196,22 @@ std::vector<HTTPPathHandler> pathHandlers;
//! Bound listening sockets
std::vector<evhttp_bound_socket *> boundSockets;
int getWorkQueueDepth()
{
return workQueue->Depth();
}
int getWorkQueueMaxDepth()
{
return workQueue->MaxDepth();
}
int getWorkQueueNumThreads()
{
return workQueue->NumThreads();
}
/** Check if a network address is allowed to access the HTTP server */
static bool ClientAllowed(const CNetAddr& netaddr)
{

4
src/httpserver.h

@ -24,6 +24,10 @@ struct event_base;
class CService;
class HTTPRequest;
int getWorkQueueDepth();
int getWorkQueueMaxDepth();
int getWorkQueueNumThreads();
/** Initialize HTTP server.
* Call this before RegisterHTTPHandler or EventBase().
*/

23
src/hush-cli

@ -1,23 +0,0 @@
#!/bin/bash
# Copyright (c) 2016-2021 The Hush developers
# Released under the GPLv3
# set working directory to the location of this script
# readlink -f does not always exist
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )"
cd $DIR
NAME=HUSH3
CLI=${KOMODOCLI:-./komodo-cli}
if [ -f $CLI ]; then
$CLI -ac_name=$NAME "$@"
else
# We prefix our binary when installed
# system wide on Debain systems, to prevent clashes,
# because we are classy like that. Fuck jl777, The KYC Traitor.
CLI=hush-komodo-cli
$CLI -ac_name=$NAME "$@"
fi

11
src/hush-cli-testnet

@ -1,11 +0,0 @@
#!/bin/bash
# Copyright (c) 2016-2021 The Hush developers
# set working directory to the location of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
NAME=HUSH3T
CLI=${KOMODOCLI:-./komodo-cli}
$CLI -ac_name=$NAME "$@"

14
src/hush-cli.bat

@ -1,14 +0,0 @@
@call :GET_CURRENT_DIR
@cd %THIS_DIR%
komodo-cli.exe -ac_name=HUSH3 %1 %2 %3 %4 %5 %6 %7 %8 %9
@goto :EOF
:GET_CURRENT_DIR
@pushd %~dp0
@set THIS_DIR=%CD%
@popd
@goto :EOF

18
src/hush-smart-chain

@ -7,18 +7,8 @@ cd $DIR
DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )"
cd $DIR
NAME=HUSH3
CLIENTNAME="GoldenSandtrout"
DEFAULTS="-ac_sapling=1 -clientname=$CLIENTNAME"
DEFAULTS=""
# This is a Hush-flavored KMD that allows us to pass in arbitary CLI
# flags, since hushd is specific to Hush mainnet
KMD=${KOMODOD:-./komodod}
if [ -f $KMD ]; then
$KMD $DEFAULTS "$@"
else
# We prefix our binary when installed
# system wide on Debain system, to prevent clashes
KMD=hush-komodod
$KMD $DEFAULTS "$@"
fi
# People should just use hushd going forward
HUSH="./hushd"
$HUSH $DEFAULTS "$@"

11
src/hush-tx

@ -1,11 +0,0 @@
#!/bin/bash
# Copyright (c) 2016-2021 The Hush developers
# Released under the GPLv3
# set working directory to the location of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
NAME=HUSHT
./komodo-tx -ac_name=$NAME "$@"

14
src/hush-tx.bat

@ -1,14 +0,0 @@
@call :GET_CURRENT_DIR
@cd %THIS_DIR%
komodo-tx.exe -ac_name=HUSH3 %1 %2 %3 %4 %5 %6 %7 %8 %9
@goto :EOF
:GET_CURRENT_DIR
@pushd %~dp0
@set THIS_DIR=%CD%
@popd
@goto :EOF

0
src/komodo-tx.cpp → src/hush-tx.cpp

126
src/hush.h

@ -82,9 +82,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
int32_t func,ht,notarized_height,num,matched=0,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; uint8_t pubkeys[64][33];
if ( (func= fgetc(fp)) != EOF )
{
if ( SMART_CHAIN_SYMBOL[0] == 0 && strcmp(symbol,"KMD") == 0 )
matched = 1;
else matched = (strcmp(symbol,SMART_CHAIN_SYMBOL) == 0);
matched = (strcmp(symbol,SMART_CHAIN_SYMBOL) == 0);
if ( fread(&ht,1,sizeof(ht),fp) != sizeof(ht) )
errs++;
if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 && func != 'T' )
@ -98,7 +96,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
else
{
//printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht);
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) || (strcmp(symbol,"KMD") == 0 && HUSH_EXTERNAL_NOTARIES == 0) )
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) )
hush_eventadd_pubkeys(sp,symbol,ht,num,pubkeys);
}
} else printf("illegal num.%d\n",num);
@ -148,7 +146,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
errs++;
//if ( matched != 0 ) global independent states -> inside *sp
//printf("%s.%d load[%s] ht.%d\n",SMART_CHAIN_SYMBOL,ht,symbol,kheight);
hush_eventadd_kmdheight(sp,symbol,ht,kheight,0);
hush_eventadd_hushheight(sp,symbol,ht,kheight,0);
}
else if ( func == 'T' )
{
@ -159,7 +157,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
errs++;
//if ( matched != 0 ) global independent states -> inside *sp
//printf("%s.%d load[%s] ht.%d t.%u\n",SMART_CHAIN_SYMBOL,ht,symbol,kheight,ktimestamp);
hush_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp);
hush_eventadd_hushheight(sp,symbol,ht,kheight,ktimestamp);
}
else if ( func == 'R' )
{
@ -228,10 +226,9 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
int32_t func= -1,ht,notarized_height,MoMdepth,num,matched=0; uint256 MoM,notarized_hash,notarized_desttxid; uint8_t pubkeys[64][33]; long fpos = *fposp;
if ( fpos < datalen )
{
func = filedata[fpos++];
if ( SMART_CHAIN_SYMBOL[0] == 0 && strcmp(symbol,"KMD") == 0 )
matched = 1;
else matched = (strcmp(symbol,SMART_CHAIN_SYMBOL) == 0);
func = filedata[fpos++];
matched = (strcmp(symbol,SMART_CHAIN_SYMBOL) == 0);
if ( memread(&ht,sizeof(ht),filedata,&fpos,datalen) != sizeof(ht) )
errs++;
if ( func == 'P' )
@ -243,7 +240,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
else
{
//printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht);
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) || (strcmp(symbol,"KMD") == 0 && HUSH_EXTERNAL_NOTARIES == 0) )
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) )
hush_eventadd_pubkeys(sp,symbol,ht,num,pubkeys);
}
} else printf("illegal num.%d\n",num);
@ -288,7 +285,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
int32_t kheight;
if ( memread(&kheight,sizeof(kheight),filedata,&fpos,datalen) != sizeof(kheight) )
errs++;
hush_eventadd_kmdheight(sp,symbol,ht,kheight,0);
hush_eventadd_hushheight(sp,symbol,ht,kheight,0);
}
else if ( func == 'T' )
{
@ -299,7 +296,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
errs++;
//if ( matched != 0 ) global independent states -> inside *sp
//printf("%s.%d load[%s] ht.%d t.%u\n",SMART_CHAIN_SYMBOL,ht,symbol,kheight,ktimestamp);
hush_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp);
hush_eventadd_hushheight(sp,symbol,ht,kheight,ktimestamp);
}
else if ( func == 'R' )
{
@ -353,7 +350,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
return(-1);
}
void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth)
void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t HUSHheight,uint32_t HUSHtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth)
{
static FILE *fp; static int32_t errs,didinit; static uint256 zero;
struct hush_state *sp; char fname[512],symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t retval,ht,func; uint8_t num,pubkeys[64][33];
@ -394,30 +391,26 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
if ( fp != 0 ) // write out funcid, height, other fields, call side effect function
{
//printf("fpos.%ld ",ftell(fp));
if ( KMDheight != 0 )
if ( HUSHheight != 0 )
{
if ( KMDtimestamp != 0 )
if ( HUSHtimestamp != 0 )
{
fputc('T',fp);
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
errs++;
if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) )
if ( fwrite(&HUSHheight,1,sizeof(HUSHheight),fp) != sizeof(HUSHheight) )
errs++;
if ( fwrite(&KMDtimestamp,1,sizeof(KMDtimestamp),fp) != sizeof(KMDtimestamp) )
if ( fwrite(&HUSHtimestamp,1,sizeof(HUSHtimestamp),fp) != sizeof(HUSHtimestamp) )
errs++;
}
else
{
} else {
fputc('K',fp);
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
errs++;
if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) )
if ( fwrite(&HUSHheight,1,sizeof(HUSHheight),fp) != sizeof(HUSHheight) )
errs++;
}
hush_eventadd_kmdheight(sp,symbol,height,KMDheight,KMDtimestamp);
}
else if ( opretbuf != 0 && opretlen > 0 )
{
hush_eventadd_hushheight(sp,symbol,height,HUSHheight,HUSHtimestamp);
} else if ( opretbuf != 0 && opretlen > 0 ) {
uint16_t olen = opretlen;
fputc('R',fp);
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
@ -432,8 +425,7 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
errs++;
if ( fwrite(opretbuf,1,olen,fp) != olen )
errs++;
//printf("create ht.%d R opret[%d] sp.%p\n",height,olen,sp);
//komodo_opreturn(height,opretvalue,opretbuf,olen,txhash,vout);
//printf("create ht.%d R opret[%d] sp.%p\n",height,olen,sp);
hush_eventadd_opreturn(sp,symbol,height,txhash,opretvalue,vout,opretbuf,olen);
}
else if ( notarypubs != 0 && numnotaries > 0 )
@ -510,7 +502,7 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
}
}
int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height)
int32_t hush_validate_chain(uint256 srchash,int32_t notarized_height)
{
static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN];
if ( (sp= hush_stateptr(symbol,dest)) == 0 )
@ -535,7 +527,7 @@ int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height)
} else return(1);
}
int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp)
int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp)
{
static uint256 zero; static FILE *signedfp;
int32_t opretlen,nid,offset,k,MoMdepth,matched,len = 0; uint256 MoM,srchash,desttxid; uint8_t crypto555[33]; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN];
@ -598,11 +590,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
matched = 0;
if ( SMART_CHAIN_SYMBOL[0] == 0 )
{
if ( strcmp("KMD",(char *)&scriptbuf[len+32 * 2 + 4]) == 0 )
matched = 1;
}
else
{
} else {
if ( scriptbuf[len] == 'K' )
{
//fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value));
@ -622,7 +610,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
memset(&MoMoMdata,0,sizeof(MoMoMdata));
if ( matched == 0 && signedmask != 0 && bitweight(signedmask) >= HUSH_MINRATIFY )
notarized = 1;
if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 || strcmp("BEER",ccdata.symbol) == 0)
if ( strcmp("DPOW",ccdata.symbol) == 0 || strncmp("ZPOW",ccdata.symbol,5) == 0 || strcmp("TUSH",ccdata.symbol) == 0)
notarized = 1;
if ( 0 && opretlen != 149 )
printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",SMART_CHAIN_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset);
@ -631,7 +619,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
if ( matched != 0 )
len += dragon_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid);
if ( matched != 0 )
validated = komodo_validate_chain(srchash,*notarizedheightp);
validated = hush_validate_chain(srchash,*notarizedheightp);
else validated = 1;
// Any notarization that is matched and has a decodable op_return is enough to pay notaries. Otherwise bugs!
if ( fJustCheck && matched != 0 )
@ -665,8 +653,8 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
// MoMoM, depth, numpairs, (notarization ht, MoMoM offset)
if ( len+48-opoffset <= opretlen && strcmp(ccdata.symbol,SMART_CHAIN_SYMBOL) == 0 )
{
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdstarti);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdendi);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.hushstarti);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.hushendi);
len += dragon_rwbignum(0,&scriptbuf[len],sizeof(MoMoMdata.MoMoM),(uint8_t *)&MoMoMdata.MoMoM);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.MoMoMdepth);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.numpairs);
@ -691,7 +679,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
}
else
{
komodo_rwccdata(SMART_CHAIN_SYMBOL,1,&ccdata,&MoMoMdata);
hush_rwccdata(SMART_CHAIN_SYMBOL,1,&ccdata,&MoMoMdata);
if ( matched != 0 )
printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",SMART_CHAIN_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff);
}
@ -700,8 +688,6 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
memset(&ccdata,0,sizeof(ccdata));
memset(&MoMoMdata,0,sizeof(MoMoMdata));
}
else if ( SMART_CHAIN_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 )
komodo_rwccdata((char *)"KMD",1,&ccdata,0);
if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
{
@ -715,48 +701,24 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
}
hush_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth);
//if ( SMART_CHAIN_SYMBOL[0] != 0 )
printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",SMART_CHAIN_SYMBOL,height,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL[0]==0?"KMD":SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),SMART_CHAIN_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth);
printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",SMART_CHAIN_SYMBOL,height,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),"HUSH",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth);
if ( SMART_CHAIN_SYMBOL[0] == 0 )
{
if ( signedfp == 0 )
{
char fname[512];
hush_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"hushsignedmasks");
if ( (signedfp= fopen(fname,"rb+")) == 0 )
signedfp = fopen(fname,"wb");
else fseek(signedfp,0,SEEK_END);
}
if ( signedfp != 0 )
{
fwrite(&height,1,sizeof(height),signedfp);
fwrite(&signedmask,1,sizeof(signedmask),signedfp);
fflush(signedfp);
}
if ( opretlen > len && scriptbuf[len] == 'A' )
{
//for (i=0; i<opretlen-len; i++)
// printf("%02x",scriptbuf[len+i]);
//printf(" Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
hush_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j,zero,0);
}
}
} //else if ( fJustCheck )
// return (-3); // if the notarisation is only invalid because its out of order it cannot be mined in a block with a valid one!
} else if ( opretlen != 149 && height > 600000 && matched != 0 )
printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL[0]==0?"KMD":SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen);
printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen);
}
else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 )
{
if ( notaryid >= 0 && notaryid < 64 )
komodo_paxpricefeed(height,&scriptbuf[len],opretlen);
hush_paxpricefeed(height,&scriptbuf[len],opretlen);
}
else if ( matched != 0 )
{
//int32_t k; for (k=0; k<scriptlen; k++)
// printf("%02x",scriptbuf[k]);
//printf(" <- script ht.%d i.%d j.%d value %.8f %s\n",height,i,j,dstr(value),SMART_CHAIN_SYMBOL);
if ( opretlen >= 32*2+4 && strcmp(SMART_CHAIN_SYMBOL[0]==0?"KMD":SMART_CHAIN_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 )
if ( opretlen >= 32*2+4 && strcmp(SMART_CHAIN_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 )
{
for (k=0; k<32; k++)
if ( scriptbuf[len+k] != 0 )
@ -764,7 +726,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
if ( k == 32 )
{
*isratificationp = 1;
printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]);
printf("%s: ISRATIFICATION (%s)\n",__func__,(char *)&scriptbuf[len+32*2+4]);
}
}
@ -775,12 +737,6 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
return(notaryid);
}
/*int32_t komodo_isratify(int32_t isspecial,int32_t numvalid)
{
if ( isspecial != 0 && numvalid >= HUSH_MINRATIFY )
return(1);
else return(0);
}*/
// Special tx have vout[0] -> CRYPTO555 address
// with more than HUSH_MINRATIFY pay2pubkey outputs -> ratify
@ -790,7 +746,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid,int32_t n);
int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys[64][33],int32_t numnotaries,uint8_t rmd160[20])
int32_t hush_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys[64][33],int32_t numnotaries,uint8_t rmd160[20])
{
int32_t i;
if ( scriptlen == 25 && memcmp(&scriptPubKey[3],rmd160,20) == 0 )
@ -818,7 +774,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
return(0);
}
memset(&zero,0,sizeof(zero));
komodo_init(pindex->GetHeight());
hush_init(pindex->GetHeight());
HUSH_INITDONE = (uint32_t)time(NULL);
if ( (sp= hush_stateptr(symbol,dest)) == 0 )
{
@ -836,7 +792,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
if ( pindex->GetHeight() != hwmheight )
{
printf("%s hwmheight.%d vs pindex->GetHeight().%d t.%u reorg.%d\n",SMART_CHAIN_SYMBOL,hwmheight,pindex->GetHeight(),(uint32_t)pindex->nTime,hwmheight-pindex->GetHeight());
komodo_purge_ccdata((int32_t)pindex->GetHeight());
hush_purge_ccdata((int32_t)pindex->GetHeight());
hwmheight = pindex->GetHeight();
}
if (!fJustCheck)
@ -853,7 +809,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
txn_count = block.vtx.size();
for (i=0; i<txn_count; i++)
{
// Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check.
// Notary pay chains need notarization in position 1, ignore the rest on validation. Check notarization is 1 on check.
if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 )
break;
txhash = block.vtx[i].GetHash();
@ -868,7 +824,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
continue;
if ( (scriptlen= gettxout_scriptPubKey(scriptPubKey,sizeof(scriptPubKey),block.vtx[i].vin[j].prevout.hash,block.vtx[i].vin[j].prevout.n)) > 0 )
{
if ( (k= komodo_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 )
if ( (k= hush_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 )
signedmask |= (1LL << k);
else if ( 0 && numvins >= 17 )
{
@ -938,7 +894,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
{
memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len);
notaryid = komodo_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,&notarizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime());
notaryid = hush_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,&notarizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime());
if ( fJustCheck && notaryid == -2 )
{
// We see a valid notarisation here, save its location.
@ -988,14 +944,14 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
{
memset(&txhash,0,sizeof(txhash));
hush_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0);
printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height);
printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+HUSH_DPOW_GAP/2)/HUSH_DPOW_GAP)+1)*HUSH_DPOW_GAP,height);
} else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries);
}
}
}
}
if ( !fJustCheck && IS_HUSH_NOTARY != 0 && SMART_CHAIN_SYMBOL[0] == 0 )
printf("%s ht.%d\n",SMART_CHAIN_SYMBOL[0] == 0 ? "KMD" : SMART_CHAIN_SYMBOL,height);
printf("%s ht.%d\n",SMART_CHAIN_SYMBOL,height);
if ( !fJustCheck && pindex->GetHeight() == hwmheight )
hush_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0,zero,0);
}

226
src/hush_bitcoind.h

@ -15,7 +15,7 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
// Hush functions that interact with bitcoind C++
// Hush functions that interact with hushd C++
#include <curl/curl.h>
#include <curl/easy.h>
#include "consensus/params.h"
@ -25,8 +25,8 @@
#include "sietch.h"
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp);
int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp);
int32_t hush_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp);
int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp);
bool EnsureWalletIsAvailable(bool avoidException);
extern bool fRequestShutdown;
extern CScript HUSH_EARLYTXID_SCRIPTPUB;
@ -367,9 +367,8 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *
return(chunk.memory);
}
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port)
{
//static void *cHandle;
char url[512],*retstr=0,*retstr2=0,postdata[8192];
if ( params == 0 || params[0] == 0 )
params = (char *)"[]";
@ -384,11 +383,11 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
return(retstr2);
}
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp)
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp)
{
char *jsonstr,params[256],*userpass; uint16_t port; cJSON *json,*item; int32_t height = 0,txid_height = 0,txid_confirmations = 0;
params[0] = 0;
*kmdnotarized_heightp = 0;
*hushnotarized_heightp = 0;
if ( strcmp(dest,"HUSH3") == 0 ) {
port = HUSH3_PORT;
userpass = HUSHUSERPASS;
@ -401,7 +400,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig
}
if ( userpass[0] != 0 )
{
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 )
if ( (jsonstr= hush_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 )
{
//printf("(%s)\n",jsonstr);
if ( (json= cJSON_Parse(jsonstr)) != 0 )
@ -409,14 +408,14 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig
if ( (item= jobj(json,(char *)"result")) != 0 )
{
height = jint(item,(char *)"blocks");
*kmdnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height;
*hushnotarized_heightp = strcmp(dest,"HUSH3") == 0 ? jint(item,(char *)"notarized") : height;
}
free_json(json);
}
free(jsonstr);
}
sprintf(params,"[\"%s\", 1]",txidstr);
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 )
if ( (jsonstr= hush_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 )
{
//printf("(%s)\n",jsonstr);
if ( (json= cJSON_Parse(jsonstr)) != 0 )
@ -437,7 +436,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig
return(txid_height);
}
int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len,uint256 NOTARIZED_HASH)
int32_t hush_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len,uint256 NOTARIZED_HASH)
{
int32_t i; uint256 hash; char params[256];
for (i=0; i<32; i++)
@ -453,19 +452,19 @@ int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len,
return(-1);
}
void komodo_reconsiderblock(uint256 blockhash)
void hush_reconsiderblock(uint256 blockhash)
{
char params[256],*jsonstr,*hexstr;
sprintf(params,"[\"%s\"]",blockhash.ToString().c_str());
if ( (jsonstr= komodo_issuemethod(ASSETCHAINS_USERPASS,(char *)"reconsiderblock",params,ASSETCHAINS_RPCPORT)) != 0 )
if ( (jsonstr= hush_issuemethod(ASSETCHAINS_USERPASS,(char *)"reconsiderblock",params,ASSETCHAINS_RPCPORT)) != 0 )
{
//fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT,jsonstr);
//fprintf(stderr,"hush_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT,jsonstr);
free(jsonstr);
}
//fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> NULL\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT);
//fprintf(stderr,"hush_reconsiderblock.(%s) (%s %u) -> NULL\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT);
}
int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID)
int32_t hush_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID)
{
char params[256],*jsonstr,*hexstr; uint8_t *script,_script[8192]; int32_t n,len,retval = -1; cJSON *json,*txjson,*vouts,*vout,*skey;
script = _script;
@ -475,34 +474,30 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
sprintf(&params[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]);
strcat(params,"\", 1]");*/
sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str());
if ( strcmp(symbol,SMART_CHAIN_SYMBOL[0]==0?(char *)"KMD":SMART_CHAIN_SYMBOL) != 0 )
if ( strcmp(symbol,SMART_CHAIN_SYMBOL[0]==0?(char *)"HUSH3":SMART_CHAIN_SYMBOL) != 0 )
return(0);
if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 )
printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",SMART_CHAIN_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT);
if ( strcmp(dest,"KMD") == 0 )
if ( strcmp(dest,"HUSH3") == 0 )
{
if ( HUSHUSERPASS[0] != 0 )
{
if ( SMART_CHAIN_SYMBOL[0] != 0 )
{
jsonstr = komodo_issuemethod(HUSHUSERPASS,(char *)"getrawtransaction",params,HUSH3_PORT);
jsonstr = hush_issuemethod(HUSHUSERPASS,(char *)"getrawtransaction",params,HUSH3_PORT);
//printf("userpass.(%s) got (%s)\n",HUSHUSERPASS,jsonstr);
}
}//else jsonstr = _dex_getrawtransaction();
else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok
}
else if ( strcmp(dest,"BTC") == 0 )
{
} else if ( strcmp(dest,"BTC") == 0 ) {
if ( BTCUSERPASS[0] != 0 )
{
//printf("BTCUSERPASS.(%s)\n",BTCUSERPASS);
jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332);
jsonstr = hush_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332);
}
//else jsonstr = _dex_getrawtransaction();
else return(0);
}
else
{
} else {
printf("[%s] verifynotarization error unexpected dest.(%s)\n",SMART_CHAIN_SYMBOL,dest);
return(-1);
}
@ -532,7 +527,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
script += 2;
len -= 2;
}
retval = komodo_verifynotarizedscript(height,script,len,NOTARIZED_HASH);
retval = hush_verifynotarizedscript(height,script,len,NOTARIZED_HASH);
}
}
}
@ -543,7 +538,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
return(retval);
}
CScript komodo_makeopret(CBlock *pblock, bool fNew)
CScript hush_makeopret(CBlock *pblock, bool fNew)
{
std::vector<uint256> vLeaves;
vLeaves.push_back(pblock->hashPrevBlock);
@ -560,7 +555,7 @@ CScript komodo_makeopret(CBlock *pblock, bool fNew)
uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; int32_t i; uint8_t revbuf[32];
memset(&hash,0,sizeof(hash));
sprintf(params,"[%d]",height);
if ( (jsonstr= komodo_issuemethod(HUSHUSERPASS,(char *)"getblockhash",params,BITCOIND_RPCPORT)) != 0 )
if ( (jsonstr= hush_issuemethod(HUSHUSERPASS,(char *)"getblockhash",params,BITCOIND_RPCPORT)) != 0 )
{
if ( (result= cJSON_Parse(jsonstr)) != 0 )
{
@ -575,7 +570,7 @@ CScript komodo_makeopret(CBlock *pblock, bool fNew)
}
free_json(result);
}
printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash);
printf("HUSH3 hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash);
free(jsonstr);
}
return(hash);
@ -583,7 +578,7 @@ CScript komodo_makeopret(CBlock *pblock, bool fNew)
uint256 _hush_getblockhash(int32_t height);*/
uint64_t komodo_seed(int32_t height)
uint64_t hush_seed(int32_t height)
{
uint64_t seed = 0;
/*if ( 0 ) // problem during init time, seeds are needed for loading blockindex, so null seeds...
@ -613,7 +608,7 @@ uint64_t komodo_seed(int32_t height)
return(seed);
}
uint32_t komodo_txtime(CScript &opret,uint64_t *valuep,uint256 hash, int32_t n, char *destaddr)
uint32_t hush_txtime(CScript &opret,uint64_t *valuep,uint256 hash, int32_t n, char *destaddr)
{
CTxDestination address; CTransaction tx; uint256 hashBlock; int32_t numvouts;
*valuep = 0;
@ -644,36 +639,10 @@ CBlockIndex *hush_getblockindex(uint256 hash)
return((it != mapBlockIndex.end()) ? it->second : NULL);
}
uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr)
{
CTxDestination address; CBlockIndex *pindex; CTransaction tx; uint256 hashBlock; uint32_t txtime = 0;
*valuep = 0;
if (!GetTransaction(hash, tx,
#ifndef HUSH_ZCASH
Params().GetConsensus(),
#endif
hashBlock, true))
{
//fprintf(stderr,"ERROR: %s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime);
return(0);
}
if ( (pindex= hush_getblockindex(hashBlock)) != 0 )
txtime = pindex->nTime;
else txtime = tx.nLockTime;
//fprintf(stderr,"%s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime);
if ( n < tx.vout.size() )
{
*valuep = tx.vout[n].nValue;
if (ExtractDestination(tx.vout[n].scriptPubKey, address))
strcpy(destaddr,CBitcoinAddress(address).ToString().c_str());
}
return(txtime);
}
bool hush_checkopret(CBlock *pblock, CScript &merkleroot)
{
merkleroot = pblock->vtx.back().vout.back().scriptPubKey;
return(merkleroot.IsOpReturn() && merkleroot == komodo_makeopret(pblock, false));
return(merkleroot.IsOpReturn() && merkleroot == hush_makeopret(pblock, false));
}
@ -690,23 +659,11 @@ bool hush_hardfork_active(uint32_t time)
return isactive;
}
int32_t komodo_isPoS(CBlock *pblock,int32_t height,bool fJustCheck)
int32_t hush_isPoS(CBlock *pblock,int32_t height,bool fJustCheck)
{
return(0);
}
void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
{
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp;
//fprintf(stderr,"disconnect ht.%d\n",pindex->GetHeight());
komodo_init(pindex->GetHeight());
if ( (sp= hush_stateptr(symbol,dest)) != 0 )
{
//sp->rewinding = pindex->GetHeight();
//fprintf(stderr,"-%d ",pindex->GetHeight());
} else printf("hush_disconnect: ht.%d cant get hush_state.(%s)\n",pindex->GetHeight(),SMART_CHAIN_SYMBOL);
}
int32_t hush_is_notarytx(const CTransaction& tx)
{
uint8_t *ptr; static uint8_t crypto555[33];
@ -719,7 +676,7 @@ int32_t hush_is_notarytx(const CTransaction& tx)
decode_hex(crypto555,33,(char *)CRYPTO555_PUBSECPSTR);
if ( memcmp(ptr+1,crypto555,33) == 0 )
{
//printf("found notarytx\n");
fprintf(stderr,"%s: found notarytx\n", __func__);
return(1);
}
}
@ -754,7 +711,7 @@ int32_t hush_block2height(CBlock *block)
}
//printf(" <- coinbase.%d ht.%d\n",(int32_t)block->vtx[0].vin[0].scriptSig.size(),height);
}
//komodo_init(height);
//hush_init(height);
}
if ( height != height2 )
{
@ -836,48 +793,7 @@ uint32_t hush_heightstamp(int32_t height)
return(0);
}
/*void komodo_pindex_init(CBlockIndex *pindex,int32_t height) gets data corrupted
{
int32_t i,num; uint8_t pubkeys[64][33]; CBlock block;
if ( pindex->didinit != 0 )
return;
//printf("pindex.%d komodo_pindex_init notary.%d from height.%d\n",pindex->GetHeight(),pindex->notaryid,height);
if ( pindex->didinit == 0 )
{
pindex->notaryid = -1;
if ( HUSH_LOADINGBLOCKS == 0 )
memset(pindex->pubkey33,0xff,33);
else memset(pindex->pubkey33,0,33);
if ( hush_blockload(block,pindex) == 0 )
{
hush_block2pubkey33(pindex->pubkey33,&block);
//for (i=0; i<33; i++)
// fprintf(stderr,"%02x",pindex->pubkey33[i]);
//fprintf(stderr," set pubkey at height %d/%d\n",pindex->GetHeight(),height);
//if ( pindex->pubkey33[0] == 2 || pindex->pubkey33[0] == 3 )
// pindex->didinit = (HUSH_LOADINGBLOCKS == 0);
} // else fprintf(stderr,"error loading block at %d/%d",pindex->GetHeight(),height);
}
if ( pindex->didinit != 0 && pindex->GetHeight() >= 0 && (num= hush_notaries(pubkeys,(int32_t)pindex->GetHeight(),(uint32_t)pindex->nTime)) > 0 )
{
for (i=0; i<num; i++)
{
if ( memcmp(pubkeys[i],pindex->pubkey33,33) == 0 )
{
pindex->notaryid = i;
break;
}
}
if ( 0 && i == num )
{
for (i=0; i<33; i++)
fprintf(stderr,"%02x",pindex->pubkey33[i]);
fprintf(stderr," unmatched pubkey at height %d/%d\n",pindex->GetHeight(),height);
}
}
}*/
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
void hush_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
{
int32_t num,i; CBlock block;
memset(pubkey33,0,33);
@ -888,35 +804,7 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
}
}
/*int8_t komodo_minerid(int32_t height,uint8_t *destpubkey33)
{
int32_t num,i,numnotaries; CBlockIndex *pindex; uint32_t timestamp=0; uint8_t pubkey33[33],pubkeys[64][33];
if ( (pindex= chainActive[height]) != 0 )
{
if ( pindex->didinit != 0 )
{
if ( destpubkey33 != 0 )
memcpy(destpubkey33,pindex->pubkey33,33);
return(pindex->notaryid);
}
komodo_index2pubkey33(pubkey33,pindex,height);
if ( destpubkey33 != 0 )
memcpy(destpubkey33,pindex->pubkey33,33);
if ( pindex->didinit != 0 )
return(pindex->notaryid);
timestamp = pindex->GetBlockTime();
if ( (num= hush_notaries(pubkeys,height,timestamp)) > 0 )
{
for (i=0; i<num; i++)
if ( memcmp(pubkeys[i],pubkey33,33) == 0 )
return(i);
}
}
fprintf(stderr,"komodo_minerid height.%d null pindex\n",height);
return(komodo_electednotary(&numnotaries,pubkey33,height,timestamp));
}*/
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height)
int32_t hush_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height)
{
// after the season HF block ALL new notaries instantly become elegible.
int32_t i,j,n,duplicate; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33];
@ -939,7 +827,9 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blo
break;
}
}
} else fprintf(stderr,"couldnt load block.%d\n",height);
} else {
fprintf(stderr,"%s: couldnt load block height %d\n",__func__,height);
}
if ( mids[0] >= 0 && i > 0 && mids[i] == mids[0] )
duplicate++;
}
@ -949,7 +839,7 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blo
else return(0);
}
int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width)
int32_t hush_minerids(uint8_t *minerids,int32_t height,int32_t width)
{
int32_t i,j,nonz,numnotaries; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33],pubkey33[33];
numnotaries = hush_notaries(notarypubs33,height,0);
@ -978,18 +868,18 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width)
return(nonz);
}
int32_t hush_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
int32_t hush_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *hushtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *hushstartip,int32_t *hushendip)
{
int32_t depth,notarized_ht; uint256 MoM,kmdtxid;
depth = hush_MoMdata(&notarized_ht,&MoM,&kmdtxid,nHeight,MoMoMp,MoMoMoffsetp,MoMoMdepthp,kmdstartip,kmdendip);
int32_t depth,notarized_ht; uint256 MoM,hushtxid;
depth = hush_MoMdata(&notarized_ht,&MoM,&hushtxid,nHeight,MoMoMp,MoMoMoffsetp,MoMoMdepthp,hushstartip,hushendip);
memset(MoMp,0,sizeof(*MoMp));
memset(kmdtxidp,0,sizeof(*kmdtxidp));
memset(hushtxidp,0,sizeof(*hushtxidp));
*notarized_heightp = 0;
if ( depth != 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight <= notarized_ht )
{
*MoMp = MoM;
*notarized_heightp = notarized_ht;
*kmdtxidp = kmdtxid;
*hushtxidp = hushtxid;
}
return(depth);
}
@ -1029,7 +919,7 @@ int32_t hush_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash)
int32_t notarized_height,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; CBlockIndex *notary,*pindex;
if ( (pindex= chainActive.LastTip()) == 0 )
return(-1);
notarized_height = komodo_notarizeddata(pindex->GetHeight(),&notarized_hash,&notarized_desttxid);
notarized_height = hush_notarizeddata(pindex->GetHeight(),&notarized_hash,&notarized_desttxid);
*notarized_heightp = notarized_height;
BlockMap::const_iterator it;
if ( notarized_height >= 0 && notarized_height <= pindex->GetHeight() && (it = mapBlockIndex.find(notarized_hash)) != mapBlockIndex.end() && (notary = it->second) != NULL )
@ -1060,12 +950,12 @@ int32_t hush_nextheight()
else return(hush_longestchain() + 1);
}
int32_t komodo_isrealtime(int32_t *kmdheightp)
int32_t hush_isrealtime(int32_t *hushheightp)
{
struct hush_state *sp; CBlockIndex *pindex;
if ( (sp= hush_stateptrget((char *)"KMD")) != 0 )
*kmdheightp = sp->CURRENT_HEIGHT;
else *kmdheightp = 0;
if ( (sp= hush_stateptrget((char *)"HUSH3")) != 0 )
*hushheightp = sp->CURRENT_HEIGHT;
else *hushheightp = 0;
if ( (pindex= chainActive.LastTip()) != 0 && pindex->GetHeight() >= (int32_t)hush_longestchain() )
return(1);
else return(0);
@ -1282,7 +1172,7 @@ int8_t hush_segid(int32_t nocache,int32_t height)
{
txid = block.vtx[txn_count-1].vin[0].prevout.hash;
vout = block.vtx[txn_count-1].vin[0].prevout.n;
txtime = komodo_txtime(opret,&value,txid,vout,destaddr);
txtime = hush_txtime(opret,&value,txid,vout,destaddr);
if ( ExtractDestination(block.vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) )
{
strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str());
@ -1322,7 +1212,7 @@ void hush_segids(uint8_t *hashbuf,int32_t height,int32_t n)
}
}
arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime)
arith_uint256 hush_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime)
{
arith_uint256 origtarget,easy; int32_t diff,tipdiff; int64_t mult; bool fNegative,fOverflow; CBlockIndex *tipindex;
if ( height > 10 && (tipindex= hush_chainactive(height - 1)) != 0 ) // disable offchain diffchange
@ -1348,7 +1238,7 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui
return(bnTarget);
}
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc)
arith_uint256 hush_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc)
{
int32_t oldflag = 0,dispflag = 0;
CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val;
@ -1455,7 +1345,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he
// lulz
int32_t komodo_is_PeiceOfShit() { return(1); }
uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount)
uint64_t hush_notarypayamount(int32_t nHeight, int64_t notarycount)
{
int8_t curEra = 0; int64_t ret = 0;
// if we have an end block in the first era, find our current era
@ -1472,7 +1362,7 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount)
if ( notarycount == 0 )
{
fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n");
fprintf(stderr, "hush_notarypayamount failed num notaries is 0!\n");
return(0);
}
// Because of reorgs we cannot use the notarized height value.
@ -1493,7 +1383,7 @@ int32_t hush_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *scri
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
{
memcpy(scriptbuf,script,len);
if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,&notarizedheight,0,1,0,timestamp) != -2 )
if ( hush_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,&notarizedheight,0,1,0,timestamp) != -2 )
{
fprintf(stderr, "<<<<<<INVALID NOTARIZATION ht.%i\n",notarizedheight);
return(0);
@ -1502,7 +1392,7 @@ int32_t hush_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *scri
return(notarizedheight);
}
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len)
uint64_t hush_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len)
{
// fetch notary pubkey array.
uint64_t total = 0, AmountToPay = 0;
@ -1522,7 +1412,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &Notar
txNew.vout.resize(NotarizationNotaries.size()+1);
// Calcualte the amount to pay according to the current era.
AmountToPay = komodo_notarypayamount(height,NotarizationNotaries.size());
AmountToPay = hush_notarypayamount(height,NotarizationNotaries.size());
if ( AmountToPay == 0 )
return(0);
@ -1597,7 +1487,7 @@ uint64_t hush_checknotarypay(CBlock *pblock,int32_t height)
{
// Create the coinbase tx again, using the extracted data, this is the same function the miner uses, with the same data.
// This allows us to know exactly that the coinbase is correct.
totalsats = komodo_notarypay(txNew, NotarizationNotaries, pblock->nTime, height, script, scriptlen);
totalsats = hush_notarypay(txNew, NotarizationNotaries, pblock->nTime, height, script, scriptlen);
}
else
{
@ -1653,7 +1543,7 @@ uint64_t hush_checknotarypay(CBlock *pblock,int32_t height)
return(0);
}
bool komodo_appendACscriptpub()
bool hush_appendACscriptpub()
{
static bool didinit = false;
if ( didinit )
@ -1748,7 +1638,7 @@ int64_t hush_checkcommission(CBlock *pblock,int32_t height)
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{
static bool didinit = false;
if ( !didinit && height > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && komodo_appendACscriptpub() )
if ( !didinit && height > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_appendACscriptpub() )
{
fprintf(stderr, "appended CC_op_return to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
didinit = true;

4
src/hush_cJSON.h

@ -36,8 +36,8 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#ifndef komodo_cJSON__h
#define komodo_cJSON__h
#ifndef hush_cJSON__h
#define hush_cJSON__h
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

50
src/hush_ccdata.h

@ -24,7 +24,7 @@ int32_t CC_firstheight;
uint256 BuildMerkleTree(bool* fMutated, const std::vector<uint256> leaves, std::vector<uint256> &vMerkleTree);
uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth)
uint256 hush_calcMoM(int32_t height,int32_t MoMdepth)
{
static uint256 zero; CBlockIndex *pindex; int32_t i; std::vector<uint256> tree, leaves;
bool fMutated;
@ -41,7 +41,7 @@ uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth)
return BuildMerkleTree(&fMutated, leaves, tree);
}
struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi)
struct hush_ccdata_entry *hush_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t hushstarti,int32_t hushendi)
{
struct hush_ccdata_entry *allMoMs=0; struct hush_ccdata *ccdata,*tmpptr; int32_t i,num,max;
bool fMutated; std::vector<uint256> tree, leaves;
@ -49,7 +49,7 @@ struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t k
portable_mutex_lock(&HUSH_CC_mutex);
DL_FOREACH_SAFE(CC_data,ccdata,tmpptr)
{
if ( ccdata->MoMdata.height <= kmdendi && ccdata->MoMdata.height >= kmdstarti )
if ( ccdata->MoMdata.height <= hushendi && ccdata->MoMdata.height >= hushstarti )
{
if ( num >= max )
{
@ -58,12 +58,12 @@ struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t k
}
allMoMs[num].MoM = ccdata->MoMdata.MoM;
allMoMs[num].notarized_height = ccdata->MoMdata.notarized_height;
allMoMs[num].kmdheight = ccdata->MoMdata.height;
allMoMs[num].hushheight = ccdata->MoMdata.height;
allMoMs[num].txi = ccdata->MoMdata.txi;
strcpy(allMoMs[num].symbol,ccdata->symbol);
num++;
}
if ( ccdata->MoMdata.height < kmdstarti )
if ( ccdata->MoMdata.height < hushstarti )
break;
}
portable_mutex_unlock(&HUSH_CC_mutex);
@ -81,7 +81,7 @@ struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t k
return(allMoMs);
}
int32_t komodo_addpair(struct hush_ccdataMoMoM *mdata,int32_t notarized_height,int32_t offset,int32_t maxpairs)
int32_t hush_addpair(struct hush_ccdataMoMoM *mdata,int32_t notarized_height,int32_t offset,int32_t maxpairs)
{
if ( maxpairs >= 0) {
if ( mdata->numpairs >= maxpairs )
@ -91,7 +91,7 @@ int32_t komodo_addpair(struct hush_ccdataMoMoM *mdata,int32_t notarized_height,i
//fprintf(stderr,"pairs reallocated to %p num.%d\n",mdata->pairs,mdata->numpairs);
}
} else {
fprintf(stderr,"komodo_addpair.maxpairs %d must be >= 0\n",(int32_t)maxpairs);
fprintf(stderr,"hush_addpair.maxpairs %d must be >= 0\n",(int32_t)maxpairs);
return(-1);
}
mdata->pairs[mdata->numpairs].notarized_height = notarized_height;
@ -100,7 +100,7 @@ int32_t komodo_addpair(struct hush_ccdataMoMoM *mdata,int32_t notarized_height,i
return(maxpairs);
}
int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mdata,char *symbol,int32_t kmdheight,int32_t notarized_height)
int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mdata,char *symbol,int32_t hushheight,int32_t notarized_height)
{
uint8_t hexdata[8192]; struct hush_ccdata *ccdata,*tmpptr; int32_t len,maxpairs,i,retval=-1,depth,starti,endi,CCid=0; struct hush_ccdata_entry *allMoMs;
starti = endi = depth = len = maxpairs = 0;
@ -114,9 +114,9 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda
portable_mutex_lock(&HUSH_CC_mutex);
DL_FOREACH_SAFE(CC_data,ccdata,tmpptr)
{
if ( ccdata->MoMdata.height < kmdheight )
if ( ccdata->MoMdata.height < hushheight )
{
//fprintf(stderr,"%s notarized.%d kmd.%d\n",ccdata->symbol,ccdata->MoMdata.notarized_height,ccdata->MoMdata.height);
//fprintf(stderr,"%s notarized.%d HUSH3.%d\n",ccdata->symbol,ccdata->MoMdata.notarized_height,ccdata->MoMdata.height);
if ( strcmp(ccdata->symbol,symbol) == 0 )
{
if ( endi == 0 )
@ -136,23 +136,23 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda
}
}
portable_mutex_unlock(&HUSH_CC_mutex);
mdata->kmdstarti = starti;
mdata->kmdendi = endi;
mdata->hushstarti = starti;
mdata->hushendi = endi;
if ( starti != 0 && endi != 0 && endi >= starti )
{
if ( (allMoMs= komodo_allMoMs(&depth,&mdata->MoMoM,starti,endi)) != 0 )
if ( (allMoMs= hush_allMoMs(&depth,&mdata->MoMoM,starti,endi)) != 0 )
{
mdata->MoMoMdepth = depth;
for (i=0; i<depth; i++)
{
if ( strcmp(symbol,allMoMs[i].symbol) == 0 )
maxpairs = komodo_addpair(mdata,allMoMs[i].notarized_height,i,maxpairs);
maxpairs = hush_addpair(mdata,allMoMs[i].notarized_height,i,maxpairs);
}
if ( mdata->numpairs > 0 )
{
len += dragon_rwnum(1,&hexdata[len],sizeof(CCid),(uint8_t *)&CCid);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdstarti);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdendi);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->hushstarti);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->hushendi);
len += dragon_rwbignum(1,&hexdata[len],sizeof(mdata->MoMoM),(uint8_t *)&mdata->MoMoM);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->MoMoMdepth);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->numpairs);
@ -160,7 +160,7 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda
{
if ( len + sizeof(uint32_t)*2 > sizeof(hexdata) )
{
fprintf(stderr,"%s %d %d i.%d of %d exceeds hexdata.%d\n",symbol,kmdheight,notarized_height,i,mdata->numpairs,(int32_t)sizeof(hexdata));
fprintf(stderr,"%s %d %d i.%d of %d exceeds hexdata.%d\n",symbol,hushheight,notarized_height,i,mdata->numpairs,(int32_t)sizeof(hexdata));
break;
}
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].notarized_height);
@ -171,7 +171,7 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda
init_hexbytes_noT(hexstr,hexdata,len);
//fprintf(stderr,"hexstr.(%s)\n",hexstr);
retval = 0;
} else fprintf(stderr,"%s %d %d too much hexdata[%d] for hexstr[%d]\n",symbol,kmdheight,notarized_height,len,hexsize);
} else fprintf(stderr,"%s %d %d too much hexdata[%d] for hexstr[%d]\n",symbol,hushheight,notarized_height,len,hexsize);
}
free(allMoMs);
}
@ -179,7 +179,7 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda
return(retval);
}
void komodo_purge_ccdata(int32_t height)
void hush_purge_ccdata(int32_t height)
{
struct hush_ccdata *ccdata,*tmpptr;
if ( SMART_CHAIN_SYMBOL[0] == 0 )
@ -203,7 +203,7 @@ void komodo_purge_ccdata(int32_t height)
}
// this is just a demo of ccdata processing to create example data for the MoMoM and allMoMs calls
int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct hush_ccdata *ccdata,struct hush_ccdataMoMoM *MoMoMdata)
int32_t hush_rwccdata(char *thischain,int32_t rwflag,struct hush_ccdata *ccdata,struct hush_ccdataMoMoM *MoMoMdata)
{
uint256 hash,zero; bits256 tmp; int32_t i,nonz; struct hush_ccdata *ptr; struct notarized_checkpoint *np;
return(0); // disable this path as libscott method is much better
@ -247,7 +247,7 @@ int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct hush_ccdata *ccdat
{
for (i=0; i<MoMoMdata->numpairs; i++)
{
if ( (np= komodo_npptr(MoMoMdata->pairs[i].notarized_height)) != 0 )
if ( (np= hush_npptr(MoMoMdata->pairs[i].notarized_height)) != 0 )
{
memset(&zero,0,sizeof(zero));
if ( memcmp(&np->MoMoM,&zero,sizeof(np->MoMoM)) == 0 )
@ -255,12 +255,12 @@ int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct hush_ccdata *ccdat
np->MoMoM = MoMoMdata->MoMoM;
np->MoMoMdepth = MoMoMdata->MoMoMdepth;
np->MoMoMoffset = MoMoMdata->MoMoMoffset;
np->kmdstarti = MoMoMdata->kmdstarti;
np->kmdendi = MoMoMdata->kmdendi;
np->hushstarti = MoMoMdata->hushstarti;
np->hushendi = MoMoMdata->hushendi;
}
else if ( memcmp(&np->MoMoM,&MoMoMdata->MoMoM,sizeof(np->MoMoM)) != 0 || np->MoMoMdepth != MoMoMdata->MoMoMdepth || np->MoMoMoffset != MoMoMdata->MoMoMoffset || np->kmdstarti != MoMoMdata->kmdstarti || np->kmdendi != MoMoMdata->kmdendi )
else if ( memcmp(&np->MoMoM,&MoMoMdata->MoMoM,sizeof(np->MoMoM)) != 0 || np->MoMoMdepth != MoMoMdata->MoMoMdepth || np->MoMoMoffset != MoMoMdata->MoMoMoffset || np->hushstarti != MoMoMdata->hushstarti || np->hushendi != MoMoMdata->hushendi )
{
fprintf(stderr,"preexisting MoMoM mismatch: %s (%d %d %d %d) vs %s (%d %d %d %d)\n",np->MoMoM.ToString().c_str(),np->MoMoMdepth,np->MoMoMoffset,np->kmdstarti,np->kmdendi,MoMoMdata->MoMoM.ToString().c_str(),MoMoMdata->MoMoMdepth,MoMoMdata->MoMoMoffset,MoMoMdata->kmdstarti,MoMoMdata->kmdendi);
fprintf(stderr,"preexisting MoMoM mismatch: %s (%d %d %d %d) vs %s (%d %d %d %d)\n",np->MoMoM.ToString().c_str(),np->MoMoMdepth,np->MoMoMoffset,np->hushstarti,np->hushendi,MoMoMdata->MoMoM.ToString().c_str(),MoMoMdata->MoMoMdepth,MoMoMdata->MoMoMoffset,MoMoMdata->hushstarti,MoMoMdata->hushendi);
}
}
}

6
src/hush_curve25519.h

@ -955,14 +955,14 @@ uint64_t conv_NXTpassword(unsigned char *mysecret,unsigned char *mypublic,uint8_
return(addr);
}
uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase)
uint256 hush_kvprivkey(uint256 *pubkeyp,char *passphrase)
{
uint256 privkey;
conv_NXTpassword((uint8_t *)&privkey,(uint8_t *)pubkeyp,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
return(privkey);
}
uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 _privkey)
uint256 hush_kvsig(uint8_t *buf,int32_t len,uint256 _privkey)
{
bits256 sig,hash,otherpub,checksig,pubkey,privkey; uint256 usig;
memcpy(&privkey,&_privkey,sizeof(privkey));
@ -984,7 +984,7 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 _privkey)
return(usig);
}
int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig)
int32_t hush_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig)
{
bits256 hash,checksig,pubkey; static uint256 zeroes;
memcpy(&pubkey,&_pubkey,sizeof(pubkey));

109
src/hush_defs.h

@ -23,7 +23,7 @@
#define HUSH_EARLYTXID_HEIGHT 100
#define ASSETCHAINS_MINHEIGHT 128
#define ASSETCHAINS_MAX_ERAS 7
#define KOMODO_ELECTION_GAP 2000
#define HUSH_DPOW_GAP 2000
#define ROUNDROBIN_DELAY 61
#define HUSH_SMART_CHAIN_MAXLEN 65
#define HUSH_LIMITED_NETWORKSIZE 4
@ -53,13 +53,15 @@ const uint32_t nHushHardforkHeight = 166250;
const uint32_t nHushHardforkHeight2 = 245055;
// This height begins Hush DPoW from Hush notaries
const uint32_t nHushHardforkHeight3 = 340420;
// No coins/code are currently using timestamp activated fork
const uint32_t nHushHardforkHeight3 = 340420;
const uint32_t nHushHardforkTimestamp = 1580303652; // Jan 29nd 1pm GMT
const uint32_t nHushHardforkTimestamp2 = 1594425600; // Jul 11th 12a GMT
// Used by HSCs
static const uint32_t HUSH_SEASON_TIMESTAMPS[NUM_HUSH_SEASONS] = {1525132800, 1563148800, nHushHardforkTimestamp, nHushHardforkTimestamp2, nHushHardforkTimestamp2*5, nHushHardforkTimestamp2*6, nHushHardforkTimestamp2*7};
// Used by HUSH3+TUSH
// Block 1702100 = nHushHardforkHeight3*5
static const int32_t HUSH_SEASON_HEIGHTS[NUM_HUSH_SEASONS] = {1,2,nHushHardforkHeight, nHushHardforkHeight2, (int)340000, nHushHardforkHeight3, nHushHardforkHeight3*5};
// Era array of pubkeys. Add extra seasons to bottom as requried, after adding appropriate info above.
@ -472,6 +474,73 @@ static const char *notaries_elected[NUM_HUSH_SEASONS][NUM_HUSH_NOTARIES][2] =
{"RAJWHL6MzGFKg7KB2sZ87KPQUSvxy3VrEW", "0389971362b002ab5dfa1b5f9c4f88e68249511a3935242ba1e0d31c1c88a36d70"},
{"RU592tQnbH8gt6xd5Uu23nEw3SucDNkXmK", "02b8b6a2266fe57b25f2d4b1da93a07d27930154e78f9d137bc7509cf1ae8e3d49"},
{"RLGCLRzaEmruPC9UmVt5qRHEhXwHip1e6d", "02a2fd96b4459411ad2b09597ba59cf52b282c56330da7c0cc6d2a5c0323a18f1e"}
},
{
// season 7
{"RFetqf8WUfWnwNeXdknkm8ojk7EXnYFzrv", "038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac"},
{"RV7YSVW89WC9jBDtFG4ubtopDRove4Tfvc", "03c9d35488be73fe4f2dbb1dc011468482d71bac32249f8cce6480bcc574415d19"},
{"RBPFE9oXceZBWTn3Vhne4FUKE9vxGEXUKX", "028a8bb6ded2692b39a69ec2d3c9836ff221815909d5cd65257374aeb66394a002"},
{"RM3cvUcafPhjyypZLEginQjdhjLnSgJHte", "03a36180014115b47b97c1c8776a269bba66047b1ce2c7eb1a3d4e995a6dfff0df"},
{"RFFX1VaTmZYPBLCzFj7w3iJQArV9ZdaWcW", "02190865f3ca3678d322c96e49a3ddf8ad394a4c8cd97d4bb3376cf547d0d83c66"},
{"RDwZsLpH1QiAbJwUEY8ajXwTzu3PaWhx7n", "023ea0babb34e1ff9f4db8131ee84ad8991b954038a1e6ef9afc2a1b3fa13bbcb9"},
{"RCUvfnmt16ZMvLTmLGGAztcAE8fBjfbP6u", "0379a5ba9fb6b463ffcdc0b1f3ecf45a5b737275354f9c2598492f20660f6f7dfd"},
{"RBLu9adNVMVf6jzLLbAenWovcwq8nU6gYd", "022cd69381231d69d6d3b9638762df849bc7bbab71cbb8383eec29ca677f1afa30"},
{"RWfv6wd2fwgecnJxC1Ykpf1SJefGh2Wc6i", "03da8a8f57d88afb61f712a8cd35462b65ce2b2575db8f9ee33a725dcd12c44755"},
{"RWiK4xooG3dPdvaovu6JvR3DWoYD4tfRjx", "02ffe66af4d71345fe6984b5002ad69206e1817566a70d9ac406a679be6a3335a0"},
{"RYLNiJiRnEGeMxx1Q2xLoFujshRNkBa2x4", "028ef6501004569c1170ce2d7ec7ecfe5739001130ad1b39129f8b88cd3d610257"},
{"RTw36Ksy5Wk1Xv3B53T79zoRd6XDsE9MS6", "02d7cf4ece00895ca857fcdd0a4c2fc9c949a518d2750396f77d9f031c08a94364"},
{"RTPkUBriQzZy67WmFhEs6aQzJn5HBB3ntb", "03319ca1eae5888c45115d160ac07c4f2abd1720926aa579d535c4b46c807bb7f7"},
{"RBmZzttvDnMaEv47cWXs8SgdC993djB68r", "034302c4e1ff72a5f5391f259f7a46e646c7845aa2c9de9fb0c0a4c4802aad79d6"},
{"RGocb2jLCa2E9kVHDUsijrVGTDP82ngGYZ", "024440a18a16e38b836b3ad9bb54ab0b5ba83b04edebb58c62c09b2de29e9fc703"},
{"RVqwCjPQ6AJ6r9WeGzQvAT4eGXDScprLkW", "028a94e53ad8ed9e78f0f8a87cf3bc4754784222ad7ddf2d3dc5fafec2f6891cde"},
{"RB2Xc8eLrATRWVsxrZKHHx3hyJz1vugMt9", "02eca07a9b5810fe929a87f90e5f02e29a06479d39cd3a888abfa1793e1565155a"},
{"RKm7WUuFfqCTiUBkbxBsdh54nT6ivXpDPX", "03e3f634671005c8ffb7fe883fcf9e08f6f5486df057f215d761741d91c88de898"},
{"RLbHTvFQoz946W3o3gXTrjxxADeUsWWW16", "02e6bb6dcecf5e3abfe239dec55842a92f096eeac7f0ff7621c3e8948e5e789b27"},
{"RD75njr2RLGC5PqjHbWwuL7ndTqZiUfYxs", "0250d9996c25a34cb1b4e86303a297fc5c49c65615eb31a57fb17d1e1b376e71be"},
{"RT1VTzZYZLWUsPWFJ2oypEqB1MXMfq8b5Y", "02d1797941b7df42a98f59ede0f22294e7c02754232a8b1de9512ededaf3f82880"},
{"RKeXriTVXioHeKpFTjC8Cjohd6DHGUcKqt", "0341e62f0cdffc4ba3e0efb793c0fcaaad1b611db7021b844f643d5c25847733d2"},
{"RQYrDEgZPKMFAgTHNkWFeMHEmpkXe8j28T", "02b8719cd8484755990158cbdf7b9d990d4a5c3741cabe204e51ed04be5bd50133"},
{"RE85TACcn8CEn26itAxQV9afxV9mVg17vm", "0367f569d3dc304e699196fe9b798671fe3f12df7851a0a474879b0dbf8bc508d1"},
{"RPYWQJXto1aeCGe8T6g9Wo4tAL4xE82LJ8", "02cf1e245dfb44e418fd550abb825a600e1753d46a51995970e70c98be539da33e"},
{"RSVHRS5wqEw7bxfuE9k6xJGbARcy5guisp", "03ab8ac83d689ce76b5d29a54c3b34d0a6cb37d64313ff4467c744787475969a23"},
{"REAQwBaJFo6DyBkwfW7rTTDbUtkdmATcQ8", "025e80f0075514cc5940de85c0c559efa99a3688faf6cccb8c1d1f38b96ca91e71"},
{"RF1gz8QBw5uFScGasqVxoUjQwJCD9zHJwC", "031cdae4b545e5049ccee8e0cb792e25795b56e08b5e64b1d972c9b94e9bfd4ed0"},
{"RTnLGoWzpsyoGSViGH8GyYcYhSveSEmnPV", "03cf3403a9d1cefa83e07b73e618a7f991d140a8283a02df3ce7c00223f27f43d0"},
{"RArURqxp6qfF7fqv38tCYr6p4zBtLtqf4x", "026bc4c91c2c35fabe88fea6470d6cda98977a97c251656adf25b81653c00c3800"},
{"RN8GCryShNFvBWtcNEWrQJ5A9AWb3JJoXt", "02afa94f6574cd0fe4f5dc83b09a2112457862421ce96bdc75c1cf25ef5b1f8c4b"},
{"RQSC2eBckcFPWzq9UtofePC31wgDySfJtw", "035d570768d844c8150a3bd966a2e13aa99316f4ab3e80370c4d16fb02f95d0974"},
{"RC4uQsfH6jXpgnTFuFiDwAFo58gHLNkWo7", "02402b0ab7001fd4bcb4fa0d8d7006a6c521b1c76e85aad7b374ecd6c5d564c237"},
{"RREcuaUWSkNzTNPBbFLbXKTKiC4fd5t47J", "03d5bf8b43c44ba064e897da47dd36dba537bebf013d28247ce7a088496dd9b66d"},
{"REFyC5e7kmse3PUapDuXHL2xmtYEGttYYL", "035f56fd01dd21725928bbd878b795dccafecc03b978dc83748e9194dcbfebfb79"},
{"RH1BLwZosLp2hv9msdZGdSu93K8GrMWw7D", "0224ab22ece88f624f80a8535b8d5194646ad6be749070ec188a22c5e29fdd7098"},
{"RNkhugMQVbqDysSayHu2eAhTQpXzKWqZ3m", "02caab4c83c8cc245a7aeb6d25504363555d1b0874aef0f9f8116b4ddb61f24799"},
{"RKiyhLELDJATA7ZCUcutkP1WCEHnAgZRZ8", "028c01859a700ed3941a5786cf2043992e17a45c6689ac4bf608ad3f19e6d0e832"},
{"RLKARvLNo6Abkh5qh5NVn2HJmYfj8ELa6A", "0300a33629da90b9d3c0519d796f4b1278355bb8c46e4caee04b1305e2ab2ff3f2"},
{"RACX21FKLenyyEf8SYK3LmjsDzkDthwUbR", "0205d73c6a3e969eff29e5f424c861d22544245e09eaafc3fefe021cad052b7c0b"},
{"RETb7pEDauKBEuTBuXDhKS3ksd2p8x9KYa", "025c1f7596fd0b7286e6ebd1b3c275a14a13aa4d134db4677769324969b7b7e3a5"},
{"RJrAo78TL6zUmiHXbBv8oRhfGKxGnPnxUu", "02d40a76fbab96a78898b7579626be6dfe360c63b91030e513f849f212d57c1af6"},
{"RL8g6ANxhZBPHHHWgApaiSQ2BSP9qKwuwf", "020236a5748ea49da891276bcb85dc03487cb9f3d0c2b2cdb35227b6a624f86797"},
{"RY3vwBjuuTCiYL5am9HmwbdCjffWd9f4CE", "032f61fd08957d9b88dabc077d8732bef6c30d0234c14e02f3a741116834f591dc"},
{"RQW4LsSzjCPtNw1HGamSaCoiirvsrZmDY5", "02e29451f9baf0186a655396726a22a20617a3e54ea895590f6066abc993f83d32"},
{"RJtjorxqhazz39UpFdhDW8MiW4E3jhXDNk", "03795b7a650db872c22f13a9c88ad5c1ad3cb07a349f1f29e9789efd27e151164b"},
{"RSi8AiCCtS3doFupdpdfuorAhkrCS6mLMu", "037a62ff6b7eb2ba1e170b5c42e7788817ded6a3a7ed841321c01cc107aa647d42"},
{"RMjMXC8m9PgAaMMvwqgLCyCrv47pp6F6XY", "033bdf151c01bc733e614f9d4f204ca44396bf56984df6643205d349a35f7b265d"},
{"RYB3ZMgHt4h7YL8TUzpqaSDw22ABksAPGC", "021266e045f95322fceddae02877dca9721792bef8f2be28cacd7c36290cd813a7"},
{"RGwy64PXswUKpiepfzgaRW98v3gsuqPtow", "03008783c34c2622e7167f0a5201846133e530e89dfe1a8fbcf4c29b33051c4565"},
{"RKJRPLaQV4AkWF6EfUUzFwawTGU4RQZgcS", "03c20a9fd21de76a20ffc87e384be735dfabb7f34a2d881ca9714830fb1bbe6bdb"},
{"RQ4SPvBKTEKyV6y31iSihtfMxi3KeyAJgV", "033c5a23c75d946c15c15fac1e6d78e08c2b656549a158627cfb6bc44bb7b3a560"},
{"RTvRBC1pCQpPKrS27Q4hUCVKVpa5tSTsFS", "02c25672fae388a0613d0127fcfe38ef37f5f354ecfdea0fb734528e354319bd9d"},
{"RKxWu9HpCg7m3UeUGw2Xs1SpFiR96fSCQj", "02ec760d09b369b82b34d864af5a468d8a7dc5609b06bce455d045d1059c4b0f71"},
{"RBAaUWAD8jwVLL7ueb7ciAQewqgheKxwdk", "0274ec3abcca214cdf7f1a565f5f3d3fa910e62e751a1ab0de148ea14ba72d6ba7"},
{"RT853SBEGt4EWrKbpSujya69DG1jSNYjob", "02e80260ca44b8539159e6af678cf5ed0bc596753e4985f66418d6417085b4104e"},
{"RKjEuhVByPwJcZ9wuBgfELiCVnBrc4F8i4", "0357c38f5d5eb1662a54b980c9243ddd8b2100d4b2b9f8175246938ef76e100678"},
{"RT6wVuFFPU5tY6C7Buup1GLV3SE5mpYEha", "02571085ead1aca86b9e90fa9a23d99a194c862524b0c714102888be5bf122dc7d"},
{"RSTgcpV82AivrvWJpd4LR2KwWirwbwXE3Y", "021a0ee4611ca4d8a2e209cc43b95036deb0a9d1cc31fc9f87d50233a44f05ec1a"},
{"RCiaXRzo4AAG3zmPL3Hx63NsRWv5UGiNuM", "02f4876be65c54613e47f7fac67f1453e8d8fde5e19fa53f278a1083a08b258ab3"},
{"RCGgLWrTTaqBhUsS1BqrmFpJZAdNJMzscv", "02893d2db5329b15a33aa7edfbf323c85cabbdc25caa6cf6186fac6052ae6d96a0"},
{"RAJWHL6MzGFKg7KB2sZ87KPQUSvxy3VrEW", "0389971362b002ab5dfa1b5f9c4f88e68249511a3935242ba1e0d31c1c88a36d70"},
{"RU592tQnbH8gt6xd5Uu23nEw3SucDNkXmK", "02b8b6a2266fe57b25f2d4b1da93a07d27930154e78f9d137bc7509cf1ae8e3d49"},
{"RLGCLRzaEmruPC9UmVt5qRHEhXwHip1e6d", "02a2fd96b4459411ad2b09597ba59cf52b282c56330da7c0cc6d2a5c0323a18f1e"}
}
};
@ -525,7 +594,7 @@ extern int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
int tx_height( const uint256 &hash );
extern std::vector<std::string> vAllowListAddress;
extern std::map <std::int8_t, int32_t> mapHeightEvalActivate;
void komodo_netevent(std::vector<uint8_t> payload);
void hush_netevent(std::vector<uint8_t> payload);
int32_t getacseason(uint32_t timestamp);
int32_t gethushseason(int32_t height);
@ -534,40 +603,40 @@ int32_t gethushseason(int32_t height);
#define HUSH_KVBINARY 2
#define PRICES_SMOOTHWIDTH 1
#define PRICES_MAXDATAPOINTS 8
uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume);
int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel);
uint64_t hush_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume);
int32_t hush_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel);
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width);
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
int32_t hush_minerids(uint8_t *minerids,int32_t height,int32_t width);
int32_t hush_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
uint32_t hush_blocktime(uint256 hash);
int32_t hush_longestchain();
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int8_t hush_segid(int32_t nocache,int32_t height);
int32_t hush_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight);
char *komodo_pricename(char *name,int32_t ind);
int32_t komodo_priceind(const char *symbol);
int32_t komodo_pricesinit();
int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip);
int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth);
char *hush_pricename(char *name,int32_t ind);
int32_t hush_priceind(const char *symbol);
int32_t hush_pricesinit();
int64_t hush_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip);
int64_t hush_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth);
int32_t hush_nextheight();
uint32_t hush_heightstamp(int32_t height);
int64_t komodo_pricemult(int32_t ind);
int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
int64_t hush_pricemult(int32_t ind);
int32_t hush_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
int32_t hush_currentheight();
int32_t komodo_notarized_bracket(struct notarized_checkpoint *nps[2],int32_t height);
arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime);
int32_t hush_notarized_bracket(struct notarized_checkpoint *nps[2],int32_t height);
arith_uint256 hush_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime);
bool hush_hardfork_active(uint32_t time);
uint256 Parseuint256(const char *hexstr);
void komodo_sendmessage(int32_t minpeers, int32_t maxpeers, const char *message, std::vector<uint8_t> payload);
void hush_sendmessage(int32_t minpeers, int32_t maxpeers, const char *message, std::vector<uint8_t> payload);
CBlockIndex *hush_getblockindex(uint256 hash);
int32_t hush_nextheight();
CBlockIndex *hush_blockindex(uint256 hash);
CBlockIndex *hush_chainactive(int32_t height);
int32_t hush_blockheight(uint256 hash);
bool komodo_txnotarizedconfirmed(uint256 txid);
bool hush_txnotarizedconfirmed(uint256 txid);
int32_t hush_blockload(CBlock& block, CBlockIndex *pindex);
uint32_t hush_chainactive_timestamp();
uint32_t GetLatestTimestamp(int32_t height);

44
src/hush_events.h

@ -25,7 +25,7 @@ struct hush_event *hush_eventadd(struct hush_state *sp,int32_t height,char *symb
struct hush_event *ep=0; uint16_t len = (uint16_t)(sizeof(*ep) + datalen);
if ( sp != 0 && SMART_CHAIN_SYMBOL[0] != 0 )
{
portable_mutex_lock(&komodo_mutex);
portable_mutex_lock(&hush_mutex);
ep = (struct hush_event *)calloc(1,len);
ep->len = len;
ep->height = height;
@ -35,7 +35,7 @@ struct hush_event *hush_eventadd(struct hush_state *sp,int32_t height,char *symb
memcpy(ep->space,data,datalen);
sp->Hush_events = (struct hush_event **)realloc(sp->Hush_events,(1 + sp->Hush_numeventss) * sizeof(*sp->Hush_events));
sp->Hush_events[sp->Hush_numeventss++] = ep;
portable_mutex_unlock(&komodo_mutex);
portable_mutex_unlock(&hush_mutex);
}
return(ep);
}
@ -43,8 +43,8 @@ struct hush_event *hush_eventadd(struct hush_state *sp,int32_t height,char *symb
void hush_eventadd_notarized(struct hush_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight,uint256 MoM,int32_t MoMdepth)
{
static uint32_t counter; int32_t verified=0; char *coin; struct hush_event_notarized N;
coin = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL;
if ( IS_HUSH_NOTARY != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 )
coin = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"HUSH3" : SMART_CHAIN_SYMBOL;
if ( IS_HUSH_NOTARY != 0 && (verified= hush_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 )
{
if ( counter++ < 100 )
printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",SMART_CHAIN_SYMBOL,height,notarizedheight,dest);
@ -62,20 +62,20 @@ void hush_eventadd_notarized(struct hush_state *sp,char *symbol,int32_t height,c
strncpy(N.dest,dest,sizeof(N.dest)-1);
hush_eventadd(sp,height,symbol,HUSH_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N));
if ( sp != 0 )
komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid,MoM,MoMdepth);
hush_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid,MoM,MoMdepth);
}
}
void hush_eventadd_pubkeys(struct hush_state *sp,char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33])
{
struct hush_event_pubkeys P;
//printf("eventadd pubkeys ht.%d\n",height);
fprintf(stderr, "%s: eventadd pubkeys height=%d\n",__func__,height);
memset(&P,0,sizeof(P));
P.num = num;
memcpy(P.pubkeys,pubkeys,33 * num);
hush_eventadd(sp,height,symbol,HUSH_EVENT_RATIFY,(uint8_t *)&P,(int32_t)(sizeof(P.num) + 33 * num));
if ( sp != 0 )
komodo_notarysinit(height,pubkeys,num);
hush_notarysinit(height,pubkeys,num);
}
void hush_eventadd_pricefeed(struct hush_state *sp,char *symbol,int32_t height,uint32_t *prices,uint8_t num)
@ -88,7 +88,7 @@ void hush_eventadd_pricefeed(struct hush_state *sp,char *symbol,int32_t height,u
memcpy(F.prices,prices,sizeof(*F.prices) * num);
hush_eventadd(sp,height,symbol,HUSH_EVENT_PRICEFEED,(uint8_t *)&F,(int32_t)(sizeof(F.num) + sizeof(*F.prices) * num));
if ( sp != 0 )
komodo_pvals(height,prices,num);
hush_pvals(height,prices,num);
} //else fprintf(stderr,"skip pricefeed[%d]\n",num);
}
@ -107,7 +107,7 @@ void hush_eventadd_opreturn(struct hush_state *sp,char *symbol,int32_t height,ui
hush_eventadd(sp,height,symbol,HUSH_EVENT_OPRETURN,opret,O.oplen);
free(opret);
if ( sp != 0 )
komodo_opreturn(height,value,buf,opretlen,txid,vout,symbol);
hush_opreturn(height,value,buf,opretlen,txid,vout,symbol);
}
}
@ -117,7 +117,7 @@ void hush_event_undo(struct hush_state *sp,struct hush_event *ep)
{
case HUSH_EVENT_RATIFY: printf("rewind of ratify, needs to be coded.%d\n",ep->height); break;
case HUSH_EVENT_NOTARIZED: break;
case HUSH_EVENT_KMDHEIGHT:
case HUSH_EVENT_HUSHHEIGHT:
if ( ep->height <= sp->SAVEDHEIGHT )
sp->SAVEDHEIGHT = ep->height;
break;
@ -155,32 +155,32 @@ void hush_event_rewind(struct hush_state *sp,char *symbol,int32_t height)
}
}
void komodo_setkmdheight(struct hush_state *sp,int32_t kmdheight,uint32_t timestamp)
void hush_sethushheight(struct hush_state *sp,int32_t hushheight,uint32_t timestamp)
{
if ( sp != 0 )
{
if ( kmdheight > sp->SAVEDHEIGHT )
if ( hushheight > sp->SAVEDHEIGHT )
{
sp->SAVEDHEIGHT = kmdheight;
sp->SAVEDHEIGHT = hushheight;
sp->SAVEDTIMESTAMP = timestamp;
}
if ( kmdheight > sp->CURRENT_HEIGHT )
sp->CURRENT_HEIGHT = kmdheight;
if ( hushheight > sp->CURRENT_HEIGHT )
sp->CURRENT_HEIGHT = hushheight;
}
}
void hush_eventadd_kmdheight(struct hush_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp)
void hush_eventadd_hushheight(struct hush_state *sp,char *symbol,int32_t height,int32_t hushheight,uint32_t timestamp)
{
uint32_t buf[2];
if ( kmdheight > 0 ) {
buf[0] = (uint32_t)kmdheight;
if ( hushheight > 0 ) {
buf[0] = (uint32_t)hushheight;
buf[1] = timestamp;
hush_eventadd(sp,height,symbol,HUSH_EVENT_KMDHEIGHT,(uint8_t *)buf,sizeof(buf));
hush_eventadd(sp,height,symbol,HUSH_EVENT_HUSHHEIGHT,(uint8_t *)buf,sizeof(buf));
if ( sp != 0 )
komodo_setkmdheight(sp,kmdheight,timestamp);
hush_sethushheight(sp,hushheight,timestamp);
} else {
//fprintf(stderr,"REWIND kmdheight.%d\n",kmdheight);
kmdheight = -kmdheight;
//fprintf(stderr,"REWIND hushheight.%d\n",hushheight);
hushheight = -hushheight;
hush_eventadd(sp,height,symbol,HUSH_EVENT_REWIND,(uint8_t *)&height,sizeof(height));
if ( sp != 0 )
hush_event_rewind(sp,symbol,height);

480
src/hush_gateway.h

File diff suppressed because it is too large

30
src/hush_globals.h

@ -20,21 +20,21 @@
void hush_prefetch(FILE *fp);
uint32_t hush_heightstamp(int32_t height);
void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth);
void komodo_init(int32_t height);
int32_t hush_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip);
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port);
void komodo_init(int32_t height);
void hush_init(int32_t height);
int32_t hush_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *hushtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *hushstartip,int32_t *hushendip);
int32_t hush_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port);
void hush_init(int32_t height);
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
int32_t komodo_isrealtime(int32_t *kmdheightp);
uint64_t komodo_paxtotal();
int32_t hush_isrealtime(int32_t *hushheightp);
uint64_t hush_paxtotal();
int32_t hush_longestchain();
uint64_t komodo_maxallowed(int32_t baseid);
int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
uint64_t hush_maxallowed(int32_t baseid);
int32_t hush_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts);
pthread_mutex_t komodo_mutex,staked_mutex;
pthread_mutex_t hush_mutex;
#define KOMODO_ELECTION_GAP 2000 //((SMART_CHAIN_SYMBOL[0] == 0) ? 2000 : 100)
#define HUSH_DPOW_GAP 2000 //((SMART_CHAIN_SYMBOL[0] == 0) ? 2000 : 100)
#define HUSH_SMART_CHAIN_MAXLEN 65
struct pax_transaction *PAX;
@ -103,15 +103,15 @@ int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL;
CScript HUSH_EARLYTXID_SCRIPTPUB;
int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
std::map <std::int8_t, int32_t> mapHeightEvalActivate;
struct komodo_kv *HUSH_KV;
struct hush_kv *HUSH_KV;
pthread_mutex_t HUSH_KV_mutex,HUSH_CC_mutex;
#define MAX_CURRENCIES 32
char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"KMD" };
"HUSH" };
int32_t komodo_baseid(char *origbase)
int32_t hush_baseid(char *origbase)
{
int32_t i; char base[64];
for (i=0; origbase[i]!=0&&i<sizeof(base); i++)
@ -132,7 +132,7 @@ uint64_t hush_current_supply(uint32_t nHeight)
uint64_t cur_money;
int32_t baseid;
//if ( (baseid = komodo_baseid(SMART_CHAIN_SYMBOL)) >= 0 && baseid < 32 )
//if ( (baseid = hush_baseid(SMART_CHAIN_SYMBOL)) >= 0 && baseid < 32 )
// cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN;
//else
{

36
src/hush_kv.h

@ -21,7 +21,7 @@
#include "hush_defs.h"
int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize)
int32_t hush_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize)
{
if ( refvalue == 0 && value == 0 )
return(0);
@ -32,7 +32,7 @@ int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint
else return(memcmp(refvalue,value,valuesize));
}
int32_t komodo_kvnumdays(uint32_t flags)
int32_t hush_kvnumdays(uint32_t flags)
{
int32_t numdays;
if ( (numdays= ((flags>>2)&0x3ff)+1) > 365 )
@ -40,25 +40,25 @@ int32_t komodo_kvnumdays(uint32_t flags)
return(numdays);
}
int32_t komodo_kvduration(uint32_t flags)
int32_t hush_kvduration(uint32_t flags)
{
return(komodo_kvnumdays(flags) * HUSH_KVDURATION);
return(hush_kvnumdays(flags) * HUSH_KVDURATION);
}
uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen)
uint64_t hush_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen)
{
int32_t numdays,k; uint64_t fee;
if ( (k= keylen) > 32 )
k = 32;
numdays = komodo_kvnumdays(flags);
numdays = hush_kvnumdays(flags);
if ( (fee= (numdays*(opretlen * opretlen / k))) < 100000 )
fee = 100000;
return(fee);
}
int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen)
int32_t hush_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen)
{
struct komodo_kv *ptr; int32_t duration,retval = -1;
struct hush_kv *ptr; int32_t duration,retval = -1;
*heightp = -1;
*flagsp = 0;
memset(pubkeyp,0,sizeof(*pubkeyp));
@ -66,7 +66,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp
HASH_FIND(hh,HUSH_KV,key,keylen,ptr);
if ( ptr != 0 )
{
duration = komodo_kvduration(ptr->flags);
duration = hush_kvduration(ptr->flags);
//fprintf(stderr,"duration.%d flags.%d current.%d ht.%d keylen.%d valuesize.%d\n",duration,ptr->flags,current_height,ptr->height,ptr->keylen,ptr->valuesize);
if ( current_height > (ptr->height + duration) )
{
@ -100,11 +100,11 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp
return(retval);
}
void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
void hush_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
{
static uint256 zeroes;
uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[DRAGON_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee;
if ( SMART_CHAIN_SYMBOL[0] == 0 ) // disable KV for KMD
uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[DRAGON_MAXSCRIPTSIZE*8]; struct hush_kv *ptr; char *transferpubstr,*tstr; uint64_t fee;
if ( SMART_CHAIN_SYMBOL[0] == 0 ) // disable KV
return;
dragon_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen);
dragon_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize);
@ -115,11 +115,11 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
{
static uint32_t counter;
if ( ++counter < 1 )
fprintf(stderr,"komodo_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen);
fprintf(stderr,"hush_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen);
return;
}
valueptr = &key[keylen];
fee = komodo_kvfee(flags,opretlen,keylen);
fee = hush_kvfee(flags,opretlen,keylen);
//fprintf(stderr,"fee %.8f vs %.8f flags.%d keylen.%d valuesize.%d height.%d (%02x %02x %02x) (%02x %02x %02x)\n",(double)fee/COIN,(double)value/COIN,flags,keylen,valuesize,height,key[0],key[1],key[2],valueptr[0],valueptr[1],valueptr[2]);
if ( value >= fee )
{
@ -139,13 +139,13 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
((uint8_t *)&sig)[i] = opretbuf[coresize+sizeof(uint256)+i];
}
memcpy(keyvalue,key,keylen);
if ( (refvaluesize= komodo_kvsearch((uint256 *)&refpubkey,height,&flags,&kvheight,&keyvalue[keylen],key,keylen)) >= 0 )
if ( (refvaluesize= hush_kvsearch((uint256 *)&refpubkey,height,&flags,&kvheight,&keyvalue[keylen],key,keylen)) >= 0 )
{
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
{
if ( komodo_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 )
if ( hush_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 )
{
//fprintf(stderr,"komodo_kvsigverify error [%d]\n",coresize-13);
//fprintf(stderr,"hush_kvsigverify error [%d]\n",coresize-13);
return;
}
}
@ -169,7 +169,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
}
else if ( ptr == 0 )
{
ptr = (struct komodo_kv *)calloc(1,sizeof(*ptr));
ptr = (struct hush_kv *)calloc(1,sizeof(*ptr));
ptr->key = (uint8_t *)calloc(1,keylen);
ptr->keylen = keylen;
memcpy(ptr->key,key,keylen);

2
src/hush_nSPV.h

@ -578,7 +578,7 @@ int32_t NSPV_notarizationextract(int32_t verifyntz,int32_t *ntzheightp,uint256 *
int32_t numsigs=0; uint8_t elected[64][33]; char *symbol; std::vector<uint8_t> opret; uint32_t nTime;
if ( tx.vout.size() >= 2 )
{
symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL;
symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"HUSH3" : SMART_CHAIN_SYMBOL;
GetOpReturnData(tx.vout[1].scriptPubKey,opret);
if ( opret.size() >= 32*2+4 )
{

4
src/hush_nSPV_fullnode.h

@ -38,7 +38,7 @@ struct NSPV_ntzargs
int32_t NSPV_notarization_find(struct NSPV_ntzargs *args,int32_t height,int32_t dir)
{
int32_t ntzheight = 0; uint256 hashBlock; CTransaction tx; Notarization nota; char *symbol; std::vector<uint8_t> opret;
symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL;
symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"HUSH3" : SMART_CHAIN_SYMBOL;
memset(args,0,sizeof(*args));
if ( dir > 0 )
height += 10;
@ -863,7 +863,7 @@ int32_t NSPV_getspentinfo(struct NSPV_spentinfo *ptr,uint256 txid,int32_t vout)
return(len);
}
void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a request
void hush_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a request
{
int32_t len,slen,ind,reqheight,n; std::vector<uint8_t> response; uint32_t timestamp = (uint32_t)time(NULL);
if ( (len= request.size()) > 0 )

8
src/hush_nSPV_superlite.h

@ -128,9 +128,9 @@ struct NSPV_ntzsproofresp *NSPV_ntzsproof_add(struct NSPV_ntzsproofresp *ptr)
return(&NSPV_ntzsproofresp_cache[i]);
}
// komodo_nSPVresp is called from async message processing
// hush_nSPVresp is called from async message processing
void komodo_nSPVresp(CNode *pfrom,std::vector<uint8_t> response) // received a response
void hush_nSPVresp(CNode *pfrom,std::vector<uint8_t> response) // received a response
{
struct NSPV_inforesp I; int32_t len; uint32_t timestamp = (uint32_t)time(NULL);
strncpy(NSPV_lastpeer,pfrom->addr.ToString().c_str(),sizeof(NSPV_lastpeer)-1);
@ -274,9 +274,9 @@ UniValue NSPV_logout()
return(result);
}
// komodo_nSPV from main polling loop (really this belongs in its own file, but it is so small, it ended up here)
// hush_nSPV from main polling loop (really this belongs in its own file, but it is so small, it ended up here)
void komodo_nSPV(CNode *pto) // polling loop from SendMessages
void hush_nSPV(CNode *pto) // polling loop from SendMessages
{
uint8_t msg[256]; int32_t i,len=0; uint32_t timestamp = (uint32_t)time(NULL);
if ( NSPV_logintime != 0 && timestamp > NSPV_logintime+NSPV_AUTOLOGOUT )

136
src/hush_notary.h

@ -62,6 +62,19 @@ const char *Notaries_genesis[][2] =
int32_t gethushseason(int32_t height)
{
bool istush = strncmp(SMART_CHAIN_SYMBOL, "TUSH",4) == 0 ? true : false;
if ( istush ) {
// TUSH is always Season 7 DPoW notaries from genblock
return 7;
}
// It is season 7 until a new consensus code change, instead
// of the old way, which requires a new code release before
// the last season block height or nodes stop working correctly
if ( height > nHushHardforkHeight3 ) {
return 7;
}
if ( height <= HUSH_SEASON_HEIGHTS[0] )
return(1);
for (int32_t i = 1; i < NUM_HUSH_SEASONS; i++)
@ -87,8 +100,9 @@ int32_t getacseason(uint32_t timestamp)
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
{
int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
static uint8_t kmd_pubkeys[NUM_HUSH_SEASONS][64][33],didinit[NUM_HUSH_SEASONS];
static uint8_t hush_pubkeys[NUM_HUSH_SEASONS][64][33],didinit[NUM_HUSH_SEASONS];
//HUSH3+TUSH use block heights, HSCs use timestamps
if ( timestamp == 0 && SMART_CHAIN_SYMBOL[0] != 0 ) {
timestamp = hush_heightstamp(height);
} else if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
@ -98,29 +112,36 @@ int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
// Find the correct DPoW Notary pubkeys for this season
int32_t hush_season = 0;
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
hush_season = ishush3 ? gethushseason(height) : getacseason(timestamp);
bool istush = strncmp(SMART_CHAIN_SYMBOL, "TUSH",4) == 0 ? true : false;
// TUSH uses height activation like HUSH3, other HSCs use timestamps
hush_season = (ishush3 || istush) ? gethushseason(height) : getacseason(timestamp);
if(IS_HUSH_NOTARY) {
fprintf(stderr,"%s: [%s] season=%d height=%d time=%d\n", __func__, ishush3 ? "HUSH3" : SMART_CHAIN_SYMBOL, hush_season, height, timestamp);
}
if ( hush_season != 0 )
{
if ( didinit[hush_season-1] == 0 )
{
for (i=0; i<NUM_HUSH_NOTARIES; i++)
decode_hex(kmd_pubkeys[hush_season-1][i],33,(char *)notaries_elected[hush_season-1][i][1]);
decode_hex(hush_pubkeys[hush_season-1][i],33,(char *)notaries_elected[hush_season-1][i][1]);
if ( ASSETCHAINS_PRIVATE != 0 )
{
// we need to populate the address array for the notary exemptions.
for (i = 0; i<NUM_HUSH_NOTARIES; i++)
pubkey2addr((char *)NOTARY_ADDRESSES[hush_season-1][i],(uint8_t *)kmd_pubkeys[hush_season-1][i]);
pubkey2addr((char *)NOTARY_ADDRESSES[hush_season-1][i],(uint8_t *)hush_pubkeys[hush_season-1][i]);
}
didinit[hush_season-1] = 1;
}
memcpy(pubkeys,kmd_pubkeys[hush_season-1],NUM_HUSH_NOTARIES * 33);
memcpy(pubkeys,hush_pubkeys[hush_season-1],NUM_HUSH_NOTARIES * 33);
return(NUM_HUSH_NOTARIES);
}
return(-1);
}
int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp)
int32_t hush_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp)
{
int32_t i,n; uint8_t pubkeys[64][33];
n = hush_notaries(pubkeys,height,timestamp);
@ -133,39 +154,24 @@ int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t hei
return(-1);
}
int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask)
{
int32_t htind,numnotaries,i,wt = 0;
htind = height / KOMODO_ELECTION_GAP;
if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP )
htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
numnotaries = Pubkeys[htind].numnotaries;
for (i=0; i<numnotaries; i++)
if ( ((1LL << i) & signedmask) != 0 )
wt++;
if ( wt > (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) )
return(1);
else return(0);
}
void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
void hush_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
{
static int32_t hwmheight;
int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N;
if ( Pubkeys == 0 )
Pubkeys = (struct knotaries_entry *)calloc(1 + (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys));
Pubkeys = (struct knotaries_entry *)calloc(1 + (HUSH_MAXBLOCKS / HUSH_DPOW_GAP),sizeof(*Pubkeys));
memset(&N,0,sizeof(N));
if ( origheight > 0 )
{
height = (origheight + KOMODO_ELECTION_GAP/2);
height /= KOMODO_ELECTION_GAP;
height = ((height + 1) * KOMODO_ELECTION_GAP);
htind = (height / KOMODO_ELECTION_GAP);
if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP )
htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
//printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,SMART_CHAIN_SYMBOL);
height = (origheight + HUSH_DPOW_GAP/2);
height /= HUSH_DPOW_GAP;
height = ((height + 1) * HUSH_DPOW_GAP);
htind = (height / HUSH_DPOW_GAP);
if ( htind >= HUSH_MAXBLOCKS / HUSH_DPOW_GAP )
htind = (HUSH_MAXBLOCKS / HUSH_DPOW_GAP) - 1;
//printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+HUSH_DPOW_GAP/2)/HUSH_DPOW_GAP)+1)*HUSH_DPOW_GAP,hwmheight,SMART_CHAIN_SYMBOL);
} else htind = 0;
pthread_mutex_lock(&komodo_mutex);
pthread_mutex_lock(&hush_mutex);
for (k=0; k<num; k++)
{
kp = (struct knotary_entry *)calloc(1,sizeof(*kp));
@ -176,11 +182,11 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
{
for (i=0; i<33; i++)
printf("%02x",pubkeys[k][i]);
printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP);
printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*HUSH_DPOW_GAP);
}
}
N.numnotaries = num;
for (i=htind; i<HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP; i++)
for (i=htind; i<HUSH_MAXBLOCKS / HUSH_DPOW_GAP; i++)
{
if ( Pubkeys[i].height != 0 && origheight < hwmheight )
{
@ -188,9 +194,9 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
break;
}
Pubkeys[i] = N;
Pubkeys[i].height = i * KOMODO_ELECTION_GAP;
Pubkeys[i].height = i * HUSH_DPOW_GAP;
}
pthread_mutex_unlock(&komodo_mutex);
pthread_mutex_unlock(&hush_mutex);
if ( origheight > hwmheight )
hwmheight = origheight;
}
@ -207,7 +213,7 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui
}
if ( height >= HUSH_NOTARIES_HARDCODED || SMART_CHAIN_SYMBOL[0] != 0 )
{
if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 )
if ( (*notaryidp= hush_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 )
{
modval = ((height % numnotaries) == *notaryidp);
return(modval);
@ -216,13 +222,13 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui
if ( height >= 250000 )
return(-1);
if ( Pubkeys == 0 )
komodo_init(0);
htind = height / KOMODO_ELECTION_GAP;
if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP )
htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
pthread_mutex_lock(&komodo_mutex);
hush_init(0);
htind = height / HUSH_DPOW_GAP;
if ( htind >= HUSH_MAXBLOCKS / HUSH_DPOW_GAP )
htind = (HUSH_MAXBLOCKS / HUSH_DPOW_GAP) - 1;
pthread_mutex_lock(&hush_mutex);
HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp);
pthread_mutex_unlock(&komodo_mutex);
pthread_mutex_unlock(&hush_mutex);
if ( kp != 0 )
{
if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 )
@ -240,7 +246,7 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui
//struct hush_state *hush_stateptr(char *symbol,char *dest);
struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx)
struct notarized_checkpoint *hush_npptr_for_height(int32_t height, int *idx)
{
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t i; struct hush_state *sp; struct notarized_checkpoint *np = 0;
if ( (sp= hush_stateptr(symbol,dest)) != 0 )
@ -257,13 +263,13 @@ struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx)
return(0);
}
struct notarized_checkpoint *komodo_npptr(int32_t height)
struct notarized_checkpoint *hush_npptr(int32_t height)
{
int idx;
return komodo_npptr_for_height(height, &idx);
return hush_npptr_for_height(height, &idx);
}
struct notarized_checkpoint *komodo_npptr_at(int idx)
struct notarized_checkpoint *hush_npptr_at(int idx)
{
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp;
if ( (sp= hush_stateptr(symbol,dest)) != 0 )
@ -272,7 +278,7 @@ struct notarized_checkpoint *komodo_npptr_at(int idx)
return(0);
}
int32_t komodo_prevMoMheight()
int32_t hush_prevMoMheight()
{
static uint256 zero;
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t i; struct hush_state *sp; struct notarized_checkpoint *np = 0;
@ -308,7 +314,7 @@ int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *tx
{
*hashp = sp->NOTARIZED_HASH;
*txidp = sp->NOTARIZED_DESTTXID;
*prevMoMheightp = komodo_prevMoMheight();
*prevMoMheightp = hush_prevMoMheight();
}
return(sp->NOTARIZED_HEIGHT);
} else return(0);
@ -333,29 +339,29 @@ int32_t hush_dpowconfs(int32_t txheight,int32_t numconfs)
return(numconfs);
}
int32_t hush_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
int32_t hush_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *hushtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *hushstartip,int32_t *hushendip)
{
struct notarized_checkpoint *np = 0;
if ( (np= komodo_npptr(height)) != 0 )
if ( (np= hush_npptr(height)) != 0 )
{
*notarized_htp = np->notarized_height;
*MoMp = np->MoM;
*kmdtxidp = np->notarized_desttxid;
*hushtxidp = np->notarized_desttxid;
*MoMoMp = np->MoMoM;
*MoMoMoffsetp = np->MoMoMoffset;
*MoMoMdepthp = np->MoMoMdepth;
*kmdstartip = np->kmdstarti;
*kmdendip = np->kmdendi;
*hushstartip = np->hushstarti;
*hushendip = np->hushendi;
return(np->MoMdepth & 0xffff);
}
*notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0;
*notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *hushstartip = *hushendip = 0;
memset(MoMp,0,sizeof(*MoMp));
memset(MoMoMp,0,sizeof(*MoMoMp));
memset(kmdtxidp,0,sizeof(*kmdtxidp));
memset(hushtxidp,0,sizeof(*hushtxidp));
return(0);
}
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp)
int32_t hush_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp)
{
struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp;
if ( (sp= hush_stateptr(symbol,dest)) != 0 )
@ -411,17 +417,17 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n
return(0);
}
void komodo_notarized_update(struct hush_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth)
void hush_notarized_update(struct hush_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth)
{
struct notarized_checkpoint *np;
if ( notarized_height >= nHeight )
{
fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight);
fprintf(stderr,"hush_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight);
return;
}
if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 )
fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",SMART_CHAIN_SYMBOL,nHeight,notarized_height);
portable_mutex_lock(&komodo_mutex);
fprintf(stderr,"[%s] hush_notarized_update nHeight.%d notarized_height.%d\n",SMART_CHAIN_SYMBOL,nHeight,notarized_height);
portable_mutex_lock(&hush_mutex);
sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS));
np = &sp->NPOINTS[sp->NUM_NPOINTS++];
memset(np,0,sizeof(*np));
@ -431,18 +437,18 @@ void komodo_notarized_update(struct hush_state *sp,int32_t nHeight,int32_t notar
sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
sp->MoM = np->MoM = MoM;
sp->MoMdepth = np->MoMdepth = MoMdepth;
portable_mutex_unlock(&komodo_mutex);
portable_mutex_unlock(&hush_mutex);
}
void komodo_init(int32_t height)
void hush_init(int32_t height)
{
static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33];
if ( 0 && height != 0 )
printf("komodo_init ht.%d didinit.%d\n",height,didinit);
printf("hush_init ht.%d didinit.%d\n",height,didinit);
memset(&zero,0,sizeof(zero));
if ( didinit == 0 )
{
pthread_mutex_init(&komodo_mutex,NULL);
pthread_mutex_init(&hush_mutex,NULL);
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
if ( height >= 0 )
{
@ -453,7 +459,7 @@ void komodo_init(int32_t height)
break;
decode_hex(pubkeys[k],33,(char *)Notaries_genesis[k][1]);
}
komodo_notarysinit(0,pubkeys,k);
hush_notarysinit(0,pubkeys,k);
}
//for (i=0; i<sizeof(Minerids); i++)
// Minerids[i] = -2;

455
src/hush_pax.h

@ -133,7 +133,7 @@ uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numpri
1, 1, 1, 1, 1, 1, 0, 0, // isum 100000000000
};
uint64_t komodo_maxallowed(int32_t baseid)
uint64_t hush_maxallowed(int32_t baseid)
{
uint64_t mult,val = COIN * (uint64_t)10000;
if ( baseid < 0 || baseid >= 32 )
@ -144,7 +144,7 @@ uint64_t komodo_maxallowed(int32_t baseid)
return(mult * val);
}
uint64_t komodo_paxvol(uint64_t volume,uint64_t price)
uint64_t hush_paxvol(uint64_t volume,uint64_t price)
{
if ( volume < 10000000000 )
return((volume * price) / 1000000000);
@ -170,7 +170,7 @@ void pax_rank(uint64_t *ranked,uint32_t *pvals)
int32_t i; uint64_t vals[32],sum = 0;
for (i=0; i<32; i++)
{
vals[i] = komodo_paxvol(M1SUPPLY[i] / MINDENOMS[i],pvals[i]);
vals[i] = hush_paxvol(M1SUPPLY[i] / MINDENOMS[i],pvals[i]);
sum += vals[i];
}
for (i=0; i<32; i++)
@ -195,108 +195,6 @@ double PAX_BTCUSD(int32_t height,uint32_t btcusd)
return(BTCUSD);
}
int32_t dpow_readprices(int32_t height,uint8_t *data,uint32_t *timestampp,double *KMDBTCp,double *BTCUSDp,double *CNYUSDp,uint32_t *pvals)
{
uint32_t kmdbtc,btcusd,cnyusd; int32_t i,n,nonz,len = 0;
if ( data[0] == 'P' && data[5] == 35 )
data++;
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)timestampp);
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&n);
if ( n != 35 )
{
printf("dpow_readprices illegal n.%d\n",n);
return(-1);
}
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&kmdbtc); // /= 1000
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&btcusd); // *= 1000
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&cnyusd);
*KMDBTCp = ((double)kmdbtc / (1000000000. * 1000.));
*BTCUSDp = PAX_BTCUSD(height,btcusd);
*CNYUSDp = ((double)cnyusd / 1000000000.);
for (i=nonz=0; i<n-3; i++)
{
if ( pvals[i] != 0 )
nonz++;
//else if ( nonz != 0 )
// printf("pvals[%d] is zero\n",i);
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&pvals[i]);
//printf("%u ",pvals[i]);
}
/*if ( nonz < n-3 )
{
//printf("nonz.%d n.%d retval -1\n",nonz,n);
return(-1);
}*/
pvals[i++] = kmdbtc;
pvals[i++] = btcusd;
pvals[i++] = cnyusd;
//printf("OP_RETURN prices\n");
return(n);
}
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize)
{
static uint32_t lastcrc;
FILE *fp; char fname[512]; uint32_t crc32,check,timestamp; int32_t i,n=0,retval,fsize,len=0; uint8_t data[8192];
#ifdef _WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
fseek(fp,0,SEEK_END);
fsize = (int32_t)ftell(fp);
rewind(fp);
if ( fsize <= maxsize-4 && fsize <= sizeof(data) && fsize > sizeof(crc32) )
{
if ( (retval= (int32_t)fread(data,1,fsize,fp)) == fsize )
{
len = dragon_rwnum(0,data,sizeof(crc32),(void *)&crc32);
check = calc_crc32(0,data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
if ( check == crc32 )
{
double KMDBTC,BTCUSD,CNYUSD; uint32_t pvals[128];
if ( dpow_readprices(height,&data[len],&timestamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals) > 0 )
{
if ( 0 && lastcrc != crc32 )
{
for (i=0; i<32; i++)
printf("%u ",pvals[i]);
printf("t%u n.%d KMD %f BTC %f CNY %f (%f)\n",timestamp,n,KMDBTC,BTCUSD,CNYUSD,CNYUSD!=0?1./CNYUSD:0);
}
if ( timestamp > time(NULL)-600 )
{
n = komodo_opreturnscript(opret,'P',data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
if ( 0 && lastcrc != crc32 )
{
for (i=0; i<n; i++)
printf("%02x",opret[i]);
printf(" coinbase opret[%d] crc32.%u:%u\n",n,crc32,check);
}
} //else printf("t%u too old for %u\n",timestamp,(uint32_t)time(NULL));
lastcrc = crc32;
}
} else printf("crc32 %u mismatch %u\n",crc32,check);
} else printf("fread.%d error != fsize.%d\n",retval,fsize);
} else printf("fsize.%d > maxsize.%d or data[%d]\n",fsize,maxsize,(int32_t)sizeof(data));
fclose(fp);
} //else printf("couldnt open %s\n",fname);
return(n);
}
/*uint32_t PAX_val32(double val)
{
uint32_t val32 = 0; struct price_resolution price;
if ( (price.Pval= val*1000000000) != 0 )
{
if ( price.Pval > 0xffffffff )
printf("Pval overflow error %lld\n",(long long)price.Pval);
else val32 = (uint32_t)price.Pval;
}
return(val32);
}*/
int32_t PAX_pubkey(int32_t rwflag,uint8_t *pubkey33,uint8_t *addrtypep,uint8_t rmd160[20],char fiat[4],uint8_t *shortflagp,int64_t *fiatoshisp)
{
if ( rwflag != 0 )
@ -330,38 +228,11 @@ double PAX_val(uint32_t pval,int32_t baseid)
return(0.);
}
void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals)
void hush_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals)
{
int32_t i,nonz; uint32_t kmdbtc,btcusd,cnyusd; double KMDBTC,BTCUSD,CNYUSD;
if ( numpvals >= 35 )
{
for (nonz=i=0; i<32; i++)
{
if ( pvals[i] != 0 )
nonz++;
//printf("%u ",pvals[i]);
}
if ( nonz == 32 )
{
kmdbtc = pvals[i++];
btcusd = pvals[i++];
cnyusd = pvals[i++];
KMDBTC = ((double)kmdbtc / (1000000000. * 1000.));
BTCUSD = PAX_BTCUSD(height,btcusd);
CNYUSD = ((double)cnyusd / 1000000000.);
portable_mutex_lock(&komodo_mutex);
PVALS = (uint32_t *)realloc(PVALS,(NUM_PRICES+1) * sizeof(*PVALS) * 36);
PVALS[36 * NUM_PRICES] = height;
memcpy(&PVALS[36 * NUM_PRICES + 1],pvals,sizeof(*pvals) * 35);
NUM_PRICES++;
portable_mutex_unlock(&komodo_mutex);
if ( 0 )
printf("OP_RETURN.%d KMD %.8f BTC %.6f CNY %.6f NUM_PRICES.%d (%llu %llu %llu)\n",height,KMDBTC,BTCUSD,CNYUSD,NUM_PRICES,(long long)kmdbtc,(long long)btcusd,(long long)cnyusd);
}
}
}
uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed)
uint64_t hush_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed)
{
int32_t i,j,k,ind,zeroes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0;
for (sum=i=zeroes=nonz=0; i<numvotes; i++)
@ -423,326 +294,26 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed)
return(sum);
}
uint64_t komodo_paxcalc(int32_t height,uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume,uint64_t refkmdbtc,uint64_t refbtcusd)
{
uint32_t pvalb,pvalr; double BTCUSD; uint64_t price,kmdbtc,btcusd,usdvol,baseusd,usdkmd,baserel,ranked[32];
if ( basevolume > HUSH_PAXMAX )
{
printf("paxcalc overflow %.8f\n",dstr(basevolume));
return(0);
}
if ( (pvalb= pvals[baseid]) != 0 )
{
if ( relid == MAX_CURRENCIES )
{
if ( height < 236000 )
{
if ( kmdbtc == 0 )
kmdbtc = pvals[MAX_CURRENCIES];
if ( btcusd == 0 )
btcusd = pvals[MAX_CURRENCIES + 1];
}
else
{
if ( (kmdbtc= pvals[MAX_CURRENCIES]) == 0 )
kmdbtc = refkmdbtc;
if ( (btcusd= pvals[MAX_CURRENCIES + 1]) == 0 )
btcusd = refbtcusd;
}
if ( kmdbtc < 25000000 )
kmdbtc = 25000000;
if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 )
{
baseusd = (((uint64_t)pvalb * 1000000000) / pvals[USD]);
usdvol = komodo_paxvol(basevolume,baseusd);
usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd;
if ( height >= 236000-10 )
{
BTCUSD = PAX_BTCUSD(height,btcusd);
if ( height < BTCFACTOR_HEIGHT || (height < 500000 && BTCUSD > 20000) )
usdkmd = ((uint64_t)kmdbtc * btcusd) / 1000000000;
else usdkmd = ((uint64_t)kmdbtc * btcusd) / 10000000;
///if ( height >= BTCFACTOR_HEIGHT && BTCUSD >= 43 )
// usdkmd = ((uint64_t)kmdbtc * btcusd) / 10000000;
//else usdkmd = ((uint64_t)kmdbtc * btcusd) / 1000000000;
price = ((uint64_t)10000000000 * MINDENOMS[USD] / MINDENOMS[baseid]) / komodo_paxvol(usdvol,usdkmd);
//fprintf(stderr,"ht.%d %.3f kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",height,BTCUSD,(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)));
//fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)),(long long)price);
//fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)));
} else price = (MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100));
return(price);
} //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd);
}
else if ( baseid == relid )
{
if ( baseid != MAX_CURRENCIES )
{
pax_rank(ranked,pvals);
//printf("%s M1 percentage %.8f\n",CURRENCIES[baseid],dstr(10 * ranked[baseid]));
return(10 * ranked[baseid]); // scaled percentage of M1 total
} else return(basevolume);
}
else if ( (pvalr= pvals[relid]) != 0 )
{
baserel = ((uint64_t)pvalb * 1000000000) / pvalr;
//printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid]));
if ( MINDENOMS[baseid] > MINDENOMS[relid] )
basevolume /= (MINDENOMS[baseid] / MINDENOMS[relid]);
else if ( MINDENOMS[baseid] < MINDENOMS[relid] )
basevolume *= (MINDENOMS[relid] / MINDENOMS[baseid]);
return(komodo_paxvol(basevolume,baserel));
}
else printf("null pval for %s\n",CURRENCIES[relid]);
} else printf("null pval for %s\n",CURRENCIES[baseid]);
return(0);
}
uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,char *base,char *rel,uint64_t basevolume,uint64_t kmdbtc,uint64_t btcusd)
{
int32_t baseid=-1,relid=-1,i; uint32_t *ptr,*pvals;
if ( height > 10 )
height -= 10;
if ( (baseid= komodo_baseid(base)) >= 0 && (relid= komodo_baseid(rel)) >= 0 )
{
//portable_mutex_lock(&komodo_mutex);
for (i=NUM_PRICES-1; i>=0; i--)
{
ptr = &PVALS[36 * i];
if ( *ptr < height )
{
pvals = &ptr[1];
if ( kmdbtcp != 0 && btcusdp != 0 )
{
*kmdbtcp = pvals[MAX_CURRENCIES] / 539;
*btcusdp = pvals[MAX_CURRENCIES + 1] / 539;
}
//portable_mutex_unlock(&komodo_mutex);
if ( kmdbtc != 0 && btcusd != 0 )
return(komodo_paxcalc(height,pvals,baseid,relid,basevolume,kmdbtc,btcusd));
else return(0);
}
}
//portable_mutex_unlock(&komodo_mutex);
} //else printf("paxprice invalid base.%s %d, rel.%s %d\n",base,baseid,rel,relid);
return(0);
}
int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height)
{
static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight = 0; int32_t incr = 10000;
if ( height >= maxheight )
{
//printf("height.%d maxheight.%d incr.%d\n",height,maxheight,incr);
if ( height >= maxheight+incr )
incr = (height - (maxheight+incr) + 1000);
KMDBTCS = (uint64_t *)realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS)));
memset(&KMDBTCS[maxheight],0,(incr * sizeof(*KMDBTCS)));
BTCUSDS = (uint64_t *)realloc(BTCUSDS,((incr + maxheight) * sizeof(*BTCUSDS)));
memset(&BTCUSDS[maxheight],0,(incr * sizeof(*BTCUSDS)));
maxheight += incr;
}
if ( rwflag == 0 )
{
*kmdbtcp = KMDBTCS[height];
*btcusdp = BTCUSDS[height];
}
else
{
KMDBTCS[height] = *kmdbtcp;
BTCUSDS[height] = *btcusdp;
}
if ( *kmdbtcp != 0 && *btcusdp != 0 )
return(0);
else return(-1);
}
uint64_t _komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
uint64_t hush_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
{
int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd;
if ( basevolume > HUSH_PAXMAX )
{
printf("komodo_paxprice overflow %.8f\n",dstr(basevolume));
return(0);
}
if ( strcmp(base,"KMD") == 0 || strcmp(base,"kmd") == 0 )
{
printf("kmd cannot be base currency\n");
return(0);
}
numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds));
memset(votes,0,sizeof(votes));
//if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) crashes when via passthru GUI use
{
memset(btcusds,0,sizeof(btcusds));
memset(kmdbtcs,0,sizeof(kmdbtcs));
for (i=0; i<numvotes; i++)
{
_komodo_paxprice(&kmdbtcs[numvotes-1-i],&btcusds[numvotes-1-i],height-i,base,rel,100000,0,0);
//printf("(%llu %llu) ",(long long)kmdbtcs[numvotes-1-i],(long long)btcusds[numvotes-1-i]);
}
kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539;
btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539;
//komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height);
}
for (i=nonz=0; i<numvotes; i++)
{
if ( (votes[numvotes-1-i]= _komodo_paxprice(0,0,height-i,base,rel,100000,kmdbtc,btcusd)) == 0 )
zeroes++;
else
{
nonz++;
sum += votes[numvotes-1-i];
//if ( (i % 10) == 0 )
// fprintf(stderr,"[%llu] ",(long long)votes[numvotes-1-i]);
}
}
//fprintf(stderr,"kmdbtc %llu btcusd %llu ",(long long)kmdbtc,(long long)btcusd);
//fprintf(stderr,"komodo_paxprice nonz.%d of numvotes.%d seed.%llu %.8f\n",nonz,numvotes,(long long)seed,nonz!=0?dstr(1000. * (double)sum/nonz):0);
if ( nonz <= (numvotes >> 1) )
{
return(0);
}
return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume / 100000);
return 0;
}
uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
uint64_t hush_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume)
{
uint64_t baseusd,basekmd,usdkmd; int32_t baseid = komodo_baseid(base);
if ( height >= 236000 && strcmp(rel,"kmd") == 0 )
{
usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN);
if ( strcmp("usd",base) == 0 )
return(komodo_paxvol(basevolume,usdkmd) * 10);
baseusd = _komodo_paxpriceB(seed,height,base,(char *)"USD",SATOSHIDEN);
basekmd = (komodo_paxvol(basevolume,baseusd) * usdkmd) / 10000000;
//if ( strcmp("KMD",base) == 0 )
// printf("baseusd.%llu usdkmd.%llu %llu\n",(long long)baseusd,(long long)usdkmd,(long long)basekmd);
return(basekmd);
} else return(_komodo_paxpriceB(seed,height,base,rel,basevolume));
return 0;
}
/*uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
{
uint64_t baseusd,basekmd,usdkmd; int32_t baseid = komodo_baseid(base);
//if ( strcmp(rel,"KMD") != 0 || baseid < 0 || MINDENOMS[baseid] == MINDENOMS[USD] )
// return(_komodo_paxpriceB(seed,height,base,rel,basevolume));
//else
{
baseusd = _komodo_paxpriceB(seed,height,base,(char *)"USD",SATOSHIDEN);
usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN);
basekmd = (komodo_paxvol(basevolume,baseusd) * usdkmd) / 10000000;
if ( strcmp("KMD",base) == 0 )
printf("baseusd.%llu usdkmd.%llu %llu\n",(long long)baseusd,(long long)usdkmd,(long long)basekmd);
return(basekmd);
}
}*/
uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume)
int32_t hush_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel)
{
int32_t i,nonz=0; int64_t diff; uint64_t price,seed,sum = 0;
if ( SMART_CHAIN_SYMBOL[0] == 0 && chainActive.LastTip() != 0 && height > chainActive.LastTip()->GetHeight() )
{
if ( height < 100000000 )
{
static uint32_t counter;
if ( counter++ < 3 )
printf("komodo_paxprice height.%d vs tip.%d\n",height,chainActive.LastTip()->GetHeight());
}
return(0);
}
*seedp = komodo_seed(height);
portable_mutex_lock(&komodo_mutex);
for (i=0; i<17; i++)
{
if ( (price= komodo_paxpriceB(*seedp,height-i,base,rel,basevolume)) != 0 )
{
sum += price;
nonz++;
if ( 0 && i == 1 && nonz == 2 )
{
diff = (((int64_t)price - (sum >> 1)) * 10000);
if ( diff < 0 )
diff = -diff;
diff /= price;
printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff);
if ( diff < 33 )
break;
}
else if ( 0 && i == 3 && nonz == 4 )
{
diff = (((int64_t)price - (sum >> 2)) * 10000);
if ( diff < 0 )
diff = -diff;
diff /= price;
printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff);
if ( diff < 20 )
break;
}
}
if ( height < 165000 || height > 236000 )
break;
}
portable_mutex_unlock(&komodo_mutex);
if ( nonz != 0 )
sum /= nonz;
//printf("-> %lld %s/%s i.%d ht.%d\n",(long long)sum,base,rel,i,height);
return(sum);
return 0;
}
int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel)
void hush_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen)
{
int32_t baseid=-1,relid=-1,i,num = 0; uint32_t *ptr;
if ( (baseid= komodo_baseid(base)) >= 0 && (relid= komodo_baseid(rel)) >= 0 )
{
for (i=NUM_PRICES-1; i>=0; i--)
{
ptr = &PVALS[36 * i];
heights[num] = *ptr;
prices[num] = komodo_paxcalc(*ptr,&ptr[1],baseid,relid,COIN,0,0);
num++;
if ( num >= max )
return(num);
}
}
return(num);
}
void komodo_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen)
{
double KMDBTC,BTCUSD,CNYUSD; uint32_t numpvals,timestamp,pvals[128]; uint256 zero;
numpvals = dpow_readprices(height,pricefeed,&timestamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals);
memset(&zero,0,sizeof(zero));
hush_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0,0,zero,0);
if ( 0 )
{
int32_t i;
for (i=0; i<numpvals; i++)
printf("%u ",pvals[i]);
printf("komodo_paxpricefeed vout OP_RETURN.%d prices numpvals.%d opretlen.%d kmdbtc %.8f BTCUSD %.8f CNYUSD %.8f\n",height,numpvals,opretlen,KMDBTC,BTCUSD,CNYUSD);
}
}
uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t height,char *origbase,int64_t fiatoshis)
{
uint8_t shortflag = 0; char base[4]; int32_t i,baseid; uint8_t addrtype,rmd160[20]; int64_t komodoshis = 0;
*seedp = komodo_seed(height);
if ( (baseid= komodo_baseid(origbase)) < 0 || baseid == MAX_CURRENCIES )
{
if ( 0 && origbase[0] != 0 )
printf("[%s] PAX_fiatdest illegal base.(%s)\n",SMART_CHAIN_SYMBOL,origbase);
return(0);
}
for (i=0; i<3; i++)
base[i] = toupper(origbase[i]);
base[i] = 0;
if ( fiatoshis < 0 )
shortflag = 1, fiatoshis = -fiatoshis;
komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis);
//printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp);
if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 )
{
PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis);
bitcoin_address(destaddr,HUSH_PUBTYPE,pubkey33,33);
}
return(komodoshis);
return 0;
}

12
src/hush_structs.h

@ -33,7 +33,7 @@
#define HUSH_MAXBLOCKS 250000 // DONT CHANGE
#define HUSH_EVENT_RATIFY 'P'
#define HUSH_EVENT_NOTARIZED 'N'
#define HUSH_EVENT_KMDHEIGHT 'K'
#define HUSH_EVENT_HUSHHEIGHT 'K'
#define HUSH_EVENT_REWIND 'B'
#define HUSH_EVENT_PRICEFEED 'V'
#define HUSH_EVENT_OPRETURN 'R'
@ -56,7 +56,7 @@
union _bits320 { uint8_t bytes[40]; uint16_t ushorts[20]; uint32_t uints[10]; uint64_t ulongs[5]; uint64_t txid; };
typedef union _bits320 bits320;
struct komodo_kv { UT_hash_handle hh; bits256 pubkey; uint8_t *key,*value; int32_t height; uint32_t flags; uint16_t keylen,valuesize; };
struct hush_kv { UT_hash_handle hh; bits256 pubkey; uint8_t *key,*value; int32_t height; uint32_t flags; uint16_t keylen,valuesize; };
struct hush_event_notarized { uint256 blockhash,desttxid,MoM; int32_t notarizedheight,MoMdepth; char dest[16]; };
struct hush_event_pubkeys { uint8_t num; uint8_t pubkeys[64][33]; };
@ -77,7 +77,7 @@ struct pax_transaction
{
UT_hash_handle hh;
uint256 txid;
uint64_t komodoshis,fiatoshis,validated;
uint64_t puposhis,fiatoshis,validated;
int32_t marked,height,otherheight,approved,didstats,ready;
uint16_t vout;
char symbol[HUSH_SMART_CHAIN_MAXLEN],source[HUSH_SMART_CHAIN_MAXLEN],coinaddr[64]; uint8_t rmd160[20],type,buf[35];
@ -88,7 +88,7 @@ struct knotaries_entry { int32_t height,numnotaries; struct knotary_entry *Notar
struct notarized_checkpoint
{
uint256 notarized_hash,notarized_desttxid,MoM,MoMoM;
int32_t nHeight,notarized_height,MoMdepth,MoMoMdepth,MoMoMoffset,kmdstarti,kmdendi;
int32_t nHeight,notarized_height,MoMdepth,MoMoMdepth,MoMoMoffset,hushstarti,hushendi;
};
struct hush_ccdataMoM
@ -97,13 +97,13 @@ struct hush_ccdataMoM
int32_t MoMdepth,notarized_height,height,txi;
};
struct hush_ccdata_entry { uint256 MoM; int32_t notarized_height,kmdheight,txi; char symbol[65]; };
struct hush_ccdata_entry { uint256 MoM; int32_t notarized_height,hushheight,txi; char symbol[65]; };
struct hush_ccdatapair { int32_t notarized_height,MoMoMoffset; };
struct hush_ccdataMoMoM
{
uint256 MoMoM;
int32_t kmdstarti,kmdendi,MoMoMoffset,MoMoMdepth,numpairs,len;
int32_t hushstarti,hushendi,MoMoMoffset,MoMoMdepth,numpairs,len;
struct hush_ccdatapair *pairs;
};

199
src/hush_utils.h

@ -809,9 +809,9 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,
return(coinaddr);
}
int32_t komodo_is_issuer()
int32_t hush_is_issuer()
{
if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) >= 0 )
if ( SMART_CHAIN_SYMBOL[0] != 0 && hush_baseid(SMART_CHAIN_SYMBOL) >= 0 )
return(1);
else return(0);
}
@ -980,7 +980,7 @@ int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *
return(len);
}
int32_t komodo_scriptitemlen(int32_t *opretlenp,uint8_t *script)
int32_t hush_scriptitemlen(int32_t *opretlenp,uint8_t *script)
{
int32_t opretlen,len = 0;
if ( (opretlen= script[len++]) >= 0x4c )
@ -999,7 +999,7 @@ int32_t komodo_scriptitemlen(int32_t *opretlenp,uint8_t *script)
return(len);
}
int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen)
int32_t hush_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen)
{
int32_t offset = 0;
script[offset++] = 0x6a;
@ -1295,7 +1295,7 @@ void dragon_initQ(queue_t *Q,char *name)
free(item);
}
uint16_t _komodo_userpass(char *username,char *password,FILE *fp)
uint16_t _hush_userpass(char *username,char *password,FILE *fp)
{
char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0;
rpcuser = rpcpassword = 0;
@ -1343,16 +1343,14 @@ void hush_statefname(char *fname,char *symbol,char *str)
printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,SMART_CHAIN_SYMBOL,n,len,&fname[len - n]);
return;
}
}
else
{
} else {
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
#endif
}
if ( symbol != 0 && symbol[0] != 0 && strcmp("KMD",symbol) != 0 )
if ( symbol != 0 && symbol[0] != 0)
{
strcat(fname,symbol);
//printf("statefname.(%s) -> (%s)\n",symbol,fname);
@ -1366,10 +1364,10 @@ void hush_statefname(char *fname,char *symbol,char *str)
//printf("test.(%s) -> [%s] statename.(%s) %s\n",test,SMART_CHAIN_SYMBOL,symbol,fname);
}
void komodo_configfile(char *symbol,uint16_t rpcport)
void hush_configfile(char *symbol,uint16_t rpcport)
{
static char myusername[512],mypassword[8192];
FILE *fp; uint16_t kmdport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
FILE *fp; uint16_t hushport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
if ( symbol != 0 && rpcport != 0 )
{
r = (uint32_t)time(NULL);
@ -1398,13 +1396,13 @@ void komodo_configfile(char *symbol,uint16_t rpcport)
#ifndef FROM_CLI
if ( (fp= fopen(fname,"wb")) != 0 )
{
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=256\nrpcallowip=127.0.0.1\nrpcbind=127.0.0.1\n",crc,password,rpcport);
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=4096\nrpcallowip=127.0.0.1\nrpcbind=127.0.0.1\n",crc,password,rpcport);
fclose(fp);
printf("Created (%s)\n",fname);
} else printf("Couldnt create (%s)\n",fname);
#endif
} else {
_komodo_userpass(myusername,mypassword,fp);
_hush_userpass(myusername,mypassword,fp);
mapArgs["-rpcpassword"] = mypassword;
mapArgs["-rpcusername"] = myusername;
//fprintf(stderr,"myusername.(%s)\n",myusername);
@ -1415,43 +1413,39 @@ void komodo_configfile(char *symbol,uint16_t rpcport)
#ifdef _WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
strcat(fname,"komodo.conf");
strcat(fname,"HUSH3.conf");
#else
while ( fname[strlen(fname)-1] != '/' )
fname[strlen(fname)-1] = 0;
#ifdef __APPLE__
strcat(fname,"Komodo.conf");
strcat(fname,"HUSH3.conf");
#else
strcat(fname,"komodo.conf");
strcat(fname,"HUSH3.conf");
#endif
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
if ( (kmdport= _komodo_userpass(username,password,fp)) != 0 )
HUSH3_PORT = kmdport;
if ( (hushport= _hush_userpass(username,password,fp)) != 0 )
HUSH3_PORT = hushport;
sprintf(HUSHUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
} //else printf("couldnt open.(%s)\n",fname);
} else {
printf("could not open.(%s)\n",fname);
}
}
uint16_t komodo_userpass(char *userpass,char *symbol)
uint16_t hush_userpass(char *userpass,char *symbol)
{
FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[HUSH_SMART_CHAIN_MAXLEN];
userpass[0] = 0;
if ( strcmp("SPECIAL",symbol) == 0 )
{
#ifdef __APPLE__
sprintf(confname,"Something.conf");
#else
sprintf(confname,"Something.conf");
#endif
}
else sprintf(confname,"%s.conf",symbol);
sprintf(confname,"%s.conf",symbol);
hush_statefname(fname,symbol,confname);
if ( (fp= fopen(fname,"rb")) != 0 )
{
port = _komodo_userpass(username,password,fp);
port = _hush_userpass(username,password,fp);
sprintf(userpass,"%s:%s",username,password);
if ( strcmp(symbol,SMART_CHAIN_SYMBOL) == 0 )
strcpy(ASSETCHAINS_USERPASS,userpass);
@ -1477,7 +1471,14 @@ uint32_t hush_smartmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t
fprintf(stderr,"%02x",extraptr[i]);
fprintf(stderr," extralen=%d crc0=%x\n",extralen,crc0);
}
return(calc_crc32(crc0,buf,len));
//TODO: why is this needed?
bool ishush3 = strncmp(symbol, "HUSH3",5) == 0 ? true : false;
if(ishush3) {
return HUSH_MAGIC;
} else {
return(calc_crc32(crc0,buf,len));
}
}
uint16_t hush_smartport(uint32_t magic,int32_t extralen)
@ -1494,13 +1495,9 @@ uint16_t hush_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extrap
{
if(fDebug)
fprintf(stderr,"%s: extralen=%d\n",__func__,extralen);
if ( strcmp("SPECIAL",symbol) == 0 )
{
*magicp = 0xdeadbeef;
return(6969);
}
*magicp = hush_smartmagic(symbol,supply,extraptr,extralen);
if(fDebug)
//if(fDebug)
fprintf(stderr,"%s: extralen=%d, supply=%lu\n",__func__,extralen, supply);
return(hush_smartport(*magicp,extralen));
@ -1516,7 +1513,6 @@ int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp)
return(notaryid);
}
// TODO: clean up this smoking bath-salts shite from KMD
char *argv0suffix[] = {
(char *)"fuckjl777d", (char *)"fuckjl777-cli", (char *)"fuckjl777d.exe", (char *)"fuckjl777-cli.exe", (char *)"btchd", (char *)"btch-cli", (char *)"btchd.exe", (char *)"btch-cli.exe"
};
@ -1739,7 +1735,7 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k)
* EhBasicSolve
* EhOptimisedSolve
* EhIsValidSolution
* Alternatively change ASSETCHAINS_N and ASSETCHAINS_K in komodo_nk.h for fast testing.
* Alternatively change ASSETCHAINS_N and ASSETCHAINS_K in hush_nk.h for fast testing.
*/
if ( k == 9 && (n == 200 || n == 210) )
return(0);
@ -1750,8 +1746,6 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k)
return(-1);
}
char *dragonfmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"dragon\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1,\\\"notarypay\\\":%i}\"";
void hush_args(char *argv0)
{
std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0;
@ -1767,15 +1761,9 @@ void hush_args(char *argv0)
{
HUSH_MININGTHREADS = GetArg("-genproclimit",-1);
}
if ( (GetBoolArg("-exchange", false)) != 0 ) {
printf("The KMD-only feature -exchange is not supported by HUSH!\n");
printf("jl777 uses this \"feature\" to steal from his own users!\n");
printf("Learn more at https://duke.hush.is :)\n");
StartShutdown();
}
DONATION_PUBKEY = GetArg("-donation", "");
NOTARY_PUBKEY = GetArg("-pubkey", "");
HUSH_DEALERNODE = GetArg("-dealer",0);
HUSH_DEALERNODE = GetArg("-dealer",0);
HUSH_TESTNODE = GetArg("-testnode",0);
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
@ -1801,7 +1789,10 @@ void hush_args(char *argv0)
}
}
name = GetArg("-ac_name","");
name = GetArg("-ac_name","HUSH3");
fprintf(stderr,".oO Starting %s Full Node (Extreme Privacy!) with genproc=%d notary=%d\n",name.c_str(),HUSH_MININGTHREADS, IS_HUSH_NOTARY);
if ( argv0 != 0 )
{
len = (int32_t)strlen(argv0);
@ -1816,18 +1807,30 @@ void hush_args(char *argv0)
}
}
}
vector<string> HUSH_nodes= {"node1.hush.is","node2.hush.is","node3.hush.is",
"node4.hush.is","node5.hush.is","node6.hush.is",
"node7.hush.is","node8.hush.is","node1.hush.land", "node2.hush.land"};
vector<string> more_nodes = mapMultiArgs["-addnode"];
if (more_nodes.size() > 0) {
fprintf(stderr,"%s: Adding %lu more nodes via custom -addnode arguments\n", __func__, more_nodes.size() );
}
// Add default HUSH nodes after custom addnodes
more_nodes.insert( more_nodes.end(), HUSH_nodes.begin(), HUSH_nodes.end() );
mapMultiArgs["-addnode"] = more_nodes;
HUSH_STOPAT = GetArg("-stopat",0);
MAX_REORG_LENGTH = GetArg("-maxreorg",MAX_REORG_LENGTH);
WITNESS_CACHE_SIZE = MAX_REORG_LENGTH+10;
ASSETCHAINS_CC = GetArg("-ac_cc",0);
HUSH_CCACTIVATE = GetArg("-ac_ccactivate",0);
ASSETCHAINS_BLOCKTIME = GetArg("-ac_blocktime",60);
// We do not support ac_public=1 chains, Hush is a platform for privacy
ASSETCHAINS_PUBLIC = 0;
ASSETCHAINS_PRIVATE = GetArg("-ac_private",0);
HUSH_SNAPSHOT_INTERVAL = GetArg("-ac_snapshot",0);
Split(GetArg("-ac_nk",""), sizeof(ASSETCHAINS_NK)/sizeof(*ASSETCHAINS_NK), ASSETCHAINS_NK, 0);
fprintf(stderr,".oO Starting HUSH Full Node (Extreme Privacy!) with genproc=%d notary=%d\n",HUSH_MININGTHREADS, IS_HUSH_NOTARY);
// -ac_ccactivateht=evalcode,height,evalcode,height,evalcode,height....
Split(GetArg("-ac_ccactivateht",""), sizeof(ccEnablesHeight)/sizeof(*ccEnablesHeight), ccEnablesHeight, 0);
@ -1886,7 +1889,14 @@ void hush_args(char *argv0)
printf("ASSETCHAINS_ALGO, %s not supported. using equihash\n", selectedAlgo.c_str());
}
// Set our symobl from -ac_name value
strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1);
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
ASSETCHAINS_LASTERA = GetArg("-ac_eras", 1);
if(ishush3) {
ASSETCHAINS_LASTERA = 3;
}
if ( ASSETCHAINS_LASTERA < 1 || ASSETCHAINS_LASTERA > ASSETCHAINS_MAX_ERAS )
{
ASSETCHAINS_LASTERA = 1;
@ -1910,10 +1920,29 @@ void hush_args(char *argv0)
Split(GetArg("-ac_halving",""), sizeof(ASSETCHAINS_HALVING)/sizeof(*ASSETCHAINS_HALVING), ASSETCHAINS_HALVING, 0);
Split(GetArg("-ac_reward",""), sizeof(ASSETCHAINS_REWARD)/sizeof(*ASSETCHAINS_REWARD), ASSETCHAINS_REWARD, 0);
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
MAX_BLOCK_SIGOPS = 60000;
ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3;
ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1;
ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0);
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
fprintf(stderr,"%s: Setting custom %s reward HUSH3=%d reward,halving,subsidy chain values...\n",__func__, SMART_CHAIN_SYMBOL, ishush3);
if(ishush3) {
fprintf(stderr,"%s: Setting custom HUSH3 reward,halving,subsidy chain values...\n",__func__);
// Migrated from hushd script
ASSETCHAINS_CC = 2;
ASSETCHAINS_BLOCKTIME = 150; // this will change to 75 at the correct block
ASSETCHAINS_COMMISSION = 11111111;
// 6250000 - (Sprout pool at block 500,000)
ASSETCHAINS_SUPPLY = 6178674;
ASSETCHAINS_FOUNDERS = 1;
ASSETCHAINS_SAPLING = 1;
// this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn
ASSETCHAINS_SCRIPTPUB = "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac";
// Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things
ASSETCHAINS_REWARD[0] = 0;
ASSETCHAINS_REWARD[1] = 1125000000;
@ -1944,11 +1973,6 @@ void hush_args(char *argv0)
}
}
MAX_BLOCK_SIGOPS = 60000;
ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3;
ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1;
ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0);
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);
if ( ASSETCHAINS_SUPPLY > (uint64_t)90*1000*1000000 )
{
fprintf(stderr,"-ac_supply must be less than 90 billion, derpz\n");
@ -1957,9 +1981,6 @@ void hush_args(char *argv0)
if(fDebug)
fprintf(stderr,"ASSETCHAINS_SUPPLY %llu\n",(long long)ASSETCHAINS_SUPPLY);
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0);
ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0);
ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0);
@ -1998,8 +2019,10 @@ void hush_args(char *argv0)
if ( ASSETCHAINS_CC != 0 )
{
uint8_t prevCCi = 0;
ASSETCHAINS_CCLIB = GetArg("-ac_cclib","");
Split(GetArg("-ac_ccenable",""), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0);
ASSETCHAINS_CCLIB = GetArg("-ac_cclib","hush3");
// these are the enabled CCs on HUSH3 mainnet
Split(GetArg("-ac_ccenable","228,234,235,236,241"), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0);
for (i=nonz=0; i<0x100; i++)
{
if ( ccenables[i] != prevCCi && ccenables[i] != 0 )
@ -2080,7 +2103,7 @@ void hush_args(char *argv0)
}
// HUSH will always be The First Pure Sapling Coin, no Sprout JoinSplits in our history! ;)
ASSETCHAINS_SAPLING = GetArg("-ac_sapling", -1);
ASSETCHAINS_SAPLING = GetArg("-ac_sapling", 1);
if (ASSETCHAINS_SAPLING == -1)
{
ASSETCHAINS_OVERWINTER = GetArg("-ac_overwinter", -1);
@ -2269,7 +2292,7 @@ void hush_args(char *argv0)
extralen += symbol.size();
}
}
//komodo_pricesinit();
//hush_pricesinit();
hush_cbopretupdate(1); // will set Mineropret
fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n");
}
@ -2298,13 +2321,11 @@ void hush_args(char *argv0)
if ( strlen(addn.c_str()) > 0 )
ASSETCHAINS_SEED = 1;
strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1);
MAX_MONEY = hush_max_money();
if ( (baseid = komodo_baseid(SMART_CHAIN_SYMBOL)) >= 0 && baseid < 32 )
if ( (baseid = hush_baseid(SMART_CHAIN_SYMBOL)) >= 0 && baseid < 32 )
{
//komodo_maxallowed(baseid);
//hush_maxallowed(baseid);
if(fDebug)
printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,SMART_CHAIN_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
}
@ -2320,6 +2341,10 @@ void hush_args(char *argv0)
if ( GetArg("-port",0) != 0 )
{
ASSETCHAINS_P2PPORT = GetArg("-port",0);
if(ishush3) {
fprintf(stderr,"set HUSH3 p2pport.%u\n",ASSETCHAINS_P2PPORT);
ASSETCHAINS_P2PPORT = 18030;
}
if(fDebug)
fprintf(stderr,"set p2pport.%u\n",ASSETCHAINS_P2PPORT);
} else ASSETCHAINS_P2PPORT = tmpport;
@ -2336,15 +2361,11 @@ void hush_args(char *argv0)
//fprintf(stderr,"Got datadir.(%s)\n",dirname);
if ( SMART_CHAIN_SYMBOL[0] != 0 )
{
int32_t komodo_baseid(char *origbase);
int32_t hush_baseid(char *origbase);
extern int COINBASE_MATURITY;
if ( strcmp(SMART_CHAIN_SYMBOL,"KMD") == 0 )
{
fprintf(stderr,"Oh hellz yezzz\n");
}
if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,SMART_CHAIN_SYMBOL)) != 0 )
if ( (port= hush_userpass(ASSETCHAINS_USERPASS,SMART_CHAIN_SYMBOL)) != 0 )
ASSETCHAINS_RPCPORT = port;
else komodo_configfile(SMART_CHAIN_SYMBOL,ASSETCHAINS_P2PPORT + 1);
else hush_configfile(SMART_CHAIN_SYMBOL,ASSETCHAINS_P2PPORT + 1);
if (ASSETCHAINS_CBMATURITY != 0)
COINBASE_MATURITY = ASSETCHAINS_CBMATURITY;
@ -2360,26 +2381,12 @@ void hush_args(char *argv0)
if ( ASSETCHAINS_RPCPORT == 0 )
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
//ASSETCHAINS_NOTARIES = GetArg("-ac_notaries","");
//komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str());
//hush_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str());
dragon_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC);
for (i=0; i<4; i++)
sprintf(&magicstr[i<<1],"%02x",magic[i]);
magicstr[8] = 0;
#ifndef FROM_CLI
/*
sprintf(fname,"%s_7776",SMART_CHAIN_SYMBOL);
// TODO: why are we doing this again? Most users do not need this
if ( (fp= fopen(fname,"wb")) != 0 )
{
int8_t notarypay = 0;
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
notarypay = 1;
fprintf(fp,dragonfmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,"78.47.196.146",notarypay);
fclose(fp);
//printf("created (%s)\n",fname);
} else printf("error creating (%s)\n",fname);
*/
#endif
if ( ASSETCHAINS_CC < 2 )
{
if ( HUSH_CCACTIVATE != 0 )
@ -2402,24 +2409,24 @@ void hush_args(char *argv0)
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
if ( iter == 0 )
strcat(fname,"Komodo\\komodo.conf");
strcat(fname,"Hush\\HUSH3\\HUSH3.conf");
else strcat(fname,"Bitcoin\\bitcoin.conf");
#else
while ( fname[strlen(fname)-1] != '/' )
fname[strlen(fname)-1] = 0;
#ifdef __APPLE__
if ( iter == 0 )
strcat(fname,"Komodo/Komodo.conf");
strcat(fname,"Hush/HUSH3/HUSH3.conf");
else strcat(fname,"Bitcoin/Bitcoin.conf");
#else
if ( iter == 0 )
strcat(fname,".komodo/komodo.conf");
strcat(fname,".hush/HUSH3/HUSH3.conf");
else strcat(fname,".bitcoin/bitcoin.conf");
#endif
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
_komodo_userpass(username,password,fp);
_hush_userpass(username,password,fp);
sprintf(iter == 0 ? HUSHUSERPASS : BTCUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
@ -2463,7 +2470,7 @@ struct hush_state *hush_stateptrget(char *base)
int32_t baseid;
if ( base == 0 || base[0] == 0 || strcmp(base,(char *)"KYCSELLOUTS") == 0 )
return(&HUSH_STATES[33]);
else if ( (baseid= komodo_baseid(base)) >= 0 )
else if ( (baseid= hush_baseid(base)) >= 0 )
return(&HUSH_STATES[baseid+1]);
else return(&HUSH_STATES[0]);
}

99
src/hushd

@ -1,99 +0,0 @@
#!/bin/bash
# Copyright (c) 2016-2021 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
# set working directory to the location of this script
# readlink -f does not always exist
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )"
cd $DIR
# Chain parameters
NAME=HUSH3
# this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn
SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac
# Hush was and will always be:
# The First Pure Sapling Zcash Protocol chain!
SAPLING=1
# We use 3 "eras" of different supply curves
ERAS=3
# These values are historical and over-ridden by internals!
# Do not change these values, change internals.
BLOCKTIME=150 # Hush goes to 75s blocktime at Block 340K
REWARD=0,1125000000,562500000
HALVING=129,340000,840000
PERC=11111111
END=128,340000,5422111
# 6250000 - (Sprout pool at block 500,000)
SUPPLY=6178674
FOUNDERS=1
CLIENTNAME=GoldenSandtrout
NODE1=node1.hush.is
NODE2=node2.hush.is
NODE3=node3.hush.is
NODE4=node4.hush.is
NODE5=node5.hush.is
NODE6=node6.hush.is
NODE7=node7.hush.is
NODE8=node8.hush.is
CCLIB=hush3
# CryptoConditions/Custom Consensus params
# CCs will effectively be turned off at Block 340K
# since transparent outputs will not be allowed, except
# for mining and dpow. CCs can be used on Hush Smart
# Chains that do not define ac_private=1
FAUCET=228
HEIR=234
CHANNEL=235
ORACLE=236
GATEWAY=241
CCENABLE=$FAUCET,$HEIR,$CHANNEL,$ORACLE,$GATEWAY
KMD=${KOMODOD:-./komodod}
if [ -f $KMD ]; then
HUSH="TheFuture"
# echo "Found binary: $KMD"
else
KMD=hush-komodod
if [ -f $KMD ]; then
echo "Found binary: $KMD"
else
echo "ERROR: Could not find Komodo binary!!!"
exit 1
fi
fi
# jl777 dishonored his village and so Duke The Elder journeys on
# with the True Extreme Privacy Cypherpunks
$KMD -ac_name=$NAME \
-ac_sapling=$SAPLING \
-ac_reward=$REWARD \
-ac_halving=$HALVING \
-ac_end=$END \
-ac_eras=$ERAS \
-ac_blocktime=$BLOCKTIME \
-ac_cc=2 \
-ac_ccenable=$CCENABLE \
-ac_founders=$FOUNDERS \
-ac_supply=$SUPPLY \
-ac_perc=$PERC \
-clientname=$CLIENTNAME \
-asmap \
-addnode=$NODE1 \
-addnode=$NODE2 \
-addnode=$NODE3 \
-addnode=$NODE4 \
-addnode=$NODE5 \
-addnode=$NODE6 \
-addnode=$NODE7 \
-addnode=$NODE8 \
-ac_cclib=$CCLIB \
-ac_script=$SCRIPT "$@"

60
src/hushd-testnet

@ -1,60 +0,0 @@
#!/bin/bash
# Copyright (c) 2016-2021 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
# set working directory to the location of this script
DIR="$( cd "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )"
cd $DIR
DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )"
cd $DIR
# TESTING VALUES, DO NOT USE EXCEPT FOR DEVELOPMENT
NAME=HUSH3T
# this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn
SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac
# Hush was and will always be:
# The First Pure Sapling Zcash Protocol chain!
SAPLING=1
# Chain parameters
ERAS=3
BLOCKTIME=150
# 6250000 - (sprout pool at block 500,000)
SUPPLY=6178674
FOUNDERS=1
REWARD=0,1125000000,562500000
PERC=11111111
HALVING=129,340000,840000
END=128,340000,5422111
CLIENTNAME=GoldenSandtrout
SEEDNODE=1.2.3.4
CCLIB=hush3
# CryptoConditions/Custom Consensus params
FAUCET=228
HEIR=234
CHANNEL=235
ORACLE=236
GATEWAY=241
CCENABLE=$FAUCET,$HEIR,$CHANNEL,$ORACLE,$GATEWAY
# jl777 dishonored his village and so Duke The Elder journeys on
# with the True Extreme Privacy Cypherpunks
KMD=${KOMODOD:-./komodod}
$KMD -ac_name=$NAME \
-ac_sapling=$SAPLING \
-ac_reward=$REWARD \
-ac_halving=$HALVING \
-ac_end=$END \
-ac_eras=$ERAS \
-ac_blocktime=$BLOCKTIME \
-ac_cc=2 \
-ac_ccenable=$CCENABLE \
-ac_founders=$FOUNDERS \
-ac_supply=$SUPPLY \
-ac_perc=$PERC \
-clientname=$CLIENTNAME \
-ac_cclib=$CCLIB \
-ac_script=$SCRIPT "$@"

10
src/hushd.bat

@ -1,10 +0,0 @@
@call :GET_CURRENT_DIR
@cd %THIS_DIR%
komodod.exe -ac_name=HUSH3 -ac_sapling=1 -ac_reward=0,1125000000,562500000 -ac_halving=129,340000,840000 -ac_end=128,340000,5422111 -ac_eras=3 -ac_blocktime=150 -ac_cc=2 -ac_ccenable=228,234,235,236,241 -ac_founders=1 -ac_supply=6178674 -ac_perc=11111111 -clientname=GoldenSandtrout -asmap -addnode=node1.hush.is -addnode=node2.hush.is -addnode=node3.hush.is -addnode=node4.hush.is -addnode=node5.hush.is -addnode=node6.hush.is -addnode=node7.hush.is -addnode=node8.hush.is -ac_cclib=hush3 -ac_script=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac -daemon %1 %2 %3 %4 %5 %6 %7 %8 %9
@goto :EOF
:GET_CURRENT_DIR
@pushd %~dp0
@set THIS_DIR=%CD%
@popd
@goto :EOF

36
src/init.cpp

@ -36,6 +36,7 @@
#include "httprpc.h"
#include "key.h"
#include "notarizationdb.h"
#include "stratum.h"
#ifdef ENABLE_MINING
#include "key_io.h"
@ -89,12 +90,13 @@
using namespace std;
#include "hush_defs.h"
static const bool DEFAULT_STRATUM_ENABLE = false;
extern void ThreadSendAlert();
extern bool hush_dailysnapshot(int32_t height);
extern int32_t HUSH_LOADINGBLOCKS;
extern char SMART_CHAIN_SYMBOL[];
extern int32_t HUSH_SNAPSHOT_INTERVAL;
extern void komodo_init(int32_t height);
extern void hush_init(int32_t height);
#ifdef ENABLE_WALLET
CWallet* pwalletMain = NULL;
@ -187,6 +189,7 @@ static boost::scoped_ptr<ECCVerifyHandle> globalVerifyHandle;
void Interrupt(boost::thread_group& threadGroup)
{
InterruptStratumServer();
InterruptHTTPServer();
InterruptHTTPRPC();
InterruptRPC();
@ -218,6 +221,7 @@ void Shutdown()
StopHTTPRPC();
StopREST();
StopRPC();
StopStratumServer();
StopHTTPServer();
#ifdef ENABLE_WALLET
if (pwalletMain)
@ -390,7 +394,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-dbcache=<n>", strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache));
strUsage += HelpMessageOpt("-loadblock=<file>", _("Imports blocks from external blk000??.dat file") + " " + _("on startup"));
strUsage += HelpMessageOpt("-maxorphantx=<n>", strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
strUsage += HelpMessageOpt("-mempooltxinputlimit=<n>", _("[DEPRECATED FROM OVERWINTER] Set the maximum number of transparent inputs in a transaction that the mempool will accept (default: 0 = no limit applied)"));
strUsage += HelpMessageOpt("-mempooltxinputlimit=<n>", _("[DEPRECATED/IGNORED] Set the maximum number of transparent inputs in a transaction that the mempool will accept (default: 0 = no limit applied)"));
strUsage += HelpMessageOpt("-par=<n>", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"),
-(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
#ifndef _WIN32
@ -412,7 +416,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-zindex", strprintf(_("Maintain extra statistics about shielded transactions and payments (default: %u)"), 0));
strUsage += HelpMessageGroup(_("Connection options:"));
strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open"));
strUsage += HelpMessageOpt("-asmap=<file>", strprintf("Specify asn mapping used for bucketing of the peers (default: %s). Relative paths will be prefixed by the net-specific datadir location.", DEFAULT_ASMAP_FILENAME));
strUsage += HelpMessageOpt("-asmap=<file>", strprintf("Specify ASN mapping used for bucketing of the peers (default: %s). Relative paths will be prefixed by the net-specific datadir location.", DEFAULT_ASMAP_FILENAME));
strUsage += HelpMessageOpt("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), 100));
strUsage += HelpMessageOpt("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), 86400));
strUsage += HelpMessageOpt("-bind=<addr>", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6"));
@ -508,7 +512,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
strUsage += HelpMessageOpt("-nuparams=hexBranchId:activationHeight", "Use given activation height for specified network upgrade (regtest-only)");
}
string debugCategories = "addrman, alert, bench, coindb, db, deletetx, estimatefee, http, libevent, lock, mempool, net, tls, partitioncheck, pow, proxy, prune, rand, reindex, rpc, selectcoins, tor, zmq, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these
string debugCategories = "addrman, alert, bench, coindb, db, deletetx, estimatefee, http, libevent, lock, mempool, net, tls, partitioncheck, pow, proxy, prune, rand, reindex, rpc, selectcoins, stratum, tor, zmq, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + debugCategories + ".");
strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features"));
@ -568,7 +572,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-rpcbind=<addr>", _("Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6. This option can be specified multiple times (default: bind to all interfaces)"));
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), 7771, 17771));
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), ASSETCHAINS_RPCPORT, 10000 + ASSETCHAINS_RPCPORT));
strUsage += HelpMessageOpt("-rpcallowip=<ip>", _("Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times"));
strUsage += HelpMessageOpt("-rpcthreads=<n>", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
if (showDebug) {
@ -582,8 +586,17 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-metricsui", _("Set to 1 for a persistent metrics screen, 0 for sequential metrics output (default: 1 if running in a console, 0 otherwise)"));
strUsage += HelpMessageOpt("-metricsrefreshtime", strprintf(_("Number of seconds between metrics refreshes (default: %u if running in a console, %u otherwise)"), 1, 600));
}
strUsage += HelpMessageGroup(_("Stratum server options:"));
strUsage += HelpMessageOpt("-stratum", _("Enable stratum server (default: off)"));
strUsage += HelpMessageOpt("-stratumaddress=<address>", _("Mining address to use when special address of 'x' is sent by miner (default: none)"));
strUsage += HelpMessageOpt("-stratumbind=<ipaddr>", _("Bind to given address to listen for Stratum work requests. Use [host]:port notation for IPv6. This option can be specified multiple times (default: bind to all interfaces)"));
strUsage += HelpMessageOpt("-stratumport=<port>", strprintf(_("Listen for Stratum work requests on <port> (default: %u or testnet: %u)"), BaseParams().StratumPort(), BaseParams().StratumPort()));
strUsage += HelpMessageOpt("-stratumallowip=<ip>", _("Allow Stratum work requests from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times"));
// "ac" stands for "affects consensus"
strUsage += HelpMessageGroup(_("Hush Smart Chain options:"));
strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash"));
strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash (200,9)"));
strUsage += HelpMessageOpt("-ac_blocktime", _("Block time in seconds, default is 60"));
strUsage += HelpMessageOpt("-ac_cc", _("Cryptoconditions, default 0"));
strUsage += HelpMessageOpt("-ac_beam", _("BEAM integration"));
@ -941,10 +954,13 @@ static void ZC_LoadParams(
bool AppInitServers(boost::thread_group& threadGroup)
{
fprintf(stderr,"%s: start\n",__func__);
RPCServer::OnStopped(&OnRPCStopped);
RPCServer::OnPreCommand(&OnRPCPreCommand);
if (!InitHTTPServer())
return false;
if (GetBoolArg("-stratum", DEFAULT_STRATUM_ENABLE) && !InitStratumServer())
return false;
if (!StartRPC())
return false;
if (!StartHTTPRPC())
@ -1092,8 +1108,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
}
// Read asmap file if configured
if (mapArgs.count("-asmap")) {
// Read asmap file by default for HUSH3 and all Hush Smart Chains
if (GetArg("-asmap",1)) {
fs::path asmap_path = fs::path(GetArg("-asmap", ""));
char cwd[1024];
@ -1577,7 +1593,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
return InitError(strprintf("User Agent comment (%s) contains unsafe characters.", cmt));
uacomments.push_back(SanitizeString(cmt, SAFE_CHARS_UA_COMMENT));
}
strSubVersion = FormatSubVersion(GetArg("-clientname","jl777sRemorse"), CLIENT_VERSION, uacomments);
strSubVersion = FormatSubVersion(GetArg("-clientname","GoldenSandrout"), CLIENT_VERSION, uacomments);
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.",
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
@ -1840,7 +1856,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// (we're likely using a testnet datadir, or the other way around).
if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0)
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
komodo_init(1);
hush_init(1);
// Initialize the block index (no-op if non-empty database was already loaded)
if (!InitBlockIndex()) {
strLoadError = _("Error initializing block database");

59
src/main.cpp

@ -82,7 +82,7 @@ int32_t hush_block2pubkey33(uint8_t *pubkey33,CBlock *block);
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
void hush_setactivation(int32_t height);
void hush_changeblocktime();
void komodo_pricesupdate(int32_t height,CBlock *pblock);
void hush_pricesupdate(int32_t height,CBlock *pblock);
BlockMap mapBlockIndex;
CChain chainActive;
CBlockIndex *pindexBestHeader = NULL;
@ -727,7 +727,7 @@ CBlockTreeDB *pblocktree = NULL;
#define HUSH_ZCASH
#include "hush.h"
UniValue komodo_snapshot(int top)
UniValue hush_snapshot(int top)
{
LOCK(cs_main);
int64_t total = -1;
@ -745,7 +745,7 @@ UniValue komodo_snapshot(int top)
return(result);
}
bool komodo_snapshot2(std::map <std::string, CAmount> &addressAmounts)
bool hush_snapshot2(std::map <std::string, CAmount> &addressAmounts)
{
if ( fAddressIndex && pblocktree != 0 )
{
@ -787,7 +787,7 @@ bool hush_dailysnapshot(int32_t height)
if ( undo_height == lastSnapShotHeight )
return true;
std::map <std::string, int64_t> addressAmounts;
if ( !komodo_snapshot2(addressAmounts) )
if ( !hush_snapshot2(addressAmounts) )
return false;
// undo blocks in reverse order
@ -1201,7 +1201,7 @@ bool ContextualCheckCoinbaseTransaction(int32_t slowflag,const CBlock *block,CBl
{
if ( slowflag != 0 && ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 )
{
if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 )
if ( hush_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 )
return(false);
}
return(true);
@ -1423,7 +1423,7 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState
{
static uint256 array[64]; static int32_t numbanned,indallvouts; int32_t j,k,n;
if ( *(int32_t *)&array[0] == 0 )
numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array)));
numbanned = hush_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array)));
n = tx.vin.size();
if ( SMART_CHAIN_SYMBOL[0] == 0 )
{
@ -1452,8 +1452,13 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState
return true;
}
// This is used only in RPC currently but hush_notaries()/gethushseason/getacseason is consensus
int32_t hush_isnotaryvout(char *coinaddr,uint32_t tiptime) {
int32_t season = getacseason(tiptime);
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
bool istush = strncmp(SMART_CHAIN_SYMBOL, "TUSH",4) == 0 ? true : false;
int32_t height = chainActive.LastTip()->GetHeight();
int32_t season = (ishush3 || istush) ? gethushseason(height) : getacseason(tiptime);
fprintf(stderr,"%s: season=%d, tiptime=%d\n", __func__, season,tiptime);
if ( NOTARY_ADDRESSES[season-1][0][0] == 0 ) {
uint8_t pubkeys[64][33];
hush_notaries(pubkeys,0,tiptime);
@ -1553,12 +1558,12 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
//fprintf(stderr,"private chain nValue %.8f iscoinbase.%d\n",(double)txout.nValue/COIN,iscoinbase);
if (iscoinbase == 0 && txout.nValue > 0)
{
// TODO: if we are upgraded to Sapling, we can allow Sprout sourced funds to sit in a transparent address
char destaddr[65];
Getscriptaddress(destaddr,txout.scriptPubKey);
if ( hush_isnotaryvout(destaddr,tiptime) == 0 )
{
invalid_private_taddr = 1;
fprintf(stderr,"%s: invalid taddr %s on private chain!\n", __func__, destaddr);
//return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain");
}
}
@ -1758,6 +1763,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
// Node operator can choose to reject tx by number of transparent inputs
static_assert(std::numeric_limits<size_t>::max() >= std::numeric_limits<int64_t>::max(), "size_t too small");
size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0);
// Limit is ignored if Overwinter is active, which is the case on HUSH3 and all HSC's
if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
limit = 0;
}
@ -2950,7 +2957,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
*pfClean = false;
bool fClean = true;
//komodo_disconnect(pindex,block); does nothing?
CBlockUndo blockUndo;
CDiskBlockPos pos = pindex->GetUndoPos();
if (pos.IsNull())
@ -3843,7 +3850,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
CValidationState stateDummy;
// don't keep staking or invalid transactions
if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight(),true) != 0)) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && hush_isPoS((CBlock *)&block,pindexDelete->GetHeight(),true) != 0)) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
{
mempool.remove(tx, removed, true);
}
@ -4034,7 +4041,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
{
//fprintf(stderr,"%s: HUSH_NSPV_FULLNODE\n", __FUNCTION__);
if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesupdate(pindexNew->GetHeight(),pblock);
hush_pricesupdate(pindexNew->GetHeight(),pblock);
if ( ASSETCHAINS_SAPLING <= 0 && pindexNew->nTime > HUSH_SAPING_ACTIVATION - 24*3600 )
hush_activate_sapling(pindexNew);
if ( ASSETCHAINS_CC != 0 && HUSH_SNAPSHOT_INTERVAL != 0 && (pindexNew->GetHeight() % HUSH_SNAPSHOT_INTERVAL) == 0 && pindexNew->GetHeight() >= HUSH_SNAPSHOT_INTERVAL )
@ -4207,19 +4214,17 @@ static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBloc
if ( reorgLength > MAX_REORG_LENGTH)
{
auto msg = strprintf(_(
"A block chain reorganization has been detected that would roll back %d blocks! "
"A block chain reorganization has been detected that would roll back %d blocks!!! "
"This is larger than the maximum of %d blocks, and so the node is shutting down for your safety."
), reorgLength, MAX_REORG_LENGTH) + "\n\n" +
_("Reorganization details") + ":\n" +
"- " + strprintf(_("Current tip: %s, height %d, work %s\nstake %s"),
pindexOldTip->phashBlock->GetHex(), pindexOldTip->GetHeight(), pindexOldTip->chainPower.chainWork.GetHex(),
pindexOldTip->chainPower.chainStake.GetHex()) + "\n" +
"- " + strprintf(_("New tip: %s, height %d, work %s\nstake %s"),
pindexMostWork->phashBlock->GetHex(), pindexMostWork->GetHeight(), pindexMostWork->chainPower.chainWork.GetHex(),
pindexMostWork->chainPower.chainStake.GetHex()) + "\n" +
"- " + strprintf(_("Current tip: %s, height %d, work %s\n"),
pindexOldTip->phashBlock->GetHex(), pindexOldTip->GetHeight(), pindexOldTip->chainPower.chainWork.GetHex()) + "\n" +
"- " + strprintf(_("New tip: %s, height %d, work %s\n"),
pindexMostWork->phashBlock->GetHex(), pindexMostWork->GetHeight(), pindexMostWork->chainPower.chainWork.GetHex()) + "\n" +
"- " + strprintf(_("Fork point: %s %s, height %d"),
SMART_CHAIN_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" +
_("Please help, human!");
_("Please help me, wise human!");
LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10);
fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg.c_str(),reorgLength+10);
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
@ -4247,7 +4252,7 @@ static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBloc
if ( !DisconnectTip(state) )
break;
}
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli -ac_name=%s stop\n",HUSH_REWIND,SMART_CHAIN_SYMBOL);
fprintf(stderr,"reached rewind.%d, best to do: ./hush-cli -ac_name=%s stop\n",HUSH_REWIND,SMART_CHAIN_SYMBOL);
sleep(20);
fprintf(stderr,"resuming normal operations\n");
HUSH_REWIND = 0;
@ -4467,7 +4472,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
if (it != mapBlockIndex.end())
{
if ( it->second != 0 ) // vNodes.size() >= HUSH_LIMITED_NETWORKSIZE, change behavior to allow komodo_ensure to work
if ( it->second != 0 ) // vNodes.size() >= HUSH_LIMITED_NETWORKSIZE
{
// this is the strange case where somehow the hash is in the mapBlockIndex via as yet undetermined process, but the pindex for the hash is not there. Theoretically it is due to processing the block headers, but I have seen it get this case without having received it from the block headers or anywhere else... jl777
//fprintf(stderr,"addtoblockindex already there %p\n",it->second);
@ -4475,7 +4480,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
}
if ( miPrev != mapBlockIndex.end() && (*miPrev).second == 0 )
{
//fprintf(stderr,"edge case of both block and prevblock in the strange state\n");
fprintf(stderr,"%s: edge case of both block and prevblock in the strange state\n", __func__);
return(0); // return here to avoid the state of pindex->GetHeight() not set and pprev NULL
}
}
@ -4996,7 +5001,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
}
// Check proof of work matches claimed amount
/*komodo_index2pubkey33(pubkey33,pindex,height);
/*hush_index2pubkey33(pubkey33,pindex,height);
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus(),blockhdr.nTime) )
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");*/
return true;
@ -7070,7 +7075,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
std::vector<uint8_t> payload;
vRecv >> payload;
komodo_netevent(payload);
hush_netevent(payload);
return(true);
} else if (strCommand == "verack") {
pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
@ -7270,7 +7275,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{
std::vector<uint8_t> payload;
vRecv >> payload;
komodo_nSPVreq(pfrom,payload);
hush_nSPVreq(pfrom,payload);
}
return(true);
} else if (strCommand == "nSPV") {
@ -7278,7 +7283,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{
std::vector<uint8_t> payload;
vRecv >> payload;
komodo_nSPVresp(pfrom,payload);
hush_nSPVresp(pfrom,payload);
}
return(true);
}
@ -8005,7 +8010,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
}
if ( HUSH_NSPV_SUPERLITE )
{
komodo_nSPV(pto);
hush_nSPV(pto);
return(true);
}
BOOST_FOREACH(const CBlockReject& reject, state.rejects)

39
src/miner.cpp

@ -137,19 +137,18 @@ void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uin
uint32_t Mining_start,Mining_height;
int32_t My_notaryid = -1;
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
int32_t komodo_baseid(char *origbase);
int32_t hush_baseid(char *origbase);
int32_t hush_longestchain();
int64_t hush_block_unlocktime(uint32_t nHeight);
uint64_t the_commission(const CBlock *block,int32_t height);
int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *ptr);
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
int32_t hush_is_notarytx(const CTransaction& tx);
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len);
uint64_t hush_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len);
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
int32_t hush_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len);
CScript komodo_mineropret(int32_t nHeight);
bool komodo_appendACscriptpub();
CScript hush_mineropret(int32_t nHeight);
bool hush_appendACscriptpub();
CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake)
{
@ -168,7 +167,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
}
} else pk = _pk;
uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
uint64_t deposits,voutsum=0; int32_t isrealtime,hushheight; uint32_t blocktime; const CChainParams& chainparams = Params();
bool fNotarizationBlock = false; std::vector<int8_t> NotarizationNotaries;
//fprintf(stderr,"create new block\n");
@ -583,7 +582,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
//pblock->nTime = blocktime + 1;
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake);
LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);
// Create coinbase tx
CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight);
@ -613,7 +612,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{
static bool didinit = false;
if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && komodo_appendACscriptpub() )
if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_appendACscriptpub() )
{
fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
didinit = true;
@ -649,7 +648,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size();
if ( script[0] == OP_RETURN )
{
uint64_t totalsats = komodo_notarypay(txNew, NotarizationNotaries, pblock->nTime, nHeight, script, scriptlen);
uint64_t totalsats = hush_notarypay(txNew, NotarizationNotaries, pblock->nTime, nHeight, script, scriptlen);
if ( totalsats == 0 )
{
fprintf(stderr, "Could not create notary payment, trying again.\n");
@ -668,7 +667,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
int32_t numv = (int32_t)txNew.vout.size();
txNew.vout.resize(numv+1);
txNew.vout[numv].nValue = 0;
txNew.vout[numv].scriptPubKey = komodo_mineropret(nHeight);
txNew.vout[numv].scriptPubKey = hush_mineropret(nHeight);
//printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size());
}
pblock->vtx[0] = txNew;
@ -880,7 +879,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake);
}
void komodo_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector<uint8_t> payload)
void hush_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector<uint8_t> payload)
{
int32_t numsent = 0;
LOCK(cs_vNodes);
@ -955,9 +954,9 @@ static bool ProcessBlockFound(CBlock* pblock)
return true;
}
int32_t komodo_baseid(char *origbase);
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t *blocktimes,int32_t *nonzpkeysp,int32_t height);
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
int32_t hush_baseid(char *origbase);
int32_t hush_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t *blocktimes,int32_t *nonzpkeysp,int32_t height);
arith_uint256 hush_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
int32_t FOUND_BLOCK,HUSH_MAYBEMINED;
extern int32_t HUSH_LASTMINED,HUSH_INSYNC;
int32_t roundrobin_delay;
@ -1055,7 +1054,7 @@ void static BitcoinMiner()
while ( (ASSETCHAIN_INIT == 0 || HUSH_INITDONE == 0) )
{
sleep(1);
if ( komodo_baseid(SMART_CHAIN_SYMBOL) < 0 )
if ( hush_baseid(SMART_CHAIN_SYMBOL) < 0 )
break;
}
if ( SMART_CHAIN_SYMBOL[0] == 0 )
@ -1184,12 +1183,12 @@ void static BitcoinMiner()
if ( SMART_CHAIN_SYMBOL[0] == 0 && notaryid >= 0 )
{
j = 65;
if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 || Mining_height > 1000000 )
if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % HUSH_DPOW_GAP) > 64 || (Mining_height % HUSH_DPOW_GAP) == 0 || Mining_height > 1000000 )
{
int32_t dispflag = 0;
if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) || notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 )
dispflag = 1;
komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->GetHeight());
hush_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->GetHeight());
if ( nonzpkeys > 0 )
{
for (i=0; i<33; i++)
@ -1238,7 +1237,7 @@ void static BitcoinMiner()
} else Mining_start = 0;
//else if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
// HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime);
// HASHTarget_POW = hush_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime);
gotinvalid = 0;
while (true)
{
@ -1463,7 +1462,7 @@ void static BitcoinMiner()
HASHTarget.SetCompact(pblock->nBits);
hashTarget = HASHTarget;
savebits = pblock->nBits;
//hashTarget = HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime);
//hashTarget = HASHTarget_POW = hush_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime);
}
/*if ( NOTARY_PUBKEY33[0] == 0 )
{
@ -1473,7 +1472,7 @@ void static BitcoinMiner()
{
// Changing pblock->nTime can change work required on testnet:
HASHTarget.SetCompact(pblock->nBits);
HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED);
HASHTarget_POW = hush_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED);
}
}*/
}

17
src/musigtest.py

@ -16,15 +16,14 @@ def def_credentials(chain):
rpcport = '';
operating_system = platform.system()
if operating_system == 'Darwin':
ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo'
ac_dir = os.environ['HOME'] + '/Library/Application Support/Hush'
elif operating_system == 'Linux':
ac_dir = os.environ['HOME'] + '/.komodo'
ac_dir = os.environ['HOME'] + '/.hush'
elif operating_system == 'Windows':
ac_dir = '%s/komodo/' % os.environ['APPDATA']
if chain == 'KMD':
coin_config_file = str(ac_dir + '/komodo.conf')
else:
coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf')
ac_dir = '%s/hush/' % os.environ['APPDATA']
coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf')
with open(coin_config_file, 'r') as f:
for line in f:
l = line.rstrip()
@ -35,8 +34,8 @@ def def_credentials(chain):
elif re.search('rpcport', l):
rpcport = l.replace('rpcport=', '')
if len(rpcport) == 0:
if chain == 'KMD':
rpcport = 7771
if chain == 'HUSH3':
rpcport = 18031
else:
print("rpcport not in conf file, exiting")
print("check " + coin_config_file)

4
src/net.cpp

@ -2120,7 +2120,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss)
random_shuffle( vRelayNodes.begin(), vRelayNodes.end(), GetRandInt );
vRelayNodes.resize(newSize);
fprintf(stderr, "%s: Relaying to %lu peers\n", __func__, newSize);
fprintf(stderr, "%s: Relaying to %lu of %lu peers\n", __func__, newSize, vNodes.size() );
// Only relay to randomly chosen 50% of peers
BOOST_FOREACH(CNode* pnode, vRelayNodes)
@ -2283,7 +2283,7 @@ bool CAddrDB::Read(CAddrMan& addr)
// ... verify the network matches ours
if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp)))
return error("%s: Invalid network magic number", __func__);
return error("%s: Invalid network magic number in %s", __func__, pathAddr.string());
// de-serialize address data into one CAddrMan object
ssPeers >> addr;

1
src/netbase.cpp

@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2016-2021 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************

12
src/pow.cpp

@ -672,14 +672,14 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
int32_t hush_currentheight();
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
void hush_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
bool hush_checkopret(CBlock *pblock, CScript &merkleroot);
CScript komodo_makeopret(CBlock *pblock, bool fNew);
CScript hush_makeopret(CBlock *pblock, bool fNew);
extern int32_t HUSH_CHOSEN_ONE;
extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
#define KOMODO_ELECTION_GAP 2000
#define HUSH_DPOW_GAP 2000
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height);
int32_t hush_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height);
int32_t HUSH_LOADINGBLOCKS = 1;
extern std::string NOTARY_PUBKEY;
@ -749,7 +749,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
CChainPower GetBlockProof(const CBlockIndex& block)
{
arith_uint256 bnWorkTarget, bnStakeTarget = arith_uint256(0);
arith_uint256 bnWorkTarget;
bool fNegative;
bool fOverflow;
@ -758,7 +758,7 @@ CChainPower GetBlockProof(const CBlockIndex& block)
if (fNegative || fOverflow || bnWorkTarget == 0)
return CChainPower(0);
return CChainPower(0, bnStakeTarget, (~bnWorkTarget / (bnWorkTarget + 1)) + 1);
return CChainPower(0, (~bnWorkTarget / (bnWorkTarget + 1)) + 1);
}
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params)

8
src/purge

@ -4,7 +4,7 @@
echo "Purging $1"
rm -rf ~/.komodo/$1/chainstate
rm -rf ~/.komodo/$1/database
rm -rf ~/.komodo/$1/blocks
rm -rf ~/.komodo/$1/komodostate
rm -rf ~/.hush/$1/chainstate
rm -rf ~/.hush/$1/database
rm -rf ~/.hush/$1/blocks
rm -rf ~/.hush/$1/hushstate

2
src/revs

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=REVS $1 $2 $3 $4

29
src/rpc/blockchain.cpp

@ -893,7 +893,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( keylen < sizeof(key) )
{
memcpy(key,params[0].get_str().c_str(),keylen);
if ( (valuesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&flags,&height,value,key,keylen)) >= 0 )
if ( (valuesize= hush_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&flags,&height,value,key,keylen)) >= 0 )
{
std::string val; char *valuestr;
val.resize(valuesize);
@ -928,7 +928,7 @@ UniValue minerids(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( pblockindex != 0 )
timestamp = pblockindex->GetBlockTime();
}
if ( (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
if ( (n= hush_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
{
memset(tally,0,sizeof(tally));
numnotaries = hush_notaries(pubkeys,height,timestamp);
@ -942,18 +942,18 @@ UniValue minerids(const UniValue& params, bool fHelp, const CPubKey& mypk)
}
for (i=0; i<64; i++)
{
UniValue item(UniValue::VOBJ); std::string hex,hushaddress; char *hexstr,kmdaddr[64],*ptr; int32_t m;
UniValue item(UniValue::VOBJ); std::string hex,hushaddress; char *hexstr,hushaddr[64],*ptr; int32_t m;
hex.resize(66);
hexstr = (char *)hex.data();
for (j=0; j<33; j++)
sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]);
item.push_back(Pair("notaryid", i));
bitcoin_address(kmdaddr,60,pubkeys[i],33);
m = (int32_t)strlen(kmdaddr);
bitcoin_address(hushaddr,60,pubkeys[i],33);
m = (int32_t)strlen(hushaddr);
hushaddress.resize(m);
ptr = (char *)hushaddress.data();
memcpy(ptr,kmdaddr,m);
memcpy(ptr,hushaddr,m);
item.push_back(Pair("HUSHaddress", hushaddress));
item.push_back(Pair("pubkey", hex));
@ -973,7 +973,7 @@ UniValue minerids(const UniValue& params, bool fHelp, const CPubKey& mypk)
UniValue notaries(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue a(UniValue::VARR); uint32_t timestamp=0; UniValue ret(UniValue::VOBJ); int32_t i,j,n,m; char *hexstr; uint8_t pubkeys[64][33]; char btcaddr[64],kmdaddr[64],*ptr;
UniValue a(UniValue::VARR); uint32_t timestamp=0; UniValue ret(UniValue::VOBJ); int32_t i,j,n,m; char *hexstr; uint8_t pubkeys[64][33]; char btcaddr[64],hushaddr[64],*ptr;
if ( fHelp || (params.size() != 1 && params.size() != 2) )
throw runtime_error("notaries height timestamp\n");
LOCK(cs_main);
@ -1011,11 +1011,11 @@ UniValue notaries(const UniValue& params, bool fHelp, const CPubKey& mypk)
memcpy(ptr,btcaddr,m);
item.push_back(Pair("BTCaddress", btcaddress));
bitcoin_address(kmdaddr,60,pubkeys[i],33);
m = (int32_t)strlen(kmdaddr);
bitcoin_address(hushaddr,60,pubkeys[i],33);
m = (int32_t)strlen(hushaddr);
hushaddress.resize(m);
ptr = (char *)hushaddress.data();
memcpy(ptr,kmdaddr,m);
memcpy(ptr,hushaddr,m);
item.push_back(Pair("HUSHaddress", hushaddress));
a.push_back(item);
}
@ -1027,7 +1027,7 @@ UniValue notaries(const UniValue& params, bool fHelp, const CPubKey& mypk)
return ret;
}
int32_t komodo_pending_withdraws(char *opretstr);
int32_t hush_pending_withdraws(char *opretstr);
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base);
extern char CURRENCIES[][8];
@ -1037,7 +1037,7 @@ UniValue paxpending(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( fHelp || params.size() != 0 )
throw runtime_error("paxpending needs no args\n");
LOCK(cs_main);
if ( (opretlen= komodo_pending_withdraws(opretbuf)) > 0 )
if ( (opretlen= hush_pending_withdraws(opretbuf)) > 0 )
ret.push_back(Pair("withdraws", opretbuf));
else ret.push_back(Pair("withdraws", (char *)""));
for (baseid=0; baseid<32; baseid++)
@ -1076,7 +1076,7 @@ UniValue paxprice(const UniValue& params, bool fHelp, const CPubKey& mypk)
else height = atoi(params[2].get_str().c_str());
//if ( params.size() == 3 || (basevolume= COIN * atof(params[3].get_str().c_str())) == 0 )
basevolume = 100000;
relvolume = komodo_paxprice(&seed,height,(char *)base.c_str(),(char *)rel.c_str(),basevolume);
relvolume = hush_paxprice(&seed,height,(char *)base.c_str(),(char *)rel.c_str(),basevolume);
ret.push_back(Pair("base", base));
ret.push_back(Pair("rel", rel));
ret.push_back(Pair("height", height));
@ -1567,7 +1567,6 @@ inline CBlockIndex* LookupBlockIndex(const uint256& hash)
UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
THROW_IF_SYNCING(HUSH_INSYNC);
if (fHelp || params.size() > 2)
throw runtime_error(
@ -1631,6 +1630,8 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk
+ HelpExampleRpc("getchaintxstats", "2016")
);
THROW_IF_SYNCING(HUSH_INSYNC);
const CBlockIndex* pindex;
int blockcount = 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; // By default: 1 month

59
src/rpc/crosschain.cpp

@ -56,10 +56,10 @@ int32_t ensure_CCrequirements(uint8_t evalcode);
bool EnsureWalletIsAvailable(bool avoidException);
int32_t hush_MoM(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip);
int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mdata,char *symbol,int32_t kmdheight,int32_t notarized_height);
struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi);
uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth);
int32_t hush_MoM(int32_t *notarized_htp,uint256 *MoMp,uint256 *hushtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *hushstartip,int32_t *hushendip);
int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mdata,char *symbol,int32_t hushheight,int32_t notarized_height);
struct hush_ccdata_entry *hush_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t hushstarti,int32_t hushendi);
uint256 hush_calcMoM(int32_t height,int32_t MoMdepth);
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
extern std::string ASSETCHAINS_SELFIMPORT;
@ -71,7 +71,7 @@ UniValue assetchainproof(const UniValue& params, bool fHelp, const CPubKey& mypk
{
uint256 hash;
// parse params and get notarisation data for tx
// parse params and get notarization data for tx
if ( fHelp || params.size() != 1)
throw runtime_error("assetchainproof needs a txid");
@ -93,7 +93,7 @@ UniValue crosschainproof(const UniValue& params, bool fHelp, const CPubKey& mypk
UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
int32_t height,depth,notarized_height,MoMoMdepth,MoMoMoffset,kmdstarti,kmdendi; uint256 MoM,MoMoM,kmdtxid; uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR);
int32_t height,depth,notarized_height,MoMoMdepth,MoMoMoffset,hushstarti,hushendi; uint256 MoM,MoMoM,hushtxid; uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR);
if ( fHelp || params.size() != 1 )
throw runtime_error("height_MoM height\n");
LOCK(cs_main);
@ -108,7 +108,7 @@ UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
height = chainActive.Tip()->GetHeight();
}
//fprintf(stderr,"height_MoM height.%d\n",height);
depth = hush_MoM(&notarized_height,&MoM,&kmdtxid,height,&MoMoM,&MoMoMoffset,&MoMoMdepth,&kmdstarti,&kmdendi);
depth = hush_MoM(&notarized_height,&MoM,&hushtxid,height,&MoMoM,&MoMoMoffset,&MoMoMdepth,&hushstarti,&hushendi);
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL)));
ret.push_back(Pair("height",height));
ret.push_back(Pair("timestamp",(uint64_t)timestamp));
@ -117,14 +117,14 @@ UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
ret.push_back(Pair("depth",depth));
ret.push_back(Pair("notarized_height",notarized_height));
ret.push_back(Pair("MoM",MoM.GetHex()));
ret.push_back(Pair("kmdtxid",kmdtxid.GetHex()));
ret.push_back(Pair("hushtxid",hushtxid.GetHex()));
if ( SMART_CHAIN_SYMBOL[0] != 0 )
{
ret.push_back(Pair("MoMoM",MoMoM.GetHex()));
ret.push_back(Pair("MoMoMoffset",MoMoMoffset));
ret.push_back(Pair("MoMoMdepth",MoMoMdepth));
ret.push_back(Pair("kmdstarti",kmdstarti));
ret.push_back(Pair("kmdendi",kmdendi));
ret.push_back(Pair("hushstarti",hushstarti));
ret.push_back(Pair("hushendi",hushendi));
}
} else ret.push_back(Pair("error",(char *)"no MoM for height"));
@ -134,18 +134,18 @@ UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
UniValue MoMoMdata(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if ( fHelp || params.size() != 3 )
throw runtime_error("MoMoMdata symbol kmdheight ccid\n");
throw runtime_error("MoMoMdata symbol hushheight ccid\n");
UniValue ret(UniValue::VOBJ);
char* symbol = (char *)params[0].get_str().c_str();
int kmdheight = atoi(params[1].get_str().c_str());
int hushheight = atoi(params[1].get_str().c_str());
uint32_t ccid = atoi(params[2].get_str().c_str());
ret.push_back(Pair("coin",symbol));
ret.push_back(Pair("kmdheight",kmdheight-5));
ret.push_back(Pair("hushheight",hushheight-5));
ret.push_back(Pair("ccid", (int) ccid));
uint256 destNotarizationTxid;
std::vector<uint256> moms;
uint256 MoMoM = CalculateProofRoot(symbol, ccid, kmdheight-5, moms, destNotarizationTxid);
uint256 MoMoM = CalculateProofRoot(symbol, ccid, hushheight-5, moms, destNotarizationTxid);
UniValue valMoms(UniValue::VARR);
for (int i=0; i<moms.size(); i++) valMoms.push_back(moms[i].GetHex());
@ -169,7 +169,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( height <= 0 || MoMdepth <= 0 || MoMdepth >= height )
throw runtime_error("calc_MoM illegal height or MoMdepth\n");
//fprintf(stderr,"height_MoM height.%d\n",height);
MoM = komodo_calcMoM(height,MoMdepth);
MoM = hush_calcMoM(height,MoMdepth);
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL)));
ret.push_back(Pair("height",height));
ret.push_back(Pair("MoMdepth",MoMdepth));
@ -670,7 +670,7 @@ UniValue migrate_createnotaryapprovaltransaction(const UniValue& params, bool fH
if (fHelp || params.size() != 2)
throw runtime_error("migrate_createnotaryapprovaltransaction burntxid txoutproof\n\n"
"Creates a tx for destination chain with burn tx proof\n"
"txoutproof should be retrieved by komodo-cli migrate_checkburntransactionsource call on the source chain\n" );
"txoutproof should be retrieved by hush-cli migrate_checkburntransactionsource call on the source chain\n" );
if (SMART_CHAIN_SYMBOL[0] == 0)
throw runtime_error("Must be called on asset chain");
@ -1126,7 +1126,7 @@ UniValue getNotarizationsForBlock(const UniValue& params, bool fHelp, const CPub
// TODO take timestamp as param, and loop blockindex to get starting/finish height.
if (fHelp || params.size() != 1)
throw runtime_error("getNotarizationsForBlock height\n\n"
"Takes a block height and returns notarisation information "
"Takes a block height and returns notarization information "
"within the block");
LOCK(cs_main);
@ -1168,34 +1168,11 @@ UniValue getNotarizationsForBlock(const UniValue& params, bool fHelp, const CPub
return out;
}
/*UniValue getNotarizationsForBlock(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (fHelp || params.size() != 1)
throw runtime_error("getNotarizationsForBlock blockHash\n\n"
"Takes a block hash and returns notarisation transactions "
"within the block");
uint256 blockHash = uint256S(params[0].get_str());
NotarizationsInBlock nibs;
GetBlockNotarizations(blockHash, nibs);
UniValue out(UniValue::VARR);
BOOST_FOREACH(const Notarization& n, nibs)
{
UniValue item(UniValue::VARR);
item.push_back(n.first.GetHex());
item.push_back(HexStr(E_MARSHAL(ss << n.second)));
out.push_back(item);
}
return out;
}*/
UniValue scanNotarizationsDB(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (fHelp || params.size() < 2 || params.size() > 3)
throw runtime_error("scanNotarizationsDB blockHeight symbol [blocksLimit=1440]\n\n"
"Scans notarisationsdb backwards from height for a notarisation"
"Scans notarizationsdb backwards from height for a notarization"
" of given symbol");
int height = atoi(params[0].get_str().c_str());
std::string symbol = params[1].get_str().c_str();

2
src/rpc/mining.cpp

@ -52,7 +52,7 @@ using namespace std;
extern int32_t ASSETCHAINS_FOUNDERS;
uint64_t the_commission(const CBlock *pblock,int32_t height);
int32_t hush_blockload(CBlock& block,CBlockIndex *pindex);
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
arith_uint256 hush_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
/**
* Return average network hashes per second based on the last 'lookup' blocks,

39
src/rpc/misc.cpp

@ -59,7 +59,7 @@ using namespace std;
int32_t hush_longestchain();
int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
bool komodo_txnotarizedconfirmed(uint256 txid);
bool hush_txnotarizedconfirmed(uint256 txid);
uint32_t hush_chainactive_timestamp();
int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
extern int32_t HUSH_LASTMINED,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC;
@ -67,7 +67,7 @@ extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
uint32_t hush_segid32(char *coinaddr);
int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp);
uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount);
uint64_t hush_notarypayamount(int32_t nHeight, int64_t notarycount);
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
@ -178,6 +178,28 @@ UniValue geterablockheights(const UniValue& params, bool fHelp, const CPubKey& m
return(ret);
}
extern int getWorkQueueDepth();
extern int getWorkQueueMaxDepth();
extern int getWorkQueueNumThreads();
UniValue rpcinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ);
if (fHelp || params.size() != 0) {
throw runtime_error(
"rpcinfo\n"
"Returns an object containing various RPC state info.\n"
);
}
LOCK(cs_main);
int depth = getWorkQueueDepth();
result.push_back(Pair("work_queue_depth", depth));
result.push_back(Pair("work_queue_max_depth", getWorkQueueMaxDepth() ));
result.push_back(Pair("work_queue_num_threads", getWorkQueueNumThreads() ));
return result;
}
UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,hushnotarized_height,txid_height;
@ -230,7 +252,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString()));
if ( HUSH_NSPV_FULLNODE )
{
txid_height = notarizedtxid_height(SMART_CHAIN_SYMBOL[0] != 0 ? (char *)"HUSH" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&hushnotarized_height);
txid_height = notarizedtxid_height( (char *)"HUSH3" ,(char *)notarized_desttxid.ToString().c_str(),&hushnotarized_height);
if ( txid_height > 0 )
obj.push_back(Pair("notarizedtxid_height", txid_height));
else obj.push_back(Pair("notarizedtxid_height", "mempool"));
@ -1189,7 +1211,7 @@ UniValue getnotarypayinfo(const UniValue& params, bool fHelp, const CPubKey& myp
balance = checkburnaddress(received, TotalNotaryPay, height, "REDVp3ox1pbcWYCzySadfHhk8UU3HM4k5x");
notarycount = hush_notaries(notarypubkeys, height, chainActive[height]->GetBlockTime());
NotaryPay = komodo_notarypayamount(height, notarycount)*notarycount;
NotaryPay = hush_notarypayamount(height, notarycount)*notarycount;
bool spent = (received != balance);
if ( !spent )
{
@ -1265,7 +1287,7 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp, const CPubKey& my
}
UniValue komodo_snapshot(int top);
UniValue hush_snapshot(int top);
UniValue getsnapshot(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
@ -1315,7 +1337,7 @@ UniValue getsnapshot(const UniValue& params, bool fHelp, const CPubKey& mypk)
+ HelpExampleRpc("getsnapshot", "1000")
);
}
result = komodo_snapshot(top);
result = hush_snapshot(top);
if ( result.size() > 0 ) {
result.push_back(Pair("end_time", (int) time(NULL)));
} else {
@ -1463,7 +1485,7 @@ UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey&
if (fHelp || params.size() < 1 || params.size() > 1)
{
string msg = "txnotarizedconfirmed txid\n"
"\nReturns true if transaction is notarized on chain that has dPoW or if confirmation number is greater than 60 on chain taht does not have dPoW.\n"
"\nReturns true if transaction is notarized on chain that has dPoW or if confirmation number is greater than 60 on chain that does not have dPoW.\n"
"\nArguments:\n"
"1. txid (string, required) Transaction id.\n"
@ -1476,7 +1498,7 @@ UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey&
throw runtime_error(msg);
}
txid = uint256S((char *)params[0].get_str().c_str());
notarizedconfirmed=komodo_txnotarizedconfirmed(txid);
notarizedconfirmed=hush_txnotarizedconfirmed(txid);
UniValue result(UniValue::VOBJ);
result.push_back(Pair("result", notarizedconfirmed));
return result;
@ -1556,6 +1578,7 @@ static const CRPCCommand commands[] =
{ "util", "z_validateaddress", &z_validateaddress, true }, /* uses wallet if enabled */
{ "util", "createmultisig", &createmultisig, true },
{ "util", "verifymessage", &verifymessage, true },
{ "util", "rpcinfo", &rpcinfo, true },
/* Not shown in help */
{ "hidden", "setmocktime", &setmocktime, true },

2
src/rpc/rawtransaction.cpp

@ -651,7 +651,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp, const CPubKey&
" ,...\n"
" }\n"
"3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n"
"4. expiryheight (numeric, optional, default=" + strprintf("%d", DEFAULT_TX_EXPIRY_DELTA) + ") Expiry height of transaction (if Overwinter is active)\n"
"4. expiryheight (numeric, optional, default=" + strprintf("%d", DEFAULT_TX_EXPIRY_DELTA) + ") Expiry height of transaction\n"
"\nResult:\n"
"\"transaction\" (string) hex string of the transaction\n"

6
src/rpc/register.h

@ -1,7 +1,7 @@
// Copyright (c) 2016-2021 The Hush developers
// Copyright (c) 2009-2016 The Bitcoin Core developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -38,6 +38,9 @@ void RegisterRawTransactionRPCCommands(CRPCTable &tableRPC);
/** Register test transaction RPC commands */
void RegisterTesttransactionsRPCCommands(CRPCTable &tableRPC);
/** Register stratum RPC commands */
void RegisterStratumRPCCommands(CRPCTable &tableRPC);
static inline void RegisterAllCoreRPCCommands(CRPCTable &tableRPC)
{
@ -49,6 +52,7 @@ static inline void RegisterAllCoreRPCCommands(CRPCTable &tableRPC)
#ifdef TESTMODE
RegisterTesttransactionsRPCCommands(tableRPC);
#endif
RegisterStratumRPCCommands(tableRPC);
}
#endif

16
src/rpc/server.cpp

@ -829,9 +829,13 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params
// Others may not have data loaded yet, such as wallet details, but
// those RPCs are written defensively to deal with that. Allowing these
// few RPCs means we can see our addresses and make private key backups
// while a very long wallet rescan is happening
// while a very long wallet rescan is happening and do other read-only devopz
if (pcmd->name != "stop" && pcmd->name != "help" && pcmd->name != "z_listaddresses" && pcmd->name != "z_exportkey" &&
pcmd->name != "listaddresses" && pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" ) {
pcmd->name != "getNotarizationsForBlock" && pcmd->name != "scanNotarizationsDB" &&
pcmd->name != "getnotarysendmany" && pcmd->name != "geterablockheights" &&
pcmd->name != "getaddressesbyaccount" && pcmd->name != "listaddresses" && pcmd->name != "z_exportwallet" &&
pcmd->name != "notaries" && pcmd->name != "signmessage" && pcmd->name != "decoderawtransaction" &&
pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" && pcmd->name != "getnetworkinfo" ) {
throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
}
}
@ -856,12 +860,10 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params
std::string HelpExampleCli(const std::string& methodname, const std::string& args)
{
if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
return "> komodo-cli " + methodname + " " + args + "\n";
} else if ((strncmp(SMART_CHAIN_SYMBOL, "HUSH3", 5) == 0) ) {
if ((strncmp(SMART_CHAIN_SYMBOL, "HUSH3", 5) == 0) ) {
return "> hush-cli " + methodname + " " + args + "\n";
} else {
return "> komodo-cli -ac_name=" + strprintf("%s", SMART_CHAIN_SYMBOL) + " " + methodname + " " + args + "\n";
return "> hush-cli -ac_name=" + strprintf("%s", SMART_CHAIN_SYMBOL) + " " + methodname + " " + args + "\n";
}
}
@ -874,7 +876,7 @@ std::string HelpExampleRpc(const std::string& methodname, const std::string& arg
string experimentalDisabledHelpMsg(const string& rpc, const string& enableArg)
{
string daemon = "hushd";
string ticker = SMART_CHAIN_SYMBOL[0] == 0 ? "komodo" : SMART_CHAIN_SYMBOL;
string ticker = SMART_CHAIN_SYMBOL;
return "\nWARNING: " + rpc + " is disabled.\n"
"To enable it, restart " + daemon + " with the -experimentalfeatures and\n"

1
src/rpc/server.h

@ -351,6 +351,7 @@ extern UniValue getrawchangeaddress(const UniValue& params, bool fHelp, const CP
extern UniValue setaccount(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue getaccount(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue getaddressesbyaccount(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue listaddresses(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue signmessage(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue verifymessage(const UniValue& params, bool fHelp, const CPubKey& mypk);

39
src/script/standard.h

@ -117,45 +117,6 @@ class COptCCParams
std::vector<unsigned char> AsVector();
};
class CStakeParams
{
public:
static const uint32_t STAKE_MINPARAMS = 4;
static const uint32_t STAKE_MAXPARAMS = 5;
uint32_t srcHeight;
uint32_t blkHeight;
uint256 prevHash;
CPubKey pk;
CStakeParams() : srcHeight(0), blkHeight(0), prevHash(), pk() {}
CStakeParams(const std::vector<std::vector<unsigned char>> &vData);
CStakeParams(uint32_t _srcHeight, uint32_t _blkHeight, const uint256 &_prevHash, const CPubKey &_pk) :
srcHeight(_srcHeight), blkHeight(_blkHeight), prevHash(_prevHash), pk(_pk) {}
std::vector<unsigned char> AsVector()
{
std::vector<unsigned char> ret;
CScript scr = CScript();
scr << OPRETTYPE_STAKEPARAMS;
scr << srcHeight;
scr << blkHeight;
scr << std::vector<unsigned char>(prevHash.begin(), prevHash.end());
if (pk.IsValid())
{
scr << std::vector<unsigned char>(pk.begin(), pk.end());
}
ret = std::vector<unsigned char>(scr.begin(), scr.end());
return ret;
}
bool IsValid() { return srcHeight != 0; }
};
/** Check whether a CTxDestination is a CNoDestination. */
bool IsValidDestination(const CTxDestination& dest);

2
src/smartchains

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2018-2020 The Hush developers
# Copyright (c) 2018-2021 The Hush developers
set -eo pipefail
# You can now add delay line to pubkey.txt file

2151
src/stratum.cpp

File diff suppressed because it is too large

21
src/stratum.h

@ -0,0 +1,21 @@
// Copyright (c) 2021-2021 The Hush developers
// Copyright (c) 2020-2021 The Freicoin Developers
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#ifndef HUSH_STRATUM_H
#define HUSH_STRATUM_H
/** Configure the stratum server. */
bool InitStratumServer();
/** Interrupt the stratum server connections. */
void InterruptStratumServer();
/** Cleanup stratum server network connections and free resources. */
void StopStratumServer();
#endif // HUSH_STRATUM_H
// End of File

3
src/sync.cpp

@ -19,12 +19,9 @@
******************************************************************************/
#include "sync.h"
#include "util.h"
#include "utilstrencodings.h"
#include <stdio.h>
#include <boost/foreach.hpp>
#include <boost/thread.hpp>

5
src/test-hush/test_addrman.cpp

@ -2,16 +2,13 @@
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#include <gtest/gtest.h>
#include "addrman.h"
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <string>
#include "hash.h"
#include "random.h"
#include "util/asmap.h"
#include "netbase.h"
#include "chainparams.h"
#include "tinyformat.h"
@ -51,7 +48,7 @@ class TestCout : public std::stringstream
using namespace std;
/* xxd -i est-komodo/data/asmap.raw | sed 's/unsigned char/static unsigned const char/g' */
/* xxd -i test-hush/data/asmap.raw | sed 's/unsigned char/static unsigned const char/g' */
static unsigned const char asmap_raw[] = {
0xfb, 0x03, 0xec, 0x0f, 0xb0, 0x3f, 0xc0, 0xfe, 0x00, 0xfb, 0x03, 0xec,
0x0f, 0xb0, 0x3f, 0xc0, 0xfe, 0x00, 0xfb, 0x03, 0xec, 0x0f, 0xb0, 0xff,

8
src/test-hush/test_eval_notarization.cpp

@ -3,7 +3,6 @@
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#include <cryptoconditions.h>
#include <gtest/gtest.h>
#include "cc/betprotocol.h"
#include "cc/eval.h"
#include "base58.h"
@ -14,16 +13,12 @@
#include "primitives/transaction.h"
#include "script/interpreter.h"
#include "script/serverchecker.h"
#include "testutils.h"
extern int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
namespace TestEvalNotarization {
class EvalMock : public Eval
{
public:
@ -86,7 +81,6 @@ namespace TestEvalNotarization {
}
// https://kmd.explorer.supernet.org/tx/5b8055d37cff745a404d1ae45e21ffdba62da7b28ed6533c67468d7379b20bae
// inputs have been dropped
static auto rawNotaryTx = "01000000000290460100000000002321020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9ac0000000000000000506a4c4dae8e0f3e6e5de498a072f5967f3c418c4faba5d56ac8ce17f472d029ef3000008f2e0100424f545300050ba773f0bc31da5839fc7cb9bd7b87f3b765ca608e5cf66785a466659b28880500000000000000";
CTransaction notaryTx;
@ -201,6 +195,4 @@ TEST(TestEvalNotarization, testInvalidNotarizationInputNotCheckSig)
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
}
} /* namespace TestEvalNotarization */

5
src/test-hush/test_parse_notarization.cpp

@ -2,14 +2,11 @@
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#include <gtest/gtest.h>
#include "cc/eval.h"
#include "core_io.h"
#include "key.h"
#include "testutils.h"
namespace TestParseNotarization {
class TestParseNotarization : public ::testing::Test, public Eval {};
@ -52,6 +49,6 @@ TEST(TestParseNotarization, test__b)
// for l in `g 'parse notarisation' ~/.komodo/debug.log | pyline 'l.split()[8]'`; do hoek decodeTx '{"hex":"'`src/komodo-cli getrawtransaction "$l"`'"}' | jq '.outputs[1].script.op_return' | pyline 'import base64; print base64.b64decode(l).encode("hex")'; done
// for l in `g 'parse notarisation' ~/.hush/HUSH3/debug.log | pyline 'l.split()[8]'`; do hoek decodeTx '{"hex":"'`src/hush-cli getrawtransaction "$l"`'"}' | jq '.outputs[1].script.op_return' | pyline 'import base64; print base64.b64decode(l).encode("hex")'; done
}

17
src/tush-cli

@ -0,0 +1,17 @@
#!/bin/bash
# Copyright (c) 2016-2021 The Hush developers
# set working directory to the location of this script
# readlink -f does not always exist
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )"
cd $DIR
NAME=TUSH
# Use the HUSHCLI env var to over-ride using the same directory as this file
CLI=${HUSHCLI:-./hush-cli}
if [ -f $CLI ]; then
$CLI -ac_name=$NAME "$@"
fi

15
src/tushd

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Copyright (c) 2016-2021 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
# set working directory to the location of this script
# readlink -f does not always exist
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )"
cd $DIR
# ./hushd -ac_name=TUSH -ac_private=1 -gen=1 -testnode=1
./hushd -ac_name=TUSH -ac_private=1 -ac_supply=55555

23
src/txdb.cpp

@ -429,23 +429,8 @@ bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &addr
uint32_t hush_segid32(char *coinaddr);
#define DECLARE_IGNORELIST std::map <std::string,int> ignoredMap = { \
{"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, \
{"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, \
{"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, \
{"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, \
{"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, \
{"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, \
{"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, \
{"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, \
{"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, \
{"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, \
{"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, \
{"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, \
{"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, \
{"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, \
{"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, \
{"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, \
{"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} \
{"RUeUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, \
{"R2d2gnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} \
};
bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, UniValue *ret)
@ -662,7 +647,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
return true;
}
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
void hush_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
bool CBlockTreeDB::blockOnchainActive(const uint256 &hash) {
BlockMap::const_iterator it = mapBlockIndex.find(hash);
@ -738,7 +723,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
if ( 0 ) // POW will be checked before any block is connected
{
uint8_t pubkey33[33];
komodo_index2pubkey33(pubkey33,pindexNew,pindexNew->GetHeight());
hush_index2pubkey33(pubkey33,pindexNew,pindexNew->GetHeight());
if (!CheckProofOfWork(header,pubkey33,pindexNew->GetHeight(),Params().GetConsensus()))
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
}

14
src/txmempool.cpp

@ -487,21 +487,7 @@ std::vector<uint256> CTxMemPool::removeExpired(unsigned int nBlockHeight)
// Remove expired txs from the mempool
LOCK(cs);
list<CTransaction> transactionsToRemove;
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++)
{
const CTransaction& tx = it->GetTx();
tipindex = chainActive.LastTip();
/*
bool fInterestNotValidated = SMART_CHAIN_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,0) < 0;
if (IsExpiredTx(tx, nBlockHeight) || fInterestNotValidated)
{
if (fInterestNotValidated && tipindex != 0)
LogPrintf("Removing interest violate txid.%s nHeight.%d nTime.%u vs locktime.%u\n",tx.GetHash().ToString(),tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,tx.nLockTime);
transactionsToRemove.push_back(tx);
}
*/
}
std::vector<uint256> ids;
for (const CTransaction& tx : transactionsToRemove) {
list<CTransaction> removed;

100
src/util.cpp

@ -497,17 +497,42 @@ boost::filesystem::path GetDefaultDataDir()
if ( SMART_CHAIN_SYMBOL[0] != 0 )
strcpy(symbol,SMART_CHAIN_SYMBOL);
else symbol[0] = 0;
// OLD NAMES:
// Windows < Vista: C:\Documents and Settings\Username\Application Data\Komodo
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Komodo
// Mac: ~/Library/Application Support/Komodo
// Unix: ~/.komodo
// NEW NAMES:
// Windows < Vista: C:\Documents and Settings\Username\Application Data\Hush
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Hush
// Mac: ~/Library/Application Support/Hush
// Unix: ~/.hush
// ~/.hush was actually used by the original 1.x version of Hush, but we will
// only make subdirectories inside of it, so we won't be able to overwrite
// an old wallet.dat from the Ice Ages :)
fs::path pathRet;
#ifdef _WIN32
// Windows
if ( symbol[0] == 0 )
return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo";
else return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / symbol;
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Hush" / symbol;
// Always use .hush/HUSH3, if it exists (even if .komodo/HUSH3 exists)
if(fs::is_directory(pathRet)) {
return pathRet;
} else {
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / symbol;
if(fs::is_directory(pathRet)) {
// existing legacy directory, use that for backward compat
return pathRet;
} else {
// For new clones, use Hush/HUSH3
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Hush" / symbol;
return pathRet;
}
}
return pathRet;
#else
fs::path pathRet;
char* pszHome = getenv("HOME");
if (pszHome == NULL || strlen(pszHome) == 0)
pathRet = fs::path("/");
@ -517,19 +542,49 @@ boost::filesystem::path GetDefaultDataDir()
// Mac
pathRet /= "Library/Application Support";
TryCreateDirectory(pathRet);
if ( symbol[0] == 0 )
return pathRet / "Komodo";
else
{
pathRet /= "Komodo";
TryCreateDirectory(pathRet);
return pathRet / symbol;
fs::path tmppath;
tmppath = pathRet;
tmppath /= "Hush";
// create Library/Application Support/Hush if it doesn't exist
TryCreateDirectory(tmppath);
// Always use Hush/HUSH3 if it exists
if(fs::is_directory(tmppath / symbol)) {
return tmppath / symbol;
} else {
// Check for legacy dir
tmppath = pathRet;
tmppath /= "Komodo";
//TryCreateDirectory(tmppath);
if(fs::is_directory( tmppath / symbol) {
// Found legacy dir, use that
return tmppath / symbol;
} else {
// For new clones, use Hush/HUSH3
tmppath = pathRet / "Hush" / HUSH3;
}
return tmppath;
}
#else
// Unix
if ( symbol[0] == 0 )
return pathRet / ".komodo";
else return pathRet / ".komodo" / symbol;
// New directory :)
fs::path tmppath = pathRet / ".hush" / symbol;
// Always use .hush/HUSH3, if it exists (even if .komodo/HUSH3 exists)
if(fs::is_directory(tmppath)) {
return tmppath;
} else {
// This is the legacy location
tmppath = pathRet / ".komodo" / symbol;
if(fs::is_directory(tmppath)) {
// existing legacy directory, use that for backward compat
return tmppath;
} else {
// For new clones, use .hush/HUSH3
tmppath = pathRet / ".hush" / symbol;
}
return tmppath;
}
#endif
#endif
}
@ -638,8 +693,6 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
path /= BaseParams().DataDir();
fs::create_directories(path);
//std::string assetpath = path + "/assets";
//boost::filesystem::create_directory(assetpath);
return path;
}
@ -652,15 +705,10 @@ void ClearDatadirCache()
boost::filesystem::path GetConfigFile()
{
char confname[512];
if ( SMART_CHAIN_SYMBOL[0] != 0 )
if ( SMART_CHAIN_SYMBOL[0] != 0 ) {
sprintf(confname,"%s.conf",SMART_CHAIN_SYMBOL);
else
{
#ifdef __APPLE__
strcpy(confname,"Komodo.conf");
#else
strcpy(confname,"komodo.conf");
#endif
} else {
strcpy(confname,"HUSH3.conf");
}
boost::filesystem::path pathConfigFile(GetArg("-conf",confname));
if (!pathConfigFile.is_complete())
@ -674,14 +722,14 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
{
boost::filesystem::ifstream streamConfig(GetConfigFile());
if (!streamConfig.good())
throw missing_zcash_conf();
throw missing_hush_conf();
set<string> setOptions;
setOptions.insert("*");
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
{
// Don't overwrite existing settings so command line settings override komodo.conf
// Don't overwrite existing settings so command line settings override HUSH3.conf
string strKey = string("-") + it->string_key;
if (mapSettingsRet.count(strKey) == 0)
{

4
src/util.h

@ -145,9 +145,9 @@ boost::filesystem::path GetConfigFile();
boost::filesystem::path GetPidFile();
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
class missing_zcash_conf : public std::runtime_error {
class missing_hush_conf : public std::runtime_error {
public:
missing_zcash_conf() : std::runtime_error("Missing komodo.conf") { }
missing_hush_conf() : std::runtime_error(strprintf("Missing %s",GetConfigFile().string() )) { }
};
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef _WIN32

2
src/validationinterface.h

@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2016-2021 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
@ -7,7 +8,6 @@
#define HUSH_VALIDATIONINTERFACE_H
#include <boost/signals2/signal.hpp>
#include "zcash/IncrementalMerkleTree.hpp"
class CBlock;

2
src/version.h

@ -21,7 +21,7 @@
#define HUSH_VERSION_H
// network protocol versioning
static const int PROTOCOL_VERSION = 1987423;
static const int PROTOCOL_VERSION = 1987424;
//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
//! In this version, 'getheaders' was introduced.

2
src/wallet-utility.cpp

@ -13,7 +13,7 @@
char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
int64_t MAX_MONEY = 200000000 * 100000000LL;
uint64_t ASSETCHAINS_SUPPLY;
uint16_t BITCOIND_RPCPORT = 7771;
uint16_t BITCOIND_RPCPORT = 18031;
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC;
uint32_t ASSETCHAINS_MAGIC = 2387029918;

2
src/wallet/asyncrpcoperation_sendmany.cpp

@ -194,9 +194,11 @@ bool AsyncRPCOperation_sendmany::main_impl() {
assert(isfromtaddr_ != isfromzaddr_);
/* TODO: this needs to allow DPoW addresses. Consensus-time checks do it correctly.
if(t_outputs_.size() > 0) {
throw JSONRPCError(RPC_WALLET_ERROR, "Extreme Privacy! You cannot send to a transparent address.");
}
*/
bool isSingleZaddrOutput = (t_outputs_.size()==0 && z_outputs_.size()==1);
bool isMultipleZaddrOutput = (t_outputs_.size()==0 && z_outputs_.size()>=1);

11
src/wallet/crypter.cpp

@ -2,7 +2,6 @@
// Copyright (c) 2016-2021 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -17,17 +16,21 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#include "crypter.h"
#include "script/script.h"
#include "script/standard.h"
#include "streams.h"
#include "util.h"
#include <string>
#include <vector>
#include <boost/foreach.hpp>
// TODO: these are not set correctly by wolfssl for some reason. Ja bless.
#undef ECC_TIMING_RESISTANT
#undef TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT 420
#define TFM_TIMING_RESISTANT 420
#undef WC_RSA_BLINDING
#define WC_RSA_BLINDING
#include <wolfssl/openssl/aes.h>
#include <wolfssl/openssl/evp.h>

8
src/wallet/db.cpp

@ -1,8 +1,8 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2016-2021 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -19,13 +19,11 @@
******************************************************************************/
#include "db.h"
#include "addrman.h"
#include "hash.h"
#include "protocol.h"
#include "util.h"
#include "utilstrencodings.h"
#include <stdint.h>
#ifndef _WIN32
@ -38,13 +36,9 @@
using namespace std;
unsigned int nWalletDBUpdated;
//
// CDB
//
CDBEnv bitdb;

104
src/wallet/rpcwallet.cpp

@ -423,6 +423,35 @@ UniValue getaccount(const UniValue& params, bool fHelp, const CPubKey& mypk)
return strAccount;
}
UniValue listaddresses(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() != 0)
throw runtime_error(
"listaddresses\n"
"\nResult:\n"
"[ (json array of string)\n"
" \"" + strprintf("%s",hush_chainname()) + "_address\" (string) a " + strprintf("%s",hush_chainname()) + " address\n"
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("listaddresses", "")
+ HelpExampleRpc("listaddresses", "")
);
LOCK2(cs_main, pwalletMain->cs_wallet);
// Find all taddrs
UniValue ret(UniValue::VARR);
for (const std::pair<CTxDestination, CAddressBookData>& item : pwalletMain->mapAddressBook) {
const CTxDestination& dest = item.first;
const std::string& strName = item.second.name;
ret.push_back(EncodeDestination(dest));
}
return ret;
}
UniValue getaddressesbyaccount(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
@ -441,8 +470,8 @@ UniValue getaddressesbyaccount(const UniValue& params, bool fHelp, const CPubKey
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressesbyaccount", "\"tabby\"")
+ HelpExampleRpc("getaddressesbyaccount", "\"tabby\"")
+ HelpExampleCli("getaddressesbyaccount", "\"\"")
+ HelpExampleRpc("getaddressesbyaccount", "\"\"")
);
LOCK2(cs_main, pwalletMain->cs_wallet);
@ -579,25 +608,25 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
#define HUSH_KVDURATION 1440
#define DRAGON_MAXSCRIPTSIZE 10001
uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
int32_t hush_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
extern int32_t HUSH_PAX;
int32_t komodo_is_issuer();
int32_t hush_is_issuer();
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t komodo_isrealtime(int32_t *kmdheightp);
int32_t hush_isrealtime(int32_t *hushheightp);
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base);
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize);
uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen);
uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey);
int32_t komodo_kvduration(uint32_t flags);
uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase);
int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig);
int32_t hush_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
int32_t hush_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize);
uint64_t hush_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen);
uint256 hush_kvsig(uint8_t *buf,int32_t len,uint256 privkey);
int32_t hush_kvduration(uint32_t flags);
uint256 hush_kvprivkey(uint256 *pubkeyp,char *passphrase);
int32_t hush_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig);
UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
static uint256 zeroes;
CWalletTx wtx; UniValue ret(UniValue::VOBJ);
uint8_t keyvalue[DRAGON_MAXSCRIPTSIZE*8],opretbuf[DRAGON_MAXSCRIPTSIZE*8]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct komodo_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig;
uint8_t keyvalue[DRAGON_MAXSCRIPTSIZE*8],opretbuf[DRAGON_MAXSCRIPTSIZE*8]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct hush_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig;
if (fHelp || params.size() < 3 )
throw runtime_error(
"kvupdate key \"value\" days passphrase\n"
@ -639,7 +668,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
//printf("flags.%d (%s) n.%d\n",flags,params[2].get_str().c_str(),n);
} else flags = 0;
if ( n >= 4 )
privkey = komodo_kvprivkey(&pubkey,(char *)(n >= 4 ? params[3].get_str().c_str() : "password"));
privkey = hush_kvprivkey(&pubkey,(char *)(n >= 4 ? params[3].get_str().c_str() : "password"));
haveprivkey = 1;
flags |= 1;
/*for (i=0; i<32; i++)
@ -659,7 +688,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
valuesize = (int32_t)strlen(params[1].get_str().c_str());
}
memcpy(keyvalue,key,keylen);
if ( (refvaluesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 )
if ( (refvaluesize= hush_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 )
{
if ( (tmpflags & HUSH_KVPROTECTED) != 0 )
{
@ -671,8 +700,8 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
}
if ( keylen+refvaluesize <= sizeof(keyvalue) )
{
sig = komodo_kvsig(keyvalue,keylen+refvaluesize,privkey);
if ( komodo_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 )
sig = hush_kvsig(keyvalue,keylen+refvaluesize,privkey);
if ( hush_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 )
{
ret.push_back(Pair("error",(char *)"error verifying sig, passphrase is probably wrong"));
printf("VERIFY ERROR\n");
@ -683,12 +712,12 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
//for (i=0; i<32; i++)
// printf("%02x",((uint8_t *)&sig)[i]);
//printf(" sig for keylen.%d + valuesize.%d\n",keylen,refvaluesize);
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "KMD" : SMART_CHAIN_SYMBOL)));
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH3" : SMART_CHAIN_SYMBOL)));
height = chainActive.LastTip()->GetHeight();
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
ret.push_back(Pair("owner",refpubkey.GetHex()));
ret.push_back(Pair("height", (int64_t)height));
duration = komodo_kvduration(flags); //((flags >> 2) + 1) * HUSH_KVDURATION;
duration = hush_kvduration(flags); //((flags >> 2) + 1) * HUSH_KVDURATION;
ret.push_back(Pair("expiration", (int64_t)(height+duration)));
ret.push_back(Pair("flags",(int64_t)flags));
ret.push_back(Pair("key",params[0].get_str()));
@ -718,13 +747,13 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
coresize += 32;
}
}
if ( (opretlen= komodo_opreturnscript(opretbuf,'K',keyvalue,coresize)) == 40 )
if ( (opretlen= hush_opreturnscript(opretbuf,'K',keyvalue,coresize)) == 40 )
opretlen++;
//for (i=0; i<opretlen; i++)
// printf("%02x",opretbuf[i]);
//printf(" opretbuf keylen.%d valuesize.%d height.%d (%02x %02x %02x)\n",*(uint16_t *)&keyvalue[0],*(uint16_t *)&keyvalue[2],*(uint32_t *)&keyvalue[4],keyvalue[8],keyvalue[9],keyvalue[10]);
EnsureWalletIsUnlocked();
fee = komodo_kvfee(flags,opretlen,keylen);
fee = hush_kvfee(flags,opretlen,keylen);
ret.push_back(Pair("fee",(double)fee/COIN));
CBitcoinAddress destaddress(CRYPTO555_HUSHADDR);
if (!destaddress.IsValid())
@ -737,13 +766,13 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,komodoshis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33];
uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,puposhis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33];
bool fSubtractFeeFromAmount = false;
if ( HUSH_PAX == 0 )
{
throw runtime_error("paxdeposit disabled without -pax");
}
if ( komodo_is_issuer() != 0 )
if ( hush_is_issuer() != 0 )
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "paxdeposit only from KYC");
if (!EnsureWalletIsAvailable(fHelp))
throw runtime_error("paxdeposit needs wallet"); //return Value::null;
@ -762,28 +791,28 @@ UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk)
fprintf(stderr,"available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis);
throw runtime_error("paxdeposit not enough available inventory");
}
komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis);
puposhis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis);
dest.append(destaddr);
CBitcoinAddress destaddress(CRYPTO555_HUSHADDR);
if (!destaddress.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address");
for (i=0; i<33; i++)
fprintf(stderr,"%02x",pubkey37[i]);
fprintf(stderr," ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed);
fprintf(stderr," ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) puposhis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)puposhis,(long long)seed);
EnsureWalletIsUnlocked();
CWalletTx wtx;
uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = komodoshis / 1000;
uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = puposhis / 1000;
if ( fee < 10000 )
fee = 10000;
dragon_rwnum(1,&pubkey37[33],sizeof(height),&height);
opretlen = komodo_opreturnscript(opretbuf,'D',pubkey37,37);
SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,komodoshis);
opretlen = hush_opreturnscript(opretbuf,'D',pubkey37,37);
SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,puposhis);
return wtx.GetHash().GetHex();
}
UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
CWalletTx wtx; std::string dest; int32_t kmdheight; uint64_t seed,komodoshis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false;
CWalletTx wtx; std::string dest; int32_t hushheight; uint64_t seed,puposhis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false;
if ( SMART_CHAIN_SYMBOL[0] == 0 )
return(0);
if (!EnsureWalletIsAvailable(fHelp))
@ -791,27 +820,27 @@ UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk)
throw runtime_error("paxwithdraw deprecated");
if (fHelp || params.size() != 2)
throw runtime_error("paxwithdraw address fiatamount");
if ( komodo_isrealtime(&kmdheight) == 0 )
if ( hush_isrealtime(&hushheight) == 0 )
return(0);
LOCK2(cs_main, pwalletMain->cs_wallet);
CBitcoinAddress address(params[0].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN;
komodoshis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),kmdheight,SMART_CHAIN_SYMBOL,fiatoshis);
puposhis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),hushheight,SMART_CHAIN_SYMBOL,fiatoshis);
dest.append(destaddr);
CBitcoinAddress destaddress(CRYPTO555_HUSHADDR);
if (!destaddress.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address");
for (i=0; i<33; i++)
printf("%02x",pubkey37[i]);
printf(" kmdheight.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",kmdheight,(char *)params[0].get_str().c_str(),SMART_CHAIN_SYMBOL,(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed);
printf(" hushheight.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) puposhis.%llu seed.%llx\n",hushheight,(char *)params[0].get_str().c_str(),SMART_CHAIN_SYMBOL,(long long)fiatoshis,destaddr,(long long)puposhis,(long long)seed);
EnsureWalletIsUnlocked();
uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = fiatoshis / 1000;
if ( fee < 10000 )
fee = 10000;
dragon_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight);
opretlen = komodo_opreturnscript(opretbuf,'W',pubkey37,37);
dragon_rwnum(1,&pubkey37[33],sizeof(hushheight),&hushheight);
opretlen = hush_opreturnscript(opretbuf,'W',pubkey37,37);
SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis);
return wtx.GetHash().GetHex();
}
@ -4996,8 +5025,8 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
"\nShield transparent coinbase funds by sending to a shielded zaddr. This is an asynchronous operation and utxos"
"\nselected for shielding will be locked. If there is an error, they are unlocked. The RPC call `listlockunspent`"
"\ncan be used to return a list of locked utxos. The number of coinbase utxos selected for shielding can be limited"
"\nby the caller. If the limit parameter is set to zero, and Overwinter is not yet active, the -mempooltxinputlimit"
"\noption will determine the number of uxtos. Any limit is constrained by the consensus rule defining a maximum"
"\nby the caller. If the limit parameter is set to zero, as many as will fit will be used."
"\nAny limit is constrained by the consensus rule defining a maximum"
"\ntransaction size of " + strprintf("%d bytes.", MAX_TX_SIZE_AFTER_SAPLING)
+ HelpRequiringPassphrase() + "\n"
"\nArguments:\n"
@ -5006,7 +5035,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
"3. fee (numeric, optional, default="
+ strprintf("%s", FormatMoney(SHIELD_COINBASE_DEFAULT_MINERS_FEE)) + ") The fee amount to attach to this transaction.\n"
"4. limit (numeric, optional, default="
+ strprintf("%d", SHIELD_COINBASE_DEFAULT_LIMIT) + ") Limit on the maximum number of utxos to shield. Set to 0 to use node option -mempooltxinputlimit (before Overwinter), or as many as will fit in the transaction (after Overwinter).\n"
+ strprintf("%d", SHIELD_COINBASE_DEFAULT_LIMIT) + ") Limit on the maximum number of utxos to shield. Set to 0 to use as many as will fit in the transaction.\n"
"\nResult:\n"
"{\n"
" \"remainingUTXOs\": xxx (numeric) Number of coinbase utxos still available for shielding.\n"
@ -8277,6 +8306,7 @@ static const CRPCCommand commands[] =
{ "wallet", "getaccount", &getaccount, true },
{ "wallet", "getalldata", &getalldata, true },
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
{ "wallet", "listaddresses", &listaddresses , true },
{ "wallet", "getbalance", &getbalance, false },
{ "wallet", "getnewaddress", &getnewaddress, true },
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, true },

2
src/wallet/test/wallet_tests.cpp

@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet,0));
BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount
// run the 'mtgox' test (see http://blockexplorer.com/tx/29a3efd3ef04f9153d47a990bd7b048a4b2d213daaa5fb8ed670fb85f13bdbcf)
// run the 'mtgox' test
// they tried to consolidate 10 50k coins into one 500k coin, and ended up with 50k in change
empty_wallet();
for (int i = 0; i < 20; i++)

11
src/wallet/wallet.cpp

@ -2717,10 +2717,12 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
CBlock block;
bool involvesMe = false;
ReadBlockFromDisk(block, pindex,1);
BOOST_FOREACH(CTransaction& tx, block.vtx)
{
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) {
involvesMe = true;
ret++;
}
}
@ -2734,8 +2736,11 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
}
}
// Build initial witness caches
BuildWitnessCache(pindex, true);
// Build initial witness caches for blocks involving one of our addresses
if (involvesMe) {
LogPrintf("%s: block has one of our transactions, building witness cache\n", __func__);
BuildWitnessCache(pindex, true);
}
//Delete Transactions
if (fTxDeleteEnabled) {
@ -3056,7 +3061,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
if ( (wtx.nLockTime >= LOCKTIME_THRESHOLD && wtx.nLockTime < now-HUSH_MAXMEMPOOLTIME) )
{
//LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", wtx.GetHash().ToString(),(uint32_t)wtx.nLockTime,now);
LogPrintf("%s: skip Relaying wtx %s nLockTime %u vs now.%u\n", __func__, wtx.GetHash().ToString(),(uint32_t)wtx.nLockTime,now);
//vwtxh.push_back(wtx.GetHash());
continue;
}

2
src/wallet/walletdb.cpp

@ -441,7 +441,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
ssValue >> wtx;
CValidationState state;
auto verifier = libzcash::ProofVerifier::Strict();
// ac_public chains set at height like KMD and ZEX, will force a rescan if we dont ignore this error: bad-txns-acpublic-chain
// ac_public chains which enable at a certain height instead of from genesis, this will force a rescan if we dont ignore this error: bad-txns-acpublic-chain
// there cannot be any ztx in the wallet on ac_public chains that started from block 1, so this wont affect those.
// ac_private chains fail this check for notary nodes, need exception. Triggers full rescan without it.
if ( !(CheckTransaction(0,wtx, state, verifier, 0, 0) && (wtx.GetHash() == hash) && state.IsValid()) && (state.GetRejectReason() != "bad-txns-acpublic-chain" && state.GetRejectReason() != "bad-txns-acprivacy-chain" && state.GetRejectReason() != "bad-txns-stakingtx") )

2
src/zcash/JoinSplit.cpp

@ -4,10 +4,8 @@
#include "JoinSplit.hpp"
#include "prf.h"
#include "sodium.h"
#include <memory>
#include <fstream>
#include "librustzcash.h"
namespace libzcash {

7
src/zush

@ -10,12 +10,7 @@ cd $DIR
NAME=ZUSH
CLI=${KOMODOCLI:-./komodo-cli}
CLI=${HUSHCLI:-./hush-cli}
if [ -f $CLI ]; then
$CLI -ac_name=$NAME "$@"
else
# We prefix our binary when installed
# system wide on Debain system, to prevent clashes
CLI=hush-komodo-cli
$CLI -ac_name=$NAME "$@"
fi

1
zcutil/build-debian-package.sh

@ -57,6 +57,7 @@ strip $DEB_BIN/hush-komodo-tx
cp $SRC_PATH/src/hushd $DEB_BIN
cp $SRC_PATH/src/hush-cli $DEB_BIN
cp $SRC_PATH/src/hush-tx $DEB_BIN
cp $SRC_PATH/src/hush-smart-chain $DEB_BIN
#cp $SRC_DEB/changelog $DEB_DOC/changelog.Debian
cp $SRC_DEB/copyright $DEB_DOC
cp -r $SRC_DEB/examples $DEB_DOC

Loading…
Cancel
Save