diff --git a/.gitignore b/.gitignore index 408d59085..03f81cc82 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.deb src/bitcoin src/test/test_bitcoin +src/core *zcashTest.pk *zcashTest.vk @@ -156,7 +157,9 @@ src/Makefile.in doc/man/Makefile.in Makefile.in src/libcc.so +src/libcc.dll src/cc/customcc.so +src/cc/customcc.dll src/HUSH3_7776 REGTEST_7776 src/cc/librogue.so diff --git a/COPYING b/COPYING index a03819aee..768d77b05 100644 --- a/COPYING +++ b/COPYING @@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -The MIT software license (http://www.opensource.org/licenses/mit-license.php) +The MIT software license (https://www.opensource.org/licenses/mit-license.php) above applies to the code directly included in this source distribution. Dependencies downloaded as part of the build process may be covered by other open-source licenses. For further details see 'contrib/debian/copyright'. diff --git a/configure.ac b/configure.ac index e3be0c9dd..eb515e59d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,9 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 3) -define(_CLIENT_VERSION_MINOR, 4) +define(_CLIENT_VERSION_MINOR, 5) define(_CLIENT_VERSION_REVISION, 0) -define(_CLIENT_VERSION_BUILD, 50) +define(_CLIENT_VERSION_BUILD, 5) 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))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) define(_CLIENT_VERSION_IS_RELEASE, true) @@ -96,12 +96,6 @@ AC_ARG_ENABLE([mining], [enable_mining=$enableval], [enable_mining=yes]) -AC_ARG_ENABLE([proton], - [AS_HELP_STRING([--disable-proton], - [disable Proton (AMQP messaging)])], - [use_proton=$enableval], - [use_proton=yes]) - AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[compile tests (default is yes)]), [use_tests=$enableval], @@ -507,15 +501,24 @@ if test x$use_hardening != xno; then HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2" ],[AC_MSG_ERROR(Cannot enable -D_FORTIFY_SOURCE=2)]) - #AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) - #AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) + if test x$BUILD_OS = xdarwin || test x$TARGET_OS = xwindows; then + # Xcode's ld (at least ld64-302.3) doesn't support -z + # mingw-w64's ld (at least mingw-w64 4.0.4-2) also appears to not support -z + AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_WARN(Cannot enable RELRO)]) + AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_WARN(Cannot enable BIND_NOW)]) + else + AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) + AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) + fi if test x$TARGET_OS != xwindows; then # All windows code is PIC, forcing it on just adds useless compile warnings - AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) - AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) - AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"],[AC_MSG_ERROR(Cannot enable -fPIE)]) - AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_ERROR(Cannot enable -pie)]) + AX_CHECK_COMPILE_FLAG([-fPIE],[PIE_FLAGS="-fPIE"],[AC_MSG_ERROR(Cannot enable -fPIE)]) + if test x$BUILD_OS = xdarwin; then + AX_CHECK_LINK_FLAG([[-Wl,-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-pie"],[AC_MSG_ERROR(Cannot enable -Wl,-pie)]) + else + AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_ERROR(Cannot enable -pie)]) + fi else # These are only available on Windows. AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"],[AC_MSG_ERROR(Cannot enable --dynamicbase)]) @@ -596,23 +599,6 @@ if test x$enable_wallet != xno; then BITCOIN_FIND_BDB62 fi -dnl Check Qpid Proton headers and library exist -if test x$use_proton = xyes; then - AC_CHECK_HEADERS([proton/connection.hpp], - [], - [AC_MSG_WARN([Proton headers not found, disabling Proton support]) - use_proton=no]) - AC_CHECK_LIB([qpid-proton-cpp], [main], - [PROTON_LIBS="-lqpid-proton-cpp -lqpid-proton"], - [AC_MSG_WARN([Proton libraries not found, disabling Proton support]) - use_proton=no]) -fi -if test x$use_proton = xyes; then - AC_DEFINE(ENABLE_PROTON, 1, [Define to 1 to enable Proton functions]) -else - AC_DEFINE(ENABLE_PROTON, 0, [Define to 1 to enable Proton functions]) -fi - if test x$build_bitcoin_utils$build_bitcoind$use_tests = xnonono; then use_boost=no else @@ -756,6 +742,14 @@ fi fi fi +# These packages don't provide pkgconfig config files across all +# platforms, so we use older autoconf detection mechanisms: +AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing)) +AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)]) + +AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing)) +AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)]) + RUST_LIBS="-lrustzcash" case $host in *mingw*) @@ -832,8 +826,6 @@ fi AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"]) -AM_CONDITIONAL([ENABLE_PROTON], [test "x$use_proton" = "xyes"]) - AC_MSG_CHECKING([whether to build test_bitcoin]) if test x$use_tests = xyes; then AC_MSG_RESULT([yes]) @@ -906,7 +898,6 @@ AC_SUBST(ZMQ_LIBS) AC_SUBST(GMP_LIBS) AC_SUBST(GMPXX_LIBS) AC_SUBST(LIBZCASH_LIBS) -AC_SUBST(PROTON_LIBS) AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile src/test/buildenv.py]) AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh]) AC_CONFIG_FILES([qa/pull-tester/tests-config.sh],[chmod +x qa/pull-tester/tests-config.sh]) @@ -953,7 +944,6 @@ esac echo echo "Options used to compile and link:" echo " with wallet = $enable_wallet" -echo " with proton = $use_proton" echo " with zmq = $use_zmq" echo " with test = $use_tests" echo " debug enabled = $enable_debug" diff --git a/contrib/amqp/amqp_sub.py b/contrib/amqp/amqp_sub.py deleted file mode 100644 index bc51e8428..000000000 --- a/contrib/amqp/amqp_sub.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python2 -# Copyright (c) 2017 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -# Requirements: -# pip install python-qpid-proton - -import binascii -from proton.handlers import MessagingHandler -from proton.reactor import Container - -port = 5672 - -class Server(MessagingHandler): - def __init__(self, url): - super(Server, self).__init__() - self.url = url - self.senders = {} - - def on_start(self, event): - print "Listening on:", self.url - self.container = event.container - self.acceptor = event.container.listen(self.url) - - def on_message(self, event): - m = event.message - topic = m.subject - body = m.body - sequence = str( m.properties['x-opt-sequence-number'] ) - if topic == "hashablock": - print '- HASH BLOCK ('+sequence+') -' - print binascii.hexlify(body) - elif topic == "hashtx": - print '- HASH TX ('+sequence+') -' - print binascii.hexlify(body) - elif topic == "rawblock": - print '- RAW BLOCK HEADER ('+sequence+') -' - print binascii.hexlify(body[:80]) - elif topic == "rawtx": - print '- RAW TX ('+sequence+') -' - print binascii.hexlify(body) - -try: - Container(Server("127.0.0.1:%i" % port)).run() -except KeyboardInterrupt: - pass - diff --git a/contrib/checkpoints.pl b/contrib/checkpoints.pl index 99a84f2c2..bf11a8f7f 100755 --- a/contrib/checkpoints.pl +++ b/contrib/checkpoints.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright 2019 The Hush developers +# Copyright 2019-2020 The Hush developers # Released under the GPLv3 use warnings; use strict; @@ -9,9 +9,13 @@ use strict; my $perday = 576; my $hush = "./src/hush-cli"; my $gethash = "$hush getblockhash"; -my $stride = shift || 1000; +my $stride = shift || 5000; my $count = 0; my $blocks = qx{$hush getblockcount}; +if($?) { + print "ERROR, exiting...\n"; + exit 1; +} my $prev = $blocks - $perday; my $last = 0; my $now = time(); @@ -53,4 +57,4 @@ if ($line1 =~ m/tx=(\d+)/) { } print "(int64_t) $time, // time of last checkpointed block\n"; print "(int64_t) $total_txs, // total txs\n"; -print "(double) $txs_per_day, // txs in the last day before block $blocks\n"; +print "(double) $txs_per_day // txs in the last day before block $blocks\n"; diff --git a/contrib/debian/copyright b/contrib/debian/copyright index 9371b7022..2f51f4a4c 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -52,10 +52,6 @@ Files: depends/sources/google*.tar.gz Copyright: 2008 Google Inc. License: BSD-3clause-Google -Files: depends/sources/qpid-proton-*.tar.gz -Copyright: 2012-2017 The Apache Software Foundation -License: Apache-Qpid-Proton-with-BSD-Subcomponents - Files: src/secp256k1/build-aux/m4/ax_jni_include_dir.m4 Copyright: 2008 Don Anderson License: GNU-All-permissive-License @@ -1101,222 +1097,6 @@ Comment: You should have received a copy of the GNU General Public License along with this program. If not, see . -License: Apache-Qpid-Proton-with-BSD-Subcomponents - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - . - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - . - 1. Definitions. - . - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - . - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - . - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - . - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - . - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - . - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - . - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - . - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - . - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - . - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - . - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - . - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - . - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - . - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - . - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - . - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - . - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - . - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - . - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - . - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - . - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - . - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - . - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - . - END OF TERMS AND CONDITIONS - . - APPENDIX: How to apply the Apache License to your work. - . - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - . - Copyright [yyyy] [name of copyright owner] - . - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - . - http://www.apache.org/licenses/LICENSE-2.0 - . - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - . - . - PROTON SUBCOMPONENTS: - . - Proton includes freegetopt with a separate BSD license. Your use - of the source code for freegetopt is subject to the terms and - conditions of its license in examples/include/pncompat/internal/LICENSE. - . - The setup scripts for the python bindings include files derived by - PyZMQ and are licensed with a separate Modified BSD license. Use of - the source code in these setup files are subject to the terms and - conditions in the license: - proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD. - License: GNU-All-permissive-License Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py index 52b48ef74..4dfffbbe9 100755 --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Copyright (c) 2014 Wladimir J. van der Laan # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php ''' A script to check that the (Linux) executables produced by gitian only contain allowed gcc, glibc and libstdc++ version symbols. This makes sure they are diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index c619cf270..317bd8694 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -85,7 +85,7 @@ script: | BASEPREFIX=`pwd`/depends # Build dependencies for each host for i in $HOSTS; do - NO_PROTON="x" make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" + make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" done # Faketime for binaries diff --git a/contrib/hush-cli.bash-completion b/contrib/hush-cli.bash-completion index 32cfe6b22..539ba8885 100644 --- a/contrib/hush-cli.bash-completion +++ b/contrib/hush-cli.bash-completion @@ -2,7 +2,7 @@ # Copyright (c) 2012-2016 The Bitcoin Core developers # Copyright (c) 2018 The Hush developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # call $hush-cli for RPC _hush_rpc() { diff --git a/contrib/hush-tx.bash-completion b/contrib/hush-tx.bash-completion index d43d0cba3..de151bcfb 100644 --- a/contrib/hush-tx.bash-completion +++ b/contrib/hush-tx.bash-completion @@ -1,7 +1,7 @@ # bash programmable completion for hush-tx(1) # Copyright (c) 2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php _hush_tx() { local cur prev words=() cword diff --git a/contrib/hush_block_subsidy_per_halving b/contrib/hush_block_subsidy_per_halving new file mode 100755 index 000000000..7e7b05b4b --- /dev/null +++ b/contrib/hush_block_subsidy_per_halving @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +# Copyright 2019-2020 The Hush developers +# Released under the GPLv3 + +use strict; +use warnings; + +my $x = 12.5 * 100000000; +my $n = 0; +while ($n<=31) { + #printf "$n,%.16g,%.16g,%.16g\n", $x, $x*0.90, $x*0.1; + printf "$n,%d,%d,%d\n", $x, $x*0.90, $x*0.1; + $x = $x / 2; + $n++; + exit if ($x <= 0); +} + diff --git a/contrib/hush_halvings b/contrib/hush_halvings new file mode 100755 index 000000000..67246bb13 --- /dev/null +++ b/contrib/hush_halvings @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +# Copyright 2019-2020 The Hush developers +# Released under the GPLv3 + +use strict; +use warnings; + +my $x = 340_000; +my $n = 0; +my $r = 12_500_000_000; +while ($n<=32) { + printf "%d,%d,%d\n", $n+1, $r, $x + 1680000*$n; + # blocktime halving at block 340000 + if ($n==0) { + $r = 3.125 * 100_000_000; + } else { + $r /= 2; + } + + $n++; +} + diff --git a/contrib/hush_supply b/contrib/hush_supply index 92e917055..fcf4460dc 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -1,33 +1,218 @@ #!/usr/bin/env perl -# Copyright 2019 The Hush developers +# Copyright 2019-2020 The Hush developers # Released under the GPLv3 use warnings; use strict; + my $supply = 0.0; -my $block = 0; -my $satoshis = 100_000_000; -my $amount = int(12.5*$satoshis); +my $block = 0; # Block 0 in Hush Smart chains is the BTC genesis block +my $puposhis = 100_000_000; +my $subsidy0 = 1_250_000_000; my $halvings = 0; +my $initial = 6178674 * $puposhis; +my $interval = 1_680_000; # ~4 years of 75s blocks +my $stop = shift || -1; +my $totalfr = 0; # total paid out to FR address -# Usage: ./hush_supply &> supply.csv -# Use this to calculate when supply hits a certain value -#while ($supply <= 21_000_000*$satoshis) { -# Use this to calculate when block rewards end -while ($halvings <= 64 && $amount >= 1) { - $block++; - if ($block < 5) { - $amount = 40_000 * $satoshis; - } else { - # Halving every 840000 blocks - if ($block % 840_000 == 0) { - $amount /= 2; - $halvings++; - } - $amount = int(12.5*$satoshis) / (2**$halvings); - } - $supply += $amount; - # block, current supply, block reward amount, number of halvings - printf "%s,%s,%s,%s\n", $block,$supply / $satoshis, $amount / $satoshis, $halvings; +if ($stop eq 'help' or $stop =~ m/-h/) { + die < supply.csv + ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT +# This will generate CSV in the form of: +# block, supply, reward, subsidy, fr, totalfr, halvings +HELP +} + + +printf "# block, supply, reward, subsidy, fr, totalfr, halvings\n"; + +# Block Reward Amounts in puposhis +# The non-integral amounts cannot be represented exactly +# 12.5 * 100000000 = 1250000000 +# 12.5 * 100000000 / 2 = 625000000 +# 12.5 * 100000000 / 4 = 312500000 +# 12.5 * 100000000 / 8 = 156250000 +# 12.5 * 100000000 / 16 = 78125000 +# 12.5 * 100000000 / 32 = 39062500 +# 12.5 * 100000000 / 64 = 19531250 +# 12.5 * 100000000 / 128 = 9765625 +# 12.5 * 100000000 / 256 = 4882812.5 +# 12.5 * 100000000 / 512 = 2441406.25 +# 12.5 * 100000000 / 1024 = 1220703.125 +# 12.5 * 100000000 / 2048 = 610351.5625 +# 12.5 * 100000000 / 4096 = 305175.78125 +# 12.5 * 100000000 / 8192 = 152587.890625 +# 12.5 * 100000000 / 16384 = 76293.9453125 +# 12.5 * 100000000 / 32768 = 38146.97265625 +# 12.5 * 100000000 / 65536 = 19073.486328125 + +# Hush Halving Heights and Block Rewards +# 1,12500000000,340000 +# 2,312500000,2020000 +# 3,156250000,3700000 +# 4,78125000,5380000 +# 5,39062500,7060000 +# 6,19531250,8740000 +# 7,9765625,10420000 +# 8,4882812,12100000 +# 9,2441406,13780000 +# 10,1220703,15460000 +# 11,610351,17140000 +# 12,305175,18820000 +# 13,152587,20500000 +# 14,76293,22180000 +# 15,38146,23860000 +# 16,19073,25540000 +# 17,9536,27220000 +# 18,4768,28900000 +# 19,2384,30580000 +# 20,1192,32260000 +# 21,596,33940000 +# 22,298,35620000 +# 23,149,37300000 +# 24,74,38980000 +# 25,37,40660000 +# 26,18,42340000 +# 27,9,44020000 +# 28,4,45700000 +# 29,2,47380000 +# 30,1,49060000 +# 31,0,50740000 + + +sub hush_block_reward +{ + my $reward = 0; + my $height = shift; + my $halvings = 0; + + if ($height >= 50740000) { + $reward = 0; + $halvings = 31; + } elsif ($height >= 49060000) { + $reward = 1; + $halvings = 30; + } elsif ($height >= 47380000) { + $reward = 1; + $halvings = 29; + } elsif ($height >= 45700000) { + $reward = 2; + $halvings = 28; + } elsif ($height >= 44020000) { + $reward = 4; + $halvings = 27; + } elsif ($height >= 42340000) { + $reward = 9; + $halvings = 26; + } elsif ($height >= 40660000) { + $reward = 18; + $halvings = 25; + } elsif ($height >= 38980000) { + $reward = 37; + $halvings = 24; + } elsif ($height >= 37380000) { + $reward = 74; + $halvings = 23; + } elsif ($height >= 35620000) { + $reward = 149; + $halvings = 22; + } elsif ($height >= 33940000) { + $reward = 298; + $halvings = 21; + } elsif ($height >= 32260001) { + $reward = 596; + $halvings = 20; + } elsif ($height >= 30580000) { + $reward = 1192; + $halvings = 19; + } elsif ($height >= 28900000) { + $reward = 2384; + $halvings = 18; + } elsif ($height >= 27220000) { + $reward = 4768; + $halvings = 17; + } elsif ($height >= 25540000) { + $reward = 9536; + $halvings = 16; + } elsif ($height >= 23860000) { + $reward = 19073; # 0.486328125 deviation + $halvings = 15; + } elsif ($height >= 22180000) { + $reward = 38146; # 0.97265625 deviation + $halvings = 14; + } elsif ($height >= 20500000) { + $reward = 76293; # 0.9453125 deviation + $halvings = 13; + } elsif ($height >= 18820000) { + $reward = 152587; # 0.890625 deviation + $halvings = 12; + } elsif ($height >= 17140000) { + $reward = 305175; # 0.78125sat deviation + $halvings = 11; + } elsif ($height >= 15460000) { + $reward = 610351; # 0.5625sat deviation + $halvings = 10; + } elsif ($height >= 13780000) { + $reward = 1220703; # 0.125sat deviation + $halvings = 9 + } elsif ($height >= 12100000) { + $reward = 2441406; # 0.25sat deviation + $halvings = 8 + } elsif ($height >= 10420000) { + $reward = 4882812; # 0.5sat deviation + $halvings = 7; + } elsif ($height >= 8740000) { + $reward = 9765625; # last exact reward + $halvings = 6; + } elsif ($height >= 7060000) { + $reward = 19531250; # 0.1953125 HUSH + $halvings = 5; + } elsif ($height >= 5380000) { + $reward = 39062500; # 0.390625 HUSH + $halvings = 4; + } elsif ($height >= 3700000) { + $reward = 78125000; # 0.78125 HUSH + $halvings = 3; + } elsif ($height >= 2020000) { + $reward = 156250000; # 1.5625 HUSH + $halvings = 2; + } elsif ($height >= 340000) { + $reward = 312500000; # 3.125 HUSH + $halvings = 1; + } elsif ($height >= 128) { + $reward = 1250000000; # 12.5 HUSH + } + + return ($reward,$halvings); +} + +# Block reward is 0 at the 31st halving +while ($halvings <= 30) { + $block++; + my ($reward,$halvings) = hush_block_reward($block); + my $fr = int($reward / 10); + my $subsidy = $reward - $fr; + + if($block == 1) { + # initial airdrop of funds from HUSH v2 network @ Block 500000 + $reward = $initial; + $subsidy= $reward; + $fr = 0; + } + $supply += $reward; + $totalfr += $fr; + + # all values in puposhis + # block, current supply, block reward amount, fr, totalfr, number of halvings + printf "%d,%d,%d,%d,%d,%d,%d\n", $block, $supply, $reward, $subsidy, $fr, $totalfr, $halvings; + exit(0) if $block == $stop; + exit(0) if ($block > 128 && $reward == 0); + exit(-1) if ($supply >= 21_000_000*$puposhis); } diff --git a/contrib/hush_supply_old b/contrib/hush_supply_old new file mode 100755 index 000000000..674424073 --- /dev/null +++ b/contrib/hush_supply_old @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +# Copyright 2019-2020 The Hush developers +# Released under the GPLv3 +use warnings; +use strict; + +my $supply = 0.0; +my $block = 0; +my $satoshis = 100_000_000; +my $amount = int(12.5*$satoshis); +my $halvings = 0; + +# Usage: ./hush_supply &> supply.csv + +# Use this to calculate when supply hits a certain value +#while ($supply <= 21_000_000*$satoshis) { +# Use this to calculate when block rewards end +while ($halvings <= 64 && $amount >= 1) { + $block++; + if ($block < 5) { + $amount = 40_000 * $satoshis; + } else { + # Halving every 840000 blocks + if ($block % 840_000 == 0) { + $amount /= 2; + $halvings++; + } + $amount = int(12.5*$satoshis) / (2**$halvings); + } + $supply += $amount; + # block, current supply, block reward amount, number of halvings + printf "%s,%s,%s,%s\n", $block,$supply / $satoshis, $amount / $satoshis, $halvings; +} diff --git a/contrib/hushd.bash-completion b/contrib/hushd.bash-completion index 8a80c96a0..313607f09 100644 --- a/contrib/hushd.bash-completion +++ b/contrib/hushd.bash-completion @@ -3,7 +3,7 @@ # Copyright (c) 2016-2017 The Zcash developers # Copyright (c) 2018 The Hush developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php _hushd() { local cur prev words=() cword diff --git a/contrib/komodo-cli.bash-completion b/contrib/komodo-cli.bash-completion index 1efc05d46..9e34cd589 100644 --- a/contrib/komodo-cli.bash-completion +++ b/contrib/komodo-cli.bash-completion @@ -1,7 +1,7 @@ # bash programmable completion for komodo-cli(1) # Copyright (c) 2012-2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # call $komodo-cli for RPC _komodo_rpc() { diff --git a/contrib/komodo-tx.bash-completion b/contrib/komodo-tx.bash-completion index 69e259381..af0c65ef9 100644 --- a/contrib/komodo-tx.bash-completion +++ b/contrib/komodo-tx.bash-completion @@ -1,7 +1,7 @@ # bash programmable completion for komodo-tx(1) # Copyright (c) 2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php _komodo_tx() { local cur prev words=() cword diff --git a/contrib/komodod.bash-completion b/contrib/komodod.bash-completion index 4c1ec516f..5509a4852 100644 --- a/contrib/komodod.bash-completion +++ b/contrib/komodod.bash-completion @@ -2,7 +2,7 @@ # Copyright (c) 2012-2017 The Bitcoin Core developers # Copyright (c) 2016-2017 The komodo developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php _komodod() { local cur prev words=() cword diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py index 8badb4b31..55488a009 100755 --- a/contrib/linearize/linearize-data.py +++ b/contrib/linearize/linearize-data.py @@ -4,7 +4,7 @@ # # Copyright (c) 2013-2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from __future__ import print_function, division diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py index 7e9cf8898..b5644ee62 100755 --- a/contrib/linearize/linearize-hashes.py +++ b/contrib/linearize/linearize-hashes.py @@ -4,7 +4,7 @@ # # Copyright (c) 2013-2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from __future__ import print_function diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py index c6a2ce636..54809a314 100755 --- a/contrib/seeds/generate-seeds.py +++ b/contrib/seeds/generate-seeds.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Copyright (c) 2014 Wladimir J. van der Laan # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php ''' Script to generate list of seed nodes for chainparams.cpp. diff --git a/contrib/zmq/zmq_sub.py b/contrib/zmq/zmq_sub.py index 3dea5e3c1..3a31b519f 100755 --- a/contrib/zmq/zmq_sub.py +++ b/contrib/zmq/zmq_sub.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import array import binascii diff --git a/depends/.gitignore b/depends/.gitignore index 1f163897b..3cb4b9ac1 100644 --- a/depends/.gitignore +++ b/depends/.gitignore @@ -7,3 +7,4 @@ x86_64* i686* mips* arm* +aarch64* diff --git a/depends/Makefile b/depends/Makefile index 636577d13..82acde0ac 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -74,9 +74,8 @@ include builders/default.mk include packages/packages.mk wallet_packages_$(NO_WALLET) = $(wallet_packages) -proton_packages_$(NO_PROTON) = $(proton_packages) -packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages) $(proton_packages_) $(wallet_packages_) +packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages) $(wallet_packages_) native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) all_packages = $(packages) $(native_packages) @@ -112,6 +111,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ + -e 's|@rust_target@|$(call rust_target,rust,$(canonical_host),$(host_os))|' \ -e 's|@no_wallet@|$(NO_WALLET)|' \ -e 's|@debug@|$(DEBUG)|' \ $< > $@ diff --git a/depends/config.site.in b/depends/config.site.in index 8cdbcd2e4..dbcb7a6e4 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -13,6 +13,9 @@ if test -z $enable_wallet && test -n "@no_wallet@"; then enable_wallet=no fi +RUST_TARGET="@rust_target@" +RUST_VENDORED_SOURCES="$depends_prefix/vendored-sources" + if test x@host_os@ = xdarwin; then BREW=no PORT=no diff --git a/depends/funcs.mk b/depends/funcs.mk index 3d89de8a7..35ca5abcf 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -40,7 +40,7 @@ endef define vendor_crate_source mkdir -p $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY) && \ -cp -r $($(1)_extract_dir) $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_name) && \ +cp -r $($(1)_extract_dir) $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_versioned_name) && \ cd $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_versioned_name) && \ rm -r `basename $($(1)_patch_dir)` .stamp_* .$($(1)_file_name).hash endef @@ -59,8 +59,8 @@ $(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SU final_build_id_long+=$($(package)_build_id_long) #override platform specific files and hashes -$(eval $(1)_file_name=$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name))) -$(eval $(1)_sha256_hash=$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash))) +$(eval $(1)_file_name=$(if $($(1)_exact_file_name),$($(1)_exact_file_name),$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name)))) +$(eval $(1)_sha256_hash=$(if $($(1)_exact_sha256_hash),$($(1)_exact_sha256_hash),$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash)))) #compute package-specific paths $(1)_build_subdir?=. @@ -91,8 +91,9 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path)) #default commands +# The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior $(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash)) -$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --strip-components=1 -xf $$($(1)_source) +$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --no-same-owner --strip-components=1 -xf $$($(1)_source) $(1)_preprocess_cmds ?= $(1)_build_cmds ?= $(1)_config_cmds ?= @@ -193,7 +194,7 @@ $($(1)_preprocessed): | $($(1)_dependencies) $($(1)_extracted) $(AT)touch $$@ $($(1)_configured): | $($(1)_preprocessed) $(AT)echo Configuring $(1)... - $(AT)rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), tar xf $($(package)_cached); ) + $(AT)rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), tar --no-same-owner -xf $($(package)_cached); ) $(AT)mkdir -p $$(@D) $(AT)+cd $$(@D); $($(1)_config_env) $(call $(1)_config_cmds, $(1)) $(AT)touch $$@ diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index 404d94c51..c8f677490 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -9,6 +9,11 @@ define $(package)_set_vars $(package)_config_opts=--disable-shared --enable-cxx --disable-replication $(package)_config_opts_mingw32=--enable-mingw $(package)_config_opts_linux=--with-pic +$(package)_config_opts_freebsd=--with-pic +ifneq ($(build_os),darwin) +$(package)_config_opts_darwin=--disable-atomicsupport +endif +$(package)_config_opts_aarch64=--disable-atomicsupport $(package)_cxxflags=-std=c++11 endef diff --git a/depends/packages/libcurl.mk b/depends/packages/libcurl.mk index fd82dc4e0..91ff1c0f1 100644 --- a/depends/packages/libcurl.mk +++ b/depends/packages/libcurl.mk @@ -4,7 +4,7 @@ $(package)_dependencies=openssl $(package)_download_path=https://curl.haxx.se/download $(package)_file_name=curl-$($(package)_version).tar.gz $(package)_sha256_hash=52af3361cf806330b88b4fe6f483b6844209d47ae196ac46da4de59bb361ab02 -$(package)_config_opts_linux=--disable-shared --enable-static --prefix=$(host_prefix) --host=x86_64-unknown-linux-gnu +$(package)_config_opts_linux=--disable-shared --enable-static --prefix=$(host_prefix) --host=$(host) $(package)_config_opts_mingw32=--enable-mingw --disable-shared --enable-static --prefix=$(host_prefix) --host=x86_64-w64-mingw32 $(package)_config_opts_darwin=--disable-shared --enable-static --prefix=$(host_prefix) $(package)_cflags_darwin=-mmacosx-version-min=10.9 diff --git a/depends/packages/librustzcash.mk b/depends/packages/librustzcash.mk index 8612ac05a..fe6ef8a58 100644 --- a/depends/packages/librustzcash.mk +++ b/depends/packages/librustzcash.mk @@ -8,15 +8,29 @@ $(package)_git_commit=06da3b9ac8f278e5d4ae13088cf0a4c03d2c13f5 $(package)_dependencies=rust $(rust_crates) $(package)_patches=cargo.config 0001-Start-using-cargo-clippy-for-CI.patch remove-dev-dependencies.diff no-groth16.patch +$(package)_rust_target=$(if $(rust_rust_target_$(canonical_host)),$(rust_rust_target_$(canonical_host)),$(canonical_host)) + ifeq ($(host_os),mingw32) $(package)_library_file=target/x86_64-pc-windows-gnu/release/rustzcash.lib +else ifneq ($(canonical_host),$(build)) +ifeq ($(host_os),darwin) +$(package)_library_file=target/x86_64-apple-darwin/release/librustzcash.a +else +$(package)_library_file=target/$($(package)_rust_target)/release/librustzcash.a +endif else $(package)_library_file=target/release/librustzcash.a endif define $(package)_set_vars $(package)_build_opts=--frozen --release -$(package)_build_opts_mingw32=--target=x86_64-pc-windows-gnu +ifneq ($(canonical_host),$(build)) +ifeq ($(host_os),darwin) +$(package)_build_opts+=--target=x86_64-apple-darwin +else +$(package)_build_opts+=--target=$($(package)_rust_target) +endif +endif endef define $(package)_preprocess_cmds @@ -27,7 +41,7 @@ define $(package)_preprocess_cmds endef define $(package)_build_cmds - cargo build --package librustzcash $($(package)_build_opts) + $(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts) endef define $(package)_stage_cmds diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 8abb7c708..9c76166af 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -1,12 +1,4 @@ -rust_packages := rust librustzcash - -ifeq ($(build_os),darwin) - zcash_packages := libgmp libsodium utfcpp -else - proton_packages := proton - zcash_packages := libgmp libsodium utfcpp -endif - +zcash_packages := libgmp libsodium utfcpp rust_crates := \ crate_aes \ crate_aesni \ diff --git a/depends/packages/proton.mk b/depends/packages/proton.mk deleted file mode 100644 index 1bb5c8865..000000000 --- a/depends/packages/proton.mk +++ /dev/null @@ -1,23 +0,0 @@ -package=proton -$(package)_version=0.26.0 -$(package)_download_path=https://archive.apache.org/dist/qpid/proton/$($(package)_version) -$(package)_file_name=qpid-proton-$($(package)_version).tar.gz -$(package)_sha256_hash=0eddac870f0085b9aeb0c9da333bd3f53fedb7c872164171a7cc06761ddbbd75 -$(package)_patches=minimal-build.patch - -define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/minimal-build.patch && \ - mkdir -p build/proton-c/src -endef - -define $(package)_config_cmds - cd build; cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX=/ -DSYSINSTALL_BINDINGS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_PYTHON=OFF -DBUILD_PHP=OFF -DBUILD_JAVA=OFF -DBUILD_PERL=OFF -DBUILD_RUBY=OFF -DBUILD_JAVASCRIPT=OFF -DBUILD_GO=OFF -DBUILD_STATIC_LIBS=ON -endef - -define $(package)_build_cmds - cd build; $(MAKE) VERBOSE=1 -endef - -define $(package)_stage_cmds - cd build; $(MAKE) VERBOSE=1 DESTDIR=$($(package)_staging_prefix_dir) install -endef diff --git a/depends/packages/rust.mk b/depends/packages/rust.mk index 9cfb95054..6fbdda037 100644 --- a/depends/packages/rust.mk +++ b/depends/packages/rust.mk @@ -1,7 +1,6 @@ package=rust $(package)_version=1.32.0 $(package)_download_path=https://static.rust-lang.org/dist - $(package)_file_name_linux=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz $(package)_sha256_hash_linux=e024698320d76b74daf0e6e71be3681a1e7923122e3ebd03673fcac3ecc23810 $(package)_file_name_darwin=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz @@ -9,20 +8,26 @@ $(package)_sha256_hash_darwin=f0dfba507192f9b5c330b5984ba71d57d434475f3d62bd44a3 $(package)_file_name_mingw32=rust-$($(package)_version)-x86_64-pc-windows-gnu.tar.gz $(package)_sha256_hash_mingw32=358e1435347c67dbf33aa9cad6fe501a833d6633ed5d5aa1863d5dffa0349be9 -ifeq ($(build_os),darwin) -$(package)_file_name=$($(package)_file_name_darwin) -$(package)_sha256_hash=$($(package)_sha256_hash_darwin) -else ifeq ($(host_os),mingw32) -$(package)_file_name=$($(package)_file_name_mingw32) -$(package)_sha256_hash=$($(package)_sha256_hash_mingw32) -else -$(package)_file_name=$($(package)_file_name_linux) -$(package)_sha256_hash=$($(package)_sha256_hash_linux) -endif +# Mapping from GCC canonical hosts to Rust targets +# If a mapping is not present, we assume they are identical, unless $host_os is +# "darwin", in which case we assume x86_64-apple-darwin. +$(package)_rust_target_x86_64-w64-mingw32=x86_64-pc-windows-gnu -ifeq ($(host_os),mingw32) +# Mapping from Rust targets to SHA-256 hashes +$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu=346efe3aef2aff7b71a611bf7661bcec5f9bc4025a599c2866ec5fd330247cb9 +$(package)_rust_std_sha256_hash_x86_64-apple-darwin=b736d035a97f830585360e54e3f8877b68c942211cf0a75e805f34bfb36103a6 +$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu=cad5f1454d591c13eeb3657f1c9dbfeb30e648f59680bd0765b94c63e7afc49e + +define rust_target +$(if $($(1)_rust_target_$(2)),$($(1)_rust_target_$(2)),$(if $(findstring darwin,$(3)),x86_64-apple-darwin,$(2))) +endef + +ifneq ($(canonical_host),$(build)) +$(package)_rust_target=$(call rust_target,$(package),$(canonical_host),$(host_os)) +$(package)_exact_file_name=rust-std-$($(package)_version)-$($(package)_rust_target).tar.gz +$(package)_exact_sha256_hash=$($(package)_rust_std_sha256_hash_$($(package)_rust_target)) $(package)_build_subdir=buildos -$(package)_extra_sources = $($(package)_file_name_$(build_os)) +$(package)_extra_sources=$($(package)_file_name_$(build_os)) define $(package)_fetch_cmds $(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ @@ -34,19 +39,19 @@ define $(package)_extract_cmds echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ echo "$($(package)_sha256_hash_$(build_os)) $($(package)_source_dir)/$($(package)_file_name_$(build_os))" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - mkdir mingw32 && \ - tar --strip-components=1 -xf $($(package)_source) -C mingw32 && \ + mkdir $(canonical_host) && \ + tar --strip-components=1 -xf $($(package)_source) -C $(canonical_host) && \ mkdir buildos && \ tar --strip-components=1 -xf $($(package)_source_dir)/$($(package)_file_name_$(build_os)) -C buildos endef define $(package)_stage_cmds - ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig && \ - cp -r ../mingw32/rust-std-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu $($(package)_staging_dir)$(host_prefix)/native/lib/rustlib + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig && \ + ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig endef else define $(package)_stage_cmds - ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig endef endif diff --git a/depends/patches/proton/minimal-build.patch b/depends/patches/proton/minimal-build.patch deleted file mode 100644 index 90588929f..000000000 --- a/depends/patches/proton/minimal-build.patch +++ /dev/null @@ -1,288 +0,0 @@ -From 03f5fc0826115edbfca468261b70c0daf627f488 Mon Sep 17 00:00:00 2001 -From: Simon -Date: Thu, 27 Apr 2017 17:15:59 -0700 -Subject: [PATCH] Enable C++11, build static library and cpp bindings with minimal dependencies. - ---- - CMakeLists.txt | 13 +++++++------ - examples/cpp/CMakeLists.txt | 1 + - proton-c/CMakeLists.txt | 32 +++++++++++++++---------------- - proton-c/bindings/CMakeLists.txt | 6 +++--- - proton-c/bindings/cpp/CMakeLists.txt | 24 +++++++++++------------ - proton-c/bindings/cpp/docs/CMakeLists.txt | 2 +- - proton-c/docs/api/CMakeLists.txt | 2 +- - 7 files changed, 41 insertions(+), 39 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index b538ffd..4a5e787 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -18,14 +18,15 @@ - # - cmake_minimum_required (VERSION 2.8.7) - -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - project (Proton C) - - # Enable C++ now for examples and bindings subdirectories, but make it optional. - enable_language(CXX OPTIONAL) - - # Enable testing --enable_testing() --include (CTest) -+#enable_testing() -+#include (CTest) - - # Pull in local cmake modules - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tools/cmake/Modules/") -@@ -141,7 +142,7 @@ set (BINDINGS_DIR ${LIB_INSTALL_DIR}/proton/bindings) - - set (SYSINSTALL_BINDINGS OFF CACHE BOOL "If SYSINSTALL_BINDINGS is OFF then proton bindings will be installed underneath ${BINDINGS_DIR} and each user will need to modify their interpreter configuration to load the appropriate binding. If SYSINSTALL_BINDINGS is ON, then each language interpreter will be queried for the appropriate directory and proton bindings will be installed and available system wide with no additional per user configuration.") - --set (BINDING_LANGS PERL PHP PYTHON RUBY) -+#set (BINDING_LANGS PERL PHP PYTHON RUBY) - - foreach (LANG ${BINDING_LANGS}) - set (SYSINSTALL_${LANG} OFF CACHE BOOL "Install ${LANG} bindings into interpreter specified location.") -@@ -156,10 +157,10 @@ set (PROTON_SHARE ${SHARE_INSTALL_DIR}/proton-${PN_VERSION}) - # End of variables used during install - - # Check for valgrind here so tests under proton-c/ and examples/ can use it. --find_program(VALGRIND_EXE valgrind DOC "Location of the valgrind program") -+#find_program(VALGRIND_EXE valgrind DOC "Location of the valgrind program") - mark_as_advanced (VALGRIND_EXE) - --option(ENABLE_VALGRIND "Use valgrind to detect run-time problems" ON) -+#option(ENABLE_VALGRIND "Use valgrind to detect run-time problems" ON) - if (ENABLE_VALGRIND) - if (NOT VALGRIND_EXE) - message(STATUS "Can't locate the valgrind command; no run-time error detection") -@@ -171,7 +172,7 @@ if (ENABLE_VALGRIND) - endif (ENABLE_VALGRIND) - - add_subdirectory(proton-c) --add_subdirectory(examples) -+#add_subdirectory(examples) - - install (FILES LICENSE README.md - DESTINATION ${PROTON_SHARE}) -diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt -index 304d899..f4877b4 100644 ---- a/examples/cpp/CMakeLists.txt -+++ b/examples/cpp/CMakeLists.txt -@@ -17,6 +17,7 @@ - # under the License. - # - -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - find_package(ProtonCpp REQUIRED) - - include_directories(${ProtonCpp_INCLUDE_DIRS}) -diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt -index 8edb661..dc7b99c 100644 ---- a/proton-c/CMakeLists.txt -+++ b/proton-c/CMakeLists.txt -@@ -22,24 +22,24 @@ include(CheckSymbolExists) - - include(soversion.cmake) - --add_custom_target(docs) --add_custom_target(doc DEPENDS docs) -+#add_custom_target(docs) -+#add_custom_target(doc DEPENDS docs) - - # Set the default SSL/TLS implementation --find_package(OpenSSL) -+#find_package(OpenSSL) - find_package(PythonInterp REQUIRED) --find_package(SWIG) -+#find_package(SWIG) - # FindSwig.cmake "forgets" make its outputs advanced like a good citizen - mark_as_advanced(SWIG_DIR SWIG_EXECUTABLE SWIG_VERSION) - - # See if Cyrus SASL is available --find_library(CYRUS_SASL_LIBRARY sasl2) --find_path(CYRUS_SASL_INCLUDE_DIR sasl/sasl.h PATH_SUFFIXES include) --find_package_handle_standard_args(CyrusSASL DEFAULT_MSG CYRUS_SASL_LIBRARY CYRUS_SASL_INCLUDE_DIR) -+#find_library(CYRUS_SASL_LIBRARY sasl2) -+#find_path(CYRUS_SASL_INCLUDE_DIR sasl/sasl.h PATH_SUFFIXES include) -+#find_package_handle_standard_args(CyrusSASL DEFAULT_MSG CYRUS_SASL_LIBRARY CYRUS_SASL_INCLUDE_DIR) - mark_as_advanced(CYRUS_SASL_LIBRARY CYRUS_SASL_INCLUDE_DIR) - - # Find saslpasswd2 executable to generate test config --find_program(SASLPASSWD_EXE saslpasswd2 DOC "Program used to make SASL user db for testing") -+#find_program(SASLPASSWD_EXE saslpasswd2 DOC "Program used to make SASL user db for testing") - mark_as_advanced(SASLPASSWD_EXE) - - if(WIN32 AND NOT CYGWIN) -@@ -315,8 +315,8 @@ pn_absolute_install_dir(EXEC_PREFIX "." ${CMAKE_INSTALL_PREFIX}) - pn_absolute_install_dir(LIBDIR ${LIB_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}) - pn_absolute_install_dir(INCLUDEDIR ${INCLUDE_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}) - --add_subdirectory(docs/api) --add_subdirectory(../tests/tools/apps/c ../tests/tools/apps/c) -+#add_subdirectory(docs/api) -+#add_subdirectory(../tests/tools/apps/c ../tests/tools/apps/c) - - # for full source distribution: - set (qpid-proton-platform-all -@@ -507,7 +507,7 @@ if (BUILD_WITH_CXX) - endif (BUILD_WITH_CXX) - - add_library ( -- qpid-proton-core SHARED -+ qpid-proton-core STATIC - ${qpid-proton-core} - ${qpid-proton-layers} - ${qpid-proton-platform} -@@ -527,7 +527,7 @@ set_target_properties ( - ) - - add_library( -- qpid-proton SHARED -+ qpid-proton STATIC - # Proton Core - ${qpid-proton-core} - ${qpid-proton-layers} -@@ -629,7 +629,7 @@ install (FILES - - # c tests: - --add_subdirectory(src/tests) -+#add_subdirectory(src/tests) - - if (CMAKE_SYSTEM_NAME STREQUAL Windows) - # No change needed for windows already use correct separator -@@ -712,7 +712,7 @@ if (BUILD_PYTHON) - - endif (BUILD_PYTHON) - --find_program(RUBY_EXE "ruby") -+#find_program(RUBY_EXE "ruby") - if (RUBY_EXE AND BUILD_RUBY) - set (rb_root "${pn_test_root}/ruby") - set (rb_src "${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby") -@@ -751,8 +751,8 @@ if (RUBY_EXE AND BUILD_RUBY) - else (DEFAULT_RUBY_TESTING) - message(STATUS "Skipping Ruby tests: missing dependencies") - endif (DEFAULT_RUBY_TESTING) --else (RUBY_EXE) -- message (STATUS "Cannot find ruby, skipping ruby tests") -+#else (RUBY_EXE) -+# message (STATUS "Cannot find ruby, skipping ruby tests") - endif() - - mark_as_advanced (RUBY_EXE RSPEC_EXE) -diff --git a/proton-c/bindings/CMakeLists.txt b/proton-c/bindings/CMakeLists.txt -index 6b88384..d1a50a5 100644 ---- a/proton-c/bindings/CMakeLists.txt -+++ b/proton-c/bindings/CMakeLists.txt -@@ -19,14 +19,14 @@ - - # Add bindings that do not require swig here - the directory name must be the same as the binding name - # See below for swig bindings --set(BINDINGS javascript cpp go) -+set(BINDINGS cpp) - - # Prerequisites for javascript. - # - # It uses a C/C++ to JavaScript cross-compiler called emscripten (https://github.com/kripken/emscripten). Emscripten takes C/C++ - # and compiles it into a highly optimisable subset of JavaScript called asm.js (http://asmjs.org/) that can be - # aggressively optimised and run at near-native speed (usually between 1.5 to 10 times slower than native C/C++). --find_package(Emscripten) -+#find_package(Emscripten) - if (EMSCRIPTEN_FOUND) - set (DEFAULT_JAVASCRIPT ON) - endif (EMSCRIPTEN_FOUND) -@@ -37,7 +37,7 @@ if (CMAKE_CXX_COMPILER) - endif (CMAKE_CXX_COMPILER) - - # Prerequisites for Go --find_program(GO_EXE go) -+#find_program(GO_EXE go) - mark_as_advanced(GO_EXE) - if (GO_EXE) - if(WIN32) -diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt -index 0cc4024..796fe29 100644 ---- a/proton-c/bindings/cpp/CMakeLists.txt -+++ b/proton-c/bindings/cpp/CMakeLists.txt -@@ -16,7 +16,7 @@ - # specific language governing permissions and limitations - # under the License. - # -- -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - include(cpp.cmake) # Compiler checks - - include_directories( -@@ -89,7 +89,7 @@ set_source_files_properties ( - COMPILE_FLAGS "${LTO}" - ) - --add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) -+add_library(qpid-proton-cpp STATIC ${qpid-proton-cpp-source}) - - target_link_libraries (qpid-proton-cpp ${PLATFORM_LIBS} qpid-proton) - -@@ -120,8 +120,8 @@ endif (MSVC) - - install (DIRECTORY "include/proton" DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.hpp") - --add_subdirectory(docs) --add_subdirectory(${CMAKE_SOURCE_DIR}/tests/tools/apps/cpp ${CMAKE_BINARY_DIR}/tests/tools/apps/cpp) -+#add_subdirectory(docs) -+#add_subdirectory(${CMAKE_SOURCE_DIR}/tests/tools/apps/cpp ${CMAKE_BINARY_DIR}/tests/tools/apps/cpp) - - # Pkg config file - configure_file( -@@ -171,12 +171,12 @@ macro(add_cpp_test test) - endif () - endmacro(add_cpp_test) - --add_cpp_test(codec_test) -+#add_cpp_test(codec_test) - #add_cpp_test(engine_test) --add_cpp_test(thread_safe_test) --add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) --add_cpp_test(message_test) --add_cpp_test(scalar_test) --add_cpp_test(value_test) --add_cpp_test(container_test) --add_cpp_test(url_test) -+#add_cpp_test(thread_safe_test) -+#add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) -+#add_cpp_test(message_test) -+#add_cpp_test(scalar_test) -+#add_cpp_test(value_test) -+#add_cpp_test(container_test) -+#add_cpp_test(url_test) -diff --git a/proton-c/bindings/cpp/docs/CMakeLists.txt b/proton-c/bindings/cpp/docs/CMakeLists.txt -index d512d15..8576867 100644 ---- a/proton-c/bindings/cpp/docs/CMakeLists.txt -+++ b/proton-c/bindings/cpp/docs/CMakeLists.txt -@@ -17,7 +17,7 @@ - # under the License. - # - --find_package(Doxygen) -+#find_package(Doxygen) - - if (DOXYGEN_FOUND) - configure_file ( -diff --git a/proton-c/docs/api/CMakeLists.txt b/proton-c/docs/api/CMakeLists.txt -index 7756e48..71ebb93 100644 ---- a/proton-c/docs/api/CMakeLists.txt -+++ b/proton-c/docs/api/CMakeLists.txt -@@ -17,7 +17,7 @@ - # under the License. - # - --find_package(Doxygen) -+#find_package(Doxygen) - if (DOXYGEN_FOUND) - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/user.doxygen.in - ${CMAKE_CURRENT_BINARY_DIR}/user.doxygen) --- -2.7.4 - diff --git a/doc/amqp.md b/doc/amqp.md deleted file mode 100644 index 431fa55b1..000000000 --- a/doc/amqp.md +++ /dev/null @@ -1,123 +0,0 @@ -# Block and Transaction Broadcasting With AMQP 1.0 (Experimental Feature) - -[AMQP](https://www.amqp.org/) is an enterprise-level message queuing -protocol for the reliable passing of real-time data and business -transactions between applications. AMQP supports both broker and -brokerless messaging. AMQP 1.0 is an open standard and has been -ratified as ISO/IEC 19464. - -The Hush daemon can be configured to act as a trusted "border -router", implementing the Hush P2P protocol and relay, making -consensus decisions, maintaining the local blockchain database, -broadcasting locally generated transactions into the network, and -providing a queryable RPC interface to interact on a polled basis for -requesting blockchain related data. However, there exists only a -limited service to notify external software of events like the arrival -of new blocks or transactions. - -The AMQP facility implements a notification interface through a set -of specific notifiers. Currently there are notifiers that publish -blocks and transactions. This read-only facility requires only the -connection of a corresponding AMQP subscriber port in receiving -software. - -Currently the facility is not authenticated nor is there any two-way -protocol involvement. Therefore, subscribers should validate the -received data since it may be out of date, incomplete or even invalid. - -Because AMQP is message oriented, subscribers receive transactions -and blocks all-at-once and do not need to implement any sort of -buffering or reassembly. - -## Prerequisites - -The AMQP feature in Hush requires [Qpid Proton](https://qpid.apache.org/proton/) -version 0.17 or newer, which you will need to install if you are not -using the depends system. Typically, it is packaged by distributions as -something like *libqpid-proton*. The C++ wrapper for AMQP *is* required. - -In order to run the example Python client scripts in contrib/ one must -also install *python-qpid-proton*, though this is not necessary for -daemon operation. - -## Enabling - -By default, the AMQP feature is automatically compiled in if the -necessary prerequisites are found. To disable, use --disable-proton -during the *configure* step of building zcashd: - - $ ./configure --disable-proton (other options) - -To actually enable operation, one must set the appropriate options on -the commandline or in the configuration file. - -## Usage - -AMQP support is currently an experimental feature, so you must pass -the option: - - -experimentalfeatures - -Currently, the following notifications are supported: - - -amqppubhashtx=address - -amqppubhashblock=address - -amqppubrawblock=address - -amqppubrawtx=address - -The address must be a valid AMQP address, where the same address can be -used in more than notification. Note that SSL and SASL addresses are -not currently supported. - -Launch zcashd like this: - - $ zcashd -amqppubhashtx=amqp://127.0.0.1:5672 - -Or this: - - $ zcashd -amqppubhashtx=amqp://127.0.0.1:5672 \ - -amqppubrawtx=amqp://127.0.0.1:5672 \ - -amqppubrawblock=amqp://127.0.0.1:5672 \ - -amqppubhashblock=amqp://127.0.0.1:5672 \ - -debug=amqp - -The debug category `amqp` enables AMQP-related logging. - -Each notification has a topic and body, where the header corresponds -to the notification type. For instance, for the notification `-amqpubhashtx` -the topic is `hashtx` (no null terminator) and the body is the hexadecimal -transaction hash (32 bytes). This transaction hash and the block hash -found in `hashblock` are in RPC byte order. - -These options can also be provided in zcash.conf. - -Please see `contrib/amqp/amqp_sub.py` for a working example of an -AMQP server listening for messages. - -## Remarks - -From the perspective of zcashd, the local end of an AMQP link is write-only. - -No information is broadcast that wasn't already received from the public -P2P network. - -No authentication or authorization is done on peers that zcashd connects -to; it is assumed that the AMQP link is exposed only to trusted entities, -using other means such as firewalling. - -TLS support may be added once OpenSSL has been removed from the Hush -project and alternative TLS implementations have been evaluated. - -SASL support may be added in a future update for secure communication. - -Note that when the block chain tip changes, a reorganisation may occur -and just the tip will be notified. It is up to the subscriber to -retrieve the chain from the last known block to the new tip. - -At present, zcashd does not try to resend a notification if there was -a problem confirming receipt. Support for delivery guarantees such as -*at-least-once* and *exactly-once* will be added in in a future update. - -Currently, zcashd appends an up-counting sequence number to each notification -which allows listeners to detect lost notifications. - diff --git a/doc/man/hush-cli.1 b/doc/man/hush-cli.1 index 5d87d8205..bba162cd6 100644 --- a/doc/man/hush-cli.1 +++ b/doc/man/hush-cli.1 @@ -1,21 +1,21 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-CLI "1" "June 2020" "hush-cli v3.4.0" "User Commands" +.TH HUSH-CLI "1" "September 2020" "hush-cli v3.5.0" "User Commands" .SH NAME -hush-cli \- manual page for hush-cli v3.4.0 +hush-cli \- manual page for hush-cli v3.5.0 .SH DESCRIPTION -Komodo RPC client version v3.4.0\-2fbcca416\-dirty +Hush RPC client version v3.5.0\-beta6\-cb09e7fed\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . .SS "Usage:" .TP -komodo\-cli [options] [params] -Send command to Komodo +hush\-cli [options] [params] +Send command to Hush .TP -komodo\-cli [options] help +hush\-cli [options] help List commands .TP -komodo\-cli [options] help +hush\-cli [options] help Get help for a command .SH OPTIONS .HP @@ -71,7 +71,7 @@ Timeout in seconds during HTTP requests, or 0 for no timeout. (default: Read extra arguments from standard input, one per line until EOF/Ctrl\-D (recommended for sensitive information such as passphrases) .SH COPYRIGHT -Hush Daemon version v3.4.0-2fbcca416-dirty +Hush Daemon version v3.5.0-beta6-cb09e7fed-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -84,7 +84,7 @@ Copyright (C) 2018-2020 The Hush developers This is experimental software!!! Distributed under the MIT software license, see the accompanying file COPYING -or . +or . This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written diff --git a/doc/man/hush-tx.1 b/doc/man/hush-tx.1 index a6d3be7ef..1ac3f4b2b 100644 --- a/doc/man/hush-tx.1 +++ b/doc/man/hush-tx.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-TX "1" "June 2020" "hush-tx v3.4.0" "User Commands" +.TH HUSH-TX "1" "September 2020" "hush-tx v3.5.0" "User Commands" .SH NAME -hush-tx \- manual page for hush-tx v3.4.0 +hush-tx \- manual page for hush-tx v3.5.0 .SH DESCRIPTION -Hush komodo\-tx utility version v3.4.0\-2fbcca416\-dirty +Hush komodo\-tx utility version v3.5.0\-beta6\-cb09e7fed\-dirty .SS "Usage:" .TP komodo\-tx [options] [commands] @@ -84,7 +84,7 @@ set=NAME:JSON\-STRING .IP Set register NAME to given JSON\-STRING .SH COPYRIGHT -Hush Daemon version v3.4.0-2fbcca416-dirty +Hush Daemon version v3.5.0-beta6-cb09e7fed-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -97,7 +97,7 @@ Copyright (C) 2018-2020 The Hush developers This is experimental software!!! Distributed under the MIT software license, see the accompanying file COPYING -or . +or . This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written diff --git a/doc/man/hushd.1 b/doc/man/hushd.1 index 6e57386b7..e17db3d83 100644 --- a/doc/man/hushd.1 +++ b/doc/man/hushd.1 @@ -1,10 +1,10 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSHD "1" "June 2020" "hushd v3.4.0" "User Commands" +.TH HUSHD "1" "September 2020" "hushd v3.5.0" "User Commands" .SH NAME -hushd \- manual page for hushd v3.4.0 +hushd \- manual page for hushd v3.5.0 .SH DESCRIPTION Found binary: ./komodod -Hush Daemon version v3.4.0\-2fbcca416\-dirty +Hush Daemon version v3.5.0\-beta6\-cb09e7fed\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -114,6 +114,11 @@ Create new files with system default permissions, instead of umask 077 Maintain a full transaction index, used by the getrawtransaction rpc call (default: 0) .HP +\fB\-txsend=\fR +.IP +Execute command to send a transaction instead of broadcasting (%s in cmd +is replaced by transaction hex) +.HP \fB\-addressindex\fR .IP Maintain a full address index, used to query for the balance, txids and @@ -346,7 +351,8 @@ Upgrade wallet to latest format on startup .HP \fB\-wallet=\fR .IP -Specify wallet file (within data directory) (default: wallet.dat) +Specify wallet file absolute path or a path relative to the data +directory (default: wallet.dat) .HP \fB\-walletbroadcast\fR .IP @@ -541,7 +547,7 @@ output (default: 1 if running in a console, 0 otherwise) Number of seconds between metrics refreshes (default: 1 if running in a console, 600 otherwise) .PP -Komodo Asset Chain options: +Hush Smart Chain options: .HP \fB\-ac_algo\fR .IP @@ -639,7 +645,7 @@ Starting supply, default is 0 .IP Enforce transaction\-rate limit, default 0 .SH COPYRIGHT -Hush Daemon version v3.4.0-2fbcca416-dirty +Hush Daemon version v3.5.0-beta6-cb09e7fed-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -652,7 +658,7 @@ Copyright (C) 2018-2020 The Hush developers This is experimental software!!! Distributed under the MIT software license, see the accompanying file COPYING -or . +or . This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written diff --git a/qa/hush/create_wallet_200k_utxos.py b/qa/hush/create_wallet_200k_utxos.py index d4a1d9d48..4a8fea2a8 100644 --- a/qa/hush/create_wallet_200k_utxos.py +++ b/qa/hush/create_wallet_200k_utxos.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Create a large wallet diff --git a/qa/hush/full_test_suite.py b/qa/hush/full_test_suite.py index fcbdf0cd8..deee55881 100755 --- a/qa/hush/full_test_suite.py +++ b/qa/hush/full_test_suite.py @@ -1,6 +1,8 @@ #!/usr/bin/env python2 +# Copyright (c) 2019-2020 Hush developers +# Released under the GPLv3 # -# Execute all of the automated tests related to Zcash. +# Execute all of the automated tests related to Hush # import argparse @@ -32,7 +34,7 @@ RE_FORTIFY_USED = re.compile('Binary compiled with FORTIFY_SOURCE support.*Yes') def test_rpath_runpath(filename): output = subprocess.check_output( - [repofile('qa/zcash/checksec.sh'), '--file', repofile(filename)] + [repofile('qa/hush/checksec.sh'), '--file', repofile(filename)] ) if RE_RPATH_RUNPATH.search(output): print('PASS: %s has no RPATH or RUNPATH.' % filename) @@ -44,7 +46,7 @@ def test_rpath_runpath(filename): def test_fortify_source(filename): proc = subprocess.Popen( - [repofile('qa/zcash/checksec.sh'), '--fortify-file', repofile(filename)], + [repofile('qa/hush/checksec.sh'), '--fortify-file', repofile(filename)], stdout=subprocess.PIPE, ) line1 = proc.stdout.readline() @@ -64,24 +66,24 @@ def check_security_hardening(): ret &= subprocess.call(['make', '-C', repofile('src'), 'check-security']) == 0 # The remaining checks are only for ELF binaries - # Assume that if zcashd is an ELF binary, they all are - with open(repofile('src/zcashd'), 'rb') as f: + # Assume that if hushd is an ELF binary, they all are + with open(repofile('src/hushd'), 'rb') as f: magic = f.read(4) if not magic.startswith(b'\x7fELF'): return ret - ret &= test_rpath_runpath('src/zcashd') - ret &= test_rpath_runpath('src/zcash-cli') - ret &= test_rpath_runpath('src/zcash-gtest') - ret &= test_rpath_runpath('src/zcash-tx') + ret &= test_rpath_runpath('src/hushd') + ret &= test_rpath_runpath('src/hush-cli') + ret &= test_rpath_runpath('src/hush-gtest') + ret &= test_rpath_runpath('src/hush-tx') ret &= test_rpath_runpath('src/test/test_bitcoin') # NOTE: checksec.sh does not reliably determine whether FORTIFY_SOURCE # is enabled for the entire binary. See issue #915. - ret &= test_fortify_source('src/zcashd') - ret &= test_fortify_source('src/zcash-cli') - ret &= test_fortify_source('src/zcash-gtest') - ret &= test_fortify_source('src/zcash-tx') + ret &= test_fortify_source('src/hushd') + ret &= test_fortify_source('src/hush-cli') + ret &= test_fortify_source('src/hush-gtest') + ret &= test_fortify_source('src/hush-tx') ret &= test_fortify_source('src/test/test_bitcoin') return ret @@ -144,7 +146,7 @@ STAGES = [ STAGE_COMMANDS = { 'btest': [repofile('src/test/test_bitcoin'), '-p'], - 'gtest': [repofile('src/zcash-gtest')], + 'gtest': [repofile('src/komodo-gtest')], 'sec-hard': check_security_hardening, 'no-dot-so': ensure_no_dot_so_in_depends, 'util-test': util_test, diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 35bf5a7e9..4af883ea3 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -96,10 +96,6 @@ if [ "x$ENABLE_ZMQ" = "x1" ]; then testScripts+=('zmq_test.py') fi -if [ "x$ENABLE_PROTON" = "x1" ]; then - testScripts+=('proton_test.py') -fi - extArg="-extended" passOn=${@#$extArg} diff --git a/qa/rpc-tests/ac_private.py b/qa/rpc-tests/ac_private.py index 9b462f50d..000d900dc 100755 --- a/qa/rpc-tests/ac_private.py +++ b/qa/rpc-tests/ac_private.py @@ -4,7 +4,7 @@ # Released under the GPLv3 # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/addressindex.py b/qa/rpc-tests/addressindex.py index 11fa7ffdb..be02aa43e 100755 --- a/qa/rpc-tests/addressindex.py +++ b/qa/rpc-tests/addressindex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test addressindex generation and fetching diff --git a/qa/rpc-tests/bip65-cltv-p2p.py b/qa/rpc-tests/bip65-cltv-p2p.py index cfd2df01e..645507a4b 100755 --- a/qa/rpc-tests/bip65-cltv-p2p.py +++ b/qa/rpc-tests/bip65-cltv-p2p.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.test_framework import ComparisonTestFramework diff --git a/qa/rpc-tests/bipdersig-p2p.py b/qa/rpc-tests/bipdersig-p2p.py index f254843f1..cbc42f85e 100755 --- a/qa/rpc-tests/bipdersig-p2p.py +++ b/qa/rpc-tests/bipdersig-p2p.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.test_framework import ComparisonTestFramework diff --git a/qa/rpc-tests/blockchain.py b/qa/rpc-tests/blockchain.py index c37db8b84..7248a9a88 100755 --- a/qa/rpc-tests/blockchain.py +++ b/qa/rpc-tests/blockchain.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test RPC calls related to blockchain state. Tests correspond to code in diff --git a/qa/rpc-tests/cryptoconditions.py b/qa/rpc-tests/cryptoconditions.py index d5456e801..67f8db904 100755 --- a/qa/rpc-tests/cryptoconditions.py +++ b/qa/rpc-tests/cryptoconditions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 7f82f2f3c..a832fbfed 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import time diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 7b9d3fbae..cdb6f8a9e 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index 27c5fce4e..6d72dac0c 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py index b12ea9f7e..d38baa941 100755 --- a/qa/rpc-tests/cryptoconditions_gateways.py +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py index 12ca8b3da..2c273d394 100755 --- a/qa/rpc-tests/cryptoconditions_heir.py +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import time diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 1db33bef7..347654979 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 57d3032b8..0444cba60 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 263d85dde..774dbe0ec 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/decodescript.py b/qa/rpc-tests/decodescript.py index 293fd0ebb..ff3c83097 100755 --- a/qa/rpc-tests/decodescript.py +++ b/qa/rpc-tests/decodescript.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/disablewallet.py b/qa/rpc-tests/disablewallet.py index 339c6a8f6..ab5ec14f9 100755 --- a/qa/rpc-tests/disablewallet.py +++ b/qa/rpc-tests/disablewallet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Exercise API with -disablewallet. diff --git a/qa/rpc-tests/dpowconfs.py b/qa/rpc-tests/dpowconfs.py index 24b328da6..491b9f25d 100755 --- a/qa/rpc-tests/dpowconfs.py +++ b/qa/rpc-tests/dpowconfs.py @@ -2,7 +2,7 @@ # Copyright (c) 2018-2019 The Hush developers # Copyright (c) 2019 The SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * diff --git a/qa/rpc-tests/feature_walletfile.py b/qa/rpc-tests/feature_walletfile.py new file mode 100755 index 000000000..f38403574 --- /dev/null +++ b/qa/rpc-tests/feature_walletfile.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# Copyright (c) 2017 The Bitcoin Core developers +# Copyright (c) 2019-2020 The Hush developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://www.opensource.org/licenses/mit-license.php +"""Test wallet file location.""" + +import os + +from test_framework.util import start_node, stop_node, assert_start_raises_init_error + +from test_framework.test_framework import BitcoinTestFramework + +class WalletFileTest(BitcoinTestFramework): + def set_test_params(self): + self.num_nodes = 1 + self.setup_clean_chain = True + + def run_test(self): + # test default wallet location + assert os.path.isfile(os.path.join(self.options.tmpdir, "node0", "regtest", "wallet.dat")) + + # test alternative wallet file name in datadir + stop_node(self.nodes[0], 0) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=altwallet.dat"]) + assert os.path.isfile(os.path.join(self.options.tmpdir, "node0", "regtest", "altwallet.dat")) + + # test wallet file outside datadir + tempname = os.path.join(self.options.tmpdir, "outsidewallet.dat") + stop_node(self.nodes[0], 0) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=%s" % tempname]) + assert os.path.isfile(tempname) + + # test the case where absolute path does not exist + assert not os.path.isdir("/this_directory_must_not_exist") + invalidpath = os.path.join("/this_directory_must_not_exist/", "foo.dat") + stop_node(self.nodes[0], 0) + assert_start_raises_init_error(0, "-wallet=%s" % invalidpath, + "Error: Absolute path %s does not exist") + + # relative path does not exist + invalidpath = os.path.join("wallet", "foo.dat") + assert_start_raises_init_error(0, "-wallet=%s" % invalidpath, + "Error: Relative path %s does not exist") + + # create dir and retry + os.mkdir(os.path.join(self.options.tmpdir, "node0", "regtest", "wallet")) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=%s" % invalidpath]) + +if __name__ == '__main__': + WalletFileTest().main() diff --git a/qa/rpc-tests/finalsaplingroot.py b/qa/rpc-tests/finalsaplingroot.py index 83f16edec..aa05fb870 100755 --- a/qa/rpc-tests/finalsaplingroot.py +++ b/qa/rpc-tests/finalsaplingroot.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( diff --git a/qa/rpc-tests/forknotify.py b/qa/rpc-tests/forknotify.py index 1be750a64..f61a21412 100755 --- a/qa/rpc-tests/forknotify.py +++ b/qa/rpc-tests/forknotify.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test -alertnotify diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py index 42896be4f..4c3c92356 100755 --- a/qa/rpc-tests/fundrawtransaction.py +++ b/qa/rpc-tests/fundrawtransaction.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/getblocktemplate.py b/qa/rpc-tests/getblocktemplate.py index af050110e..013836b1e 100755 --- a/qa/rpc-tests/getblocktemplate.py +++ b/qa/rpc-tests/getblocktemplate.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, connect_nodes_bi, \ diff --git a/qa/rpc-tests/getblocktemplate_longpoll.py b/qa/rpc-tests/getblocktemplate_longpoll.py index 37a40384b..20ff4a6ad 100755 --- a/qa/rpc-tests/getblocktemplate_longpoll.py +++ b/qa/rpc-tests/getblocktemplate_longpoll.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import AuthServiceProxy diff --git a/qa/rpc-tests/getblocktemplate_proposals.py b/qa/rpc-tests/getblocktemplate_proposals.py index 16b2e9b94..450e13cfa 100755 --- a/qa/rpc-tests/getblocktemplate_proposals.py +++ b/qa/rpc-tests/getblocktemplate_proposals.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/getchaintips.py b/qa/rpc-tests/getchaintips.py index 6a2bcb296..2a90b2a2a 100755 --- a/qa/rpc-tests/getchaintips.py +++ b/qa/rpc-tests/getchaintips.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Exercise the getchaintips API. We introduce a network split, work # on chains of different lengths, and join the network together again. diff --git a/qa/rpc-tests/httpbasics.py b/qa/rpc-tests/httpbasics.py index b1a4623bd..2170a7b8e 100755 --- a/qa/rpc-tests/httpbasics.py +++ b/qa/rpc-tests/httpbasics.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test rpc http basics diff --git a/qa/rpc-tests/invalidateblock.py b/qa/rpc-tests/invalidateblock.py index 5cbd1ea98..6c9f15d38 100755 --- a/qa/rpc-tests/invalidateblock.py +++ b/qa/rpc-tests/invalidateblock.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test InvalidateBlock code diff --git a/qa/rpc-tests/invalidblockrequest.py b/qa/rpc-tests/invalidblockrequest.py index 05b33d772..16030c3b4 100755 --- a/qa/rpc-tests/invalidblockrequest.py +++ b/qa/rpc-tests/invalidblockrequest.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.test_framework import ComparisonTestFramework diff --git a/qa/rpc-tests/ivk_import_export.py b/qa/rpc-tests/ivk_import_export.py index 0546b0a44..ccaa05bd2 100755 --- a/qa/rpc-tests/ivk_import_export.py +++ b/qa/rpc-tests/ivk_import_export.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2019 Bartlomiej Lisiecki # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/key_import_export.py b/qa/rpc-tests/key_import_export.py index 87b2daa2b..7b5c042a8 100755 --- a/qa/rpc-tests/key_import_export.py +++ b/qa/rpc-tests/key_import_export.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/keypool.py b/qa/rpc-tests/keypool.py index a7b32e13f..54a022324 100755 --- a/qa/rpc-tests/keypool.py +++ b/qa/rpc-tests/keypool.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Exercise the wallet keypool, and interaction with wallet encryption/locking diff --git a/qa/rpc-tests/listtransactions.py b/qa/rpc-tests/listtransactions.py index a735f41ab..07444741b 100755 --- a/qa/rpc-tests/listtransactions.py +++ b/qa/rpc-tests/listtransactions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Exercise the listtransactions API diff --git a/qa/rpc-tests/maxblocksinflight.py b/qa/rpc-tests/maxblocksinflight.py index beef3d2ea..e38f49c7b 100755 --- a/qa/rpc-tests/maxblocksinflight.py +++ b/qa/rpc-tests/maxblocksinflight.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \ diff --git a/qa/rpc-tests/mempool_nu_activation.py b/qa/rpc-tests/mempool_nu_activation.py index 2ed238c65..71fba44b5 100755 --- a/qa/rpc-tests/mempool_nu_activation.py +++ b/qa/rpc-tests/mempool_nu_activation.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/mempool_reorg.py b/qa/rpc-tests/mempool_reorg.py index ad12dadf2..b0bb2a7e1 100755 --- a/qa/rpc-tests/mempool_reorg.py +++ b/qa/rpc-tests/mempool_reorg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test re-org scenarios with a mempool that contains transactions diff --git a/qa/rpc-tests/mempool_resurrect_test.py b/qa/rpc-tests/mempool_resurrect_test.py index faa97d461..975f6bac2 100755 --- a/qa/rpc-tests/mempool_resurrect_test.py +++ b/qa/rpc-tests/mempool_resurrect_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test resurrection of mined transactions when diff --git a/qa/rpc-tests/mempool_spendcoinbase.py b/qa/rpc-tests/mempool_spendcoinbase.py index 5366fb955..22c8ef88a 100755 --- a/qa/rpc-tests/mempool_spendcoinbase.py +++ b/qa/rpc-tests/mempool_spendcoinbase.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test spending coinbase transactions. diff --git a/qa/rpc-tests/mempool_tx_expiry.py b/qa/rpc-tests/mempool_tx_expiry.py index b5ee4bd2a..7abebd643 100755 --- a/qa/rpc-tests/mempool_tx_expiry.py +++ b/qa/rpc-tests/mempool_tx_expiry.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test proper expiry for transactions >= version 3 diff --git a/qa/rpc-tests/mempool_tx_input_limit.py b/qa/rpc-tests/mempool_tx_input_limit.py index 9a7131cfe..861cb0423 100755 --- a/qa/rpc-tests/mempool_tx_input_limit.py +++ b/qa/rpc-tests/mempool_tx_input_limit.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/merkle_blocks.py b/qa/rpc-tests/merkle_blocks.py index 13b98e140..b9613bf0f 100755 --- a/qa/rpc-tests/merkle_blocks.py +++ b/qa/rpc-tests/merkle_blocks.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test merkleblock fetch/validation diff --git a/qa/rpc-tests/nodehandling.py b/qa/rpc-tests/nodehandling.py index 391a935d0..4e9eb5d8f 100755 --- a/qa/rpc-tests/nodehandling.py +++ b/qa/rpc-tests/nodehandling.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test node handling diff --git a/qa/rpc-tests/p2p-acceptblock.py b/qa/rpc-tests/p2p-acceptblock.py index 25221fbed..0a71f2eb3 100755 --- a/qa/rpc-tests/p2p-acceptblock.py +++ b/qa/rpc-tests/p2p-acceptblock.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.mininode import CBlockHeader, CInv, NodeConn, NodeConnCB, \ diff --git a/qa/rpc-tests/p2p_node_bloom.py b/qa/rpc-tests/p2p_node_bloom.py index 18476a981..8b9687d3a 100755 --- a/qa/rpc-tests/p2p_node_bloom.py +++ b/qa/rpc-tests/p2p_node_bloom.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \ msg_filteradd, msg_filterclear, mininode_lock, SPROUT_PROTO_VERSION diff --git a/qa/rpc-tests/p2p_txexpiry_dos.py b/qa/rpc-tests/p2p_txexpiry_dos.py index ec970435a..0ee0718a1 100755 --- a/qa/rpc-tests/p2p_txexpiry_dos.py +++ b/qa/rpc-tests/p2p_txexpiry_dos.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \ CTransaction, msg_tx, mininode_lock, OVERWINTER_PROTO_VERSION diff --git a/qa/rpc-tests/prioritisetransaction.py b/qa/rpc-tests/prioritisetransaction.py index 134b9b160..94424ce51 100755 --- a/qa/rpc-tests/prioritisetransaction.py +++ b/qa/rpc-tests/prioritisetransaction.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/proton_test.py b/qa/rpc-tests/proton_test.py deleted file mode 100755 index d9fb27bd3..000000000 --- a/qa/rpc-tests/proton_test.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python2 -# Copyright (c) 2017 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -# -# Test Proton interface (provides AMQP 1.0 messaging support). -# -# Requirements: -# Python library for Qpid Proton: -# https://pypi.python.org/pypi/python-qpid-proton -# To install: -# pip install python-qpid-proton -# - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, bytes_to_hex_str, \ - start_nodes - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -import threading - - -class Server(MessagingHandler): - - def __init__(self, url, limit): - super(Server, self).__init__() - self.url = url - self.counter = limit - self.blockhashes = [] - self.txids = [] - self.blockseq = -1 - self.txidseq = -1 - - def on_start(self, event): - print "Proton listening on:", self.url - self.container = event.container - self.acceptor = event.container.listen(self.url) - - def on_message(self, event): - m = event.message - hash = bytes_to_hex_str(m.body) - sequence = m.properties['x-opt-sequence-number'] - if m.subject == "hashtx": - self.txids.append(hash) - - # Test that sequence id is incrementing - assert(sequence == 1 + self.txidseq) - self.txidseq = sequence - elif m.subject == "hashblock": - self.blockhashes.append(hash) - - # Test that sequence id is incrementing - assert(sequence == 1 + self.blockseq) - self.blockseq = sequence - - self.counter = self.counter - 1 - if self.counter == 0: - self.container.stop() - - -class ProtonTest (BitcoinTestFramework): - - port = 25672 - numblocks = 10 # must be even, as two nodes generate equal number - assert(numblocks % 2 == 0) - - def setup_nodes(self): - - # Launch proton server in background thread - # It terminates after receiving numblocks * 2 messages (one for coinbase, one for block) - self.server = Server("127.0.0.1:%i" % self.port, self.numblocks * 2) - self.container = Container(self.server) - self.t1 = threading.Thread(target=self.container.run) - self.t1.start() - - return start_nodes(4, self.options.tmpdir, extra_args=[ - ['-experimentalfeatures', '-debug=amqp', '-amqppubhashtx=amqp://127.0.0.1:'+str(self.port), - '-amqppubhashblock=amqp://127.0.0.1:'+str(self.port)], - [], - [], - [] - ]) - - def run_test(self): - self.sync_all() - baseheight = self.nodes[0].getblockcount() # 200 blocks already mined - - # generate some blocks - self.nodes[0].generate(self.numblocks/2) - self.sync_all() - self.nodes[1].generate(self.numblocks/2) - self.sync_all() - - # wait for server to finish - self.t1.join() - - # sequence numbers have already been checked in the server's message handler - - # sanity check that we have the right number of block hashes and coinbase txids - assert_equal(len(self.server.blockhashes), self.numblocks) - assert_equal(len(self.server.txids), self.numblocks) - - # verify that each block has the correct coinbase txid - for i in xrange(0, self.numblocks): - height = baseheight + i + 1 - blockhash = self.nodes[0].getblockhash(height) - assert_equal(blockhash, self.server.blockhashes[i]) - resp = self.nodes[0].getblock(blockhash) - coinbase = resp["tx"][0] - assert_equal(coinbase, self.server.txids[i]) - - -if __name__ == '__main__': - ProtonTest().main() diff --git a/qa/rpc-tests/proxy_test.py b/qa/rpc-tests/proxy_test.py index e4fb48820..2678dd6c9 100755 --- a/qa/rpc-tests/proxy_test.py +++ b/qa/rpc-tests/proxy_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/pruning.py b/qa/rpc-tests/pruning.py index 2639060fa..7cab0fc9c 100755 --- a/qa/rpc-tests/pruning.py +++ b/qa/rpc-tests/pruning.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test pruning code diff --git a/qa/rpc-tests/rawtransactions.py b/qa/rpc-tests/rawtransactions.py index 182f87f08..4b9ed5ef0 100755 --- a/qa/rpc-tests/rawtransactions.py +++ b/qa/rpc-tests/rawtransactions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test re-org scenarios with a mempool that contains transactions diff --git a/qa/rpc-tests/receivedby.py b/qa/rpc-tests/receivedby.py index 59f7bf258..9e60cb639 100755 --- a/qa/rpc-tests/receivedby.py +++ b/qa/rpc-tests/receivedby.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Exercise the listreceivedbyaddress API diff --git a/qa/rpc-tests/regtest_signrawtransaction.py b/qa/rpc-tests/regtest_signrawtransaction.py index 78ec1fbc8..26e66bd9b 100755 --- a/qa/rpc-tests/regtest_signrawtransaction.py +++ b/qa/rpc-tests/regtest_signrawtransaction.py @@ -2,7 +2,7 @@ # Copyright (c) 2019-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import start_nodes, wait_and_assert_operationid_status diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py index b14ec765d..afdf7c4d2 100755 --- a/qa/rpc-tests/rest.py +++ b/qa/rpc-tests/rest.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test REST interface diff --git a/qa/rpc-tests/rewind_index.py b/qa/rpc-tests/rewind_index.py index 8c5c606df..a96c190e9 100755 --- a/qa/rpc-tests/rewind_index.py +++ b/qa/rpc-tests/rewind_index.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py index 72e14d655..df2f5a0ef 100755 --- a/qa/rpc-tests/rpcbind_test.py +++ b/qa/rpc-tests/rpcbind_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Test for -rpcbind, as well as -rpcallowip and -rpcconnect diff --git a/qa/rpc-tests/script_test.py b/qa/rpc-tests/script_test.py index c3ad541e5..b0f78a20d 100755 --- a/qa/rpc-tests/script_test.py +++ b/qa/rpc-tests/script_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # ''' diff --git a/qa/rpc-tests/signrawtransactions.py b/qa/rpc-tests/signrawtransactions.py index 95d242854..3fe32f03a 100755 --- a/qa/rpc-tests/signrawtransactions.py +++ b/qa/rpc-tests/signrawtransactions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/smartfees.py b/qa/rpc-tests/smartfees.py index e111a406b..b20847868 100755 --- a/qa/rpc-tests/smartfees.py +++ b/qa/rpc-tests/smartfees.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test fee estimation code diff --git a/qa/rpc-tests/spentindex.py b/qa/rpc-tests/spentindex.py index ebe2b8cc2..672b8b2e7 100755 --- a/qa/rpc-tests/spentindex.py +++ b/qa/rpc-tests/spentindex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test addressindex generation and fetching diff --git a/qa/rpc-tests/test_framework/bignum.py b/qa/rpc-tests/test_framework/bignum.py index b0c58ccd4..f77e36824 100644 --- a/qa/rpc-tests/test_framework/bignum.py +++ b/qa/rpc-tests/test_framework/bignum.py @@ -5,7 +5,7 @@ # This file is copied from python-bitcoinlib. # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # """Bignum routines""" diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py index 1fe2a5dda..fbcc9a36f 100644 --- a/qa/rpc-tests/test_framework/blocktools.py +++ b/qa/rpc-tests/test_framework/blocktools.py @@ -1,7 +1,7 @@ # blocktools.py - utilities for manipulating blocks and transactions # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint diff --git a/qa/rpc-tests/test_framework/comptool.py b/qa/rpc-tests/test_framework/comptool.py index 7f9a97d68..d38595ba1 100755 --- a/qa/rpc-tests/test_framework/comptool.py +++ b/qa/rpc-tests/test_framework/comptool.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from mininode import CBlock, CTransaction, CInv, NodeConn, NodeConnCB, \ diff --git a/qa/rpc-tests/test_framework/netutil.py b/qa/rpc-tests/test_framework/netutil.py index b30a88a4f..bd71d21cf 100644 --- a/qa/rpc-tests/test_framework/netutil.py +++ b/qa/rpc-tests/test_framework/netutil.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Linux network utilities import sys diff --git a/qa/rpc-tests/test_framework/script.py b/qa/rpc-tests/test_framework/script.py index 55a7f8e51..5c81f84d1 100644 --- a/qa/rpc-tests/test_framework/script.py +++ b/qa/rpc-tests/test_framework/script.py @@ -4,7 +4,7 @@ # This file is modified from python-bitcoinlib. # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # """Scripts diff --git a/qa/rpc-tests/test_framework/socks5.py b/qa/rpc-tests/test_framework/socks5.py index 1dbfb98d5..bc4cd466a 100644 --- a/qa/rpc-tests/test_framework/socks5.py +++ b/qa/rpc-tests/test_framework/socks5.py @@ -1,6 +1,6 @@ # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php ''' Dummy Socks5 server for testing. ''' diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 78c66089a..b6fe49625 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -2,7 +2,7 @@ # Copyright (c) 2018-2019 The SuperNET developers # Copyright (c) 2018-2020 The Hush developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Helpful routines for regression testing # diff --git a/qa/rpc-tests/txindex.py b/qa/rpc-tests/txindex.py index e59b6d7d9..aa3fb69b2 100755 --- a/qa/rpc-tests/txindex.py +++ b/qa/rpc-tests/txindex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test txindex generation and fetching diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py index bbe383d16..ce3b7713a 100755 --- a/qa/rpc-tests/txn_doublespend.py +++ b/qa/rpc-tests/txn_doublespend.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test proper accounting with malleable transactions diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py index 0268dd292..c0c407bde 100755 --- a/qa/rpc-tests/wallet.py +++ b/qa/rpc-tests/wallet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/wallet_1941.py b/qa/rpc-tests/wallet_1941.py index 6f90f33bd..b3033d8ed 100755 --- a/qa/rpc-tests/wallet_1941.py +++ b/qa/rpc-tests/wallet_1941.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # This is a regression test for #1941. diff --git a/qa/rpc-tests/wallet_addresses.py b/qa/rpc-tests/wallet_addresses.py index 0b9669972..dffdc2bd6 100755 --- a/qa/rpc-tests/wallet_addresses.py +++ b/qa/rpc-tests/wallet_addresses.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, start_nodes diff --git a/qa/rpc-tests/wallet_anchorfork.py b/qa/rpc-tests/wallet_anchorfork.py index 1cb16e152..17f342b1b 100755 --- a/qa/rpc-tests/wallet_anchorfork.py +++ b/qa/rpc-tests/wallet_anchorfork.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/wallet_changeindicator.py b/qa/rpc-tests/wallet_changeindicator.py index 428d0c508..98591405b 100755 --- a/qa/rpc-tests/wallet_changeindicator.py +++ b/qa/rpc-tests/wallet_changeindicator.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_true, assert_false, wait_and_assert_operationid_status diff --git a/qa/rpc-tests/wallet_import_export.py b/qa/rpc-tests/wallet_import_export.py index cdcc01d1f..2b4c25a66 100755 --- a/qa/rpc-tests/wallet_import_export.py +++ b/qa/rpc-tests/wallet_import_export.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_true, start_nodes diff --git a/qa/rpc-tests/wallet_listnotes.py b/qa/rpc-tests/wallet_listnotes.py index 90fbcced1..2a1aa8fce 100755 --- a/qa/rpc-tests/wallet_listnotes.py +++ b/qa/rpc-tests/wallet_listnotes.py @@ -2,7 +2,7 @@ # Copyright (c) 2019-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, start_nodes, wait_and_assert_operationid_status diff --git a/qa/rpc-tests/wallet_listreceived.py b/qa/rpc-tests/wallet_listreceived.py index ec9ac9371..dbc8a3fa9 100755 --- a/qa/rpc-tests/wallet_listreceived.py +++ b/qa/rpc-tests/wallet_listreceived.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_true, assert_false diff --git a/qa/rpc-tests/wallet_mergetoaddress.py b/qa/rpc-tests/wallet_mergetoaddress.py index e5d5089a4..61cf8baef 100755 --- a/qa/rpc-tests/wallet_mergetoaddress.py +++ b/qa/rpc-tests/wallet_mergetoaddress.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/wallet_nullifiers.py b/qa/rpc-tests/wallet_nullifiers.py index 9b4e5649c..9da25ce45 100755 --- a/qa/rpc-tests/wallet_nullifiers.py +++ b/qa/rpc-tests/wallet_nullifiers.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/wallet_overwintertx.py b/qa/rpc-tests/wallet_overwintertx.py index d77a114db..3969927a4 100755 --- a/qa/rpc-tests/wallet_overwintertx.py +++ b/qa/rpc-tests/wallet_overwintertx.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/wallet_persistence.py b/qa/rpc-tests/wallet_persistence.py index 581cad473..190509a58 100755 --- a/qa/rpc-tests/wallet_persistence.py +++ b/qa/rpc-tests/wallet_persistence.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( diff --git a/qa/rpc-tests/wallet_protectcoinbase.py b/qa/rpc-tests/wallet_protectcoinbase.py index 71512840d..b181c02c6 100755 --- a/qa/rpc-tests/wallet_protectcoinbase.py +++ b/qa/rpc-tests/wallet_protectcoinbase.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/wallet_shieldcoinbase.py b/qa/rpc-tests/wallet_shieldcoinbase.py index f325b29ca..8f24a2587 100755 --- a/qa/rpc-tests/wallet_shieldcoinbase.py +++ b/qa/rpc-tests/wallet_shieldcoinbase.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/wallet_treestate.py b/qa/rpc-tests/wallet_treestate.py index b3edcd7c5..d965558a2 100755 --- a/qa/rpc-tests/wallet_treestate.py +++ b/qa/rpc-tests/wallet_treestate.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/walletbackup.py b/qa/rpc-tests/walletbackup.py index 78128ad49..b552cf961 100755 --- a/qa/rpc-tests/walletbackup.py +++ b/qa/rpc-tests/walletbackup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php """ Exercise the wallet backup code. Ported from walletbackup.sh. diff --git a/qa/rpc-tests/zapwallettxes.py b/qa/rpc-tests/zapwallettxes.py index 5da4ba125..a61f18ebb 100755 --- a/qa/rpc-tests/zapwallettxes.py +++ b/qa/rpc-tests/zapwallettxes.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/zkey_import_export.py b/qa/rpc-tests/zkey_import_export.py index 775233b6d..aeae9aa9f 100755 --- a/qa/rpc-tests/zkey_import_export.py +++ b/qa/rpc-tests/zkey_import_export.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/zmq_test.py b/qa/rpc-tests/zmq_test.py index dcb899861..117d16048 100755 --- a/qa/rpc-tests/zmq_test.py +++ b/qa/rpc-tests/zmq_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test ZMQ interface diff --git a/src/Makefile.am b/src/Makefile.am index b44dd13c5..dc66cb4a8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,9 +54,6 @@ LIBZCASH=libzcash.a if ENABLE_ZMQ LIBBITCOIN_ZMQ=libbitcoin_zmq.a endif -if ENABLE_PROTON -LIBBITCOIN_PROTON=libbitcoin_proton.a -endif if BUILD_BITCOIN_LIBS LIBZCASH_CONSENSUS=libzcashconsensus.la endif @@ -65,13 +62,13 @@ LIBBITCOIN_WALLET=libbitcoin_wallet.a endif $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g " + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -g " $(LIBUNIVALUE): $(wildcard univalue/lib/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g " + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -g " $(LIBCRYPTOCONDITIONS): $(wildcard cryptoconditions/src/*) $(wildcard cryptoconditions/include/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g " + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -g " # Make is not made aware of per-object dependencies to avoid limiting building parallelization # But to build the less dependent modules first, we manually select their order here: @@ -89,9 +86,6 @@ endif if ENABLE_ZMQ EXTRA_LIBRARIES += $(LIBBITCOIN_ZMQ) endif -if ENABLE_PROTON -EXTRA_LIBRARIES += $(LIBBITCOIN_PROTON) -endif lib_LTLIBRARIES = $(LIBZCASH_CONSENSUS) @@ -331,15 +325,6 @@ libbitcoin_zmq_a_SOURCES = \ zmq/zmqpublishnotifier.cpp endif -if ENABLE_PROTON -libbitcoin_proton_a_CPPFLAGS = $(BITCOIN_INCLUDES) -libbitcoin_proton_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -libbitcoin_proton_a_SOURCES = \ - amqp/amqpabstractnotifier.cpp \ - amqp/amqpnotificationinterface.cpp \ - amqp/amqppublishnotifier.cpp -endif - # wallet: komodod, but only linked when wallet enabled libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -477,7 +462,7 @@ libbitcoin_server_a_SOURCES += rpc/testtransactions.cpp endif -# cli: zcash-cli +# cli libbitcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_cli_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_cli_a_SOURCES = \ @@ -504,7 +489,6 @@ komodod_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ $(LIBBITCOIN_ZMQ) \ - $(LIBBITCOIN_PROTON) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH) \ $(LIBLEVELDB) \ @@ -524,7 +508,6 @@ komodod_LDADD += \ $(EVENT_PTHREADS_LIBS) \ $(EVENT_LIBS) \ $(ZMQ_LIBS) \ - $(PROTON_LIBS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) @@ -538,10 +521,6 @@ if TARGET_LINUX komodod_LDADD += libcc.so $(LIBSECP256K1) endif -if ENABLE_PROTON -komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) -endif - # [+] Decker: use static linking for libstdc++.6.dylib, libgomp.1.dylib, libgcc_s.1.dylib if TARGET_DARWIN komodod_LDFLAGS += -static-libgcc diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index 1f1b511db..bcf2ddaf9 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -1,4 +1,5 @@ - +# Copyright (c) 2019-2020 Hush developers +# Released under the GPLv3 TESTS += komodo-gtest bin_PROGRAMS += komodo-gtest @@ -9,7 +10,6 @@ komodo_gtest_SOURCES = \ gtest/test_checktransaction.cpp \ gtest/json_test_vectors.cpp \ gtest/json_test_vectors.h \ - # gtest/test_foundersreward.cpp \ gtest/test_wallet_zkeys.cpp \ # These tests are order-dependent, because they # depend on global state (see #1539) @@ -65,11 +65,6 @@ endif komodo_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) -if ENABLE_PROTON -komodo_gtest_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) -endif - - komodo_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static komodo_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 14324b02b..0e2433bfd 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -130,10 +130,6 @@ if ENABLE_ZMQ test_test_bitcoin_LDADD += $(ZMQ_LIBS) endif -if ENABLE_PROTON -test_test_bitcoin_LDADD += $(PROTON_LIBS) -endif - nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES) $(BITCOIN_TESTS): $(GENERATED_TEST_FILES) diff --git a/src/addressindex.h b/src/addressindex.h index 643f06e13..804dd57cd 100644 --- a/src/addressindex.h +++ b/src/addressindex.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ADDRESSINDEX_H #define BITCOIN_ADDRESSINDEX_H @@ -79,4 +80,4 @@ struct CMempoolAddressDeltaKeyCompare } }; -#endif // BITCOIN_ADDRESSINDEX_H \ No newline at end of file +#endif // BITCOIN_ADDRESSINDEX_H diff --git a/src/addrman.cpp b/src/addrman.cpp index 1c8bf4b7c..2f02f3b17 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012 Pieter Wuille +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -268,7 +269,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP if (pinfo) { // periodically update nTime - bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60); + bool fCurrentlyOnline = (GetTime() - addr.nTime < 24 * 60 * 60); int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60); if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty)) pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty); diff --git a/src/addrman.h b/src/addrman.h index 0390b4e9b..b23ab5aa3 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -1,6 +1,7 @@ // Copyright (c) 2012 Pieter Wuille +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -112,10 +113,10 @@ public: int GetBucketPosition(const uint256 &nKey, bool fNew, int nBucket) const; //! Determine whether the statistics about this entry are bad enough so that it can just be deleted - bool IsTerrible(int64_t nNow = GetAdjustedTime()) const; + bool IsTerrible(int64_t nNow = GetTime()) const; //! Calculate the relative chance this entry should be given when selecting nodes to connect to - double GetChance(int64_t nNow = GetAdjustedTime()) const; + double GetChance(int64_t nNow = GetTime()) const; }; @@ -530,7 +531,7 @@ public: } //! Mark an entry as accessible. - void Good(const CService &addr, int64_t nTime = GetAdjustedTime()) + void Good(const CService &addr, int64_t nTime = GetTime()) { { LOCK(cs); @@ -541,7 +542,7 @@ public: } //! Mark an entry as connection attempted to. - void Attempt(const CService &addr, int64_t nTime = GetAdjustedTime()) + void Attempt(const CService &addr, int64_t nTime = GetTime()) { { LOCK(cs); @@ -580,7 +581,7 @@ public: } //! Mark an entry as currently-connected-to. - void Connected(const CService &addr, int64_t nTime = GetAdjustedTime()) + void Connected(const CService &addr, int64_t nTime = GetTime()) { { LOCK(cs); diff --git a/src/alert.cpp b/src/alert.cpp index 99f6472e9..db70cd620 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -1,7 +1,8 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -117,7 +118,7 @@ uint256 CAlert::GetHash() const bool CAlert::IsInEffect() const { - return (GetAdjustedTime() < nExpiration); + return (GetTime() < nExpiration); } bool CAlert::Cancels(const CAlert& alert) const @@ -152,7 +153,7 @@ bool CAlert::RelayTo(CNode* pnode) const { if (AppliesTo(pnode->nVersion, pnode->strSubVer) || AppliesToMe() || - GetAdjustedTime() < nRelayUntil) + GetTime() < nRelayUntil) { pnode->PushMessage("alert", *this); return true; diff --git a/src/alert.h b/src/alert.h index 16204c9c5..01bec7fdd 100644 --- a/src/alert.h +++ b/src/alert.h @@ -1,7 +1,8 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/alertkeys.h b/src/alertkeys.h index 106576add..1c4bcbc2c 100644 --- a/src/alertkeys.h +++ b/src/alertkeys.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -16,7 +17,7 @@ #ifndef BITCOIN_ALERTKEYS_H #define BITCOIN_ALERTKEYS_H -// REMINDER: DO NOT COMMIT YOUR PRIVATE KEYS TO THE GIT REPOSITORY! +// REMINDER: DO NOT COMMIT YOUR PRIVATE KEYS TO THE GIT REPOSITORY, lulz const char* pszPrivKey = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; const char* pszTestNetPrivKey = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; diff --git a/src/amount.cpp b/src/amount.cpp index 3feb37ccc..874d0dc72 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/amount.h b/src/amount.h index c5f49593c..942b22e69 100644 --- a/src/amount.h +++ b/src/amount.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/amqp/amqpabstractnotifier.cpp b/src/amqp/amqpabstractnotifier.cpp deleted file mode 100644 index 57686ef1d..000000000 --- a/src/amqp/amqpabstractnotifier.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "amqpabstractnotifier.h" -#include "util.h" - - -AMQPAbstractNotifier::~AMQPAbstractNotifier() -{ -} - -bool AMQPAbstractNotifier::NotifyBlock(const CBlockIndex * /*CBlockIndex*/) -{ - return true; -} - -bool AMQPAbstractNotifier::NotifyTransaction(const CTransaction &/*transaction*/) -{ - return true; -} diff --git a/src/amqp/amqpabstractnotifier.h b/src/amqp/amqpabstractnotifier.h deleted file mode 100644 index c993a2b3e..000000000 --- a/src/amqp/amqpabstractnotifier.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPABSTRACTNOTIFIER_H -#define ZCASH_AMQP_AMQPABSTRACTNOTIFIER_H - -#include "amqpconfig.h" - -class CBlockIndex; -class AMQPAbstractNotifier; - -typedef AMQPAbstractNotifier* (*AMQPNotifierFactory)(); - -class AMQPAbstractNotifier -{ -public: - AMQPAbstractNotifier() { } - virtual ~AMQPAbstractNotifier(); - - template - static AMQPAbstractNotifier* Create() - { - return new T(); - } - - std::string GetType() const { return type; } - void SetType(const std::string &t) { type = t; } - std::string GetAddress() const { return address; } - void SetAddress(const std::string &a) { address = a; } - - virtual bool Initialize() = 0; - virtual void Shutdown() = 0; - - virtual bool NotifyBlock(const CBlockIndex *pindex); - virtual bool NotifyTransaction(const CTransaction &transaction); - -protected: - std::string type; - std::string address; -}; - -#endif // ZCASH_AMQP_AMQPABSTRACTNOTIFIER_H diff --git a/src/amqp/amqpconfig.h b/src/amqp/amqpconfig.h deleted file mode 100644 index dcc5f7709..000000000 --- a/src/amqp/amqpconfig.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPCONFIG_H -#define ZCASH_AMQP_AMQPCONFIG_H - -#if defined(HAVE_CONFIG_H) -#include "config/bitcoin-config.h" -#endif - -#include -#include - -#if ENABLE_PROTON -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#include "primitives/block.h" -#include "primitives/transaction.h" - -#endif // ZCASH_AMQP_AMQPCONFIG_H diff --git a/src/amqp/amqpnotificationinterface.cpp b/src/amqp/amqpnotificationinterface.cpp deleted file mode 100644 index 66f5398ca..000000000 --- a/src/amqp/amqpnotificationinterface.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "amqpnotificationinterface.h" -#include "amqppublishnotifier.h" - -#include "version.h" -#include "main.h" -#include "streams.h" -#include "util.h" - -// AMQP 1.0 Support -// -// The boost::signals2 signals and slot system is thread safe, so CValidationInterface listeners -// can be invoked from any thread. -// -// Currently signals are fired from main.cpp so the callbacks should be invoked on the same thread. -// It should be safe to share objects responsible for sending, as they should not be run concurrently -// across different threads. -// -// Developers should be mindful of where notifications are fired to avoid potential race conditions. -// For example, different signals targeting the same address could be fired from different threads -// in different parts of the system around the same time. -// -// Like the ZMQ notification interface, if a notifier fails to send a message, the notifier is shut down. -// - -AMQPNotificationInterface::AMQPNotificationInterface() -{ -} - -AMQPNotificationInterface::~AMQPNotificationInterface() -{ - Shutdown(); - - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ++i) { - delete *i; - } -} - -AMQPNotificationInterface* AMQPNotificationInterface::CreateWithArguments(const std::map &args) -{ - AMQPNotificationInterface* notificationInterface = nullptr; - std::map factories; - std::list notifiers; - - factories["pubhashblock"] = AMQPAbstractNotifier::Create; - factories["pubhashtx"] = AMQPAbstractNotifier::Create; - factories["pubrawblock"] = AMQPAbstractNotifier::Create; - factories["pubrawtx"] = AMQPAbstractNotifier::Create; - - for (std::map::const_iterator i=factories.begin(); i!=factories.end(); ++i) { - std::map::const_iterator j = args.find("-amqp" + i->first); - if (j!=args.end()) { - AMQPNotifierFactory factory = i->second; - std::string address = j->second; - AMQPAbstractNotifier *notifier = factory(); - notifier->SetType(i->first); - notifier->SetAddress(address); - notifiers.push_back(notifier); - } - } - - if (!notifiers.empty()) { - notificationInterface = new AMQPNotificationInterface(); - notificationInterface->notifiers = notifiers; - - if (!notificationInterface->Initialize()) { - delete notificationInterface; - notificationInterface = nullptr; - } - } - - return notificationInterface; -} - -// Called at startup to conditionally set up -bool AMQPNotificationInterface::Initialize() -{ - LogPrint("amqp", "amqp: Initialize notification interface\n"); - - std::list::iterator i = notifiers.begin(); - for (; i != notifiers.end(); ++i) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->Initialize()) { - LogPrint("amqp", "amqp: Notifier %s ready (address = %s)\n", notifier->GetType(), notifier->GetAddress()); - } else { - LogPrint("amqp", "amqp: Notifier %s failed (address = %s)\n", notifier->GetType(), notifier->GetAddress()); - break; - } - } - - if (i != notifiers.end()) { - return false; - } - - return true; -} - -// Called during shutdown sequence -void AMQPNotificationInterface::Shutdown() -{ - LogPrint("amqp", "amqp: Shutdown notification interface\n"); - - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ++i) { - AMQPAbstractNotifier *notifier = *i; - notifier->Shutdown(); - } -} - -void AMQPNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex) -{ - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->NotifyBlock(pindex)) { - i++; - } else { - notifier->Shutdown(); - i = notifiers.erase(i); - } - } -} - -void AMQPNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlock *pblock) -{ - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->NotifyTransaction(tx)) { - i++; - } else { - notifier->Shutdown(); - i = notifiers.erase(i); - } - } -} diff --git a/src/amqp/amqpnotificationinterface.h b/src/amqp/amqpnotificationinterface.h deleted file mode 100644 index 0c07ce235..000000000 --- a/src/amqp/amqpnotificationinterface.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H -#define ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H - -#include "validationinterface.h" -#include -#include - -class CBlockIndex; -class AMQPAbstractNotifier; - -class AMQPNotificationInterface : public CValidationInterface -{ -public: - virtual ~AMQPNotificationInterface(); - - static AMQPNotificationInterface* CreateWithArguments(const std::map &args); - -protected: - bool Initialize(); - void Shutdown(); - - // CValidationInterface - void SyncTransaction(const CTransaction &tx, const CBlock *pblock); - void UpdatedBlockTip(const CBlockIndex *pindex); - -private: - AMQPNotificationInterface(); - - std::list notifiers; -}; - -#endif // ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H diff --git a/src/amqp/amqppublishnotifier.cpp b/src/amqp/amqppublishnotifier.cpp deleted file mode 100644 index 589eb151f..000000000 --- a/src/amqp/amqppublishnotifier.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "amqppublishnotifier.h" -#include "main.h" -#include "util.h" - -#include "amqpsender.h" - -#include -#include - -static std::multimap mapPublishNotifiers; - -static const char *MSG_HASHBLOCK = "hashblock"; -static const char *MSG_HASHTX = "hashtx"; -static const char *MSG_RAWBLOCK = "rawblock"; -static const char *MSG_RAWTX = "rawtx"; - -// Invoke this method from a new thread to run the proton container event loop. -void AMQPAbstractPublishNotifier::SpawnProtonContainer() -{ - try { - proton::default_container(*handler_).run(); - } - catch (const proton::error_condition &e) { - LogPrint("amqp", "amqp: container error: %s\n", e.what()); - } - catch (const std::runtime_error &e) { - LogPrint("amqp", "amqp: runtime error: %s\n", e.what()); - } - catch (const std::exception &e) { - LogPrint("amqp", "amqp: exception: %s\n", e.what()); - } - catch (...) { - LogPrint("amqp", "amqp: unknown error\n"); - } - handler_->terminate(); -} - -bool AMQPAbstractPublishNotifier::Initialize() -{ - std::multimap::iterator i = mapPublishNotifiers.find(address); - - if (i == mapPublishNotifiers.end()) { - try { - handler_ = std::make_shared(address); - thread_ = std::make_shared(&AMQPAbstractPublishNotifier::SpawnProtonContainer, this); - } - catch (std::exception &e) { - LogPrint("amqp", "amqp: initialization error: %s\n", e.what()); - return false; - } - mapPublishNotifiers.insert(std::make_pair(address, this)); - } else { - // copy the shared ptrs to the message handler and the thread where the proton container is running - handler_ = i->second->handler_; - thread_ = i->second->thread_; - mapPublishNotifiers.insert(std::make_pair(address, this)); - } - - return true; -} - - -void AMQPAbstractPublishNotifier::Shutdown() -{ - LogPrint("amqp", "amqp: Shutdown notifier %s at %s\n", GetType(), GetAddress()); - - int count = mapPublishNotifiers.count(address); - - // remove this notifier from the list of publishers using this address - typedef std::multimap::iterator iterator; - std::pair iterpair = mapPublishNotifiers.equal_range(address); - - for (iterator it = iterpair.first; it != iterpair.second; ++it) { - if (it->second == this) { - mapPublishNotifiers.erase(it); - break; - } - } - - // terminate the connection if this is the last publisher using this address - if (count == 1) { - handler_->terminate(); - if (thread_.get() != nullptr) { - if (thread_->joinable()) { - thread_->join(); - } - } - } -} - - -bool AMQPAbstractPublishNotifier::SendMessage(const char *command, const void* data, size_t size) -{ - try { - proton::binary content; - const char *p = (const char *)data; - content.assign(p, p + size); - - proton::message message(content); - message.subject(std::string(command)); - proton::message::property_map & props = message.properties(); - props.put("x-opt-sequence-number", sequence_); - handler_->publish(message); - - } catch (proton::error_condition &e) { - LogPrint("amqp", "amqp: error : %s\n", e.what()); - return false; - } - catch (const std::runtime_error &e) { - LogPrint("amqp", "amqp: runtime error: %s\n", e.what()); - return false; - } - catch (const std::exception &e) { - LogPrint("amqp", "amqp: exception: %s\n", e.what()); - return false; - } - catch (...) { - LogPrint("amqp", "amqp: unknown error\n"); - return false; - } - - sequence_++; - - return true; -} - -bool AMQPPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex) -{ - uint256 hash = pindex->GetBlockHash(); - LogPrint("amqp", "amqp: Publish hashblock %s\n", hash.GetHex()); - char data[32]; - for (unsigned int i = 0; i < 32; i++) - data[31 - i] = hash.begin()[i]; - return SendMessage(MSG_HASHBLOCK, data, 32); -} - -bool AMQPPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &transaction) -{ - uint256 hash = transaction.GetHash(); - LogPrint("amqp", "amqp: Publish hashtx %s\n", hash.GetHex()); - char data[32]; - for (unsigned int i = 0; i < 32; i++) - data[31 - i] = hash.begin()[i]; - return SendMessage(MSG_HASHTX, data, 32); -} - -bool AMQPPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex) -{ - LogPrint("amqp", "amqp: Publish rawblock %s\n", pindex->GetBlockHash().GetHex()); - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - { - LOCK(cs_main); - CBlock block; - if(!ReadBlockFromDisk(block, pindex)) { - LogPrint("amqp", "amqp: Can't read block from disk"); - return false; - } - - ss << block; - } - - return SendMessage(MSG_RAWBLOCK, &(*ss.begin()), ss.size()); -} - -bool AMQPPublishRawTransactionNotifier::NotifyTransaction(const CTransaction &transaction) -{ - uint256 hash = transaction.GetHash(); - LogPrint("amqp", "amqp: Publish rawtx %s\n", hash.GetHex()); - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << transaction; - return SendMessage(MSG_RAWTX, &(*ss.begin()), ss.size()); -} diff --git a/src/amqp/amqppublishnotifier.h b/src/amqp/amqppublishnotifier.h deleted file mode 100644 index 08b3aba08..000000000 --- a/src/amqp/amqppublishnotifier.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H -#define ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H - -#include "amqpabstractnotifier.h" -#include "amqpconfig.h" -#include "amqpsender.h" - -#include -#include - -class CBlockIndex; - -class AMQPAbstractPublishNotifier : public AMQPAbstractNotifier -{ -private: - uint64_t sequence_; // memory only, per notifier instance: upcounting message sequence number - - std::shared_ptr thread_; // proton container thread, may be shared between notifiers - std::shared_ptr handler_; // proton container message handler, may be shared between notifiers - -public: - bool SendMessage(const char *command, const void* data, size_t size); - bool Initialize(); - void Shutdown(); - void SpawnProtonContainer(); -}; - -class AMQPPublishHashBlockNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyBlock(const CBlockIndex *pindex); -}; - -class AMQPPublishHashTransactionNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyTransaction(const CTransaction &transaction); -}; - -class AMQPPublishRawBlockNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyBlock(const CBlockIndex *pindex); -}; - -class AMQPPublishRawTransactionNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyTransaction(const CTransaction &transaction); -}; - -#endif // ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H diff --git a/src/amqp/amqpsender.h b/src/amqp/amqpsender.h deleted file mode 100644 index 7fa85d89c..000000000 --- a/src/amqp/amqpsender.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPSENDER_H -#define ZCASH_AMQP_AMQPSENDER_H - -#include "amqpconfig.h" - -#include -#include -#include -#include - -class AMQPSender : public proton::messaging_handler { - private: - std::deque messages_; - proton::url url_; - proton::connection conn_; - proton::sender sender_; - std::mutex lock_; - std::atomic terminated_ = {false}; - - public: - - AMQPSender(const std::string& url) : url_(url) {} - - // Callback to initialize the container when run() is invoked - void on_container_start(proton::container& c) override { - proton::duration t(10000); // milliseconds - proton::connection_options opts = proton::connection_options().idle_timeout(t); - conn_ = c.connect(url_, opts); - sender_ = conn_.open_sender(url_.path()); - } - - // Remote end signals when the local end can send (i.e. has credit) - void on_sendable(proton::sender &s) override { - dispatch(); - } - - // Publish message by adding to queue and trying to dispatch it - void publish(const proton::message &m) { - add_message(m); - dispatch(); - } - - // Add message to queue - void add_message(const proton::message &m) { - std::lock_guard guard(lock_); - messages_.push_back(m); - } - - // Send messages in queue - void dispatch() { - std::lock_guard guard(lock_); - - if (isTerminated()) { - throw std::runtime_error("amqp connection was terminated"); - } - - if (!conn_.active()) { - throw std::runtime_error("amqp connection is not active"); - } - - while (messages_.size() > 0) { - if (sender_.credit()) { - const proton::message& m = messages_.front(); - sender_.send(m); - messages_.pop_front(); - } else { - break; - } - } - } - - // Close connection to remote end. Container event-loop, by default, will auto-stop. - void terminate() { - std::lock_guard guard(lock_); - conn_.close(); - terminated_.store(true); - } - - bool isTerminated() const { - return terminated_.load(); - } - - void on_transport_error(proton::transport &t) override { - t.connection().close(); - throw t.error(); - } - - void on_connection_error(proton::connection &c) override { - c.close(); - throw c.error(); - } - - void on_session_error(proton::session &s) override { - s.connection().close(); - throw s.error(); - } - - void on_receiver_error(proton::receiver &r) override { - r.connection().close(); - throw r.error(); - } - - void on_sender_error(proton::sender &s) override { - s.connection().close(); - throw s.error(); - } - -}; - - -#endif //ZCASH_AMQP_AMQPSENDER_H diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index d7a5c0afe..23c897f5f 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/arith_uint256.h b/src/arith_uint256.h index b51f82f14..223e97be5 100644 --- a/src/arith_uint256.h +++ b/src/arith_uint256.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/asyncrpcoperation.cpp b/src/asyncrpcoperation.cpp index 75c8da9e6..328b3b9ff 100644 --- a/src/asyncrpcoperation.cpp +++ b/src/asyncrpcoperation.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/asyncrpcoperation.h b/src/asyncrpcoperation.h index 3fe966977..5c6125df7 100644 --- a/src/asyncrpcoperation.h +++ b/src/asyncrpcoperation.h @@ -1,6 +1,7 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/asyncrpcqueue.cpp b/src/asyncrpcqueue.cpp index 5bcb20f8d..bb7532ad0 100644 --- a/src/asyncrpcqueue.cpp +++ b/src/asyncrpcqueue.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/asyncrpcqueue.h b/src/asyncrpcqueue.h index 0d228564f..ac42270e3 100644 --- a/src/asyncrpcqueue.h +++ b/src/asyncrpcqueue.h @@ -1,6 +1,7 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/base58.cpp b/src/base58.cpp index 383666d82..c270e5473 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/base58.h b/src/base58.h index 8be0247e0..dbedc677f 100644 --- a/src/base58.h +++ b/src/base58.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/bech32.cpp b/src/bech32.cpp index 78c35b976..ba2ba8904 100644 --- a/src/bech32.cpp +++ b/src/bech32.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2017 Pieter Wuille +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "bech32.h" diff --git a/src/bech32.h b/src/bech32.h index 2e2823e97..88a11486f 100644 --- a/src/bech32.h +++ b/src/bech32.h @@ -1,8 +1,9 @@ // Copyright (c) 2017 Pieter Wuille +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php -// Bech32 is a string encoding format used in newer address types. +// Bech32 is a string encoding format used in Sapling zaddrs // The output consists of a human-readable part (alphanumeric), a // separator character (1), and a base32 data section, the last // 6 characters of which are a checksum. diff --git a/src/bitcoin-cli-res.rc b/src/bitcoin-cli-res.rc index 3e46f5a16..a2fc33737 100644 --- a/src/bitcoin-cli-res.rc +++ b/src/bitcoin-cli-res.rc @@ -16,12 +16,12 @@ BEGIN BEGIN BLOCK "040904E4" // U.S. English - multilingual (hex) BEGIN - VALUE "CompanyName", "Komodo" - VALUE "FileDescription", "komodo-cli (JSON-RPC client for Komodo)" + VALUE "CompanyName", "Hush" + VALUE "FileDescription", "komodo-cli (JSON-RPC client for Hush-flavored Komodo)" VALUE "FileVersion", VER_FILEVERSION_STR VALUE "InternalName", "komodo-cli" VALUE "LegalCopyright", COPYRIGHT_STR - VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or https://www.opensource.org/licenses/mit-license.php" VALUE "OriginalFilename", "komodo-cli.exe" VALUE "ProductName", "komodo-cli" VALUE "ProductVersion", VER_PRODUCTVERSION_STR diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 544972586..1c9b86959 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -101,12 +102,12 @@ static int AppInitRPC(int argc, char* argv[]) strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { - std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); + std::string strUsage = _("Hush RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { strUsage += "\n" + _("Usage:") + "\n" + - " komodo-cli [options] [params] " + _("Send command to Komodo") + "\n" + - " komodo-cli [options] help " + _("List commands") + "\n" + - " komodo-cli [options] help " + _("Get help for a command") + "\n"; + " hush-cli [options] [params] " + _("Send command to Hush") + "\n" + + " hush-cli [options] help " + _("List commands") + "\n" + + " hush-cli [options] help " + _("Get help for a command") + "\n"; strUsage += "\n" + HelpMessageCli(); } else { diff --git a/src/bitcoin-tx-res.rc b/src/bitcoin-tx-res.rc index cb540fdc1..a1b64f529 100644 --- a/src/bitcoin-tx-res.rc +++ b/src/bitcoin-tx-res.rc @@ -21,7 +21,7 @@ BEGIN VALUE "FileVersion", VER_FILEVERSION_STR VALUE "InternalName", "hush-tx" VALUE "LegalCopyright", COPYRIGHT_STR - VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or https://www.opensource.org/licenses/mit-license.php" VALUE "OriginalFilename", "hush-tx.exe" VALUE "ProductName", "hush-tx" VALUE "ProductVersion", VER_PRODUCTVERSION_STR diff --git a/src/bitcoind-res.rc b/src/bitcoind-res.rc index 246ba98ac..4e9f11470 100644 --- a/src/bitcoind-res.rc +++ b/src/bitcoind-res.rc @@ -21,7 +21,7 @@ BEGIN VALUE "FileVersion", VER_FILEVERSION_STR VALUE "InternalName", "komodod" VALUE "LegalCopyright", COPYRIGHT_STR - VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or https://www.opensource.org/licenses/mit-license.php" VALUE "OriginalFilename", "komodod.exe" VALUE "ProductName", "komodod" VALUE "ProductVersion", VER_PRODUCTVERSION_STR diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index f8dac619b..ac9a94d46 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/bloom.cpp b/src/bloom.cpp index d7a7742fe..dbef9b97a 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/bloom.h b/src/bloom.h index e4677d6d0..c5df9f4be 100644 --- a/src/bloom.h +++ b/src/bloom.h @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/cc/Makefile_custom b/src/cc/Makefile_custom old mode 100755 new mode 100644 index 79219ec96..3989eefa3 --- a/src/cc/Makefile_custom +++ b/src/cc/Makefile_custom @@ -2,6 +2,7 @@ SHELL = /bin/sh CC = gcc CC_DARWIN = g++-8 CC_WIN = x86_64-w64-mingw32-gcc-posix +CC_AARCH64 = aarch64-linux-gnu-g++ CFLAGS_DARWIN = -DBUILD_CUSTOMCC -std=c++11 -arch x86_64 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared CFLAGS_WIN = -Wno-write-strings -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../../depends/x86_64-w64-mingw32/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared @@ -28,6 +29,10 @@ else ifeq ($(HOST),x86_64-w64-mingw32) $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) cp $(TARGET_WIN) ../libcc.dll #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host +else ifeq ($(HOST),aarch64-linux-gnu) + $(info LINUX ARM 64bit ) + $(CC_AARCH64) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) + cp $(TARGET) ../libcc.so else $(info LINUX) $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) diff --git a/src/cc/makecustom b/src/cc/makecustom index 7f1c789c9..3516b4023 100755 --- a/src/cc/makecustom +++ b/src/cc/makecustom @@ -1,5 +1,5 @@ #!/bin/sh -if make -f Makefile_custom "$@"; then +if HOST="$HOST" make -B -f Makefile_custom "$@"; then echo CUSTOMCC BUILD SUCCESSFUL else echo CUSTOMCC BUILD FAILED diff --git a/src/chain.cpp b/src/chain.cpp index f8530056d..50bacf9ac 100644 --- a/src/chain.cpp +++ b/src/chain.cpp @@ -3,7 +3,7 @@ // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chain.h b/src/chain.h index 03fc75660..4f8d20b0d 100644 --- a/src/chain.h +++ b/src/chain.h @@ -1,8 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -276,9 +276,12 @@ public: //! inputs and outputs. int64_t nShieldedTx; - //! (memory only) Number of shielded outputs in the block up to and including this block. + //! (memory only) Number of shielded outputs int64_t nShieldedOutputs; + //! (memory only) Number of shielded spends + int64_t nShieldedSpends; + //! (memory only) Number of fully shielded transactions. A fully shielded transaction is defined //! as a transaction containing JoinSplits and only shielded inputs and outputs, i.e. no transparent // inputs or outputs: z->z or z->(z,z) or z->(z,z,z,) etc... @@ -332,6 +335,9 @@ public: //! (memory only) Number of shielded outputs in the chain up to and including this block. int64_t nChainShieldedOutputs; + //! (memory only) Number of shielded spends in the chain up to and including this block. + int64_t nChainShieldedSpends; + //! (memory only) Number of fully shielded transactions. A fully shielded transaction is defined //! as a transaction containing JoinSplits and only shielded inputs and outputs, i.e. no transparent // inputs or outputs: z->z or z->(z,z) or z->(z,z,z,) etc... @@ -429,18 +435,20 @@ public: nChainNotarizations = 0; nChainFullyShieldedTx = 0; nChainShieldedOutputs = 0; + nChainShieldedSpends = 0; nChainShieldedPayments = 0; nChainShieldingPayments = 0; nChainDeshieldingPayments = 0; nChainFullyShieldedPayments = 0; - // Shieldex Index stats + // Shielded Index stats nPayments = 0; nShieldedTx = 0; nShieldingTx = 0; nNotarizations = 0; nDeshieldingTx = 0; nShieldedOutputs = 0; + nShieldedSpends = 0; nFullyShieldedTx = 0; nShieldedPayments = 0; nShieldingPayments = 0; @@ -679,6 +687,7 @@ public: READWRITE(nDeshieldingPayments); READWRITE(nFullyShieldedPayments); READWRITE(nShieldedOutputs); + READWRITE(nShieldedSpends); } } diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 0a2b819e7..f53af85c5 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -544,6 +544,14 @@ int32_t MAX_BLOCK_SIZE(int32_t height) else return(2000000); } +// Change the Hush blocktime at run-time(!) +void hush_changeblocktime() +{ + pCurrentParams->consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; + pCurrentParams->consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + fprintf(stderr,"HUSH blocktime changing to %d seconds\n",ASSETCHAINS_BLOCKTIME); +} + void komodo_setactivation(int32_t height) { pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height; @@ -585,153 +593,79 @@ void *chainparams_commandline() pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = ASSETCHAINS_OVERWINTER; // Generated at 1575831755 via hush3 contrib/checkpoints.pl by Duke Leto if (strcmp(ASSETCHAINS_SYMBOL,"HUSH3") == 0) { + // Generated at 1596199654 via hush3 contrib/checkpoints.pl by Duke Leto checkpointData = //(Checkpoints::CCheckpointData) { boost::assign::map_list_of (0, pCurrentParams->consensus.hashGenesisBlock) - (1000, uint256S("0x0000001893130f005d2e90fcdf40057ae06390bd0490740aae2843e62aeb7bc2")) - (2000, uint256S("0x00000003003e6c8fa176ef293d1322514778343601fa21dfdb0c9aacef189576")) - (3000, uint256S("0x00000005c1419d252bc59d77c06e07aad61702c8b3e76d2070577a18159ab59d")) - (4000, uint256S("0x00000008bc4094ea475a871302361ffdc6bfd63ded049d172c8dad01ed67fd3c")) - (5000, uint256S("0x000000018f8543066baa9c5f83e981749da4cb625fad02c187b4a9c4693ebd60")) - (6000, uint256S("0x0000000567191591911b33b852e4b87de119df2c773bc800b5a3655be18eb98e")) - (7000, uint256S("0x000000082e7b000480d0317d9115f0d0737e78fa2381a2d6456f598bf83fe2f0")) - (8000, uint256S("0x0000000415226fff123cd868e255a23d72e204d61bb405fb9dde0810e7721ebf")) - (9000, uint256S("0x00000000bd26f7b8d6d80230aad06c0cd590758176b8558da7dfc14161a23ab7")) + // Generated at 1600532337 via hush3 contrib/checkpoints.pl by Duke Leto + (5000, uint256S("0x000000018f8543066baa9c5f83e981749da4cb625fad02c187b4a9c4693ebd60")) (10000, uint256S("0x00000002d177d1cbfeaf7c27a2a32766ea9063d222cbcc7623dc08355b07a3ad")) - (11000, uint256S("0x0000000284bcffa3bef4097178a94b6b9a788261981253cb8cd6db6b47634732")) - (12000, uint256S("0x000000006cf15fdb94253a9389d95ef607c3484c635fe0c8a1f1ec1e5a1c6865")) - (13000, uint256S("0x00000001cdc66e08f7f13c775aa1220a801a33df90edba7bbcffac8d06181207")) - (14000, uint256S("0x0000000443e432c7dbf0707a12c5671dd1ca606f962368a847bbcff2f5fc2135")) (15000, uint256S("0x000000008dbfbd5d5e27d819bf2989c5658c3494608bfa1320ad0b090660cd44")) - (16000, uint256S("0x00000003c6a59e5b10e1a1c6bef08dee4d33d1841156bf97e26c3e4df789b128")) - (17000, uint256S("0x00000001debe3734ef4b6aacedde4a6b04cd1c60d4cf37b9f4689f2225ff7c24")) - (18000, uint256S("0x00000002e37eccfa7bacd9c201468c754cbef50be9411e3f907891755eef4c6d")) - (19000, uint256S("0x000000044636331c0277abb5592529cae1303d2bd43981a8382b4cc152a8d024")) (20000, uint256S("0x00000000a7840e1fccedb13672804e94fcaa87c0360ee4f7353a6b93e5a59da8")) - (21000, uint256S("0x00000003a89b17d0cd489045ad62531c4211ee17c3609ed3e4291a067636d526")) - (22000, uint256S("0x0000000352a7a25b3fe5f1a32a2c42260d32345487b92b6e520eecec0ee6aca4")) - (23000, uint256S("0x00000002c1fdc5cc1211b7adff3b7e755059638fd98bd9da1cdd86bd9a0af1fd")) - (24000, uint256S("0x0000000603a6190bbfdcdc5da9645d069aebd7a0b29607077470089c7b4a1188")) (25000, uint256S("0x0000000519d6ab6ca9c705ebafa9946bce34934709621bc22227567e90608667")) - (26000, uint256S("0x0000000146e7314e2ebb2bfc10b9fe0fdd744734910a3971bbc4e970fe2c4cb9")) - (27000, uint256S("0x000000047060e4173b4edd6374c3580580981dea20d0b49ea15c9fdfa97ba104")) - (28000, uint256S("0x000000065eea521cccf6b1f99e1a77683717d02ddaed654a4c85d717e1e8c957")) - (29000, uint256S("0x00000001ecdbcd195e04f792721262dc79bb070e73b6606b389825b5ae8e4791")) (30000, uint256S("0x0000000240de901e9e70d2db5badf62886ab0e8c442107d571bc04b3bdd43052")) - (31000, uint256S("0x00000002d39f4f3504660e13e956c12aa3411a0ba392b3797d95f15e8fbd1958")) - (32000, uint256S("0x0000000130cd781ed559d553f35a6bc99ed252aadd92b2a461bd332ca2d69a96")) - (33000, uint256S("0x000000035ad950b0e78bbaf19f7a97865f29edd600e7aee4a3fce2e42db29d38")) - (34000, uint256S("0x00000004f33b5ff97c128bfbef656aa10341e2606f54e198d5280016d2578eca")) (35000, uint256S("0x00000000ad1ef91eb70011a94646c148f1b8949b464a0de82adf1ba1ce6175a5")) - (36000, uint256S("0x00000003b1450e1cf9f4e5f53534777b24039fcde81ec7ac1c2ea754a26fcd78")) - (37000, uint256S("0x0000000337c4407954be01dcaf75a660e4b5b69e9e923bd62e74b0e44f01d9df")) - (38000, uint256S("0x00000002b5d6f83f8d2ef7d88c3cdff1e444882819a70a7c7281d1d92f81bc9a")) - (39000, uint256S("0x00000001a1eb6a530b065c873f65219de3282c4f386ba68bc2a0b88dc2b4c5cd")) (40000, uint256S("0x000000013b65e22d0bb6a9103dc71da5a1b7fa2acbc1c7d7a4d8f7730c37d4ab")) - (41000, uint256S("0x000000027dbc2315769690cf93c79c54e0591c808d83decb66302492f0f79f1c")) - (42000, uint256S("0x00000000ca09a12162a92b9ecbf6bf00a2bb822a77dd142df26d81db95c21bed")) - (43000, uint256S("0x000000050c4c80b9e53b960a638bd231c193a383f0df162c720e4594ba427a4b")) - (44000, uint256S("0x00000000f42d6c43703dbb47847298cedcbef8a27018baed8f4a217e7d5d823c")) (45000, uint256S("0x00000004da449923c218bd3e69745ebafca41c32e0c81ab6b485ae6c4c80df18")) - (46000, uint256S("0x00000006e4bdf2707158e266d2d54294b20063c0f1723abed97fafe7ecf4b2de")) - (47000, uint256S("0x0000000015d099357b0c8cbc24d8e2bd18e5e47eabe6ff89c09c9837bb071cd8")) - (48000, uint256S("0x00000009c9ddaffefc5d5c78a6f89b872fdd732c16a5311debed6b92255f340b")) - (49000, uint256S("0x00000008447d907ddc1d87df0ea235636baaaf34bc1000620e8173f1d8f7758c")) (50000, uint256S("0x000000027470e84cd195242f199b90fde40b70f80fac7a7080b1517c95cf56c6")) - (51000, uint256S("0x000000015190913dec8a508bc219b0a0a1587b50acb23b48343010015cb5ec69")) - (52000, uint256S("0x000000071608ad395dc31dc3011d5cad7f7a7296e34490a1e9e2dcf060bcc649")) - (53000, uint256S("0x0000000608fa8a454c3c0e5e06bf091c4cfa131e7b91eb6622087cfc3fa4c149")) - (54000, uint256S("0x0000000455eac130c205512cc0bffaa3ecb2d393cbf0d9e943c3d5911ea06a4b")) (55000, uint256S("0x00000000a20b276ed95b261a51681fb2d0d58e528cc8cd2e5fb7fdeb732b1861")) - (56000, uint256S("0x000000016057dfbf2fc59650b63b7c2dc2379af75cf00c0ee3f3835e992ec11e")) - (57000, uint256S("0x00000003a1eff8b5160655111ff1c0f1426b2b879c1f6fd761332b82c8640c67")) - (58000, uint256S("0x00000001b0ac789061a277b553de1aae373533f5b6b1330326744ac7087c87c9")) - (59000, uint256S("0x0000000a0dee07bdf593a68e5463cb5553f9bce3367a39d88f07ea43709eba87")) (60000, uint256S("0x000000060382850eadef184b67f38c0b2de27157296f3d9d8e2b7b70b1f76127")) - (61000, uint256S("0x0000000492a93fd6c9eb080f3398517b39c8eaf835440d2571e515f76a931bf2")) - (62000, uint256S("0x00000005ee0b8f7fcae8e6b17b12ab66f17cf34697182afc29d863d9844a84a9")) - (63000, uint256S("0x000000045842b1c05c7e9a1a887e9a6ecdcaea2f4e03b9476031ed609ace91d2")) - (64000, uint256S("0x00000004259921159c0714b90b1950fbae7eee2a14687dcfc57ab22b39c8123c")) (65000, uint256S("0x0000000618eb1c909301585f6b8f17ee6d09da97c580fe70d59babcd7864b556")) - (66000, uint256S("0x000000049c85139efb1694525b5cf864a6021e49a412aaea9ff2b2b6ee04e1ca")) - (67000, uint256S("0x0000000141358b3ae2c4ab2a384f963f4fdc925060c42de5578aec82c1de3189")) - (68000, uint256S("0x0000000405b0273ba96d1e83e27e50ecf5f123c2e3e05b56524cc2cd79ea18e7")) - (69000, uint256S("0x0000000764c8a434a1583b2578155a18720bbad67cc2c06e2fb013e872b1b10e")) (70000, uint256S("0x00000006d11cf168399c719b2bb036eadd09e740c98764d82adf75f5a800e90d")) - (71000, uint256S("0x00000002339c3cf62fc4716899a0e341969d85146dcb98854607332f81e5f258")) - (72000, uint256S("0x000000055e39f9cd963bac08c9c10ab982491d50b66486099675b015016dad7a")) - (73000, uint256S("0x0000000766261dbd9e48a0d544d012f57ab7890a761d893851b63e0e5b5e47dc")) - (74000, uint256S("0x000000058bd8080674ffb086704fbfde45e91172d0784416ed5356d20bd60fd7")) (75000, uint256S("0x00000007abb9cb521244c988f0ace53bf230bdf9c9db75d0102472a721c6b038")) - (76000, uint256S("0x000000071789d7ecf5e8c7e1a982e119d0b9d6748cb01426a5b8fff77a54f76b")) - (77000, uint256S("0x00000007364be847b08481f87bbe4db69a79f5c4388e3c898ea140011a121ca7")) - (78000, uint256S("0x000000031b7afd1aa244d78056606bf718cb96cb1fe1656070d37ed9d4031ebf")) - (79000, uint256S("0x00000003125d8e62fa215c1797229d271db705299f43e1db85edb7ac68349127")) (80000, uint256S("0x000000031c23c3a1828b3a432ab27c6b34a93741f5711507abeb34a822ba5311")) - (81000, uint256S("0x0000000212aab2361322e29a1037b82624fc2acdb61dd457ae25e4dffca14b42")) - (82000, uint256S("0x00000003140442a0d3b5ba57d2e51ed4a2ec39fb6ee8c9e2d70d530f46843f57")) - (83000, uint256S("0x0000000404e963d87db2ccd709377d5fd8b28c67c51ffcace62290844b895ba0")) - (84000, uint256S("0x00000003076c29391d9a5910e287d5319f4bf29f92eb309a8dd72cbf98847102")) (85000, uint256S("0x00000006fc5823857bdd44f89f4a97838a9f735c7bdf81bd89f50110dc16fbab")) - (86000, uint256S("0x00000002247705c4f02ab4a672686dadba9de55fcf71433388a4250af6d1154d")) - (87000, uint256S("0x00000000302718129c873c0ba6e571512ab5c4216e0d978ed3ef1d4dccddbb26")) - (88000, uint256S("0x00000002129732e7d8d99d78eef4ed3318cdbd73883d88e7c2b9534d11284486")) - (89000, uint256S("0x00000001513759a2e2b6e6c30ee8db631957511adcefa518ad31e0b1ec4e789d")) (90000, uint256S("0x00000003e62dcb81fe33178e2dc45c70ca04733542179ac5d93bceb7c456f365")) - (91000, uint256S("0x00000000674963dd8d6d7dab67d1df8c6e9455cef55014aa15082722f9d7f115")) - (92000, uint256S("0x00000004f4e1151df0905baf82bd29ece0fc7db8d96a2ae6c0efad0e0e68e55e")) - (93000, uint256S("0x00000002876b9eb7b41e025d55d7dd740b5dc811eae0909169081e705c61b6b5")) - (94000, uint256S("0x00000001efdcd19bf060a424cd0cef2d04f0d206fae21a72a57b4cc8d1019421")) (95000, uint256S("0x00000002a22cae35b32e31ffbe55d2d56ef04f010aebd19f1536b7582c1ea4d9")) - (96000, uint256S("0x0000000433d2385e8260c26dabec1c5f7376ed63b478c5d94bc15ee521a86ee3")) - (97000, uint256S("0x00000003112c73fd4cf10604e1a44b7acd698e196cbe16e63abdcd34008f4b36")) - (98000, uint256S("0x0000000179fb7ea8e68c54de5d09e531b5cbbfe7f5d128f3f93f55576673ddc7")) - (99000, uint256S("0x00000002e8e3a9f26154b941837d42ad62ea153d75be61a13c04e2249a781243")) - (100000, uint256S("0x00000001bc1c40d120bf2df1654f3fb5e4d28d4ff292d05667cf5610042c794a")) - (101000, uint256S("0x00000003a52ec72d58bdb88096334a29eddb17fd454a7c15aba815358f3b4285")) - (102000, uint256S("0x00000002a602644eb8765aab158112307f25bc6e8f82c1220be08642be6d12ca")) - (103000, uint256S("0x000000044a6a0aca758af879fee5bbbfc4ac75287f63cc91ad26bc921d3c44ac")) - (104000, uint256S("0x000000013fe4abb66862573821938d8e203da577e8c15055249a5fc4d6ca28f6")) - (105000, uint256S("0x0000000175182a7f9c46aaae8723a664168af4be37c5d73e8f773df6b67a458b")) - (106000, uint256S("0x000000005426bdc52efa996e5bd44f0d5f075fdd865063a1c5c341f4b37aa8d7")) - (107000, uint256S("0x000000026ce5ee0c6f81786838f502ab3ac4b52371716b3956bb58f91fe2a79e")) - (108000, uint256S("0x000000042a0f660df6ef24e237b4010749b7cc7ba402fe7f6af98643df62cb0b")) - (109000, uint256S("0x000000020debe96d90bc1d317036404c4518309e93c45303f86bdef7fac213df")) - (110000, uint256S("0x000000030ba3cdbb85d5028379dfe50fbf28c04f8add3300814c2f649ec53594")) - (111000, uint256S("0x000000030d9aa7e30990157616d54e5c32a26a0fbb5db1a7fde7e192bb2bd992")) - (112000, uint256S("0x00000003885472c246e7f5cc5c9982ce0d1ed292ff0b09451c272f201ff1bd3a")) - (113000, uint256S("0x000000027d6d7f782a510fa9b2a41f8f1a713fa4ff12906e453ba59af911cbfc")) - (114000, uint256S("0x000000046020cd15a3803db747ec6811bee5703c9b67b54185d8fae23f7617cf")) - (115000, uint256S("0x000000019fd1a317c649c83c6b2a3f6bca7e82fac2fc89ce69de4b6d5715050b")) - (116000, uint256S("0x00000002cad5e312f8553c3ca053f3588d53561722ce3bf20d55eb4654707668")) - (117000, uint256S("0x0000000339f55a289fabf4881ab5d89739779bc0e1ab5650830b4fec8870d183")) - (118000, uint256S("0x000000027bc70600ad7355ee66e6ca0b9d2fd24b7778014bb464a7bbc37627de")) - (119000, uint256S("0x00000001ddca829e3480f45ec3f7291fe9d611dd4600c047516729052a881058")) - (120000, uint256S("0x0000000217decb42c4ea26cbee700e728a558ae648393b8014f035566ef2a456")) - (121000, uint256S("0x00000000f2798338531f5a39201960a80ec28203cdd5dcd27718f6a7fd6723bf")) - (122000, uint256S("0x00000001204dfcde9f95ef04a25f54553329a48fe34078e213d93199dfe0c26b")) - (123000, uint256S("0x0000000220091729c30ec5a296a5218e0500bff2dfe10a5d9e5ceca2ea39482b")) - (124000, uint256S("0x00000002415360bf949d8e96362ce7b0aada6adbcfb73aba536fa7a329fec49f")) - (125000, uint256S("0x000000002aeab45f5e399d027976c49f4c7732ddbb78d7dc729fb226346ea3f1")) - (126000, uint256S("0x0000000067f239b6b78180145dc4ccbda1c71d506201f807912ddc170683808d")) - (127000, uint256S("0x00000001962a64e4e5a9e9c6cc286e2bcf155734c24f2c9481128e37ac6d9712")) - (128000, uint256S("0x000000011dfac6f7447ae6de5002dd3bf5ddc94faadb706f45e0b4724257dfe5")) - (129000, uint256S("0x0000000014f4aa454784a182645fa425834f8f9464abea319ea0afe5d3ccd91a")) - (130000, uint256S("0x000000001c4a5aa11e6c142931463fcf7a9f5b9fb41061d26c18ff1860431881")) - (131000, uint256S("0x000000003c44e490a60f7aa1941835277230706cfbf58dc8113610cc9c3582eb")) - (132000, uint256S("0x0000000041bef6adaff29263986224bd5a2999e2aec38aa07b52fa67eed1402f")) - (133000, uint256S("0x0000000162eb0ea1633481197a8ddc3743ff32ce2e8ecc249f9a8e9912459e05")) - (134000, uint256S("0x00000002a34611317b4b1d8bc8640282ffb7d7c86fc858af7e0abb0bca6b720d")) - (135000, uint256S("0x000000025f9502fc7474d62a0a23417cc5b77f3a049260e65b5b810d71074743")) - (136000, uint256S("0x00000000af2a19997fde28b70235070f627f3b5900a9ee13c927529a11110bc6")), - (int64_t) 1575741799, // time of last checkpointed block - (int64_t) 274689, // total txs - (double) 1065 // txs in the last day before block 136590 + (100000, uint256S("0x00000001bc1c40d120bf2df1654f3fb5e4d28d4ff292d05667cf5610042c794a")) + (105000, uint256S("0x0000000175182a7f9c46aaae8723a664168af4be37c5d73e8f773df6b67a458b")) + (110000, uint256S("0x000000030ba3cdbb85d5028379dfe50fbf28c04f8add3300814c2f649ec53594")) + (115000, uint256S("0x000000019fd1a317c649c83c6b2a3f6bca7e82fac2fc89ce69de4b6d5715050b")) + (120000, uint256S("0x0000000217decb42c4ea26cbee700e728a558ae648393b8014f035566ef2a456")) + (125000, uint256S("0x000000002aeab45f5e399d027976c49f4c7732ddbb78d7dc729fb226346ea3f1")) + (130000, uint256S("0x000000001c4a5aa11e6c142931463fcf7a9f5b9fb41061d26c18ff1860431881")) + (135000, uint256S("0x000000025f9502fc7474d62a0a23417cc5b77f3a049260e65b5b810d71074743")) + (140000, uint256S("0x00000000ea91b31e677db9f506e9de4ce03b609275212072759aada24b4654bf")) + (145000, uint256S("0x000000003f623cfbe83830077ce9d79f692cb1cd39f027d2bbfba0861dc050d7")) + (150000, uint256S("0x00000001850c65319eb4048f175e9540091dad9e4a7f8aeb5c989137e15a8524")) + (155000, uint256S("0x00000003c30e0e03841c63a47e934c0ba7f42578c6065ca03436dca8c99918da")) + (160000, uint256S("0x0000000553274de0e5f07bf3a63bdb6ab71158a3506829fd6f7df2cd51d5b2a3")) + (165000, uint256S("0x00000002c72ab9752b4f605b303f5c006600eb8e62baab7016af2e0454894c9b")) + (170000, uint256S("0x0000000191d6e3c5473215ab1e28a8fa8db6172eb4ec6fed371d4bd71224adb0")) + (175000, uint256S("0x00000000ac73f67cdc92b225e0895054ba4349d68ddca707ba536d9946f14a2b")) + (180000, uint256S("0x00000003119d28eed1fd0c2e2a33510b2b740c1227a9e0e59157228f8e9e1666")) + (185000, uint256S("0x000000032f71875bf21794a8aa44720e10bef77c12af1aec30951999a4d190d7")) + (190000, uint256S("0x000000002beb4cc8e79a3aed7b1b8329b31a55a3e1556b0933953450a0c185b9")) + (195000, uint256S("0x00000001f2fec10089b395c2df2edbfd15e67077ea48706a43bedaf5eae0e5ca")) + (200000, uint256S("0x00000003d57cdb7fba2f3b641d288737945de2434adeb0b3b3f2ef35a66e45ab")) + (205000, uint256S("0x000000011c8311c289958290444111ffc33261773cc171bfe9a492f59dd2be01")) + (210000, uint256S("0x000000006e43c9650b62ae15d05ada7d12be75df37a8b600b636268b144e2aab")) + (215000, uint256S("0x0000000385861debdf375a584fc33c6da0a13b9ae41cb904483903f29b8f423c")) + (220000, uint256S("0x00000000dd40d7372e60da03205bfc9bd796cc467737e093a58ab08b688014a4")) + (225000, uint256S("0x0000000216ec6bc7a702846ac429ff9e9b1dc14c0528689e810f663a05045f24")) + (230000, uint256S("0x000000015b0545acc87aa652a8d8d5aac1ecfc5e15d9e3a9e4171d472fdfa9b4")) + (235000, uint256S("0x00000000b841e412b8828fe64693bec0a6922d048f8ae061ba547fcad93f7e8f")) + (240000, uint256S("0x000000013e22209c4587e7fce090b7219f2d96640172697d276b606cf53ce07b")) + (245000, uint256S("0x00000002c0b1deff663826669c4a5bbfcba9cf7029598a35bb999afb27cce854")) + (250000, uint256S("0x00000003cba3713646dc533b75fba6f6fe02779e4fb934cda4fe2109c9403268")) + (255000, uint256S("0x00000000b76f444f3f5258a2d20d2639c0bffebb6ee0217caa56fcd0404337d5")) + (260000, uint256S("0x00000001f2dc5f292d9ee232d463faf1bc59362b9b3432f5bd1f72ffc76716f8")) + (265000, uint256S("0x00000003c2dc488c16fc1d73b288065e89bfb9e38dd08cc543867b0b7aa26047")) + (270000, uint256S("0x000000026cc545eed18b508c3368cd20256c012bfa10f5f115b21ad0101c02cb")) + (275000, uint256S("0x0000000376ee6074814c8274238f88e48f96a87ee6ba63e7d349554128087014")) + (280000, uint256S("0x000000036b2c0edb762736b4243cdba4d5b576456cc4c6b6a29ed69d27f0c4d9")) + (285000, uint256S("0x000000064ca1b27d679ffc9e25af53d531d9f80bc00fd130f5a71054b2f96124")) + (290000, uint256S("0x00000000c9bd5248099f4caca2a5b1da88548cd1824bb22a0efa6c30cf6ccfce")) + (295000, uint256S("0x00000002fb6bbf41e4f17f88301895c9143ea93e628523b97e5bd5765070d803")) + (300000, uint256S("0x000000033322d90275a09f4094e5c43db1f7017f788145d5a0edfa8200ecedad")), + (int64_t) 1600695750, // time of last checkpointed block + (int64_t) 576831, // total txs + (double) 1134 // txs in the last day before block 300768 }; } else { checkpointData = //(Checkpoints::CCheckpointData) - { + { boost::assign::map_list_of (0, pCurrentParams->consensus.hashGenesisBlock), (int64_t)1231006505, @@ -742,6 +676,7 @@ void *chainparams_commandline() } pCurrentParams->SetCheckpointData(checkpointData); + fprintf(stderr,"%s: Set checkpoint data\n", __func__); ASSETCHAIN_INIT = 1; return(0); diff --git a/src/chainparams.h b/src/chainparams.h index daa16af8c..3cbca2f9b 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 4ec957ba1..ad08fd314 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h index 94e3a4238..68e15dc06 100644 --- a/src/chainparamsbase.h +++ b/src/chainparamsbase.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 026475f88..50c1dd992 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/checkpoints.h b/src/checkpoints.h index 1b21755f0..2c8e9943a 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -1,6 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/checkqueue.h b/src/checkqueue.h index fc3cdb610..9c09dfdc1 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -1,6 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 084bbd5ce..aa3a02198 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -64,6 +65,7 @@ const std::string CLIENT_NAME = GetArg("-clientname", "MagicBean"); #include "build.h" #endif +//TODO: clean up this stuff //! git will put "#define GIT_ARCHIVE 1" on the next line inside archives. #define GIT_ARCHIVE 1 #ifdef GIT_ARCHIVE diff --git a/src/clientversion.h b/src/clientversion.h index c62e6d3e0..1b82e158b 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -2,7 +2,7 @@ // Copyright (c) 2016-2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -33,7 +33,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 ! #define CLIENT_VERSION_MAJOR 3 -#define CLIENT_VERSION_MINOR 4 +#define CLIENT_VERSION_MINOR 5 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 50 @@ -56,7 +56,7 @@ #define DO_STRINGIZE(X) #X //! Copyright string used in Windows .rc files -#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, The Zcash developers, Komodo developers, Hush developers" +#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core, Zcash, Komodo, Hush Developers" /** * bitcoind-res.rc includes this file, but it cannot cope with real c++ code. diff --git a/src/coincontrol.h b/src/coincontrol.h index 02d487a4c..38cc9fc96 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -1,6 +1,7 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/coins.cpp b/src/coins.cpp index 03b046a70..3f96cead9 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/coins.h b/src/coins.h index 2d08be42c..bebd99f77 100644 --- a/src/coins.h +++ b/src/coins.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/compat.h b/src/compat.h index 44b7dcee2..53f08d928 100644 --- a/src/compat.h +++ b/src/compat.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/compat/byteswap.h b/src/compat/byteswap.h index 899220bdc..70832d157 100644 --- a/src/compat/byteswap.h +++ b/src/compat/byteswap.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_COMPAT_BYTESWAP_H #define BITCOIN_COMPAT_BYTESWAP_H diff --git a/src/compat/endian.h b/src/compat/endian.h index 9fec2a07f..faf83fa48 100644 --- a/src/compat/endian.h +++ b/src/compat/endian.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_COMPAT_ENDIAN_H #define BITCOIN_COMPAT_ENDIAN_H diff --git a/src/compat/glibc_compat.cpp b/src/compat/glibc_compat.cpp index 3b9c70df7..9edc33d27 100644 --- a/src/compat/glibc_compat.cpp +++ b/src/compat/glibc_compat.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/compat/glibc_sanity.cpp b/src/compat/glibc_sanity.cpp index d62d74d46..9103be293 100644 --- a/src/compat/glibc_sanity.cpp +++ b/src/compat/glibc_sanity.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/compat/glibcxx_sanity.cpp b/src/compat/glibcxx_sanity.cpp index cee8a98c7..800ea93e2 100644 --- a/src/compat/glibcxx_sanity.cpp +++ b/src/compat/glibcxx_sanity.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/compat/sanity.h b/src/compat/sanity.h index 909c4f6da..90536fcc5 100644 --- a/src/compat/sanity.h +++ b/src/compat/sanity.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_COMPAT_SANITY_H #define BITCOIN_COMPAT_SANITY_H diff --git a/src/compat/strnlen.cpp b/src/compat/strnlen.cpp index 1ac266c2d..db7acc1fa 100644 --- a/src/compat/strnlen.cpp +++ b/src/compat/strnlen.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/compressor.cpp b/src/compressor.cpp index e3479474d..86dbcc562 100644 --- a/src/compressor.cpp +++ b/src/compressor.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/compressor.h b/src/compressor.h index f4e4a256d..e1626410e 100644 --- a/src/compressor.h +++ b/src/compressor.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index eba39b644..8613c89e7 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/params.h b/src/consensus/params.h index 67d84af0b..e4242ad33 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index 984ca377e..f7a4ffe8f 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2018 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/upgrades.h b/src/consensus/upgrades.h index 38eadc9ef..912968508 100644 --- a/src/consensus/upgrades.h +++ b/src/consensus/upgrades.h @@ -1,6 +1,6 @@ // Copyright (c) 2018 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/validation.h b/src/consensus/validation.h index a3d718c05..52a30cfd1 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/core_io.h b/src/core_io.h index dbf30b9e9..4627aa7b2 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/core_memusage.h b/src/core_memusage.h index b2f4a28ae..3b53d320d 100644 --- a/src/core_memusage.h +++ b/src/core_memusage.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CORE_MEMUSAGE_H #define BITCOIN_CORE_MEMUSAGE_H diff --git a/src/core_read.cpp b/src/core_read.cpp index 9817a2165..e0366c2fc 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/core_write.cpp b/src/core_write.cpp index 780540027..63cb51dae 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/crypto/bip39/Makefile b/src/crypto/bip39/Makefile new file mode 100644 index 000000000..4a5dec3d8 --- /dev/null +++ b/src/crypto/bip39/Makefile @@ -0,0 +1,66 @@ +CC ?= gcc + +OPTFLAGS ?= -O3 -g + +CFLAGS += $(OPTFLAGS) \ + -std=gnu99 \ + -W \ + -Wall \ + -Wextra \ + -Wimplicit-function-declaration \ + -Wredundant-decls \ + -Wstrict-prototypes \ + -Wundef \ + -Wshadow \ + -Wpointer-arith \ + -Wformat \ + -Wreturn-type \ + -Wsign-compare \ + -Wmultichar \ + -Wformat-nonliteral \ + -Winit-self \ + -Wuninitialized \ + -Wformat-security \ + -Werror + +VALGRIND ?= 1 + +CFLAGS += -I. +CFLAGS += -DVALGRIND=$(VALGRIND) +CFLAGS += $(shell pkg-config --cflags openssl) + +# disable certain optimizations and features when small footprint is required +ifdef SMALL +CFLAGS += -DUSE_PRECOMPUTED_CP=0 +endif + +SRCS = bignum.c ecdsa.c curves.c secp256k1.c nist256p1.c rand.c hmac.c bip32.c bip39.c pbkdf2.c base58.c base32.c +#SRCS += address.c +#SRCS += script.c +SRCS += ripemd160.c +SRCS += sha2.c +SRCS += sha3.c +SRCS += hasher.c +#SRCS += aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c +#SRCS += ed25519-donna/curve25519-donna-32bit.c ed25519-donna/curve25519-donna-helpers.c ed25519-donna/modm-donna-32bit.c +#SRCS += ed25519-donna/ed25519-donna-basepoint-table.c ed25519-donna/ed25519-donna-32bit-tables.c ed25519-donna/ed25519-donna-impl-base.c +#SRCS += ed25519-donna/ed25519.c ed25519-donna/curve25519-donna-scalarmult-base.c ed25519-donna/ed25519-sha3.c ed25519-donna/ed25519-keccak.c +#SRCS += blake256.c +#SRCS += blake2b.c blake2s.c +#SRCS += chacha20poly1305/chacha20poly1305.c chacha20poly1305/chacha_merged.c chacha20poly1305/poly1305-donna.c chacha20poly1305/rfc7539.c +SRCS += memzero.c + +OBJS = $(SRCS:.c=.o) + +TESTLIBS = $(shell pkg-config --libs check) -lpthread -lm +TESTSSLLIBS = $(shell pkg-config --libs openssl) + +all: hasher.o bip39.o memzero.o pbkdf2.o base58.o base32.o + @echo "Created object files, donezo" + +%.o: %.c %.h options.h + $(CC) $(CFLAGS) -o $@ -c $< + +clean: + rm -rf *.o + diff --git a/src/crypto/bip39/README.md b/src/crypto/bip39/README.md new file mode 100644 index 000000000..b8e03fc93 --- /dev/null +++ b/src/crypto/bip39/README.md @@ -0,0 +1,3 @@ +# trezor-firmware bip39 + +Imported from https://github.com/trezor/trezor-firmware/commit/047fcffde1f8530d3aee279b731e5e5f5901590a diff --git a/src/crypto/bip39/base32.c b/src/crypto/bip39/base32.c new file mode 100644 index 000000000..06760ccae --- /dev/null +++ b/src/crypto/bip39/base32.c @@ -0,0 +1,233 @@ +/** + * Copyright (c) 2017 Saleem Rashid + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, E1PRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "base32.h" + +#include + +const char *BASE32_ALPHABET_RFC4648 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ23456789"; + +static inline void base32_5to8(const uint8_t *in, uint8_t length, uint8_t *out); +static inline bool base32_8to5(const uint8_t *in, uint8_t length, uint8_t *out, const char *alphabet); +static inline void base32_8to5_raw(const uint8_t *in, uint8_t length, uint8_t *out); + +static inline int base32_encode_character(uint8_t decoded, const char *alphabet); +static inline int base32_decode_character(char encoded, const char *alphabet); + +char *base32_encode(const uint8_t *in, size_t inlen, char *out, size_t outlen, const char *alphabet) { + size_t length = base32_encoded_length(inlen); + if (outlen <= length) { + return NULL; + } + + base32_encode_unsafe(in, inlen, (uint8_t *) out); + + for (size_t i = 0; i < length; i++) { + int ret = base32_encode_character(out[i], alphabet); + + if (ret == -1) { + return false; + } else { + out[i] = ret; + } + } + + out[length] = '\0'; + return &out[length]; +} + +uint8_t *base32_decode(const char *in, size_t inlen, uint8_t *out, size_t outlen, const char *alphabet) { + size_t length = base32_decoded_length(inlen); + if (outlen < length) { + return NULL; + } + + if (!base32_decode_unsafe((uint8_t *) in, inlen, (uint8_t *) out, alphabet)) { + return NULL; + } + + return &out[length]; +} + +void base32_encode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out) { + uint8_t remainder = inlen % 5; + size_t limit = inlen - remainder; + + size_t i, j; + for (i = 0, j = 0; i < limit; i += 5, j += 8) { + base32_5to8(&in[i], 5, &out[j]); + } + + if (remainder) base32_5to8(&in[i], remainder, &out[j]); +} + +bool base32_decode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out, const char *alphabet) { + uint8_t remainder = inlen % 8; + size_t limit = inlen - remainder; + + size_t i, j; + for (i = 0, j = 0; i < limit; i += 8, j += 5) { + if (!base32_8to5(&in[i], 8, &out[j], alphabet)) { + return false; + } + } + + if (remainder && !base32_8to5(&in[i], remainder, &out[j], alphabet)) { + return false; + } + + return true; +} + +size_t base32_encoded_length(size_t inlen) { + uint8_t remainder = inlen % 5; + + return (inlen / 5) * 8 + (remainder * 8 + 4) / 5; +} + +size_t base32_decoded_length(size_t inlen) { + uint8_t remainder = inlen % 8; + + return (inlen / 8) * 5 + (remainder * 5) / 8; +} + +void base32_5to8(const uint8_t *in, uint8_t length, uint8_t *out) { + if (length >= 1) { + out[0] = (in[0] >> 3); + out[1] = (in[0] & 7) << 2; + } + + if (length >= 2) { + out[1] |= (in[1] >> 6); + out[2] = (in[1] >> 1) & 31; + out[3] = (in[1] & 1) << 4; + } + + if (length >= 3) { + out[3] |= (in[2] >> 4); + out[4] = (in[2] & 15) << 1; + } + + if (length >= 4) { + out[4] |= (in[3] >> 7); + out[5] = (in[3] >> 2) & 31; + out[6] = (in[3] & 3) << 3; + } + + if (length >= 5) { + out[6] |= (in[4] >> 5); + out[7] = (in[4] & 31); + } +} + +bool base32_8to5(const uint8_t *in, uint8_t length, uint8_t *out, const char *alphabet) { + if (length == 1 || length == 3 || length == 6 || length > 8) { + return false; + } + + if (alphabet) { + uint8_t decoded[length]; + + for (size_t i = 0; i < length; i++) { + int ret = base32_decode_character(in[i], alphabet); + + if (ret == -1) { + return false; + } else { + decoded[i] = ret; + } + } + + base32_8to5_raw(decoded, length, out); + } else { + base32_8to5_raw(in, length, out); + } + + return true; +} + +void base32_8to5_raw(const uint8_t *in, uint8_t length, uint8_t *out) { + if (length >= 2) { + out[0] = (in[0] << 3); + out[0] |= (in[1] >> 2); + } + + if (length >= 4) { + out[1] = (in[1] & 3) << 6; + out[1] |= (in[2] << 1); + out[1] |= (in[3] >> 4); + } + + if (length >= 5) { + out[2] = (in[3] & 15) << 4; + out[2] |= (in[4] >> 1); + } + + if (length >= 7) { + out[3] = (in[4] & 1) << 7; + out[3] |= (in[5] << 2); + out[3] |= (in[6] >> 3); + } + + if (length >= 8) { + out[4] = (in[6] & 7) << 5; + out[4] |= (in[7] & 31); + } +} + +int base32_encode_character(uint8_t decoded, const char *alphabet) { + if (decoded >> 5) { + return -1; + } + + if (alphabet == BASE32_ALPHABET_RFC4648) { + if (decoded < 26) { + return 'A' + decoded; + } else { + return '2' - 26 + decoded; + } + } + + return alphabet[decoded]; +} + +int base32_decode_character(char encoded, const char *alphabet) { + if (alphabet == BASE32_ALPHABET_RFC4648) { + if (encoded >= 'A' && encoded <= 'Z') { + return encoded - 'A'; + } else if (encoded >= 'a' && encoded <= 'z') { + return encoded - 'a'; + } else if (encoded >= '2' && encoded <= '7') { + return encoded - '2' + 26; + } else { + return -1; + } + } + + const char *occurrence = strchr(alphabet, encoded); + + if (occurrence) { + return occurrence - alphabet; + } else { + return -1; + } +} diff --git a/src/crypto/bip39/base32.h b/src/crypto/bip39/base32.h new file mode 100644 index 000000000..250997967 --- /dev/null +++ b/src/crypto/bip39/base32.h @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2017 Saleem Rashid + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __BASE32_H__ +#define __BASE32_H__ + +#include +#include +#include + +extern const char *BASE32_ALPHABET_RFC4648; + +char *base32_encode(const uint8_t *in, size_t inlen, char *out, size_t outlen, const char *alphabet); +void base32_encode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out); + +uint8_t *base32_decode(const char *in, size_t inlen, uint8_t *out, size_t outlen, const char *alphabet); +bool base32_decode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out, const char *alphabet); + +size_t base32_encoded_length(size_t inlen); +size_t base32_decoded_length(size_t inlen); + +#endif diff --git a/src/crypto/bip39/base58.c b/src/crypto/bip39/base58.c new file mode 100644 index 000000000..cd74617b8 --- /dev/null +++ b/src/crypto/bip39/base58.c @@ -0,0 +1,285 @@ +/** + * Copyright (c) 2012-2014 Luke Dashjr + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include "base58.h" +#include "sha2.h" +#include "ripemd160.h" +#include "memzero.h" + +const char b58digits_ordered[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; +const int8_t b58digits_map[] = { + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8,-1,-1,-1,-1,-1,-1, + -1, 9,10,11,12,13,14,15,16,-1,17,18,19,20,21,-1, + 22,23,24,25,26,27,28,29,30,31,32,-1,-1,-1,-1,-1, + -1,33,34,35,36,37,38,39,40,41,42,43,-1,44,45,46, + 47,48,49,50,51,52,53,54,55,56,57,-1,-1,-1,-1,-1, +}; + +bool b58tobin(void *bin, size_t *binszp, const char *b58) +{ + size_t binsz = *binszp; + + if (binsz == 0) { + return false; + } + + const unsigned char *b58u = (const unsigned char*)b58; + unsigned char *binu = bin; + size_t outisz = (binsz + 3) / 4; + uint32_t outi[outisz]; + uint64_t t; + uint32_t c; + size_t i, j; + uint8_t bytesleft = binsz % 4; + uint32_t zeromask = bytesleft ? (0xffffffff << (bytesleft * 8)) : 0; + unsigned zerocount = 0; + size_t b58sz; + + b58sz = strlen(b58); + + memzero(outi, sizeof(outi)); + + // Leading zeros, just count + for (i = 0; i < b58sz && b58u[i] == '1'; ++i) + ++zerocount; + + for ( ; i < b58sz; ++i) + { + if (b58u[i] & 0x80) + // High-bit set on invalid digit + return false; + if (b58digits_map[b58u[i]] == -1) + // Invalid base58 digit + return false; + c = (unsigned)b58digits_map[b58u[i]]; + for (j = outisz; j--; ) + { + t = ((uint64_t)outi[j]) * 58 + c; + c = (t & 0x3f00000000) >> 32; + outi[j] = t & 0xffffffff; + } + if (c) + // Output number too big (carry to the next int32) + return false; + if (outi[0] & zeromask) + // Output number too big (last int32 filled too far) + return false; + } + + j = 0; + switch (bytesleft) { + case 3: + *(binu++) = (outi[0] & 0xff0000) >> 16; + //-fallthrough + case 2: + *(binu++) = (outi[0] & 0xff00) >> 8; + //-fallthrough + case 1: + *(binu++) = (outi[0] & 0xff); + ++j; + //-fallthrough + default: + break; + } + + for (; j < outisz; ++j) + { + *(binu++) = (outi[j] >> 0x18) & 0xff; + *(binu++) = (outi[j] >> 0x10) & 0xff; + *(binu++) = (outi[j] >> 8) & 0xff; + *(binu++) = (outi[j] >> 0) & 0xff; + } + + // Count canonical base58 byte count + binu = bin; + for (i = 0; i < binsz; ++i) + { + if (binu[i]) { + if (zerocount > i) { + /* result too large */ + return false; + } + break; + } + --*binszp; + } + *binszp += zerocount; + + return true; +} + +int b58check(const void *bin, size_t binsz, HasherType hasher_type, const char *base58str) +{ + unsigned char buf[32]; + const uint8_t *binc = bin; + unsigned i; + if (binsz < 4) + return -4; + hasher_Raw(hasher_type, bin, binsz - 4, buf); + if (memcmp(&binc[binsz - 4], buf, 4)) + return -1; + + // Check number of zeros is correct AFTER verifying checksum (to avoid possibility of accessing base58str beyond the end) + for (i = 0; binc[i] == '\0' && base58str[i] == '1'; ++i) + {} // Just finding the end of zeros, nothing to do in loop + if (binc[i] == '\0' || base58str[i] == '1') + return -3; + + return binc[0]; +} + +bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz) +{ + const uint8_t *bin = data; + int carry; + ssize_t i, j, high, zcount = 0; + size_t size; + + while (zcount < (ssize_t)binsz && !bin[zcount]) + ++zcount; + + size = (binsz - zcount) * 138 / 100 + 1; + uint8_t buf[size]; + memzero(buf, size); + + for (i = zcount, high = size - 1; i < (ssize_t)binsz; ++i, high = j) + { + for (carry = bin[i], j = size - 1; (j > high) || carry; --j) + { + carry += 256 * buf[j]; + buf[j] = carry % 58; + carry /= 58; + } + } + + for (j = 0; j < (ssize_t)size && !buf[j]; ++j); + + if (*b58sz <= zcount + size - j) + { + *b58sz = zcount + size - j + 1; + return false; + } + + if (zcount) + memset(b58, '1', zcount); + for (i = zcount; j < (ssize_t)size; ++i, ++j) + b58[i] = b58digits_ordered[buf[j]]; + b58[i] = '\0'; + *b58sz = i + 1; + + return true; +} + +int base58_encode_check(const uint8_t *data, int datalen, HasherType hasher_type, char *str, int strsize) +{ + if (datalen > 128) { + return 0; + } + uint8_t buf[datalen + 32]; + uint8_t *hash = buf + datalen; + memcpy(buf, data, datalen); + hasher_Raw(hasher_type, data, datalen, hash); + size_t res = strsize; + bool success = b58enc(str, &res, buf, datalen + 4); + memzero(buf, sizeof(buf)); + return success ? res : 0; +} + +int base58_decode_check(const char *str, HasherType hasher_type, uint8_t *data, int datalen) +{ + if (datalen > 128) { + return 0; + } + uint8_t d[datalen + 4]; + size_t res = datalen + 4; + if (b58tobin(d, &res, str) != true) { + return 0; + } + uint8_t *nd = d + datalen + 4 - res; + if (b58check(nd, res, hasher_type, str) < 0) { + return 0; + } + memcpy(data, nd, res - 4); + return res - 4; +} + +#if USE_GRAPHENE +int b58gphcheck(const void *bin, size_t binsz, const char *base58str) +{ + unsigned char buf[32]; + const uint8_t *binc = bin; + unsigned i; + if (binsz < 4) + return -4; + ripemd160(bin, binsz - 4, buf); // No double SHA256, but a single RIPEMD160 + if (memcmp(&binc[binsz - 4], buf, 4)) + return -1; + + // Check number of zeros is correct AFTER verifying checksum (to avoid possibility of accessing base58str beyond the end) + for (i = 0; binc[i] == '\0' && base58str[i] == '1'; ++i) + {} // Just finding the end of zeros, nothing to do in loop + if (binc[i] == '\0' || base58str[i] == '1') + return -3; + + return binc[0]; +} + +int base58gph_encode_check(const uint8_t *data, int datalen, char *str, int strsize) +{ + if (datalen > 128) { + return 0; + } + uint8_t buf[datalen + 32]; + uint8_t *hash = buf + datalen; + memcpy(buf, data, datalen); + ripemd160(data, datalen, hash); // No double SHA256, but a single RIPEMD160 + size_t res = strsize; + bool success = b58enc(str, &res, buf, datalen + 4); + memzero(buf, sizeof(buf)); + return success ? res : 0; +} + +int base58gph_decode_check(const char *str, uint8_t *data, int datalen) +{ + if (datalen > 128) { + return 0; + } + uint8_t d[datalen + 4]; + size_t res = datalen + 4; + if (b58tobin(d, &res, str) != true) { + return 0; + } + uint8_t *nd = d + datalen + 4 - res; + if (b58gphcheck(nd, res, str) < 0) { + return 0; + } + memcpy(data, nd, res - 4); + return res - 4; +} +#endif diff --git a/src/crypto/bip39/base58.h b/src/crypto/bip39/base58.h new file mode 100644 index 000000000..0fa9167bf --- /dev/null +++ b/src/crypto/bip39/base58.h @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __BASE58_H__ +#define __BASE58_H__ + +#include +#include +#include "hasher.h" +#include "options.h" + +extern const char b58digits_ordered[]; +extern const int8_t b58digits_map[]; + +int base58_encode_check(const uint8_t *data, int len, HasherType hasher_type, char *str, int strsize); +int base58_decode_check(const char *str, HasherType hasher_type, uint8_t *data, int datalen); + +// Private +bool b58tobin(void *bin, size_t *binszp, const char *b58); +int b58check(const void *bin, size_t binsz, HasherType hasher_type, const char *base58str); +bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz); + +#if USE_GRAPHENE +int base58gph_encode_check(const uint8_t *data, int datalen, char *str, int strsize); +int base58gph_decode_check(const char *str, uint8_t *data, int datalen); +int b58gphcheck(const void *bin, size_t binsz, const char *base58str); +#endif + +#endif diff --git a/src/crypto/bip39/bip32.h b/src/crypto/bip39/bip32.h new file mode 100644 index 000000000..c0a04b5f8 --- /dev/null +++ b/src/crypto/bip39/bip32.h @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __BIP32_H__ +#define __BIP32_H__ + +#include +#include +#include +#include "ecdsa.h" +#include "ed25519-donna/ed25519.h" +#include "options.h" + +typedef struct { + const char *bip32_name; // string for generating BIP32 xprv from seed + const ecdsa_curve *params; // ecdsa curve parameters, null for ed25519 + + HasherType hasher_base58; + HasherType hasher_sign; + HasherType hasher_pubkey; + HasherType hasher_script; +} curve_info; + +typedef struct { + uint32_t depth; + uint32_t child_num; + uint8_t chain_code[32]; + + uint8_t private_key[32]; + uint8_t private_key_extension[32]; + + uint8_t public_key[33]; + const curve_info *curve; +} HDNode; + +int hdnode_from_xpub(uint32_t depth, uint32_t child_num, const uint8_t *chain_code, const uint8_t *public_key, const char *curve, HDNode *out); + +int hdnode_from_xprv(uint32_t depth, uint32_t child_num, const uint8_t *chain_code, const uint8_t *private_key, const char *curve, HDNode *out); + +int hdnode_from_seed(const uint8_t *seed, int seed_len, const char *curve, HDNode *out); + +#define hdnode_private_ckd_prime(X, I) hdnode_private_ckd((X), ((I) | 0x80000000)) + +int hdnode_private_ckd(HDNode *inout, uint32_t i); + +#if USE_CARDANO +int hdnode_private_ckd_cardano(HDNode *inout, uint32_t i); +int hdnode_from_seed_cardano(const uint8_t *pass, int pass_len, const uint8_t *seed, int seed_len, HDNode *out); +#endif + +int hdnode_public_ckd_cp(const ecdsa_curve *curve, const curve_point *parent, const uint8_t *parent_chain_code, uint32_t i, curve_point *child, uint8_t *child_chain_code); + +int hdnode_public_ckd(HDNode *inout, uint32_t i); + +void hdnode_public_ckd_address_optimized(const curve_point *pub, const uint8_t *chain_code, uint32_t i, uint32_t version, HasherType hasher_pubkey, HasherType hasher_base58, char *addr, int addrsize, int addrformat); + +#if USE_BIP32_CACHE +int hdnode_private_ckd_cached(HDNode *inout, const uint32_t *i, size_t i_count, uint32_t *fingerprint); +#endif + +uint32_t hdnode_fingerprint(HDNode *node); + +void hdnode_fill_public_key(HDNode *node); + +#if USE_ETHEREUM +int hdnode_get_ethereum_pubkeyhash(const HDNode *node, uint8_t *pubkeyhash); +#endif + +#if USE_NEM +int hdnode_get_nem_address(HDNode *node, uint8_t version, char *address); +int hdnode_get_nem_shared_key(const HDNode *node, const ed25519_public_key peer_public_key, const uint8_t *salt, ed25519_public_key mul, uint8_t *shared_key); +int hdnode_nem_encrypt(const HDNode *node, const ed25519_public_key public_key, const uint8_t *iv, const uint8_t *salt, const uint8_t *payload, size_t size, uint8_t *buffer); +int hdnode_nem_decrypt(const HDNode *node, const ed25519_public_key public_key, uint8_t *iv, const uint8_t *salt, const uint8_t *payload, size_t size, uint8_t *buffer); +#endif + +int hdnode_sign(HDNode *node, const uint8_t *msg, uint32_t msg_len, HasherType hasher_sign, uint8_t *sig, uint8_t *pby, int (*is_canonical)(uint8_t by, uint8_t sig[64])); +int hdnode_sign_digest(HDNode *node, const uint8_t *digest, uint8_t *sig, uint8_t *pby, int (*is_canonical)(uint8_t by, uint8_t sig[64])); + +int hdnode_get_shared_key(const HDNode *node, const uint8_t *peer_public_key, uint8_t *session_key, int *result_size); + +int hdnode_serialize_public(const HDNode *node, uint32_t fingerprint, uint32_t version, char *str, int strsize); + +int hdnode_serialize_private(const HDNode *node, uint32_t fingerprint, uint32_t version, char *str, int strsize); + +int hdnode_deserialize(const char *str, uint32_t version_public, uint32_t version_private, const char *curve, HDNode *node, uint32_t *fingerprint); + +void hdnode_get_address_raw(HDNode *node, uint32_t version, uint8_t *addr_raw); +void hdnode_get_address(HDNode *node, uint32_t version, char *addr, int addrsize); + +const curve_info *get_curve_by_name(const char *curve_name); + +#endif diff --git a/src/crypto/bip39/bip39.c b/src/crypto/bip39/bip39.c new file mode 100644 index 000000000..76e0792ad --- /dev/null +++ b/src/crypto/bip39/bip39.c @@ -0,0 +1,283 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +#include "bip39.h" +#include "bip39_english.h" +#include "hmac.h" +#include "memzero.h" +#include "options.h" +#include "pbkdf2.h" +#include "rand.h" +#include "sha2.h" + +#if USE_BIP39_CACHE + +int BIP39_WORDS = 2048; + +static int bip39_cache_index = 0; + +static CONFIDENTIAL struct { + bool set; + char mnemonic[256]; + char passphrase[64]; + uint8_t seed[512 / 8]; +} bip39_cache[BIP39_CACHE_SIZE]; + +#endif + +const char *mnemonic_generate(int strength) { + if (strength % 32 || strength < 128 || strength > 256) { + return 0; + } + uint8_t data[32] = {0}; + random_buffer(data, 32); + const char *r = mnemonic_from_data(data, strength / 8); + memzero(data, sizeof(data)); + return r; +} + +static CONFIDENTIAL char mnemo[24 * 10]; + +const char *mnemonic_from_data(const uint8_t *data, int len) { + if (len % 4 || len < 16 || len > 32) { + return 0; + } + + uint8_t bits[32 + 1] = {0}; + + sha256_Raw(data, len, bits); + // checksum + bits[len] = bits[0]; + // data + memcpy(bits, data, len); + + int mlen = len * 3 / 4; + + int i = 0, j = 0, idx = 0; + char *p = mnemo; + for (i = 0; i < mlen; i++) { + idx = 0; + for (j = 0; j < 11; j++) { + idx <<= 1; + idx += (bits[(i * 11 + j) / 8] & (1 << (7 - ((i * 11 + j) % 8)))) > 0; + } + strcpy(p, wordlist[idx]); + p += strlen(wordlist[idx]); + *p = (i < mlen - 1) ? ' ' : 0; + p++; + } + memzero(bits, sizeof(bits)); + + return mnemo; +} + +void mnemonic_clear(void) { memzero(mnemo, sizeof(mnemo)); } + +int mnemonic_to_entropy(const char *mnemonic, uint8_t *entropy) { + if (!mnemonic) { + return 0; + } + + uint32_t i = 0, n = 0; + + while (mnemonic[i]) { + if (mnemonic[i] == ' ') { + n++; + } + i++; + } + n++; + + // check number of words + if (n != 12 && n != 18 && n != 24) { + return 0; + } + + char current_word[10] = {0}; + uint32_t j = 0, k = 0, ki = 0, bi = 0; + uint8_t bits[32 + 1] = {0}; + + memzero(bits, sizeof(bits)); + i = 0; + while (mnemonic[i]) { + j = 0; + while (mnemonic[i] != ' ' && mnemonic[i] != 0) { + if (j >= sizeof(current_word) - 1) { + return 0; + } + current_word[j] = mnemonic[i]; + i++; + j++; + } + current_word[j] = 0; + if (mnemonic[i] != 0) { + i++; + } + k = 0; + for (;;) { + if (!wordlist[k]) { // word not found + return 0; + } + if (strcmp(current_word, wordlist[k]) == 0) { // word found on index k + for (ki = 0; ki < 11; ki++) { + if (k & (1 << (10 - ki))) { + bits[bi / 8] |= 1 << (7 - (bi % 8)); + } + bi++; + } + break; + } + k++; + } + } + if (bi != n * 11) { + return 0; + } + memcpy(entropy, bits, sizeof(bits)); + return n * 11; +} + +int mnemonic_check(const char *mnemonic) { + uint8_t bits[32 + 1] = {0}; + int seed_len = mnemonic_to_entropy(mnemonic, bits); + if (seed_len != (12 * 11) && seed_len != (18 * 11) && seed_len != (24 * 11)) { + return 0; + } + int words = seed_len / 11; + + uint8_t checksum = bits[words * 4 / 3]; + sha256_Raw(bits, words * 4 / 3, bits); + if (words == 12) { + return (bits[0] & 0xF0) == (checksum & 0xF0); // compare first 4 bits + } else if (words == 18) { + return (bits[0] & 0xFC) == (checksum & 0xFC); // compare first 6 bits + } else if (words == 24) { + return bits[0] == checksum; // compare 8 bits + } + return 0; +} + +// passphrase must be at most 256 characters otherwise it would be truncated +void mnemonic_to_seed(const char *mnemonic, const char *passphrase, + uint8_t seed[512 / 8], + void (*progress_callback)(uint32_t current, + uint32_t total)) { + int mnemoniclen = strlen(mnemonic); + int passphraselen = strnlen(passphrase, 256); +#if USE_BIP39_CACHE + // check cache + if (mnemoniclen < 256 && passphraselen < 64) { + for (int i = 0; i < BIP39_CACHE_SIZE; i++) { + if (!bip39_cache[i].set) continue; + if (strcmp(bip39_cache[i].mnemonic, mnemonic) != 0) continue; + if (strcmp(bip39_cache[i].passphrase, passphrase) != 0) continue; + // found the correct entry + memcpy(seed, bip39_cache[i].seed, 512 / 8); + return; + } + } +#endif + uint8_t salt[8 + 256] = {0}; + memcpy(salt, "mnemonic", 8); + memcpy(salt + 8, passphrase, passphraselen); + static CONFIDENTIAL PBKDF2_HMAC_SHA512_CTX pctx; + pbkdf2_hmac_sha512_Init(&pctx, (const uint8_t *)mnemonic, mnemoniclen, salt, + passphraselen + 8, 1); + if (progress_callback) { + progress_callback(0, BIP39_PBKDF2_ROUNDS); + } + for (int i = 0; i < 16; i++) { + pbkdf2_hmac_sha512_Update(&pctx, BIP39_PBKDF2_ROUNDS / 16); + if (progress_callback) { + progress_callback((i + 1) * BIP39_PBKDF2_ROUNDS / 16, + BIP39_PBKDF2_ROUNDS); + } + } + pbkdf2_hmac_sha512_Final(&pctx, seed); + memzero(salt, sizeof(salt)); +#if USE_BIP39_CACHE + // store to cache + if (mnemoniclen < 256 && passphraselen < 64) { + bip39_cache[bip39_cache_index].set = true; + strcpy(bip39_cache[bip39_cache_index].mnemonic, mnemonic); + strcpy(bip39_cache[bip39_cache_index].passphrase, passphrase); + memcpy(bip39_cache[bip39_cache_index].seed, seed, 512 / 8); + bip39_cache_index = (bip39_cache_index + 1) % BIP39_CACHE_SIZE; + } +#endif +} + +// binary search for finding the word in the wordlist +int mnemonic_find_word(const char *word) { + int lo = 0, hi = BIP39_WORDS - 1; + while (lo <= hi) { + int mid = lo + (hi - lo) / 2; + int cmp = strcmp(word, wordlist[mid]); + if (cmp == 0) { + return mid; + } + if (cmp > 0) { + lo = mid + 1; + } else { + hi = mid - 1; + } + } + return -1; +} + +const char *mnemonic_complete_word(const char *prefix, int len) { + // we need to perform linear search, + // because we want to return the first match + for (const char *const *w = wordlist; *w != 0; w++) { + if (strncmp(*w, prefix, len) == 0) { + return *w; + } + } + return NULL; +} + +const char *mnemonic_get_word(int index) { + if (index >= 0 && index < BIP39_WORDS) { + return wordlist[index]; + } else { + return NULL; + } +} + +uint32_t mnemonic_word_completion_mask(const char *prefix, int len) { + if (len <= 0) { + return 0x3ffffff; // all letters (bits 1-26 set) + } + uint32_t res = 0; + for (const char *const *w = wordlist; *w != 0; w++) { + const char *word = *w; + if (strncmp(word, prefix, len) == 0 && word[len] >= 'a' && + word[len] <= 'z') { + res |= 1 << (word[len] - 'a'); + } + } + return res; +} diff --git a/src/crypto/bip39/bip39.h b/src/crypto/bip39/bip39.h new file mode 100644 index 000000000..ac76101d7 --- /dev/null +++ b/src/crypto/bip39/bip39.h @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __BIP39_H__ +#define __BIP39_H__ + +#include + +#define BIP39_PBKDF2_ROUNDS 2048 + +const char *mnemonic_generate(int strength); // strength in bits +const char *mnemonic_from_data(const uint8_t *data, int len); +void mnemonic_clear(void); + +int mnemonic_check(const char *mnemonic); + +int mnemonic_to_entropy(const char *mnemonic, uint8_t *entropy); + +// passphrase must be at most 256 characters otherwise it would be truncated +void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t seed[512 / 8], void (*progress_callback)(uint32_t current, uint32_t total)); + +const char * const *mnemonic_wordlist(void); + +#endif diff --git a/src/crypto/bip39/bip39_english.h b/src/crypto/bip39/bip39_english.h new file mode 100644 index 000000000..77607ba7f --- /dev/null +++ b/src/crypto/bip39/bip39_english.h @@ -0,0 +1,2074 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +static const char * const wordlist[] = { +"abandon", +"ability", +"able", +"about", +"above", +"absent", +"absorb", +"abstract", +"absurd", +"abuse", +"access", +"accident", +"account", +"accuse", +"achieve", +"acid", +"acoustic", +"acquire", +"across", +"act", +"action", +"actor", +"actress", +"actual", +"adapt", +"add", +"addict", +"address", +"adjust", +"admit", +"adult", +"advance", +"advice", +"aerobic", +"affair", +"afford", +"afraid", +"again", +"age", +"agent", +"agree", +"ahead", +"aim", +"air", +"airport", +"aisle", +"alarm", +"album", +"alcohol", +"alert", +"alien", +"all", +"alley", +"allow", +"almost", +"alone", +"alpha", +"already", +"also", +"alter", +"always", +"amateur", +"amazing", +"among", +"amount", +"amused", +"analyst", +"anchor", +"ancient", +"anger", +"angle", +"angry", +"animal", +"ankle", +"announce", +"annual", +"another", +"answer", +"antenna", +"antique", +"anxiety", +"any", +"apart", +"apology", +"appear", +"apple", +"approve", +"april", +"arch", +"arctic", +"area", +"arena", +"argue", +"arm", +"armed", +"armor", +"army", +"around", +"arrange", +"arrest", +"arrive", +"arrow", +"art", +"artefact", +"artist", +"artwork", +"ask", +"aspect", +"assault", +"asset", +"assist", +"assume", +"asthma", +"athlete", +"atom", +"attack", +"attend", +"attitude", +"attract", +"auction", +"audit", +"august", +"aunt", +"author", +"auto", +"autumn", +"average", +"avocado", +"avoid", +"awake", +"aware", +"away", +"awesome", +"awful", +"awkward", +"axis", +"baby", +"bachelor", +"bacon", +"badge", +"bag", +"balance", +"balcony", +"ball", +"bamboo", +"banana", +"banner", +"bar", +"barely", +"bargain", +"barrel", +"base", +"basic", +"basket", +"battle", +"beach", +"bean", +"beauty", +"because", +"become", +"beef", +"before", +"begin", +"behave", +"behind", +"believe", +"below", +"belt", +"bench", +"benefit", +"best", +"betray", +"better", +"between", +"beyond", +"bicycle", +"bid", +"bike", +"bind", +"biology", +"bird", +"birth", +"bitter", +"black", +"blade", +"blame", +"blanket", +"blast", +"bleak", +"bless", +"blind", +"blood", +"blossom", +"blouse", +"blue", +"blur", +"blush", +"board", +"boat", +"body", +"boil", +"bomb", +"bone", +"bonus", +"book", +"boost", +"border", +"boring", +"borrow", +"boss", +"bottom", +"bounce", +"box", +"boy", +"bracket", +"brain", +"brand", +"brass", +"brave", +"bread", +"breeze", +"brick", +"bridge", +"brief", +"bright", +"bring", +"brisk", +"broccoli", +"broken", +"bronze", +"broom", +"brother", +"brown", +"brush", +"bubble", +"buddy", +"budget", +"buffalo", +"build", +"bulb", +"bulk", +"bullet", +"bundle", +"bunker", +"burden", +"burger", +"burst", +"bus", +"business", +"busy", +"butter", +"buyer", +"buzz", +"cabbage", +"cabin", +"cable", +"cactus", +"cage", +"cake", +"call", +"calm", +"camera", +"camp", +"can", +"canal", +"cancel", +"candy", +"cannon", +"canoe", +"canvas", +"canyon", +"capable", +"capital", +"captain", +"car", +"carbon", +"card", +"cargo", +"carpet", +"carry", +"cart", +"case", +"cash", +"casino", +"castle", +"casual", +"cat", +"catalog", +"catch", +"category", +"cattle", +"caught", +"cause", +"caution", +"cave", +"ceiling", +"celery", +"cement", +"census", +"century", +"cereal", +"certain", +"chair", +"chalk", +"champion", +"change", +"chaos", +"chapter", +"charge", +"chase", +"chat", +"cheap", +"check", +"cheese", +"chef", +"cherry", +"chest", +"chicken", +"chief", +"child", +"chimney", +"choice", +"choose", +"chronic", +"chuckle", +"chunk", +"churn", +"cigar", +"cinnamon", +"circle", +"citizen", +"city", +"civil", +"claim", +"clap", +"clarify", +"claw", +"clay", +"clean", +"clerk", +"clever", +"click", +"client", +"cliff", +"climb", +"clinic", +"clip", +"clock", +"clog", +"close", +"cloth", +"cloud", +"clown", +"club", +"clump", +"cluster", +"clutch", +"coach", +"coast", +"coconut", +"code", +"coffee", +"coil", +"coin", +"collect", +"color", +"column", +"combine", +"come", +"comfort", +"comic", +"common", +"company", +"concert", +"conduct", +"confirm", +"congress", +"connect", +"consider", +"control", +"convince", +"cook", +"cool", +"copper", +"copy", +"coral", +"core", +"corn", +"correct", +"cost", +"cotton", +"couch", +"country", +"couple", +"course", +"cousin", +"cover", +"coyote", +"crack", +"cradle", +"craft", +"cram", +"crane", +"crash", +"crater", +"crawl", +"crazy", +"cream", +"credit", +"creek", +"crew", +"cricket", +"crime", +"crisp", +"critic", +"crop", +"cross", +"crouch", +"crowd", +"crucial", +"cruel", +"cruise", +"crumble", +"crunch", +"crush", +"cry", +"crystal", +"cube", +"culture", +"cup", +"cupboard", +"curious", +"current", +"curtain", +"curve", +"cushion", +"custom", +"cute", +"cycle", +"dad", +"damage", +"damp", +"dance", +"danger", +"daring", +"dash", +"daughter", +"dawn", +"day", +"deal", +"debate", +"debris", +"decade", +"december", +"decide", +"decline", +"decorate", +"decrease", +"deer", +"defense", +"define", +"defy", +"degree", +"delay", +"deliver", +"demand", +"demise", +"denial", +"dentist", +"deny", +"depart", +"depend", +"deposit", +"depth", +"deputy", +"derive", +"describe", +"desert", +"design", +"desk", +"despair", +"destroy", +"detail", +"detect", +"develop", +"device", +"devote", +"diagram", +"dial", +"diamond", +"diary", +"dice", +"diesel", +"diet", +"differ", +"digital", +"dignity", +"dilemma", +"dinner", +"dinosaur", +"direct", +"dirt", +"disagree", +"discover", +"disease", +"dish", +"dismiss", +"disorder", +"display", +"distance", +"divert", +"divide", +"divorce", +"dizzy", +"doctor", +"document", +"dog", +"doll", +"dolphin", +"domain", +"donate", +"donkey", +"donor", +"door", +"dose", +"double", +"dove", +"draft", +"dragon", +"drama", +"drastic", +"draw", +"dream", +"dress", +"drift", +"drill", +"drink", +"drip", +"drive", +"drop", +"drum", +"dry", +"duck", +"dumb", +"dune", +"during", +"dust", +"dutch", +"duty", +"dwarf", +"dynamic", +"eager", +"eagle", +"early", +"earn", +"earth", +"easily", +"east", +"easy", +"echo", +"ecology", +"economy", +"edge", +"edit", +"educate", +"effort", +"egg", +"eight", +"either", +"elbow", +"elder", +"electric", +"elegant", +"element", +"elephant", +"elevator", +"elite", +"else", +"embark", +"embody", +"embrace", +"emerge", +"emotion", +"employ", +"empower", +"empty", +"enable", +"enact", +"end", +"endless", +"endorse", +"enemy", +"energy", +"enforce", +"engage", +"engine", +"enhance", +"enjoy", +"enlist", +"enough", +"enrich", +"enroll", +"ensure", +"enter", +"entire", +"entry", +"envelope", +"episode", +"equal", +"equip", +"era", +"erase", +"erode", +"erosion", +"error", +"erupt", +"escape", +"essay", +"essence", +"estate", +"eternal", +"ethics", +"evidence", +"evil", +"evoke", +"evolve", +"exact", +"example", +"excess", +"exchange", +"excite", +"exclude", +"excuse", +"execute", +"exercise", +"exhaust", +"exhibit", +"exile", +"exist", +"exit", +"exotic", +"expand", +"expect", +"expire", +"explain", +"expose", +"express", +"extend", +"extra", +"eye", +"eyebrow", +"fabric", +"face", +"faculty", +"fade", +"faint", +"faith", +"fall", +"false", +"fame", +"family", +"famous", +"fan", +"fancy", +"fantasy", +"farm", +"fashion", +"fat", +"fatal", +"father", +"fatigue", +"fault", +"favorite", +"feature", +"february", +"federal", +"fee", +"feed", +"feel", +"female", +"fence", +"festival", +"fetch", +"fever", +"few", +"fiber", +"fiction", +"field", +"figure", +"file", +"film", +"filter", +"final", +"find", +"fine", +"finger", +"finish", +"fire", +"firm", +"first", +"fiscal", +"fish", +"fit", +"fitness", +"fix", +"flag", +"flame", +"flash", +"flat", +"flavor", +"flee", +"flight", +"flip", +"float", +"flock", +"floor", +"flower", +"fluid", +"flush", +"fly", +"foam", +"focus", +"fog", +"foil", +"fold", +"follow", +"food", +"foot", +"force", +"forest", +"forget", +"fork", +"fortune", +"forum", +"forward", +"fossil", +"foster", +"found", +"fox", +"fragile", +"frame", +"frequent", +"fresh", +"friend", +"fringe", +"frog", +"front", +"frost", +"frown", +"frozen", +"fruit", +"fuel", +"fun", +"funny", +"furnace", +"fury", +"future", +"gadget", +"gain", +"galaxy", +"gallery", +"game", +"gap", +"garage", +"garbage", +"garden", +"garlic", +"garment", +"gas", +"gasp", +"gate", +"gather", +"gauge", +"gaze", +"general", +"genius", +"genre", +"gentle", +"genuine", +"gesture", +"ghost", +"giant", +"gift", +"giggle", +"ginger", +"giraffe", +"girl", +"give", +"glad", +"glance", +"glare", +"glass", +"glide", +"glimpse", +"globe", +"gloom", +"glory", +"glove", +"glow", +"glue", +"goat", +"goddess", +"gold", +"good", +"goose", +"gorilla", +"gospel", +"gossip", +"govern", +"gown", +"grab", +"grace", +"grain", +"grant", +"grape", +"grass", +"gravity", +"great", +"green", +"grid", +"grief", +"grit", +"grocery", +"group", +"grow", +"grunt", +"guard", +"guess", +"guide", +"guilt", +"guitar", +"gun", +"gym", +"habit", +"hair", +"half", +"hammer", +"hamster", +"hand", +"happy", +"harbor", +"hard", +"harsh", +"harvest", +"hat", +"have", +"hawk", +"hazard", +"head", +"health", +"heart", +"heavy", +"hedgehog", +"height", +"hello", +"helmet", +"help", +"hen", +"hero", +"hidden", +"high", +"hill", +"hint", +"hip", +"hire", +"history", +"hobby", +"hockey", +"hold", +"hole", +"holiday", +"hollow", +"home", +"honey", +"hood", +"hope", +"horn", +"horror", +"horse", +"hospital", +"host", +"hotel", +"hour", +"hover", +"hub", +"huge", +"human", +"humble", +"humor", +"hundred", +"hungry", +"hunt", +"hurdle", +"hurry", +"hurt", +"husband", +"hybrid", +"ice", +"icon", +"idea", +"identify", +"idle", +"ignore", +"ill", +"illegal", +"illness", +"image", +"imitate", +"immense", +"immune", +"impact", +"impose", +"improve", +"impulse", +"inch", +"include", +"income", +"increase", +"index", +"indicate", +"indoor", +"industry", +"infant", +"inflict", +"inform", +"inhale", +"inherit", +"initial", +"inject", +"injury", +"inmate", +"inner", +"innocent", +"input", +"inquiry", +"insane", +"insect", +"inside", +"inspire", +"install", +"intact", +"interest", +"into", +"invest", +"invite", +"involve", +"iron", +"island", +"isolate", +"issue", +"item", +"ivory", +"jacket", +"jaguar", +"jar", +"jazz", +"jealous", +"jeans", +"jelly", +"jewel", +"job", +"join", +"joke", +"journey", +"joy", +"judge", +"juice", +"jump", +"jungle", +"junior", +"junk", +"just", +"kangaroo", +"keen", +"keep", +"ketchup", +"key", +"kick", +"kid", +"kidney", +"kind", +"kingdom", +"kiss", +"kit", +"kitchen", +"kite", +"kitten", +"kiwi", +"knee", +"knife", +"knock", +"know", +"lab", +"label", +"labor", +"ladder", +"lady", +"lake", +"lamp", +"language", +"laptop", +"large", +"later", +"latin", +"laugh", +"laundry", +"lava", +"law", +"lawn", +"lawsuit", +"layer", +"lazy", +"leader", +"leaf", +"learn", +"leave", +"lecture", +"left", +"leg", +"legal", +"legend", +"leisure", +"lemon", +"lend", +"length", +"lens", +"leopard", +"lesson", +"letter", +"level", +"liar", +"liberty", +"library", +"license", +"life", +"lift", +"light", +"like", +"limb", +"limit", +"link", +"lion", +"liquid", +"list", +"little", +"live", +"lizard", +"load", +"loan", +"lobster", +"local", +"lock", +"logic", +"lonely", +"long", +"loop", +"lottery", +"loud", +"lounge", +"love", +"loyal", +"lucky", +"luggage", +"lumber", +"lunar", +"lunch", +"luxury", +"lyrics", +"machine", +"mad", +"magic", +"magnet", +"maid", +"mail", +"main", +"major", +"make", +"mammal", +"man", +"manage", +"mandate", +"mango", +"mansion", +"manual", +"maple", +"marble", +"march", +"margin", +"marine", +"market", +"marriage", +"mask", +"mass", +"master", +"match", +"material", +"math", +"matrix", +"matter", +"maximum", +"maze", +"meadow", +"mean", +"measure", +"meat", +"mechanic", +"medal", +"media", +"melody", +"melt", +"member", +"memory", +"mention", +"menu", +"mercy", +"merge", +"merit", +"merry", +"mesh", +"message", +"metal", +"method", +"middle", +"midnight", +"milk", +"million", +"mimic", +"mind", +"minimum", +"minor", +"minute", +"miracle", +"mirror", +"misery", +"miss", +"mistake", +"mix", +"mixed", +"mixture", +"mobile", +"model", +"modify", +"mom", +"moment", +"monitor", +"monkey", +"monster", +"month", +"moon", +"moral", +"more", +"morning", +"mosquito", +"mother", +"motion", +"motor", +"mountain", +"mouse", +"move", +"movie", +"much", +"muffin", +"mule", +"multiply", +"muscle", +"museum", +"mushroom", +"music", +"must", +"mutual", +"myself", +"mystery", +"myth", +"naive", +"name", +"napkin", +"narrow", +"nasty", +"nation", +"nature", +"near", +"neck", +"need", +"negative", +"neglect", +"neither", +"nephew", +"nerve", +"nest", +"net", +"network", +"neutral", +"never", +"news", +"next", +"nice", +"night", +"noble", +"noise", +"nominee", +"noodle", +"normal", +"north", +"nose", +"notable", +"note", +"nothing", +"notice", +"novel", +"now", +"nuclear", +"number", +"nurse", +"nut", +"oak", +"obey", +"object", +"oblige", +"obscure", +"observe", +"obtain", +"obvious", +"occur", +"ocean", +"october", +"odor", +"off", +"offer", +"office", +"often", +"oil", +"okay", +"old", +"olive", +"olympic", +"omit", +"once", +"one", +"onion", +"online", +"only", +"open", +"opera", +"opinion", +"oppose", +"option", +"orange", +"orbit", +"orchard", +"order", +"ordinary", +"organ", +"orient", +"original", +"orphan", +"ostrich", +"other", +"outdoor", +"outer", +"output", +"outside", +"oval", +"oven", +"over", +"own", +"owner", +"oxygen", +"oyster", +"ozone", +"pact", +"paddle", +"page", +"pair", +"palace", +"palm", +"panda", +"panel", +"panic", +"panther", +"paper", +"parade", +"parent", +"park", +"parrot", +"party", +"pass", +"patch", +"path", +"patient", +"patrol", +"pattern", +"pause", +"pave", +"payment", +"peace", +"peanut", +"pear", +"peasant", +"pelican", +"pen", +"penalty", +"pencil", +"people", +"pepper", +"perfect", +"permit", +"person", +"pet", +"phone", +"photo", +"phrase", +"physical", +"piano", +"picnic", +"picture", +"piece", +"pig", +"pigeon", +"pill", +"pilot", +"pink", +"pioneer", +"pipe", +"pistol", +"pitch", +"pizza", +"place", +"planet", +"plastic", +"plate", +"play", +"please", +"pledge", +"pluck", +"plug", +"plunge", +"poem", +"poet", +"point", +"polar", +"pole", +"police", +"pond", +"pony", +"pool", +"popular", +"portion", +"position", +"possible", +"post", +"potato", +"pottery", +"poverty", +"powder", +"power", +"practice", +"praise", +"predict", +"prefer", +"prepare", +"present", +"pretty", +"prevent", +"price", +"pride", +"primary", +"print", +"priority", +"prison", +"private", +"prize", +"problem", +"process", +"produce", +"profit", +"program", +"project", +"promote", +"proof", +"property", +"prosper", +"protect", +"proud", +"provide", +"public", +"pudding", +"pull", +"pulp", +"pulse", +"pumpkin", +"punch", +"pupil", +"puppy", +"purchase", +"purity", +"purpose", +"purse", +"push", +"put", +"puzzle", +"pyramid", +"quality", +"quantum", +"quarter", +"question", +"quick", +"quit", +"quiz", +"quote", +"rabbit", +"raccoon", +"race", +"rack", +"radar", +"radio", +"rail", +"rain", +"raise", +"rally", +"ramp", +"ranch", +"random", +"range", +"rapid", +"rare", +"rate", +"rather", +"raven", +"raw", +"razor", +"ready", +"real", +"reason", +"rebel", +"rebuild", +"recall", +"receive", +"recipe", +"record", +"recycle", +"reduce", +"reflect", +"reform", +"refuse", +"region", +"regret", +"regular", +"reject", +"relax", +"release", +"relief", +"rely", +"remain", +"remember", +"remind", +"remove", +"render", +"renew", +"rent", +"reopen", +"repair", +"repeat", +"replace", +"report", +"require", +"rescue", +"resemble", +"resist", +"resource", +"response", +"result", +"retire", +"retreat", +"return", +"reunion", +"reveal", +"review", +"reward", +"rhythm", +"rib", +"ribbon", +"rice", +"rich", +"ride", +"ridge", +"rifle", +"right", +"rigid", +"ring", +"riot", +"ripple", +"risk", +"ritual", +"rival", +"river", +"road", +"roast", +"robot", +"robust", +"rocket", +"romance", +"roof", +"rookie", +"room", +"rose", +"rotate", +"rough", +"round", +"route", +"royal", +"rubber", +"rude", +"rug", +"rule", +"run", +"runway", +"rural", +"sad", +"saddle", +"sadness", +"safe", +"sail", +"salad", +"salmon", +"salon", +"salt", +"salute", +"same", +"sample", +"sand", +"satisfy", +"satoshi", +"sauce", +"sausage", +"save", +"say", +"scale", +"scan", +"scare", +"scatter", +"scene", +"scheme", +"school", +"science", +"scissors", +"scorpion", +"scout", +"scrap", +"screen", +"script", +"scrub", +"sea", +"search", +"season", +"seat", +"second", +"secret", +"section", +"security", +"seed", +"seek", +"segment", +"select", +"sell", +"seminar", +"senior", +"sense", +"sentence", +"series", +"service", +"session", +"settle", +"setup", +"seven", +"shadow", +"shaft", +"shallow", +"share", +"shed", +"shell", +"sheriff", +"shield", +"shift", +"shine", +"ship", +"shiver", +"shock", +"shoe", +"shoot", +"shop", +"short", +"shoulder", +"shove", +"shrimp", +"shrug", +"shuffle", +"shy", +"sibling", +"sick", +"side", +"siege", +"sight", +"sign", +"silent", +"silk", +"silly", +"silver", +"similar", +"simple", +"since", +"sing", +"siren", +"sister", +"situate", +"six", +"size", +"skate", +"sketch", +"ski", +"skill", +"skin", +"skirt", +"skull", +"slab", +"slam", +"sleep", +"slender", +"slice", +"slide", +"slight", +"slim", +"slogan", +"slot", +"slow", +"slush", +"small", +"smart", +"smile", +"smoke", +"smooth", +"snack", +"snake", +"snap", +"sniff", +"snow", +"soap", +"soccer", +"social", +"sock", +"soda", +"soft", +"solar", +"soldier", +"solid", +"solution", +"solve", +"someone", +"song", +"soon", +"sorry", +"sort", +"soul", +"sound", +"soup", +"source", +"south", +"space", +"spare", +"spatial", +"spawn", +"speak", +"special", +"speed", +"spell", +"spend", +"sphere", +"spice", +"spider", +"spike", +"spin", +"spirit", +"split", +"spoil", +"sponsor", +"spoon", +"sport", +"spot", +"spray", +"spread", +"spring", +"spy", +"square", +"squeeze", +"squirrel", +"stable", +"stadium", +"staff", +"stage", +"stairs", +"stamp", +"stand", +"start", +"state", +"stay", +"steak", +"steel", +"stem", +"step", +"stereo", +"stick", +"still", +"sting", +"stock", +"stomach", +"stone", +"stool", +"story", +"stove", +"strategy", +"street", +"strike", +"strong", +"struggle", +"student", +"stuff", +"stumble", +"style", +"subject", +"submit", +"subway", +"success", +"such", +"sudden", +"suffer", +"sugar", +"suggest", +"suit", +"summer", +"sun", +"sunny", +"sunset", +"super", +"supply", +"supreme", +"sure", +"surface", +"surge", +"surprise", +"surround", +"survey", +"suspect", +"sustain", +"swallow", +"swamp", +"swap", +"swarm", +"swear", +"sweet", +"swift", +"swim", +"swing", +"switch", +"sword", +"symbol", +"symptom", +"syrup", +"system", +"table", +"tackle", +"tag", +"tail", +"talent", +"talk", +"tank", +"tape", +"target", +"task", +"taste", +"tattoo", +"taxi", +"teach", +"team", +"tell", +"ten", +"tenant", +"tennis", +"tent", +"term", +"test", +"text", +"thank", +"that", +"theme", +"then", +"theory", +"there", +"they", +"thing", +"this", +"thought", +"three", +"thrive", +"throw", +"thumb", +"thunder", +"ticket", +"tide", +"tiger", +"tilt", +"timber", +"time", +"tiny", +"tip", +"tired", +"tissue", +"title", +"toast", +"tobacco", +"today", +"toddler", +"toe", +"together", +"toilet", +"token", +"tomato", +"tomorrow", +"tone", +"tongue", +"tonight", +"tool", +"tooth", +"top", +"topic", +"topple", +"torch", +"tornado", +"tortoise", +"toss", +"total", +"tourist", +"toward", +"tower", +"town", +"toy", +"track", +"trade", +"traffic", +"tragic", +"train", +"transfer", +"trap", +"trash", +"travel", +"tray", +"treat", +"tree", +"trend", +"trial", +"tribe", +"trick", +"trigger", +"trim", +"trip", +"trophy", +"trouble", +"truck", +"true", +"truly", +"trumpet", +"trust", +"truth", +"try", +"tube", +"tuition", +"tumble", +"tuna", +"tunnel", +"turkey", +"turn", +"turtle", +"twelve", +"twenty", +"twice", +"twin", +"twist", +"two", +"type", +"typical", +"ugly", +"umbrella", +"unable", +"unaware", +"uncle", +"uncover", +"under", +"undo", +"unfair", +"unfold", +"unhappy", +"uniform", +"unique", +"unit", +"universe", +"unknown", +"unlock", +"until", +"unusual", +"unveil", +"update", +"upgrade", +"uphold", +"upon", +"upper", +"upset", +"urban", +"urge", +"usage", +"use", +"used", +"useful", +"useless", +"usual", +"utility", +"vacant", +"vacuum", +"vague", +"valid", +"valley", +"valve", +"van", +"vanish", +"vapor", +"various", +"vast", +"vault", +"vehicle", +"velvet", +"vendor", +"venture", +"venue", +"verb", +"verify", +"version", +"very", +"vessel", +"veteran", +"viable", +"vibrant", +"vicious", +"victory", +"video", +"view", +"village", +"vintage", +"violin", +"virtual", +"virus", +"visa", +"visit", +"visual", +"vital", +"vivid", +"vocal", +"voice", +"void", +"volcano", +"volume", +"vote", +"voyage", +"wage", +"wagon", +"wait", +"walk", +"wall", +"walnut", +"want", +"warfare", +"warm", +"warrior", +"wash", +"wasp", +"waste", +"water", +"wave", +"way", +"wealth", +"weapon", +"wear", +"weasel", +"weather", +"web", +"wedding", +"weekend", +"weird", +"welcome", +"west", +"wet", +"whale", +"what", +"wheat", +"wheel", +"when", +"where", +"whip", +"whisper", +"wide", +"width", +"wife", +"wild", +"will", +"win", +"window", +"wine", +"wing", +"wink", +"winner", +"winter", +"wire", +"wisdom", +"wise", +"wish", +"witness", +"wolf", +"woman", +"wonder", +"wood", +"wool", +"word", +"work", +"world", +"worry", +"worth", +"wrap", +"wreck", +"wrestle", +"wrist", +"write", +"wrong", +"yard", +"year", +"yellow", +"you", +"young", +"youth", +"zebra", +"zero", +"zone", +"zoo", +0, +}; diff --git a/src/crypto/bip39/bip39_mnemonic.c b/src/crypto/bip39/bip39_mnemonic.c new file mode 100644 index 000000000..a4dc27b86 --- /dev/null +++ b/src/crypto/bip39/bip39_mnemonic.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include "bip39.h" +#include + +// NOTE: We must override this to implement actual RNG! +void random_buffer(uint8_t *buf, size_t len) { + if( len > 0 ) { + randombytes_buf(buf, len); + } +} + +int main(int argc, char **argv) +{ + char *this = argv[0]; + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", this); + return 1; + } + if (sodium_init() == -1) { + fprintf(stderr, "libsodium init failed! :(\n"); + return 1; + } + int strength = 256; + const char *mnemonic = mnemonic_generate(strength); + printf("%s\n", mnemonic); + return 0; +} diff --git a/src/crypto/bip39/bip39bruteforce.c b/src/crypto/bip39/bip39bruteforce.c new file mode 100644 index 000000000..10fd69da7 --- /dev/null +++ b/src/crypto/bip39/bip39bruteforce.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include "bip39.h" +#include "bip32.h" +#include "ecdsa.h" +#include "curves.h" + +char iter[256]; +uint8_t seed[512 / 8]; +uint8_t addr[21], pubkeyhash[20]; +int count = 0, found = 0; +HDNode node; +clock_t start; + +// around 280 tries per second + +// testing data: +// +// mnemonic: "all all all all all all all all all all all all" +// address: "1JAd7XCBzGudGpJQSDSfpmJhiygtLQWaGL" +// passphrase: "" +// +// mnemonic: "all all all all all all all all all all all all" +// address: "1N3uJ5AU3FTYQ1ZQgTMtYmgSvMBmQiGVBS" +// passphrase: "testing" + +int main(int argc, char **argv) +{ + if (argc != 2 && argc != 3) { + fprintf(stderr, "Usage: bip39bruteforce address [mnemonic]\n"); + return 1; + } + const char *address = argv[1]; + const char *mnemonic, *item; + if (argc == 3) { + mnemonic = argv[2]; + item = "passphrase"; + } else { + mnemonic = NULL; + item = "mnemonic"; + } + if (mnemonic && !mnemonic_check(mnemonic)) { + fprintf(stderr, "\"%s\" is not a valid mnemonic\n", mnemonic); + return 2; + } + if (!ecdsa_address_decode(address, 0, HASHER_SHA2, addr)) { + fprintf(stderr, "\"%s\" is not a valid address\n", address); + return 3; + } + printf("Reading %ss from stdin ...\n", item); + start = clock(); + for (;;) { + if (fgets(iter, 256, stdin) == NULL) break; + int len = strlen(iter); + if (len <= 0) { + continue; + } + count++; + iter[len - 1] = 0; + if (mnemonic) { + mnemonic_to_seed(mnemonic, iter, seed, NULL); + } else { + mnemonic_to_seed(iter, "", seed, NULL); + } + hdnode_from_seed(seed, 512 / 8, SECP256K1_NAME, &node); + hdnode_private_ckd_prime(&node, 44); + hdnode_private_ckd_prime(&node, 0); + hdnode_private_ckd_prime(&node, 0); + hdnode_private_ckd(&node, 0); + hdnode_private_ckd(&node, 0); + hdnode_fill_public_key(&node); + ecdsa_get_pubkeyhash(node.public_key, HASHER_SHA2, pubkeyhash); + if (memcmp(addr + 1, pubkeyhash, 20) == 0) { + found = 1; + break; + } + } + float dur = (float)(clock() - start) / CLOCKS_PER_SEC; + printf("Tried %d %ss in %f seconds = %f tries/second\n", count, item, dur, (float)count/dur); + if (found) { + printf("Correct %s found! :-)\n\"%s\"\n", item, iter); + return 0; + } + printf("Correct %s not found. :-(\n", item); + return 4; +} diff --git a/src/crypto/bip39/blake256.h b/src/crypto/bip39/blake256.h new file mode 100644 index 000000000..313b6260e --- /dev/null +++ b/src/crypto/bip39/blake256.h @@ -0,0 +1,53 @@ +// Copyright (c) 2014-2017, The Monero Project +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other +// materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its contributors may be +// used to endorse or promote products derived from this software without specific +// prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers + +#ifndef __BLAKE256_H__ +#define __BLAKE256_H__ + +#include +#include + +#define BLAKE256_DIGEST_LENGTH 32 +#define BLAKE256_BLOCK_LENGTH 64 + +typedef struct { + uint32_t h[8], s[4], t[2]; + size_t buflen; + uint8_t nullt; + uint8_t buf[64]; +} BLAKE256_CTX; + +void blake256_Init(BLAKE256_CTX *); +void blake256_Update(BLAKE256_CTX *, const uint8_t *, size_t); +void blake256_Final(BLAKE256_CTX *, uint8_t *); + +void blake256(const uint8_t *, size_t, uint8_t *); + +#endif /* __BLAKE256_H__ */ diff --git a/src/crypto/bip39/blake2_common.h b/src/crypto/bip39/blake2_common.h new file mode 100644 index 000000000..40c6da3b5 --- /dev/null +++ b/src/crypto/bip39/blake2_common.h @@ -0,0 +1,39 @@ +static inline uint32_t load32( const void *src ) +{ + uint32_t w; + memcpy(&w, src, sizeof w); + return w; +} + +static inline uint64_t load64( const void *src ) +{ + uint64_t w; + memcpy(&w, src, sizeof w); + return w; +} + +static inline void store16( void *dst, uint16_t w ) +{ + memcpy(dst, &w, sizeof w); +} + +static inline void store32( void *dst, uint32_t w ) +{ + memcpy(dst, &w, sizeof w); +} + +static inline void store64( void *dst, uint64_t w ) +{ + memcpy(dst, &w, sizeof w); +} + +static inline uint32_t rotr32( const uint32_t w, const unsigned c ) +{ + return ( w >> c ) | ( w << ( 32 - c ) ); +} + +static inline uint64_t rotr64( const uint64_t w, const unsigned c ) +{ + return ( w >> c ) | ( w << ( 64 - c ) ); +} + diff --git a/src/crypto/bip39/blake2b.h b/src/crypto/bip39/blake2b.h new file mode 100644 index 000000000..1a43e92d1 --- /dev/null +++ b/src/crypto/bip39/blake2b.h @@ -0,0 +1,41 @@ +#ifndef __BLAKE2B_H__ +#define __BLAKE2B_H__ + +#include +#include + +enum blake2b_constant +{ + BLAKE2B_BLOCKBYTES = 128, + BLAKE2B_OUTBYTES = 64, + BLAKE2B_KEYBYTES = 64, + BLAKE2B_SALTBYTES = 16, + BLAKE2B_PERSONALBYTES = 16 +}; + +typedef struct __blake2b_state +{ + uint64_t h[8]; + uint64_t t[2]; + uint64_t f[2]; + uint8_t buf[BLAKE2B_BLOCKBYTES]; + size_t buflen; + size_t outlen; + uint8_t last_node; +} blake2b_state; + +#define BLAKE2B_CTX blake2b_state +#define BLAKE2B_BLOCK_LENGTH BLAKE2B_BLOCKBYTES +#define BLAKE2B_DIGEST_LENGTH BLAKE2B_OUTBYTES +#define BLAKE2B_KEY_LENGTH BLAKE2B_KEYBYTES + +int blake2b_Init(blake2b_state *S, size_t outlen); +int blake2b_InitKey(blake2b_state *S, size_t outlen, const void *key, size_t keylen); +int blake2b_InitPersonal(blake2b_state *S, size_t outlen, const void *personal, size_t personal_len); +int blake2b_Update(blake2b_state *S, const void *pin, size_t inlen); +int blake2b_Final(blake2b_state *S, void *out, size_t outlen); + +int blake2b(const uint8_t *msg, uint32_t msg_len, void *out, size_t outlen); +int blake2b_Key(const uint8_t *msg, uint32_t msg_len, const void *key, size_t keylen, void *out, size_t outlen); + +#endif diff --git a/src/crypto/bip39/blake2s.h b/src/crypto/bip39/blake2s.h new file mode 100644 index 000000000..57991bc91 --- /dev/null +++ b/src/crypto/bip39/blake2s.h @@ -0,0 +1,41 @@ +#ifndef __BLAKE2S_H__ +#define __BLAKE2S_H__ + +#include +#include + +enum blake2s_constant +{ + BLAKE2S_BLOCKBYTES = 64, + BLAKE2S_OUTBYTES = 32, + BLAKE2S_KEYBYTES = 32, + BLAKE2S_SALTBYTES = 8, + BLAKE2S_PERSONALBYTES = 8 +}; + +typedef struct __blake2s_state +{ + uint32_t h[8]; + uint32_t t[2]; + uint32_t f[2]; + uint8_t buf[BLAKE2S_BLOCKBYTES]; + uint32_t buflen; + uint8_t outlen; + uint8_t last_node; +} blake2s_state; + +#define BLAKE2S_CTX blake2s_state +#define BLAKE2S_BLOCK_LENGTH BLAKE2S_BLOCKBYTES +#define BLAKE2S_DIGEST_LENGTH BLAKE2S_OUTBYTES +#define BLAKE2S_KEY_LENGTH BLAKE2S_KEYBYTES + +int blake2s_Init(blake2s_state *S, size_t outlen); +int blake2s_InitKey(blake2s_state *S, size_t outlen, const void *key, size_t keylen); +int blake2s_InitPersonal(blake2s_state *S, size_t outlen, const void *personal, size_t personal_len); +int blake2s_Update(blake2s_state *S, const void *pin, size_t inlen); +int blake2s_Final(blake2s_state *S, void *out, size_t outlen); + +int blake2s(const uint8_t *msg, uint32_t msg_len, void *out, size_t outlen); +int blake2s_Key(const uint8_t *msg, uint32_t msg_len, const void *key, size_t keylen, void *out, size_t outlen); + +#endif diff --git a/src/crypto/bip39/hasher.c b/src/crypto/bip39/hasher.c new file mode 100644 index 000000000..dac3e9bf5 --- /dev/null +++ b/src/crypto/bip39/hasher.c @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2017 Saleem Rashid + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "hasher.h" +#include "ripemd160.h" + +void hasher_InitParam(Hasher *hasher, HasherType type, const void *param, uint32_t param_size) { + hasher->type = type; + hasher->param = param; + hasher->param_size = param_size; + + switch (hasher->type) { + case HASHER_SHA2: + case HASHER_SHA2D: + case HASHER_SHA2_RIPEMD: + sha256_Init(&hasher->ctx.sha2); + break; + case HASHER_SHA3: +#if USE_KECCAK + case HASHER_SHA3K: +#endif + sha3_256_Init(&hasher->ctx.sha3); + break; + case HASHER_BLAKE: + case HASHER_BLAKED: + case HASHER_BLAKE_RIPEMD: + blake256_Init(&hasher->ctx.blake); + break; + case HASHER_GROESTLD_TRUNC: + groestl512_Init(&hasher->ctx.groestl); + break; + case HASHER_BLAKE2B: + blake2b_Init(&hasher->ctx.blake2b, 32); + break; + case HASHER_BLAKE2B_PERSONAL: + blake2b_InitPersonal(&hasher->ctx.blake2b, 32, hasher->param, hasher->param_size); + break; + } +} + +void hasher_Init(Hasher *hasher, HasherType type) { + hasher_InitParam(hasher, type, NULL, 0); +} + +void hasher_Reset(Hasher *hasher) { + hasher_InitParam(hasher, hasher->type, hasher->param, hasher->param_size); +} + +void hasher_Update(Hasher *hasher, const uint8_t *data, size_t length) { + switch (hasher->type) { + case HASHER_SHA2: + case HASHER_SHA2D: + case HASHER_SHA2_RIPEMD: + sha256_Update(&hasher->ctx.sha2, data, length); + break; + case HASHER_SHA3: +#if USE_KECCAK + case HASHER_SHA3K: +#endif + sha3_Update(&hasher->ctx.sha3, data, length); + break; + case HASHER_BLAKE: + case HASHER_BLAKED: + case HASHER_BLAKE_RIPEMD: + blake256_Update(&hasher->ctx.blake, data, length); + break; + case HASHER_GROESTLD_TRUNC: + groestl512_Update(&hasher->ctx.groestl, data, length); + break; + case HASHER_BLAKE2B: + case HASHER_BLAKE2B_PERSONAL: + blake2b_Update(&hasher->ctx.blake2b, data, length); + break; + } +} + +void hasher_Final(Hasher *hasher, uint8_t hash[HASHER_DIGEST_LENGTH]) { + switch (hasher->type) { + case HASHER_SHA2: + sha256_Final(&hasher->ctx.sha2, hash); + break; + case HASHER_SHA2D: + sha256_Final(&hasher->ctx.sha2, hash); + hasher_Raw(HASHER_SHA2, hash, HASHER_DIGEST_LENGTH, hash); + break; + case HASHER_SHA2_RIPEMD: + sha256_Final(&hasher->ctx.sha2, hash); + ripemd160(hash, HASHER_DIGEST_LENGTH, hash); + break; + case HASHER_SHA3: + sha3_Final(&hasher->ctx.sha3, hash); + break; +#if USE_KECCAK + case HASHER_SHA3K: + keccak_Final(&hasher->ctx.sha3, hash); + break; +#endif + case HASHER_BLAKE: + blake256_Final(&hasher->ctx.blake, hash); + break; + case HASHER_BLAKED: + blake256_Final(&hasher->ctx.blake, hash); + hasher_Raw(HASHER_BLAKE, hash, HASHER_DIGEST_LENGTH, hash); + break; + case HASHER_BLAKE_RIPEMD: + blake256_Final(&hasher->ctx.blake, hash); + ripemd160(hash, HASHER_DIGEST_LENGTH, hash); + break; + case HASHER_GROESTLD_TRUNC: + groestl512_DoubleTrunc(&hasher->ctx.groestl, hash); + break; + case HASHER_BLAKE2B: + case HASHER_BLAKE2B_PERSONAL: + blake2b_Final(&hasher->ctx.blake2b, hash, 32); + break; + } +} + +void hasher_Raw(HasherType type, const uint8_t *data, size_t length, uint8_t hash[HASHER_DIGEST_LENGTH]) { + Hasher hasher; + + hasher_Init(&hasher, type); + hasher_Update(&hasher, data, length); + hasher_Final(&hasher, hash); +} diff --git a/src/crypto/bip39/hasher.h b/src/crypto/bip39/hasher.h new file mode 100644 index 000000000..0cde1df8b --- /dev/null +++ b/src/crypto/bip39/hasher.h @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2017 Saleem Rashid + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __HASHER_H__ +#define __HASHER_H__ + +#include +#include + +#include "sha2.h" +#include "sha3.h" +#include "blake256.h" +#include "groestl.h" +#include "blake2b.h" + +#define HASHER_DIGEST_LENGTH 32 + +typedef enum { + HASHER_SHA2, + HASHER_SHA2D, + HASHER_SHA2_RIPEMD, + + HASHER_SHA3, +#if USE_KECCAK + HASHER_SHA3K, +#endif + + HASHER_BLAKE, + HASHER_BLAKED, + HASHER_BLAKE_RIPEMD, + + HASHER_GROESTLD_TRUNC, /* Double Groestl512 hasher truncated to 256 bits */ + + HASHER_BLAKE2B, + HASHER_BLAKE2B_PERSONAL, +} HasherType; + +typedef struct { + HasherType type; + + union { + SHA256_CTX sha2; // for HASHER_SHA2{,D} + SHA3_CTX sha3; // for HASHER_SHA3{,K} + BLAKE256_CTX blake; // for HASHER_BLAKE{,D} + GROESTL512_CTX groestl; // for HASHER_GROESTLD_TRUNC + BLAKE2B_CTX blake2b; // for HASHER_BLAKE2B{,_PERSONAL} + } ctx; + + const void *param; + uint32_t param_size; +} Hasher; + +void hasher_InitParam(Hasher *hasher, HasherType type, const void *param, uint32_t param_size); +void hasher_Init(Hasher *hasher, HasherType type); +void hasher_Reset(Hasher *hasher); +void hasher_Update(Hasher *hasher, const uint8_t *data, size_t length); +void hasher_Final(Hasher *hasher, uint8_t hash[HASHER_DIGEST_LENGTH]); + +void hasher_Raw(HasherType type, const uint8_t *data, size_t length, uint8_t hash[HASHER_DIGEST_LENGTH]); + +#endif diff --git a/src/crypto/bip39/hmac.c b/src/crypto/bip39/hmac.c new file mode 100644 index 000000000..654f2d6e8 --- /dev/null +++ b/src/crypto/bip39/hmac.c @@ -0,0 +1,176 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include + +#include "hmac.h" +#include "memzero.h" +#include "options.h" + +void hmac_sha256_Init(HMAC_SHA256_CTX *hctx, const uint8_t *key, + const uint32_t keylen) { + static CONFIDENTIAL uint8_t i_key_pad[SHA256_BLOCK_LENGTH]; + memzero(i_key_pad, SHA256_BLOCK_LENGTH); + if (keylen > SHA256_BLOCK_LENGTH) { + sha256_Raw(key, keylen, i_key_pad); + } else { + memcpy(i_key_pad, key, keylen); + } + for (int i = 0; i < SHA256_BLOCK_LENGTH; i++) { + hctx->o_key_pad[i] = i_key_pad[i] ^ 0x5c; + i_key_pad[i] ^= 0x36; + } + sha256_Init(&(hctx->ctx)); + sha256_Update(&(hctx->ctx), i_key_pad, SHA256_BLOCK_LENGTH); + memzero(i_key_pad, sizeof(i_key_pad)); +} + +void hmac_sha256_Update(HMAC_SHA256_CTX *hctx, const uint8_t *msg, + const uint32_t msglen) { + sha256_Update(&(hctx->ctx), msg, msglen); +} + +void hmac_sha256_Final(HMAC_SHA256_CTX *hctx, uint8_t *hmac) { + sha256_Final(&(hctx->ctx), hmac); + sha256_Init(&(hctx->ctx)); + sha256_Update(&(hctx->ctx), hctx->o_key_pad, SHA256_BLOCK_LENGTH); + sha256_Update(&(hctx->ctx), hmac, SHA256_DIGEST_LENGTH); + sha256_Final(&(hctx->ctx), hmac); + memzero(hctx, sizeof(HMAC_SHA256_CTX)); +} + +void hmac_sha256(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, + const uint32_t msglen, uint8_t *hmac) { + static CONFIDENTIAL HMAC_SHA256_CTX hctx; + hmac_sha256_Init(&hctx, key, keylen); + hmac_sha256_Update(&hctx, msg, msglen); + hmac_sha256_Final(&hctx, hmac); +} + +void hmac_sha256_prepare(const uint8_t *key, const uint32_t keylen, + uint32_t *opad_digest, uint32_t *ipad_digest) { + static CONFIDENTIAL uint32_t key_pad[SHA256_BLOCK_LENGTH / sizeof(uint32_t)]; + + memzero(key_pad, sizeof(key_pad)); + if (keylen > SHA256_BLOCK_LENGTH) { + static CONFIDENTIAL SHA256_CTX context; + sha256_Init(&context); + sha256_Update(&context, key, keylen); + sha256_Final(&context, (uint8_t *)key_pad); + } else { + memcpy(key_pad, key, keylen); + } + + /* compute o_key_pad and its digest */ + for (int i = 0; i < SHA256_BLOCK_LENGTH / (int)sizeof(uint32_t); i++) { + uint32_t data = 0; +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE32(key_pad[i], data); +#else + data = key_pad[i]; +#endif + key_pad[i] = data ^ 0x5c5c5c5c; + } + sha256_Transform(sha256_initial_hash_value, key_pad, opad_digest); + + /* convert o_key_pad to i_key_pad and compute its digest */ + for (int i = 0; i < SHA256_BLOCK_LENGTH / (int)sizeof(uint32_t); i++) { + key_pad[i] = key_pad[i] ^ 0x5c5c5c5c ^ 0x36363636; + } + sha256_Transform(sha256_initial_hash_value, key_pad, ipad_digest); + memzero(key_pad, sizeof(key_pad)); +} + +void hmac_sha512_Init(HMAC_SHA512_CTX *hctx, const uint8_t *key, + const uint32_t keylen) { + static CONFIDENTIAL uint8_t i_key_pad[SHA512_BLOCK_LENGTH]; + memzero(i_key_pad, SHA512_BLOCK_LENGTH); + if (keylen > SHA512_BLOCK_LENGTH) { + sha512_Raw(key, keylen, i_key_pad); + } else { + memcpy(i_key_pad, key, keylen); + } + for (int i = 0; i < SHA512_BLOCK_LENGTH; i++) { + hctx->o_key_pad[i] = i_key_pad[i] ^ 0x5c; + i_key_pad[i] ^= 0x36; + } + sha512_Init(&(hctx->ctx)); + sha512_Update(&(hctx->ctx), i_key_pad, SHA512_BLOCK_LENGTH); + memzero(i_key_pad, sizeof(i_key_pad)); +} + +void hmac_sha512_Update(HMAC_SHA512_CTX *hctx, const uint8_t *msg, + const uint32_t msglen) { + sha512_Update(&(hctx->ctx), msg, msglen); +} + +void hmac_sha512_Final(HMAC_SHA512_CTX *hctx, uint8_t *hmac) { + sha512_Final(&(hctx->ctx), hmac); + sha512_Init(&(hctx->ctx)); + sha512_Update(&(hctx->ctx), hctx->o_key_pad, SHA512_BLOCK_LENGTH); + sha512_Update(&(hctx->ctx), hmac, SHA512_DIGEST_LENGTH); + sha512_Final(&(hctx->ctx), hmac); + memzero(hctx, sizeof(HMAC_SHA512_CTX)); +} + +void hmac_sha512(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, + const uint32_t msglen, uint8_t *hmac) { + HMAC_SHA512_CTX hctx = {0}; + hmac_sha512_Init(&hctx, key, keylen); + hmac_sha512_Update(&hctx, msg, msglen); + hmac_sha512_Final(&hctx, hmac); +} + +void hmac_sha512_prepare(const uint8_t *key, const uint32_t keylen, + uint64_t *opad_digest, uint64_t *ipad_digest) { + static CONFIDENTIAL uint64_t key_pad[SHA512_BLOCK_LENGTH / sizeof(uint64_t)]; + + memzero(key_pad, sizeof(key_pad)); + if (keylen > SHA512_BLOCK_LENGTH) { + static CONFIDENTIAL SHA512_CTX context; + sha512_Init(&context); + sha512_Update(&context, key, keylen); + sha512_Final(&context, (uint8_t *)key_pad); + } else { + memcpy(key_pad, key, keylen); + } + + /* compute o_key_pad and its digest */ + for (int i = 0; i < SHA512_BLOCK_LENGTH / (int)sizeof(uint64_t); i++) { + uint64_t data = 0; +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE64(key_pad[i], data); +#else + data = key_pad[i]; +#endif + key_pad[i] = data ^ 0x5c5c5c5c5c5c5c5c; + } + sha512_Transform(sha512_initial_hash_value, key_pad, opad_digest); + + /* convert o_key_pad to i_key_pad and compute its digest */ + for (int i = 0; i < SHA512_BLOCK_LENGTH / (int)sizeof(uint64_t); i++) { + key_pad[i] = key_pad[i] ^ 0x5c5c5c5c5c5c5c5c ^ 0x3636363636363636; + } + sha512_Transform(sha512_initial_hash_value, key_pad, ipad_digest); + memzero(key_pad, sizeof(key_pad)); +} diff --git a/src/crypto/bip39/hmac.h b/src/crypto/bip39/hmac.h new file mode 100644 index 000000000..3cfc0cd0f --- /dev/null +++ b/src/crypto/bip39/hmac.h @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT HMAC_SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __HMAC_H__ +#define __HMAC_H__ + +#include +#include "sha2.h" + +typedef struct _HMAC_SHA256_CTX { + uint8_t o_key_pad[SHA256_BLOCK_LENGTH]; + SHA256_CTX ctx; +} HMAC_SHA256_CTX; + +typedef struct _HMAC_SHA512_CTX { + uint8_t o_key_pad[SHA512_BLOCK_LENGTH]; + SHA512_CTX ctx; +} HMAC_SHA512_CTX; + +void hmac_sha256_Init(HMAC_SHA256_CTX *hctx, const uint8_t *key, const uint32_t keylen); +void hmac_sha256_Update(HMAC_SHA256_CTX *hctx, const uint8_t *msg, const uint32_t msglen); +void hmac_sha256_Final(HMAC_SHA256_CTX *hctx, uint8_t *hmac); +void hmac_sha256(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, const uint32_t msglen, uint8_t *hmac); +void hmac_sha256_prepare(const uint8_t *key, const uint32_t keylen, uint32_t *opad_digest, uint32_t *ipad_digest); + +void hmac_sha512_Init(HMAC_SHA512_CTX *hctx, const uint8_t *key, const uint32_t keylen); +void hmac_sha512_Update(HMAC_SHA512_CTX *hctx, const uint8_t *msg, const uint32_t msglen); +void hmac_sha512_Final(HMAC_SHA512_CTX *hctx, uint8_t *hmac); +void hmac_sha512(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, const uint32_t msglen, uint8_t *hmac); +void hmac_sha512_prepare(const uint8_t *key, const uint32_t keylen, uint64_t *opad_digest, uint64_t *ipad_digest); + +#endif diff --git a/src/crypto/bip39/hmac_drbg.c b/src/crypto/bip39/hmac_drbg.c new file mode 100644 index 000000000..1ed1401b8 --- /dev/null +++ b/src/crypto/bip39/hmac_drbg.c @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2019 Andrew R. Kozlik + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "hmac_drbg.h" +#include +#include "memzero.h" +#include "sha2.h" + +static void update_k(HMAC_DRBG_CTX *ctx, uint8_t domain, const uint8_t *data1, + size_t len1, const uint8_t *data2, size_t len2) { + // Computes K = HMAC(K, V || domain || data1 || data 2). + + // First hash operation of HMAC. + uint32_t h[SHA256_BLOCK_LENGTH / sizeof(uint32_t)] = {0}; + if (len1 + len2 == 0) { + ctx->v[8] = 0x00800000; + ctx->v[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH + 1) * 8; + sha256_Transform(ctx->idig, ctx->v, h); + ctx->v[8] = 0x80000000; + ctx->v[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8; + } else { + SHA256_CTX sha_ctx = {0}; + memcpy(sha_ctx.state, ctx->idig, SHA256_DIGEST_LENGTH); + for (size_t i = 0; i < SHA256_DIGEST_LENGTH / sizeof(uint32_t); i++) { +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE32(ctx->v[i], sha_ctx.buffer[i]); +#else + sha_ctx.buffer[i] = ctx->v[i]; +#endif + } + ((uint8_t *)sha_ctx.buffer)[SHA256_DIGEST_LENGTH] = domain; + sha_ctx.bitcount = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH + 1) * 8; + sha256_Update(&sha_ctx, data1, len1); + sha256_Update(&sha_ctx, data2, len2); + sha256_Final(&sha_ctx, (uint8_t *)h); +#if BYTE_ORDER == LITTLE_ENDIAN + for (size_t i = 0; i < SHA256_DIGEST_LENGTH / sizeof(uint32_t); i++) + REVERSE32(h[i], h[i]); +#endif + } + + // Second hash operation of HMAC. + h[8] = 0x80000000; + h[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8; + sha256_Transform(ctx->odig, h, h); + + // Precompute the inner digest and outer digest of K. + h[8] = 0; + h[15] = 0; + for (size_t i = 0; i < SHA256_BLOCK_LENGTH / sizeof(uint32_t); i++) { + h[i] ^= 0x36363636; + } + sha256_Transform(sha256_initial_hash_value, h, ctx->idig); + + for (size_t i = 0; i < SHA256_BLOCK_LENGTH / sizeof(uint32_t); i++) { + h[i] = h[i] ^ 0x36363636 ^ 0x5c5c5c5c; + } + sha256_Transform(sha256_initial_hash_value, h, ctx->odig); + memzero(h, sizeof(h)); +} + +static void update_v(HMAC_DRBG_CTX *ctx) { + sha256_Transform(ctx->idig, ctx->v, ctx->v); + sha256_Transform(ctx->odig, ctx->v, ctx->v); +} + +void hmac_drbg_init(HMAC_DRBG_CTX *ctx, const uint8_t *entropy, + size_t entropy_len, const uint8_t *nonce, + size_t nonce_len) { + uint32_t h[SHA256_BLOCK_LENGTH / sizeof(uint32_t)] = {0}; + + // Precompute the inner digest and outer digest of K = 0x00 ... 0x00. + memset(h, 0x36, sizeof(h)); + sha256_Transform(sha256_initial_hash_value, h, ctx->idig); + memset(h, 0x5c, sizeof(h)); + sha256_Transform(sha256_initial_hash_value, h, ctx->odig); + + // Let V = 0x01 ... 0x01. + memset(ctx->v, 1, SHA256_DIGEST_LENGTH); + for (size_t i = 9; i < 15; i++) ctx->v[i] = 0; + ctx->v[8] = 0x80000000; + ctx->v[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8; + + hmac_drbg_reseed(ctx, entropy, entropy_len, nonce, nonce_len); + + memzero(h, sizeof(h)); +} + +void hmac_drbg_reseed(HMAC_DRBG_CTX *ctx, const uint8_t *entropy, size_t len, + const uint8_t *addin, size_t addin_len) { + update_k(ctx, 0, entropy, len, addin, addin_len); + update_v(ctx); + if (len == 0) return; + update_k(ctx, 1, entropy, len, addin, addin_len); + update_v(ctx); +} + +void hmac_drbg_generate(HMAC_DRBG_CTX *ctx, uint8_t *buf, size_t len) { + size_t i = 0; + while (i < len) { + update_v(ctx); + for (size_t j = 0; j < 8 && i < len; j++) { + uint32_t r = ctx->v[j]; + for (int k = 24; k >= 0 && i < len; k -= 8) { + buf[i++] = (r >> k) & 0xFF; + } + } + } + update_k(ctx, 0, NULL, 0, NULL, 0); + update_v(ctx); +} diff --git a/src/crypto/bip39/hmac_drbg.h b/src/crypto/bip39/hmac_drbg.h new file mode 100644 index 000000000..4b969dedb --- /dev/null +++ b/src/crypto/bip39/hmac_drbg.h @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2019 Andrew R. Kozlik + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __HMAC_DRBG_H__ +#define __HMAC_DRBG_H__ + +#include +#include + +// HMAC based Deterministic Random Bit Generator with SHA-256 + +typedef struct _HMAC_DRBG_CTX { + uint32_t odig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t idig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t v[SHA256_BLOCK_LENGTH / sizeof(uint32_t)]; +} HMAC_DRBG_CTX; + +void hmac_drbg_init(HMAC_DRBG_CTX *ctx, const uint8_t *buf, size_t len, + const uint8_t *nonce, size_t nonce_len); +void hmac_drbg_reseed(HMAC_DRBG_CTX *ctx, const uint8_t *buf, size_t len, + const uint8_t *addin, size_t addin_len); +void hmac_drbg_generate(HMAC_DRBG_CTX *ctx, uint8_t *buf, size_t len); + +#endif diff --git a/src/crypto/bip39/memzero.c b/src/crypto/bip39/memzero.c new file mode 100644 index 000000000..3c3a7383d --- /dev/null +++ b/src/crypto/bip39/memzero.c @@ -0,0 +1,66 @@ +#ifndef __STDC_WANT_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 // C11's bounds-checking interface. +#endif +#include + +#ifdef _WIN32 +#include +#endif + +#ifdef __unix__ +#include +#include +#endif + +// C11's bounds-checking interface. +#if defined(__STDC_LIB_EXT1__) +#define HAVE_MEMSET_S 1 +#endif + +// GNU C Library version 2.25 or later. +#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25)) +#define HAVE_EXPLICIT_BZERO 1 +#endif + +// Newlib +#if defined( __NEWLIB__) +#define HAVE_EXPLICIT_BZERO 1 +#endif + +// FreeBSD version 11.0 or later. +#if defined(__FreeBSD__) && __FreeBSD_version >= 1100037 +#define HAVE_EXPLICIT_BZERO 1 +#endif + +// OpenBSD version 5.5 or later. +#if defined(__OpenBSD__) && OpenBSD >= 201405 +#define HAVE_EXPLICIT_BZERO 1 +#endif + +// NetBSD version 7.2 or later. +#if defined(__NetBSD__) && __NetBSD_Version__ >= 702000000 +#define HAVE_EXPLICIT_MEMSET 1 +#endif + +// Adapted from https://github.com/jedisct1/libsodium/blob/1647f0d53ae0e370378a9195477e3df0a792408f/src/libsodium/sodium/utils.c#L102-L130 + +void memzero(void *const pnt, const size_t len) +{ +#ifdef _WIN32 + SecureZeroMemory(pnt, len); +#elif defined(HAVE_MEMSET_S) + memset_s(pnt, (rsize_t) len, 0, (rsize_t) len); +#elif defined(HAVE_EXPLICIT_BZERO) + explicit_bzero(pnt, len); +#elif defined(HAVE_EXPLICIT_MEMSET) + explicit_memset(pnt, 0, len); +#else + volatile unsigned char *volatile pnt_ = + (volatile unsigned char *volatile) pnt; + size_t i = (size_t) 0U; + + while (i < len) { + pnt_[i++] = 0U; + } +#endif +} diff --git a/src/crypto/bip39/memzero.h b/src/crypto/bip39/memzero.h new file mode 100644 index 000000000..a7797d2b3 --- /dev/null +++ b/src/crypto/bip39/memzero.h @@ -0,0 +1,8 @@ +#ifndef __MEMZERO_H__ +#define __MEMZERO_H__ + +#include + +void memzero(void * const pnt, const size_t len); + +#endif diff --git a/src/crypto/bip39/options.h b/src/crypto/bip39/options.h new file mode 100644 index 000000000..e57654e6c --- /dev/null +++ b/src/crypto/bip39/options.h @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __OPTIONS_H__ +#define __OPTIONS_H__ + +// use precomputed Curve Points (some scalar multiples of curve base point G) +#ifndef USE_PRECOMPUTED_CP +#define USE_PRECOMPUTED_CP 1 +#endif + +// use fast inverse method +#ifndef USE_INVERSE_FAST +#define USE_INVERSE_FAST 1 +#endif + +// support for printing bignum256 structures via printf +#ifndef USE_BN_PRINT +#define USE_BN_PRINT 0 +#endif + +// use deterministic signatures +#ifndef USE_RFC6979 +#define USE_RFC6979 1 +#endif + +// implement BIP32 caching +#ifndef USE_BIP32_CACHE +#define USE_BIP32_CACHE 1 +#define BIP32_CACHE_SIZE 10 +#define BIP32_CACHE_MAXDEPTH 8 +#endif + +// support constructing BIP32 nodes from ed25519 and curve25519 curves. +#ifndef USE_BIP32_25519_CURVES +#define USE_BIP32_25519_CURVES 1 +#endif + +// implement BIP39 caching +#ifndef USE_BIP39_CACHE +#define USE_BIP39_CACHE 1 +#define BIP39_CACHE_SIZE 4 +#endif + +// support Ethereum operations +#ifndef USE_ETHEREUM +#define USE_ETHEREUM 0 +#endif + +// support Graphene operations (STEEM, BitShares) +#ifndef USE_GRAPHENE +#define USE_GRAPHENE 0 +#endif + +// support NEM operations +#ifndef USE_NEM +#define USE_NEM 0 +#endif + +// support MONERO operations +#ifndef USE_MONERO +#define USE_MONERO 0 +#endif + +// support CARDANO operations +#ifndef USE_CARDANO +#define USE_CARDANO 0 +#endif + +// support Keccak hashing +#ifndef USE_KECCAK +#define USE_KECCAK 1 +#endif + +// add way how to mark confidential data +#ifndef CONFIDENTIAL +#define CONFIDENTIAL +#endif + +#endif diff --git a/src/crypto/bip39/pbkdf2.c b/src/crypto/bip39/pbkdf2.c new file mode 100644 index 000000000..d9e142297 --- /dev/null +++ b/src/crypto/bip39/pbkdf2.c @@ -0,0 +1,179 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pbkdf2.h" +#include +#include "hmac.h" +#include "memzero.h" +#include "sha2.h" + +void pbkdf2_hmac_sha256_Init(PBKDF2_HMAC_SHA256_CTX *pctx, const uint8_t *pass, + int passlen, const uint8_t *salt, int saltlen, + uint32_t blocknr) { + SHA256_CTX ctx = {0}; +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE32(blocknr, blocknr); +#endif + + hmac_sha256_prepare(pass, passlen, pctx->odig, pctx->idig); + memzero(pctx->g, sizeof(pctx->g)); + pctx->g[8] = 0x80000000; + pctx->g[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8; + + memcpy(ctx.state, pctx->idig, sizeof(pctx->idig)); + ctx.bitcount = SHA256_BLOCK_LENGTH * 8; + sha256_Update(&ctx, salt, saltlen); + sha256_Update(&ctx, (uint8_t *)&blocknr, sizeof(blocknr)); + sha256_Final(&ctx, (uint8_t *)pctx->g); +#if BYTE_ORDER == LITTLE_ENDIAN + for (uint32_t k = 0; k < SHA256_DIGEST_LENGTH / sizeof(uint32_t); k++) { + REVERSE32(pctx->g[k], pctx->g[k]); + } +#endif + sha256_Transform(pctx->odig, pctx->g, pctx->g); + memcpy(pctx->f, pctx->g, SHA256_DIGEST_LENGTH); + pctx->first = 1; +} + +void pbkdf2_hmac_sha256_Update(PBKDF2_HMAC_SHA256_CTX *pctx, + uint32_t iterations) { + for (uint32_t i = pctx->first; i < iterations; i++) { + sha256_Transform(pctx->idig, pctx->g, pctx->g); + sha256_Transform(pctx->odig, pctx->g, pctx->g); + for (uint32_t j = 0; j < SHA256_DIGEST_LENGTH / sizeof(uint32_t); j++) { + pctx->f[j] ^= pctx->g[j]; + } + } + pctx->first = 0; +} + +void pbkdf2_hmac_sha256_Final(PBKDF2_HMAC_SHA256_CTX *pctx, uint8_t *key) { +#if BYTE_ORDER == LITTLE_ENDIAN + for (uint32_t k = 0; k < SHA256_DIGEST_LENGTH / sizeof(uint32_t); k++) { + REVERSE32(pctx->f[k], pctx->f[k]); + } +#endif + memcpy(key, pctx->f, SHA256_DIGEST_LENGTH); + memzero(pctx, sizeof(PBKDF2_HMAC_SHA256_CTX)); +} + +void pbkdf2_hmac_sha256(const uint8_t *pass, int passlen, const uint8_t *salt, + int saltlen, uint32_t iterations, uint8_t *key, + int keylen) { + uint32_t last_block_size = keylen % SHA256_DIGEST_LENGTH; + uint32_t blocks_count = keylen / SHA256_DIGEST_LENGTH; + if (last_block_size) { + blocks_count++; + } else { + last_block_size = SHA256_DIGEST_LENGTH; + } + for (uint32_t blocknr = 1; blocknr <= blocks_count; blocknr++) { + PBKDF2_HMAC_SHA256_CTX pctx = {0}; + pbkdf2_hmac_sha256_Init(&pctx, pass, passlen, salt, saltlen, blocknr); + pbkdf2_hmac_sha256_Update(&pctx, iterations); + uint8_t digest[SHA256_DIGEST_LENGTH] = {0}; + pbkdf2_hmac_sha256_Final(&pctx, digest); + uint32_t key_offset = (blocknr - 1) * SHA256_DIGEST_LENGTH; + if (blocknr < blocks_count) { + memcpy(key + key_offset, digest, SHA256_DIGEST_LENGTH); + } else { + memcpy(key + key_offset, digest, last_block_size); + } + } +} + +void pbkdf2_hmac_sha512_Init(PBKDF2_HMAC_SHA512_CTX *pctx, const uint8_t *pass, + int passlen, const uint8_t *salt, int saltlen, + uint32_t blocknr) { + SHA512_CTX ctx = {0}; +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE32(blocknr, blocknr); +#endif + + hmac_sha512_prepare(pass, passlen, pctx->odig, pctx->idig); + memzero(pctx->g, sizeof(pctx->g)); + pctx->g[8] = 0x8000000000000000; + pctx->g[15] = (SHA512_BLOCK_LENGTH + SHA512_DIGEST_LENGTH) * 8; + + memcpy(ctx.state, pctx->idig, sizeof(pctx->idig)); + ctx.bitcount[0] = SHA512_BLOCK_LENGTH * 8; + ctx.bitcount[1] = 0; + sha512_Update(&ctx, salt, saltlen); + sha512_Update(&ctx, (uint8_t *)&blocknr, sizeof(blocknr)); + sha512_Final(&ctx, (uint8_t *)pctx->g); +#if BYTE_ORDER == LITTLE_ENDIAN + for (uint32_t k = 0; k < SHA512_DIGEST_LENGTH / sizeof(uint64_t); k++) { + REVERSE64(pctx->g[k], pctx->g[k]); + } +#endif + sha512_Transform(pctx->odig, pctx->g, pctx->g); + memcpy(pctx->f, pctx->g, SHA512_DIGEST_LENGTH); + pctx->first = 1; +} + +void pbkdf2_hmac_sha512_Update(PBKDF2_HMAC_SHA512_CTX *pctx, + uint32_t iterations) { + for (uint32_t i = pctx->first; i < iterations; i++) { + sha512_Transform(pctx->idig, pctx->g, pctx->g); + sha512_Transform(pctx->odig, pctx->g, pctx->g); + for (uint32_t j = 0; j < SHA512_DIGEST_LENGTH / sizeof(uint64_t); j++) { + pctx->f[j] ^= pctx->g[j]; + } + } + pctx->first = 0; +} + +void pbkdf2_hmac_sha512_Final(PBKDF2_HMAC_SHA512_CTX *pctx, uint8_t *key) { +#if BYTE_ORDER == LITTLE_ENDIAN + for (uint32_t k = 0; k < SHA512_DIGEST_LENGTH / sizeof(uint64_t); k++) { + REVERSE64(pctx->f[k], pctx->f[k]); + } +#endif + memcpy(key, pctx->f, SHA512_DIGEST_LENGTH); + memzero(pctx, sizeof(PBKDF2_HMAC_SHA512_CTX)); +} + +void pbkdf2_hmac_sha512(const uint8_t *pass, int passlen, const uint8_t *salt, + int saltlen, uint32_t iterations, uint8_t *key, + int keylen) { + uint32_t last_block_size = keylen % SHA512_DIGEST_LENGTH; + uint32_t blocks_count = keylen / SHA512_DIGEST_LENGTH; + if (last_block_size) { + blocks_count++; + } else { + last_block_size = SHA512_DIGEST_LENGTH; + } + for (uint32_t blocknr = 1; blocknr <= blocks_count; blocknr++) { + PBKDF2_HMAC_SHA512_CTX pctx = {0}; + pbkdf2_hmac_sha512_Init(&pctx, pass, passlen, salt, saltlen, blocknr); + pbkdf2_hmac_sha512_Update(&pctx, iterations); + uint8_t digest[SHA512_DIGEST_LENGTH] = {0}; + pbkdf2_hmac_sha512_Final(&pctx, digest); + uint32_t key_offset = (blocknr - 1) * SHA512_DIGEST_LENGTH; + if (blocknr < blocks_count) { + memcpy(key + key_offset, digest, SHA512_DIGEST_LENGTH); + } else { + memcpy(key + key_offset, digest, last_block_size); + } + } +} diff --git a/src/crypto/bip39/pbkdf2.h b/src/crypto/bip39/pbkdf2.h new file mode 100644 index 000000000..e3f440c8f --- /dev/null +++ b/src/crypto/bip39/pbkdf2.h @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __PBKDF2_H__ +#define __PBKDF2_H__ + +#include +#include "sha2.h" + +typedef struct _PBKDF2_HMAC_SHA256_CTX { + uint32_t odig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t idig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t f[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t g[SHA256_BLOCK_LENGTH / sizeof(uint32_t)]; + char first; +} PBKDF2_HMAC_SHA256_CTX; + +typedef struct _PBKDF2_HMAC_SHA512_CTX { + uint64_t odig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t idig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t f[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t g[SHA512_BLOCK_LENGTH / sizeof(uint64_t)]; + char first; +} PBKDF2_HMAC_SHA512_CTX; + +void pbkdf2_hmac_sha256_Init(PBKDF2_HMAC_SHA256_CTX *pctx, const uint8_t *pass, int passlen, const uint8_t *salt, int saltlen, uint32_t blocknr); +void pbkdf2_hmac_sha256_Update(PBKDF2_HMAC_SHA256_CTX *pctx, uint32_t iterations); +void pbkdf2_hmac_sha256_Final(PBKDF2_HMAC_SHA256_CTX *pctx, uint8_t *key); +void pbkdf2_hmac_sha256(const uint8_t *pass, int passlen, const uint8_t *salt, int saltlen, uint32_t iterations, uint8_t *key, int keylen); + +void pbkdf2_hmac_sha512_Init(PBKDF2_HMAC_SHA512_CTX *pctx, const uint8_t *pass, int passlen, const uint8_t *salt, int saltlen, uint32_t blocknr); +void pbkdf2_hmac_sha512_Update(PBKDF2_HMAC_SHA512_CTX *pctx, uint32_t iterations); +void pbkdf2_hmac_sha512_Final(PBKDF2_HMAC_SHA512_CTX *pctx, uint8_t *key); +void pbkdf2_hmac_sha512(const uint8_t *pass, int passlen, const uint8_t *salt, int saltlen, uint32_t iterations, uint8_t *key, int keylen); + +#endif diff --git a/src/crypto/bip39/rand.c b/src/crypto/bip39/rand.c new file mode 100644 index 000000000..ea95d143b --- /dev/null +++ b/src/crypto/bip39/rand.c @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "rand.h" + +#ifndef RAND_PLATFORM_INDEPENDENT + +#pragma message( \ + "NOT SUITABLE FOR PRODUCTION USE! Replace random32() function with your own secure code.") + +// The following code is not supposed to be used in a production environment. +// It's included only to make the library testable. +// The message above tries to prevent any accidental use outside of the test +// environment. +// +// You are supposed to replace the random8() and random32() function with your +// own secure code. There is also a possibility to replace the random_buffer() +// function as it is defined as a weak symbol. + +static uint32_t seed = 0; + +void random_reseed(const uint32_t value) { seed = value; } + +uint32_t random32(void) { + // Linear congruential generator from Numerical Recipes + // https://en.wikipedia.org/wiki/Linear_congruential_generator + seed = 1664525 * seed + 1013904223; + return seed; +} + +#endif /* RAND_PLATFORM_INDEPENDENT */ + +// +// The following code is platform independent +// + +void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) { + uint32_t r = 0; + for (size_t i = 0; i < len; i++) { + if (i % 4 == 0) { + r = random32(); + } + buf[i] = (r >> ((i % 4) * 8)) & 0xFF; + } +} + +uint32_t random_uniform(uint32_t n) { + uint32_t x = 0, max = 0xFFFFFFFF - (0xFFFFFFFF % n); + while ((x = random32()) >= max) + ; + return x / (max / n); +} + +void random_permute(char *str, size_t len) { + for (int i = len - 1; i >= 1; i--) { + int j = random_uniform(i + 1); + char t = str[j]; + str[j] = str[i]; + str[i] = t; + } +} diff --git a/src/crypto/bip39/rand.h b/src/crypto/bip39/rand.h new file mode 100644 index 000000000..49d9cfaf2 --- /dev/null +++ b/src/crypto/bip39/rand.h @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __RAND_H__ +#define __RAND_H__ + +#include +#include + +void random_reseed(const uint32_t value); +uint32_t random32(void); +void random_buffer(uint8_t *buf, size_t len); + +uint32_t random_uniform(uint32_t n); +void random_permute(char *buf, size_t len); + +#endif diff --git a/src/crypto/bip39/secp256k1.h b/src/crypto/bip39/secp256k1.h new file mode 100644 index 000000000..234ca97a9 --- /dev/null +++ b/src/crypto/bip39/secp256k1.h @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __SECP256K1_H__ +#define __SECP256K1_H__ + +#include + +#include "ecdsa.h" +#include "bip32.h" + +extern const ecdsa_curve secp256k1; +extern const curve_info secp256k1_info; +extern const curve_info secp256k1_decred_info; +extern const curve_info secp256k1_groestl_info; +extern const curve_info secp256k1_smart_info; + +#endif diff --git a/src/crypto/bip39/sha2.c b/src/crypto/bip39/sha2.c new file mode 100644 index 000000000..b37e5cb41 --- /dev/null +++ b/src/crypto/bip39/sha2.c @@ -0,0 +1,1283 @@ +/** + * Copyright (c) 2000-2001 Aaron D. Gifford + * Copyright (c) 2013-2014 Pavol Rusnak + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include "sha2.h" +#include "memzero.h" + +/* + * ASSERT NOTE: + * Some sanity checking code is included using assert(). On my FreeBSD + * system, this additional code can be removed by compiling with NDEBUG + * defined. Check your own systems manpage on assert() to see how to + * compile WITHOUT the sanity checking code on your system. + * + * UNROLLED TRANSFORM LOOP NOTE: + * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform + * loop version for the hash transform rounds (defined using macros + * later in this file). Either define on the command line, for example: + * + * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c + * + * or define below: + * + * #define SHA2_UNROLL_TRANSFORM + * + */ + + +/*** SHA-256/384/512 Machine Architecture Definitions *****************/ +/* + * BYTE_ORDER NOTE: + * + * Please make sure that your system defines BYTE_ORDER. If your + * architecture is little-endian, make sure it also defines + * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are + * equivilent. + * + * If your system does not define the above, then you can do so by + * hand like this: + * + * #define LITTLE_ENDIAN 1234 + * #define BIG_ENDIAN 4321 + * + * And for little-endian machines, add: + * + * #define BYTE_ORDER LITTLE_ENDIAN + * + * Or for big-endian machines: + * + * #define BYTE_ORDER BIG_ENDIAN + * + * The FreeBSD machine this was written on defines BYTE_ORDER + * appropriately by including (which in turn includes + * where the appropriate definitions are actually + * made). + */ + +#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) +#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN +#endif + +typedef uint8_t sha2_byte; /* Exactly 1 byte */ +typedef uint32_t sha2_word32; /* Exactly 4 bytes */ +typedef uint64_t sha2_word64; /* Exactly 8 bytes */ + +/*** SHA-256/384/512 Various Length Definitions ***********************/ +/* NOTE: Most of these are in sha2.h */ +#define SHA1_SHORT_BLOCK_LENGTH (SHA1_BLOCK_LENGTH - 8) +#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8) +#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) + +/* + * Macro for incrementally adding the unsigned 64-bit integer n to the + * unsigned 128-bit integer (represented using a two-element array of + * 64-bit words): + */ +#define ADDINC128(w,n) { \ + (w)[0] += (sha2_word64)(n); \ + if ((w)[0] < (n)) { \ + (w)[1]++; \ + } \ +} + +#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l)) + +/*** THE SIX LOGICAL FUNCTIONS ****************************************/ +/* + * Bit shifting and rotation (used by the six SHA-XYZ logical functions: + * + * NOTE: In the original SHA-256/384/512 document, the shift-right + * function was named R and the rotate-right function was called S. + * (See: http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf on the + * web.) + * + * The newer NIST FIPS 180-2 document uses a much clearer naming + * scheme, SHR for shift-right, ROTR for rotate-right, and ROTL for + * rotate-left. (See: + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf + * on the web.) + * + * WARNING: These macros must be used cautiously, since they reference + * supplied parameters sometimes more than once, and thus could have + * unexpected side-effects if used without taking this into account. + */ + +/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ +#define SHR(b,x) ((x) >> (b)) +/* 32-bit Rotate-right (used in SHA-256): */ +#define ROTR32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) +/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ +#define ROTR64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) +/* 32-bit Rotate-left (used in SHA-1): */ +#define ROTL32(b,x) (((x) << (b)) | ((x) >> (32 - (b)))) + +/* Two of six logical functions used in SHA-1, SHA-256, SHA-384, and SHA-512: */ +#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) +#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) + +/* Function used in SHA-1: */ +#define Parity(x,y,z) ((x) ^ (y) ^ (z)) + +/* Four of six logical functions used in SHA-256: */ +#define Sigma0_256(x) (ROTR32(2, (x)) ^ ROTR32(13, (x)) ^ ROTR32(22, (x))) +#define Sigma1_256(x) (ROTR32(6, (x)) ^ ROTR32(11, (x)) ^ ROTR32(25, (x))) +#define sigma0_256(x) (ROTR32(7, (x)) ^ ROTR32(18, (x)) ^ SHR(3 , (x))) +#define sigma1_256(x) (ROTR32(17, (x)) ^ ROTR32(19, (x)) ^ SHR(10, (x))) + +/* Four of six logical functions used in SHA-384 and SHA-512: */ +#define Sigma0_512(x) (ROTR64(28, (x)) ^ ROTR64(34, (x)) ^ ROTR64(39, (x))) +#define Sigma1_512(x) (ROTR64(14, (x)) ^ ROTR64(18, (x)) ^ ROTR64(41, (x))) +#define sigma0_512(x) (ROTR64( 1, (x)) ^ ROTR64( 8, (x)) ^ SHR( 7, (x))) +#define sigma1_512(x) (ROTR64(19, (x)) ^ ROTR64(61, (x)) ^ SHR( 6, (x))) + +/*** INTERNAL FUNCTION PROTOTYPES *************************************/ +/* NOTE: These should not be accessed directly from outside this + * library -- they are intended for private internal visibility/use + * only. + */ +static void sha512_Last(SHA512_CTX*); + + +/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ + +/* Hash constant words K for SHA-1: */ +#define K1_0_TO_19 0x5a827999UL +#define K1_20_TO_39 0x6ed9eba1UL +#define K1_40_TO_59 0x8f1bbcdcUL +#define K1_60_TO_79 0xca62c1d6UL + +/* Initial hash value H for SHA-1: */ +const sha2_word32 sha1_initial_hash_value[SHA1_DIGEST_LENGTH / sizeof(sha2_word32)] = { + 0x67452301UL, + 0xefcdab89UL, + 0x98badcfeUL, + 0x10325476UL, + 0xc3d2e1f0UL +}; + +/* Hash constant words K for SHA-256: */ +static const sha2_word32 K256[64] = { + 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, + 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, + 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, + 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, + 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, + 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, + 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, + 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, + 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, + 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, + 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, + 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, + 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, + 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, + 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, + 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL +}; + +/* Initial hash value H for SHA-256: */ +const sha2_word32 sha256_initial_hash_value[8] = { + 0x6a09e667UL, + 0xbb67ae85UL, + 0x3c6ef372UL, + 0xa54ff53aUL, + 0x510e527fUL, + 0x9b05688cUL, + 0x1f83d9abUL, + 0x5be0cd19UL +}; + +/* Hash constant words K for SHA-384 and SHA-512: */ +static const sha2_word64 K512[80] = { + 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, + 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, + 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, + 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, + 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, + 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, + 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, + 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, + 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, + 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, + 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, + 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, + 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, + 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, + 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, + 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, + 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, + 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, + 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, + 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, + 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, + 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, + 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, + 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, + 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, + 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, + 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, + 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, + 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, + 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, + 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, + 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, + 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, + 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, + 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, + 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, + 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, + 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, + 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, + 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL +}; + +/* Initial hash value H for SHA-512 */ +const sha2_word64 sha512_initial_hash_value[8] = { + 0x6a09e667f3bcc908ULL, + 0xbb67ae8584caa73bULL, + 0x3c6ef372fe94f82bULL, + 0xa54ff53a5f1d36f1ULL, + 0x510e527fade682d1ULL, + 0x9b05688c2b3e6c1fULL, + 0x1f83d9abfb41bd6bULL, + 0x5be0cd19137e2179ULL +}; + +/* + * Constant used by SHA256/384/512_End() functions for converting the + * digest to a readable hexadecimal character string: + */ +static const char *sha2_hex_digits = "0123456789abcdef"; + + +/*** SHA-1: ***********************************************************/ +void sha1_Init(SHA1_CTX* context) { + MEMCPY_BCOPY(context->state, sha1_initial_hash_value, SHA1_DIGEST_LENGTH); + memzero(context->buffer, SHA1_BLOCK_LENGTH); + context->bitcount = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-1 round macros: */ + +#define ROUND1_0_TO_15(a,b,c,d,e) \ + (e) = ROTL32(5, (a)) + Ch((b), (c), (d)) + (e) + \ + K1_0_TO_19 + ( W1[j] = *data++ ); \ + (b) = ROTL32(30, (b)); \ + j++; + +#define ROUND1_16_TO_19(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Ch(b,c,d) + e + K1_0_TO_19 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_20_TO_39(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Parity(b,c,d) + e + K1_20_TO_39 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_40_TO_59(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Maj(b,c,d) + e + K1_40_TO_59 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_60_TO_79(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Parity(b,c,d) + e + K1_60_TO_79 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +void sha1_Transform(const sha2_word32* state_in, const sha2_word32* data, sha2_word32* state_out) { + sha2_word32 a = 0, b = 0, c = 0, d = 0, e = 0; + sha2_word32 T1 = 0; + sha2_word32 W1[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + + j = 0; + + /* Rounds 0 to 15 unrolled: */ + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + + /* Rounds 16 to 19 unrolled: */ + ROUND1_16_TO_19(e,a,b,c,d); + ROUND1_16_TO_19(d,e,a,b,c); + ROUND1_16_TO_19(c,d,e,a,b); + ROUND1_16_TO_19(b,c,d,e,a); + + /* Rounds 20 to 39 unrolled: */ + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + + /* Rounds 40 to 59 unrolled: */ + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + + /* Rounds 60 to 79 unrolled: */ + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + + /* Clean up */ + a = b = c = d = e = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void sha1_Transform(const sha2_word32* state_in, const sha2_word32* data, sha2_word32* state_out) { + sha2_word32 a = 0, b = 0, c = 0, d = 0, e = 0; + sha2_word32 T1 = 0; + sha2_word32 W1[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + j = 0; + do { + T1 = ROTL32(5, a) + Ch(b, c, d) + e + K1_0_TO_19 + (W1[j] = *data++); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 16); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Ch(b,c,d) + e + K1_0_TO_19 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 20); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Parity(b,c,d) + e + K1_20_TO_39 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 40); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Maj(b,c,d) + e + K1_40_TO_59 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 60); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Parity(b,c,d) + e + K1_60_TO_79 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 80); + + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + + /* Clean up */ + a = b = c = d = e = T1 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void sha1_Update(SHA1_CTX* context, const sha2_byte *data, size_t len) { + unsigned int freespace = 0, usedspace = 0; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + usedspace = (context->bitcount >> 3) % SHA1_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA1_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, freespace); + context->bitcount += freespace << 3; + len -= freespace; + data += freespace; +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + sha1_Transform(context->state, context->buffer, context->state); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, len); + context->bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA1_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + MEMCPY_BCOPY(context->buffer, data, SHA1_BLOCK_LENGTH); +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + sha1_Transform(context->state, context->buffer, context->state); + context->bitcount += SHA1_BLOCK_LENGTH << 3; + len -= SHA1_BLOCK_LENGTH; + data += SHA1_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->buffer, data, len); + context->bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void sha1_Final(SHA1_CTX* context, sha2_byte digest[]) { + unsigned int usedspace = 0; + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + usedspace = (context->bitcount >> 3) % SHA1_BLOCK_LENGTH; + /* Begin padding with a 1 bit: */ + ((uint8_t*)context->buffer)[usedspace++] = 0x80; + + if (usedspace > SHA1_SHORT_BLOCK_LENGTH) { + memzero(((uint8_t*)context->buffer) + usedspace, SHA1_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + /* Do second-to-last transform: */ + sha1_Transform(context->state, context->buffer, context->state); + + /* And prepare the last transform: */ + usedspace = 0; + } + /* Set-up for the last transform: */ + memzero(((uint8_t*)context->buffer) + usedspace, SHA1_SHORT_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 14; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + /* Set the bit count: */ + context->buffer[14] = context->bitcount >> 32; + context->buffer[15] = context->bitcount & 0xffffffff; + + /* Final transform: */ + sha1_Transform(context->state, context->buffer, context->state); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + for (int j = 0; j < 5; j++) { + REVERSE32(context->state[j],context->state[j]); + } +#endif + MEMCPY_BCOPY(digest, context->state, SHA1_DIGEST_LENGTH); + } + + /* Clean up state data: */ + memzero(context, sizeof(SHA1_CTX)); + usedspace = 0; +} + +char *sha1_End(SHA1_CTX* context, char buffer[]) { + sha2_byte digest[SHA1_DIGEST_LENGTH] = {0}, *d = digest; + int i = 0; + + if (buffer != (char*)0) { + sha1_Final(context, digest); + + for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + memzero(context, sizeof(SHA1_CTX)); + } + memzero(digest, SHA1_DIGEST_LENGTH); + return buffer; +} + +void sha1_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA1_DIGEST_LENGTH]) { + SHA1_CTX context = {0}; + sha1_Init(&context); + sha1_Update(&context, data, len); + sha1_Final(&context, digest); +} + +char* sha1_Data(const sha2_byte* data, size_t len, char digest[SHA1_DIGEST_STRING_LENGTH]) { + SHA1_CTX context = {0}; + + sha1_Init(&context); + sha1_Update(&context, data, len); + return sha1_End(&context, digest); +} + +/*** SHA-256: *********************************************************/ +void sha256_Init(SHA256_CTX* context) { + if (context == (SHA256_CTX*)0) { + return; + } + MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH); + memzero(context->buffer, SHA256_BLOCK_LENGTH); + context->bitcount = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-256 round macros: */ + +#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ + K256[j] + (W256[j] = *data++); \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + +#define ROUND256(a,b,c,d,e,f,g,h) \ + s0 = W256[(j+1)&0x0f]; \ + s0 = sigma0_256(s0); \ + s1 = W256[(j+14)&0x0f]; \ + s1 = sigma1_256(s1); \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \ + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + +void sha256_Transform(const sha2_word32* state_in, const sha2_word32* data, sha2_word32* state_out) { + sha2_word32 a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, s0 = 0, s1 = 0; + sha2_word32 T1 = 0; + sha2_word32 W256[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + f = state_in[5]; + g = state_in[6]; + h = state_in[7]; + + j = 0; + do { + /* Rounds 0 to 15 (unrolled): */ + ROUND256_0_TO_15(a,b,c,d,e,f,g,h); + ROUND256_0_TO_15(h,a,b,c,d,e,f,g); + ROUND256_0_TO_15(g,h,a,b,c,d,e,f); + ROUND256_0_TO_15(f,g,h,a,b,c,d,e); + ROUND256_0_TO_15(e,f,g,h,a,b,c,d); + ROUND256_0_TO_15(d,e,f,g,h,a,b,c); + ROUND256_0_TO_15(c,d,e,f,g,h,a,b); + ROUND256_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds to 64: */ + do { + ROUND256(a,b,c,d,e,f,g,h); + ROUND256(h,a,b,c,d,e,f,g); + ROUND256(g,h,a,b,c,d,e,f); + ROUND256(f,g,h,a,b,c,d,e); + ROUND256(e,f,g,h,a,b,c,d); + ROUND256(d,e,f,g,h,a,b,c); + ROUND256(c,d,e,f,g,h,a,b); + ROUND256(b,c,d,e,f,g,h,a); + } while (j < 64); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + state_out[5] = state_in[5] + f; + state_out[6] = state_in[6] + g; + state_out[7] = state_in[7] + h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void sha256_Transform(const sha2_word32* state_in, const sha2_word32* data, sha2_word32* state_out) { + sha2_word32 a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, s0 = 0, s1 = 0; + sha2_word32 T1 = 0, T2 = 0 , W256[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + f = state_in[5]; + g = state_in[6]; + h = state_in[7]; + + j = 0; + do { + /* Apply the SHA-256 compression function to update a..h with copy */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++); + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W256[(j+1)&0x0f]; + s0 = sigma0_256(s0); + s1 = W256[(j+14)&0x0f]; + s1 = sigma1_256(s1); + + /* Apply the SHA-256 compression function to update a..h */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 64); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + state_out[5] = state_in[5] + f; + state_out[6] = state_in[6] + g; + state_out[7] = state_in[7] + h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void sha256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { + unsigned int freespace = 0, usedspace = 0; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA256_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, freespace); + context->bitcount += freespace << 3; + len -= freespace; + data += freespace; +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + sha256_Transform(context->state, context->buffer, context->state); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, len); + context->bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA256_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + MEMCPY_BCOPY(context->buffer, data, SHA256_BLOCK_LENGTH); +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + sha256_Transform(context->state, context->buffer, context->state); + context->bitcount += SHA256_BLOCK_LENGTH << 3; + len -= SHA256_BLOCK_LENGTH; + data += SHA256_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->buffer, data, len); + context->bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void sha256_Final(SHA256_CTX* context, sha2_byte digest[]) { + unsigned int usedspace = 0; + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + /* Begin padding with a 1 bit: */ + ((uint8_t*)context->buffer)[usedspace++] = 0x80; + + if (usedspace > SHA256_SHORT_BLOCK_LENGTH) { + memzero(((uint8_t*)context->buffer) + usedspace, SHA256_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + /* Do second-to-last transform: */ + sha256_Transform(context->state, context->buffer, context->state); + + /* And prepare the last transform: */ + usedspace = 0; + } + /* Set-up for the last transform: */ + memzero(((uint8_t*)context->buffer) + usedspace, SHA256_SHORT_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 14; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + /* Set the bit count: */ + context->buffer[14] = context->bitcount >> 32; + context->buffer[15] = context->bitcount & 0xffffffff; + + /* Final transform: */ + sha256_Transform(context->state, context->buffer, context->state); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + for (int j = 0; j < 8; j++) { + REVERSE32(context->state[j],context->state[j]); + } +#endif + MEMCPY_BCOPY(digest, context->state, SHA256_DIGEST_LENGTH); + } + + /* Clean up state data: */ + memzero(context, sizeof(SHA256_CTX)); + usedspace = 0; +} + +char *sha256_End(SHA256_CTX* context, char buffer[]) { + sha2_byte digest[SHA256_DIGEST_LENGTH] = {0}, *d = digest; + int i = 0; + + if (buffer != (char*)0) { + sha256_Final(context, digest); + + for (i = 0; i < SHA256_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + memzero(context, sizeof(SHA256_CTX)); + } + memzero(digest, SHA256_DIGEST_LENGTH); + return buffer; +} + +void sha256_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA256_DIGEST_LENGTH]) { + SHA256_CTX context = {0}; + sha256_Init(&context); + sha256_Update(&context, data, len); + sha256_Final(&context, digest); +} + +char* sha256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { + SHA256_CTX context = {0}; + + sha256_Init(&context); + sha256_Update(&context, data, len); + return sha256_End(&context, digest); +} + + +/*** SHA-512: *********************************************************/ +void sha512_Init(SHA512_CTX* context) { + if (context == (SHA512_CTX*)0) { + return; + } + MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH); + memzero(context->buffer, SHA512_BLOCK_LENGTH); + context->bitcount[0] = context->bitcount[1] = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-512 round macros: */ +#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ + K512[j] + (W512[j] = *data++); \ + (d) += T1; \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ + j++ + +#define ROUND512(a,b,c,d,e,f,g,h) \ + s0 = W512[(j+1)&0x0f]; \ + s0 = sigma0_512(s0); \ + s1 = W512[(j+14)&0x0f]; \ + s1 = sigma1_512(s1); \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \ + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ + j++ + +void sha512_Transform(const sha2_word64* state_in, const sha2_word64* data, sha2_word64* state_out) { + sha2_word64 a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, s0 = 0, s1 = 0; + sha2_word64 T1 = 0, W512[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + f = state_in[5]; + g = state_in[6]; + h = state_in[7]; + + j = 0; + do { + ROUND512_0_TO_15(a,b,c,d,e,f,g,h); + ROUND512_0_TO_15(h,a,b,c,d,e,f,g); + ROUND512_0_TO_15(g,h,a,b,c,d,e,f); + ROUND512_0_TO_15(f,g,h,a,b,c,d,e); + ROUND512_0_TO_15(e,f,g,h,a,b,c,d); + ROUND512_0_TO_15(d,e,f,g,h,a,b,c); + ROUND512_0_TO_15(c,d,e,f,g,h,a,b); + ROUND512_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds up to 79: */ + do { + ROUND512(a,b,c,d,e,f,g,h); + ROUND512(h,a,b,c,d,e,f,g); + ROUND512(g,h,a,b,c,d,e,f); + ROUND512(f,g,h,a,b,c,d,e); + ROUND512(e,f,g,h,a,b,c,d); + ROUND512(d,e,f,g,h,a,b,c); + ROUND512(c,d,e,f,g,h,a,b); + ROUND512(b,c,d,e,f,g,h,a); + } while (j < 80); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + state_out[5] = state_in[5] + f; + state_out[6] = state_in[6] + g; + state_out[7] = state_in[7] + h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void sha512_Transform(const sha2_word64* state_in, const sha2_word64* data, sha2_word64* state_out) { + sha2_word64 a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, s0 = 0, s1 = 0; + sha2_word64 T1 = 0, T2 = 0, W512[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + f = state_in[5]; + g = state_in[6]; + h = state_in[7]; + + j = 0; + do { + /* Apply the SHA-512 compression function to update a..h with copy */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W512[(j+1)&0x0f]; + s0 = sigma0_512(s0); + s1 = W512[(j+14)&0x0f]; + s1 = sigma1_512(s1); + + /* Apply the SHA-512 compression function to update a..h */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 80); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + state_out[5] = state_in[5] + f; + state_out[6] = state_in[6] + g; + state_out[7] = state_in[7] + h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void sha512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { + unsigned int freespace = 0, usedspace = 0; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA512_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, freespace); + ADDINC128(context->bitcount, freespace << 3); + len -= freespace; + data += freespace; +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE64(context->buffer[j],context->buffer[j]); + } +#endif + sha512_Transform(context->state, context->buffer, context->state); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, len); + ADDINC128(context->bitcount, len << 3); + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA512_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + MEMCPY_BCOPY(context->buffer, data, SHA512_BLOCK_LENGTH); +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE64(context->buffer[j],context->buffer[j]); + } +#endif + sha512_Transform(context->state, context->buffer, context->state); + ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); + len -= SHA512_BLOCK_LENGTH; + data += SHA512_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->buffer, data, len); + ADDINC128(context->bitcount, len << 3); + } + /* Clean up: */ + usedspace = freespace = 0; +} + +static void sha512_Last(SHA512_CTX* context) { + unsigned int usedspace = 0; + + usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + /* Begin padding with a 1 bit: */ + ((uint8_t*)context->buffer)[usedspace++] = 0x80; + + if (usedspace > SHA512_SHORT_BLOCK_LENGTH) { + memzero(((uint8_t*)context->buffer) + usedspace, SHA512_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE64(context->buffer[j],context->buffer[j]); + } +#endif + /* Do second-to-last transform: */ + sha512_Transform(context->state, context->buffer, context->state); + + /* And prepare the last transform: */ + usedspace = 0; + } + /* Set-up for the last transform: */ + memzero(((uint8_t*)context->buffer) + usedspace, SHA512_SHORT_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 14; j++) { + REVERSE64(context->buffer[j],context->buffer[j]); + } +#endif + /* Store the length of input data (in bits): */ + context->buffer[14] = context->bitcount[1]; + context->buffer[15] = context->bitcount[0]; + + /* Final transform: */ + sha512_Transform(context->state, context->buffer, context->state); +} + +void sha512_Final(SHA512_CTX* context, sha2_byte digest[]) { + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + sha512_Last(context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + for (int j = 0; j < 8; j++) { + REVERSE64(context->state[j],context->state[j]); + } +#endif + MEMCPY_BCOPY(digest, context->state, SHA512_DIGEST_LENGTH); + } + + /* Zero out state data */ + memzero(context, sizeof(SHA512_CTX)); +} + +char *sha512_End(SHA512_CTX* context, char buffer[]) { + sha2_byte digest[SHA512_DIGEST_LENGTH] = {0}, *d = digest; + int i = 0; + + if (buffer != (char*)0) { + sha512_Final(context, digest); + + for (i = 0; i < SHA512_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + memzero(context, sizeof(SHA512_CTX)); + } + memzero(digest, SHA512_DIGEST_LENGTH); + return buffer; +} + +void sha512_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA512_DIGEST_LENGTH]) { + SHA512_CTX context = {0}; + sha512_Init(&context); + sha512_Update(&context, data, len); + sha512_Final(&context, digest); +} + +char* sha512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { + SHA512_CTX context = {0}; + + sha512_Init(&context); + sha512_Update(&context, data, len); + return sha512_End(&context, digest); +} diff --git a/src/crypto/bip39/sha2.h b/src/crypto/bip39/sha2.h new file mode 100644 index 000000000..7f519c50b --- /dev/null +++ b/src/crypto/bip39/sha2.h @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2000-2001 Aaron D. Gifford + * Copyright (c) 2013-2014 Pavol Rusnak + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __SHA2_H__ +#define __SHA2_H__ + +#include +#include + +#define SHA1_BLOCK_LENGTH 64 +#define SHA1_DIGEST_LENGTH 20 +#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) +#define SHA256_BLOCK_LENGTH 64 +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA512_BLOCK_LENGTH 128 +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) + +typedef struct _SHA1_CTX { + uint32_t state[5]; + uint64_t bitcount; + uint32_t buffer[SHA1_BLOCK_LENGTH/sizeof(uint32_t)]; +} SHA1_CTX; +typedef struct _SHA256_CTX { + uint32_t state[8]; + uint64_t bitcount; + uint32_t buffer[SHA256_BLOCK_LENGTH/sizeof(uint32_t)]; +} SHA256_CTX; +typedef struct _SHA512_CTX { + uint64_t state[8]; + uint64_t bitcount[2]; + uint64_t buffer[SHA512_BLOCK_LENGTH/sizeof(uint64_t)]; +} SHA512_CTX; + +/*** ENDIAN REVERSAL MACROS *******************************************/ +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN 1234 +#define BIG_ENDIAN 4321 +#endif + +#ifndef BYTE_ORDER +#define BYTE_ORDER LITTLE_ENDIAN +#endif + +#if BYTE_ORDER == LITTLE_ENDIAN +#define REVERSE32(w,x) { \ + uint32_t tmp = (w); \ + tmp = (tmp >> 16) | (tmp << 16); \ + (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ +} +#define REVERSE64(w,x) { \ + uint64_t tmp = (w); \ + tmp = (tmp >> 32) | (tmp << 32); \ + tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ + ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ + (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \ + ((tmp & 0x0000ffff0000ffffULL) << 16); \ +} +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +extern const uint32_t sha256_initial_hash_value[8]; +extern const uint64_t sha512_initial_hash_value[8]; + +void sha1_Transform(const uint32_t* state_in, const uint32_t* data, uint32_t* state_out); +void sha1_Init(SHA1_CTX *); +void sha1_Update(SHA1_CTX*, const uint8_t*, size_t); +void sha1_Final(SHA1_CTX*, uint8_t[SHA1_DIGEST_LENGTH]); +char* sha1_End(SHA1_CTX*, char[SHA1_DIGEST_STRING_LENGTH]); +void sha1_Raw(const uint8_t*, size_t, uint8_t[SHA1_DIGEST_LENGTH]); +char* sha1_Data(const uint8_t*, size_t, char[SHA1_DIGEST_STRING_LENGTH]); + +void sha256_Transform(const uint32_t* state_in, const uint32_t* data, uint32_t* state_out); +void sha256_Init(SHA256_CTX *); +void sha256_Update(SHA256_CTX*, const uint8_t*, size_t); +void sha256_Final(SHA256_CTX*, uint8_t[SHA256_DIGEST_LENGTH]); +char* sha256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); +void sha256_Raw(const uint8_t*, size_t, uint8_t[SHA256_DIGEST_LENGTH]); +char* sha256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); + +void sha512_Transform(const uint64_t* state_in, const uint64_t* data, uint64_t* state_out); +void sha512_Init(SHA512_CTX*); +void sha512_Update(SHA512_CTX*, const uint8_t*, size_t); +void sha512_Final(SHA512_CTX*, uint8_t[SHA512_DIGEST_LENGTH]); +char* sha512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); +void sha512_Raw(const uint8_t*, size_t, uint8_t[SHA512_DIGEST_LENGTH]); +char* sha512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); + +#endif diff --git a/src/crypto/bip39/sha3.c b/src/crypto/bip39/sha3.c new file mode 100644 index 000000000..80ac28ff6 --- /dev/null +++ b/src/crypto/bip39/sha3.c @@ -0,0 +1,397 @@ +/* sha3.c - an implementation of Secure Hash Algorithm 3 (Keccak). + * based on the + * The Keccak SHA-3 submission. Submission to NIST (Round 3), 2011 + * by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche + * + * Copyright: 2013 Aleksey Kravchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. Use this program at your own risk! + */ + +#include +#include + +#include "sha3.h" +#include "memzero.h" + +#define I64(x) x##LL +#define ROTL64(qword, n) ((qword) << (n) ^ ((qword) >> (64 - (n)))) +#define le2me_64(x) (x) +#define IS_ALIGNED_64(p) (0 == (7 & ((const char*)(p) - (const char*)0))) +# define me64_to_le_str(to, from, length) memcpy((to), (from), (length)) + +/* constants */ +#define NumberOfRounds 24 + +/* SHA3 (Keccak) constants for 24 rounds */ +static uint64_t keccak_round_constants[NumberOfRounds] = { + I64(0x0000000000000001), I64(0x0000000000008082), I64(0x800000000000808A), I64(0x8000000080008000), + I64(0x000000000000808B), I64(0x0000000080000001), I64(0x8000000080008081), I64(0x8000000000008009), + I64(0x000000000000008A), I64(0x0000000000000088), I64(0x0000000080008009), I64(0x000000008000000A), + I64(0x000000008000808B), I64(0x800000000000008B), I64(0x8000000000008089), I64(0x8000000000008003), + I64(0x8000000000008002), I64(0x8000000000000080), I64(0x000000000000800A), I64(0x800000008000000A), + I64(0x8000000080008081), I64(0x8000000000008080), I64(0x0000000080000001), I64(0x8000000080008008) +}; + +/* Initializing a sha3 context for given number of output bits */ +static void keccak_Init(SHA3_CTX *ctx, unsigned bits) +{ + /* NB: The Keccak capacity parameter = bits * 2 */ + unsigned rate = 1600 - bits * 2; + + memzero(ctx, sizeof(SHA3_CTX)); + ctx->block_size = rate / 8; + assert(rate <= 1600 && (rate % 64) == 0); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void sha3_224_Init(SHA3_CTX *ctx) +{ + keccak_Init(ctx, 224); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void sha3_256_Init(SHA3_CTX *ctx) +{ + keccak_Init(ctx, 256); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void sha3_384_Init(SHA3_CTX *ctx) +{ + keccak_Init(ctx, 384); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void sha3_512_Init(SHA3_CTX *ctx) +{ + keccak_Init(ctx, 512); +} + +/* Keccak theta() transformation */ +static void keccak_theta(uint64_t *A) +{ + unsigned int x = 0; + uint64_t C[5] = {0}, D[5] = {0}; + + for (x = 0; x < 5; x++) { + C[x] = A[x] ^ A[x + 5] ^ A[x + 10] ^ A[x + 15] ^ A[x + 20]; + } + D[0] = ROTL64(C[1], 1) ^ C[4]; + D[1] = ROTL64(C[2], 1) ^ C[0]; + D[2] = ROTL64(C[3], 1) ^ C[1]; + D[3] = ROTL64(C[4], 1) ^ C[2]; + D[4] = ROTL64(C[0], 1) ^ C[3]; + + for (x = 0; x < 5; x++) { + A[x] ^= D[x]; + A[x + 5] ^= D[x]; + A[x + 10] ^= D[x]; + A[x + 15] ^= D[x]; + A[x + 20] ^= D[x]; + } +} + +/* Keccak pi() transformation */ +static void keccak_pi(uint64_t *A) +{ + uint64_t A1 = 0; + A1 = A[1]; + A[ 1] = A[ 6]; + A[ 6] = A[ 9]; + A[ 9] = A[22]; + A[22] = A[14]; + A[14] = A[20]; + A[20] = A[ 2]; + A[ 2] = A[12]; + A[12] = A[13]; + A[13] = A[19]; + A[19] = A[23]; + A[23] = A[15]; + A[15] = A[ 4]; + A[ 4] = A[24]; + A[24] = A[21]; + A[21] = A[ 8]; + A[ 8] = A[16]; + A[16] = A[ 5]; + A[ 5] = A[ 3]; + A[ 3] = A[18]; + A[18] = A[17]; + A[17] = A[11]; + A[11] = A[ 7]; + A[ 7] = A[10]; + A[10] = A1; + /* note: A[ 0] is left as is */ +} + +/* Keccak chi() transformation */ +static void keccak_chi(uint64_t *A) +{ + int i = 0; + for (i = 0; i < 25; i += 5) { + uint64_t A0 = A[0 + i], A1 = A[1 + i]; + A[0 + i] ^= ~A1 & A[2 + i]; + A[1 + i] ^= ~A[2 + i] & A[3 + i]; + A[2 + i] ^= ~A[3 + i] & A[4 + i]; + A[3 + i] ^= ~A[4 + i] & A0; + A[4 + i] ^= ~A0 & A1; + } +} + +static void sha3_permutation(uint64_t *state) +{ + int round = 0; + for (round = 0; round < NumberOfRounds; round++) + { + keccak_theta(state); + + /* apply Keccak rho() transformation */ + state[ 1] = ROTL64(state[ 1], 1); + state[ 2] = ROTL64(state[ 2], 62); + state[ 3] = ROTL64(state[ 3], 28); + state[ 4] = ROTL64(state[ 4], 27); + state[ 5] = ROTL64(state[ 5], 36); + state[ 6] = ROTL64(state[ 6], 44); + state[ 7] = ROTL64(state[ 7], 6); + state[ 8] = ROTL64(state[ 8], 55); + state[ 9] = ROTL64(state[ 9], 20); + state[10] = ROTL64(state[10], 3); + state[11] = ROTL64(state[11], 10); + state[12] = ROTL64(state[12], 43); + state[13] = ROTL64(state[13], 25); + state[14] = ROTL64(state[14], 39); + state[15] = ROTL64(state[15], 41); + state[16] = ROTL64(state[16], 45); + state[17] = ROTL64(state[17], 15); + state[18] = ROTL64(state[18], 21); + state[19] = ROTL64(state[19], 8); + state[20] = ROTL64(state[20], 18); + state[21] = ROTL64(state[21], 2); + state[22] = ROTL64(state[22], 61); + state[23] = ROTL64(state[23], 56); + state[24] = ROTL64(state[24], 14); + + keccak_pi(state); + keccak_chi(state); + + /* apply iota(state, round) */ + *state ^= keccak_round_constants[round]; + } +} + +/** + * The core transformation. Process the specified block of data. + * + * @param hash the algorithm state + * @param block the message block to process + * @param block_size the size of the processed block in bytes + */ +static void sha3_process_block(uint64_t hash[25], const uint64_t *block, size_t block_size) +{ + /* expanded loop */ + hash[ 0] ^= le2me_64(block[ 0]); + hash[ 1] ^= le2me_64(block[ 1]); + hash[ 2] ^= le2me_64(block[ 2]); + hash[ 3] ^= le2me_64(block[ 3]); + hash[ 4] ^= le2me_64(block[ 4]); + hash[ 5] ^= le2me_64(block[ 5]); + hash[ 6] ^= le2me_64(block[ 6]); + hash[ 7] ^= le2me_64(block[ 7]); + hash[ 8] ^= le2me_64(block[ 8]); + /* if not sha3-512 */ + if (block_size > 72) { + hash[ 9] ^= le2me_64(block[ 9]); + hash[10] ^= le2me_64(block[10]); + hash[11] ^= le2me_64(block[11]); + hash[12] ^= le2me_64(block[12]); + /* if not sha3-384 */ + if (block_size > 104) { + hash[13] ^= le2me_64(block[13]); + hash[14] ^= le2me_64(block[14]); + hash[15] ^= le2me_64(block[15]); + hash[16] ^= le2me_64(block[16]); + /* if not sha3-256 */ + if (block_size > 136) { + hash[17] ^= le2me_64(block[17]); +#ifdef FULL_SHA3_FAMILY_SUPPORT + /* if not sha3-224 */ + if (block_size > 144) { + hash[18] ^= le2me_64(block[18]); + hash[19] ^= le2me_64(block[19]); + hash[20] ^= le2me_64(block[20]); + hash[21] ^= le2me_64(block[21]); + hash[22] ^= le2me_64(block[22]); + hash[23] ^= le2me_64(block[23]); + hash[24] ^= le2me_64(block[24]); + } +#endif + } + } + } + /* make a permutation of the hash */ + sha3_permutation(hash); +} + +#define SHA3_FINALIZED 0x80000000 + +/** + * Calculate message hash. + * Can be called repeatedly with chunks of the message to be hashed. + * + * @param ctx the algorithm context containing current hashing state + * @param msg message chunk + * @param size length of the message chunk + */ +void sha3_Update(SHA3_CTX *ctx, const unsigned char *msg, size_t size) +{ + size_t idx = (size_t)ctx->rest; + size_t block_size = (size_t)ctx->block_size; + + if (ctx->rest & SHA3_FINALIZED) return; /* too late for additional input */ + ctx->rest = (unsigned)((ctx->rest + size) % block_size); + + /* fill partial block */ + if (idx) { + size_t left = block_size - idx; + memcpy((char*)ctx->message + idx, msg, (size < left ? size : left)); + if (size < left) return; + + /* process partial block */ + sha3_process_block(ctx->hash, ctx->message, block_size); + msg += left; + size -= left; + } + while (size >= block_size) { + uint64_t *aligned_message_block = NULL; + if (IS_ALIGNED_64(msg)) { + /* the most common case is processing of an already aligned message + without copying it */ + aligned_message_block = (uint64_t*)(void*)msg; + } else { + memcpy(ctx->message, msg, block_size); + aligned_message_block = ctx->message; + } + + sha3_process_block(ctx->hash, aligned_message_block, block_size); + msg += block_size; + size -= block_size; + } + if (size) { + memcpy(ctx->message, msg, size); /* save leftovers */ + } +} + +/** + * Store calculated hash into the given array. + * + * @param ctx the algorithm context containing current hashing state + * @param result calculated hash in binary form + */ +void sha3_Final(SHA3_CTX *ctx, unsigned char* result) +{ + size_t digest_length = 100 - ctx->block_size / 2; + const size_t block_size = ctx->block_size; + + if (!(ctx->rest & SHA3_FINALIZED)) + { + /* clear the rest of the data queue */ + memzero((char*)ctx->message + ctx->rest, block_size - ctx->rest); + ((char*)ctx->message)[ctx->rest] |= 0x06; + ((char*)ctx->message)[block_size - 1] |= 0x80; + + /* process final block */ + sha3_process_block(ctx->hash, ctx->message, block_size); + ctx->rest = SHA3_FINALIZED; /* mark context as finalized */ + } + + assert(block_size > digest_length); + if (result) me64_to_le_str(result, ctx->hash, digest_length); + memzero(ctx, sizeof(SHA3_CTX)); +} + +#if USE_KECCAK +/** +* Store calculated hash into the given array. +* +* @param ctx the algorithm context containing current hashing state +* @param result calculated hash in binary form +*/ +void keccak_Final(SHA3_CTX *ctx, unsigned char* result) +{ + size_t digest_length = 100 - ctx->block_size / 2; + const size_t block_size = ctx->block_size; + + if (!(ctx->rest & SHA3_FINALIZED)) + { + /* clear the rest of the data queue */ + memzero((char*)ctx->message + ctx->rest, block_size - ctx->rest); + ((char*)ctx->message)[ctx->rest] |= 0x01; + ((char*)ctx->message)[block_size - 1] |= 0x80; + + /* process final block */ + sha3_process_block(ctx->hash, ctx->message, block_size); + ctx->rest = SHA3_FINALIZED; /* mark context as finalized */ + } + + assert(block_size > digest_length); + if (result) me64_to_le_str(result, ctx->hash, digest_length); + memzero(ctx, sizeof(SHA3_CTX)); +} + +void keccak_256(const unsigned char* data, size_t len, unsigned char* digest) +{ + SHA3_CTX ctx = {0}; + keccak_256_Init(&ctx); + keccak_Update(&ctx, data, len); + keccak_Final(&ctx, digest); +} + +void keccak_512(const unsigned char* data, size_t len, unsigned char* digest) +{ + SHA3_CTX ctx = {0}; + keccak_512_Init(&ctx); + keccak_Update(&ctx, data, len); + keccak_Final(&ctx, digest); +} +#endif /* USE_KECCAK */ + +void sha3_256(const unsigned char* data, size_t len, unsigned char* digest) +{ + SHA3_CTX ctx = {0}; + sha3_256_Init(&ctx); + sha3_Update(&ctx, data, len); + sha3_Final(&ctx, digest); +} + +void sha3_512(const unsigned char* data, size_t len, unsigned char* digest) +{ + SHA3_CTX ctx = {0}; + sha3_512_Init(&ctx); + sha3_Update(&ctx, data, len); + sha3_Final(&ctx, digest); +} diff --git a/src/crypto/bip39/sha3.h b/src/crypto/bip39/sha3.h new file mode 100644 index 000000000..367369d4d --- /dev/null +++ b/src/crypto/bip39/sha3.h @@ -0,0 +1,89 @@ +/* sha3.h - an implementation of Secure Hash Algorithm 3 (Keccak). + * based on the + * The Keccak SHA-3 submission. Submission to NIST (Round 3), 2011 + * by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche + * + * Copyright: 2013 Aleksey Kravchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. Use this program at your own risk! + */ + +#ifndef __SHA3_H__ +#define __SHA3_H__ + +#include +#include "options.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define sha3_224_hash_size 28 +#define sha3_256_hash_size 32 +#define sha3_384_hash_size 48 +#define sha3_512_hash_size 64 +#define sha3_max_permutation_size 25 +#define sha3_max_rate_in_qwords 24 + +#define SHA3_224_BLOCK_LENGTH 144 +#define SHA3_256_BLOCK_LENGTH 136 +#define SHA3_384_BLOCK_LENGTH 104 +#define SHA3_512_BLOCK_LENGTH 72 + +#define SHA3_224_DIGEST_LENGTH sha3_224_hash_size +#define SHA3_256_DIGEST_LENGTH sha3_256_hash_size +#define SHA3_384_DIGEST_LENGTH sha3_384_hash_size +#define SHA3_512_DIGEST_LENGTH sha3_512_hash_size + +/** + * SHA3 Algorithm context. + */ +typedef struct SHA3_CTX +{ + /* 1600 bits algorithm hashing state */ + uint64_t hash[sha3_max_permutation_size]; + /* 1536-bit buffer for leftovers */ + uint64_t message[sha3_max_rate_in_qwords]; + /* count of bytes in the message[] buffer */ + unsigned rest; + /* size of a message block processed at once */ + unsigned block_size; +} SHA3_CTX; + +/* methods for calculating the hash function */ + +void sha3_224_Init(SHA3_CTX *ctx); +void sha3_256_Init(SHA3_CTX *ctx); +void sha3_384_Init(SHA3_CTX *ctx); +void sha3_512_Init(SHA3_CTX *ctx); +void sha3_Update(SHA3_CTX *ctx, const unsigned char* msg, size_t size); +void sha3_Final(SHA3_CTX *ctx, unsigned char* result); + +#if USE_KECCAK +#define keccak_224_Init sha3_224_Init +#define keccak_256_Init sha3_256_Init +#define keccak_384_Init sha3_384_Init +#define keccak_512_Init sha3_512_Init +#define keccak_Update sha3_Update +void keccak_Final(SHA3_CTX *ctx, unsigned char* result); +void keccak_256(const unsigned char* data, size_t len, unsigned char* digest); +void keccak_512(const unsigned char* data, size_t len, unsigned char* digest); +#endif + +void sha3_256(const unsigned char* data, size_t len, unsigned char* digest); +void sha3_512(const unsigned char* data, size_t len, unsigned char* digest); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* __SHA3_H__ */ diff --git a/src/crypto/common.h b/src/crypto/common.h index 12bdbec19..130f78fa9 100644 --- a/src/crypto/common.h +++ b/src/crypto/common.h @@ -2,7 +2,7 @@ // Copyright (c) 2019-2020 The Hush developers // Released under the GPLv3 // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_COMMON_H #define BITCOIN_CRYPTO_COMMON_H diff --git a/src/crypto/ctaes/COPYING b/src/crypto/ctaes/COPYING new file mode 100644 index 000000000..415b202a2 --- /dev/null +++ b/src/crypto/ctaes/COPYING @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Pieter Wuille + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/crypto/ctaes/README.md b/src/crypto/ctaes/README.md new file mode 100644 index 000000000..0e7fe1775 --- /dev/null +++ b/src/crypto/ctaes/README.md @@ -0,0 +1,41 @@ +ctaes +===== + +Simple C module for constant-time AES encryption and decryption. + +Features: +* Simple, pure C code without any dependencies. +* No tables or data-dependent branches whatsoever, but using bit sliced approach from https://eprint.iacr.org/2009/129.pdf. +* Very small object code: slightly over 4k of executable code when compiled with -Os. +* Slower than implementations based on precomputed tables or specialized instructions, but can do ~15 MB/s on modern CPUs. + +Performance +----------- + +Compiled with GCC 5.3.1 with -O3, on an Intel(R) Core(TM) i7-4800MQ CPU, numbers in CPU cycles: + +| Algorithm | Key schedule | Encryption per byte | Decryption per byte | +| --------- | ------------:| -------------------:| -------------------:| +| AES-128 | 2.8k | 154 | 161 | +| AES-192 | 3.1k | 169 | 181 | +| AES-256 | 4.0k | 191 | 203 | + +Build steps +----------- + +Object code: + + $ gcc -O3 ctaes.c -c -o ctaes.o + +Tests: + + $ gcc -O3 ctaes.c test.c -o test + +Benchmark: + + $ gcc -O3 ctaes.c bench.c -o bench + +Review +------ + +Results of a formal review of the code can be found in http://bitcoin.sipa.be/ctaes/review.zip diff --git a/src/crypto/ctaes/bench.c b/src/crypto/ctaes/bench.c new file mode 100644 index 000000000..a86df496c --- /dev/null +++ b/src/crypto/ctaes/bench.c @@ -0,0 +1,170 @@ +#include +#include +#include "sys/time.h" + +#include "ctaes.h" + +static double gettimedouble(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_usec * 0.000001 + tv.tv_sec; +} + +static void print_number(double x) { + double y = x; + int c = 0; + if (y < 0.0) { + y = -y; + } + while (y < 100.0) { + y *= 10.0; + c++; + } + printf("%.*f", c, x); +} + +static void run_benchmark(char *name, void (*benchmark)(void*), void (*setup)(void*), void (*teardown)(void*), void* data, int count, int iter) { + int i; + double min = HUGE_VAL; + double sum = 0.0; + double max = 0.0; + for (i = 0; i < count; i++) { + double begin, total; + if (setup != NULL) { + setup(data); + } + begin = gettimedouble(); + benchmark(data); + total = gettimedouble() - begin; + if (teardown != NULL) { + teardown(data); + } + if (total < min) { + min = total; + } + if (total > max) { + max = total; + } + sum += total; + } + printf("%s: min ", name); + print_number(min * 1000000000.0 / iter); + printf("ns / avg "); + print_number((sum / count) * 1000000000.0 / iter); + printf("ns / max "); + print_number(max * 1000000000.0 / iter); + printf("ns\n"); +} + +static void bench_AES128_init(void* data) { + AES128_ctx* ctx = (AES128_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES128_init(ctx, (unsigned char*)ctx); + } +} + +static void bench_AES128_encrypt_setup(void* data) { + AES128_ctx* ctx = (AES128_ctx*)data; + static const unsigned char key[16] = {0}; + AES128_init(ctx, key); +} + +static void bench_AES128_encrypt(void* data) { + const AES128_ctx* ctx = (const AES128_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES128_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES128_decrypt(void* data) { + const AES128_ctx* ctx = (const AES128_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES128_decrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES192_init(void* data) { + AES192_ctx* ctx = (AES192_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES192_init(ctx, (unsigned char*)ctx); + } +} + +static void bench_AES192_encrypt_setup(void* data) { + AES192_ctx* ctx = (AES192_ctx*)data; + static const unsigned char key[16] = {0}; + AES192_init(ctx, key); +} + +static void bench_AES192_encrypt(void* data) { + const AES192_ctx* ctx = (const AES192_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES192_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES192_decrypt(void* data) { + const AES192_ctx* ctx = (const AES192_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES192_decrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES256_init(void* data) { + AES256_ctx* ctx = (AES256_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES256_init(ctx, (unsigned char*)ctx); + } +} + + +static void bench_AES256_encrypt_setup(void* data) { + AES256_ctx* ctx = (AES256_ctx*)data; + static const unsigned char key[16] = {0}; + AES256_init(ctx, key); +} + +static void bench_AES256_encrypt(void* data) { + const AES256_ctx* ctx = (const AES256_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES256_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES256_decrypt(void* data) { + const AES256_ctx* ctx = (const AES256_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES256_decrypt(ctx, 1, scratch, scratch); + } +} + +int main(void) { + AES128_ctx ctx128; + AES192_ctx ctx192; + AES256_ctx ctx256; + run_benchmark("aes128_init", bench_AES128_init, NULL, NULL, &ctx128, 20, 50000); + run_benchmark("aes128_encrypt_byte", bench_AES128_encrypt, bench_AES128_encrypt_setup, NULL, &ctx128, 20, 4000000); + run_benchmark("aes128_decrypt_byte", bench_AES128_decrypt, bench_AES128_encrypt_setup, NULL, &ctx128, 20, 4000000); + run_benchmark("aes192_init", bench_AES192_init, NULL, NULL, &ctx192, 20, 50000); + run_benchmark("aes192_encrypt_byte", bench_AES192_encrypt, bench_AES192_encrypt_setup, NULL, &ctx192, 20, 4000000); + run_benchmark("aes192_decrypt_byte", bench_AES192_decrypt, bench_AES192_encrypt_setup, NULL, &ctx192, 20, 4000000); + run_benchmark("aes256_init", bench_AES256_init, NULL, NULL, &ctx256, 20, 50000); + run_benchmark("aes256_encrypt_byte", bench_AES256_encrypt, bench_AES256_encrypt_setup, NULL, &ctx256, 20, 4000000); + run_benchmark("aes256_decrypt_byte", bench_AES256_decrypt, bench_AES256_encrypt_setup, NULL, &ctx256, 20, 4000000); + return 0; +} diff --git a/src/crypto/ctaes/ctaes.c b/src/crypto/ctaes/ctaes.c new file mode 100644 index 000000000..a21b9f3ee --- /dev/null +++ b/src/crypto/ctaes/ctaes.c @@ -0,0 +1,556 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or https://www.opensource.org/licenses/mit-license.php* + **********************************************************************/ + +/* Constant time, unoptimized, concise, plain C, AES implementation + * Based On: + * Emilia Kasper and Peter Schwabe, Faster and Timing-Attack Resistant AES-GCM + * http://www.iacr.org/archive/ches2009/57470001/57470001.pdf + * But using 8 16-bit integers representing a single AES state rather than 8 128-bit + * integers representing 8 AES states. + */ + +#include "ctaes.h" + +/* Slice variable slice_i contains the i'th bit of the 16 state variables in this order: + * 0 1 2 3 + * 4 5 6 7 + * 8 9 10 11 + * 12 13 14 15 + */ + +/** Convert a byte to sliced form, storing it corresponding to given row and column in s */ +static void LoadByte(AES_state* s, unsigned char byte, int r, int c) { + int i; + for (i = 0; i < 8; i++) { + s->slice[i] |= (byte & 1) << (r * 4 + c); + byte >>= 1; + } +} + +/** Load 16 bytes of data into 8 sliced integers */ +static void LoadBytes(AES_state *s, const unsigned char* data16) { + int c; + for (c = 0; c < 4; c++) { + int r; + for (r = 0; r < 4; r++) { + LoadByte(s, *(data16++), r, c); + } + } +} + +/** Convert 8 sliced integers into 16 bytes of data */ +static void SaveBytes(unsigned char* data16, const AES_state *s) { + int c; + for (c = 0; c < 4; c++) { + int r; + for (r = 0; r < 4; r++) { + int b; + uint8_t v = 0; + for (b = 0; b < 8; b++) { + v |= ((s->slice[b] >> (r * 4 + c)) & 1) << b; + } + *(data16++) = v; + } + } +} + +/* S-box implementation based on the gate logic from: + * Joan Boyar and Rene Peralta, A depth-16 circuit for the AES S-box. + * https://eprint.iacr.org/2011/332.pdf +*/ +static void SubBytes(AES_state *s, int inv) { + /* Load the bit slices */ + uint16_t U0 = s->slice[7], U1 = s->slice[6], U2 = s->slice[5], U3 = s->slice[4]; + uint16_t U4 = s->slice[3], U5 = s->slice[2], U6 = s->slice[1], U7 = s->slice[0]; + + uint16_t T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16; + uint16_t T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, D; + uint16_t M1, M6, M11, M13, M15, M20, M21, M22, M23, M25, M37, M38, M39, M40; + uint16_t M41, M42, M43, M44, M45, M46, M47, M48, M49, M50, M51, M52, M53, M54; + uint16_t M55, M56, M57, M58, M59, M60, M61, M62, M63; + + if (inv) { + uint16_t R5, R13, R17, R18, R19; + /* Undo linear postprocessing */ + T23 = U0 ^ U3; + T22 = ~(U1 ^ U3); + T2 = ~(U0 ^ U1); + T1 = U3 ^ U4; + T24 = ~(U4 ^ U7); + R5 = U6 ^ U7; + T8 = ~(U1 ^ T23); + T19 = T22 ^ R5; + T9 = ~(U7 ^ T1); + T10 = T2 ^ T24; + T13 = T2 ^ R5; + T3 = T1 ^ R5; + T25 = ~(U2 ^ T1); + R13 = U1 ^ U6; + T17 = ~(U2 ^ T19); + T20 = T24 ^ R13; + T4 = U4 ^ T8; + R17 = ~(U2 ^ U5); + R18 = ~(U5 ^ U6); + R19 = ~(U2 ^ U4); + D = U0 ^ R17; + T6 = T22 ^ R17; + T16 = R13 ^ R19; + T27 = T1 ^ R18; + T15 = T10 ^ T27; + T14 = T10 ^ R18; + T26 = T3 ^ T16; + } else { + /* Linear preprocessing. */ + T1 = U0 ^ U3; + T2 = U0 ^ U5; + T3 = U0 ^ U6; + T4 = U3 ^ U5; + T5 = U4 ^ U6; + T6 = T1 ^ T5; + T7 = U1 ^ U2; + T8 = U7 ^ T6; + T9 = U7 ^ T7; + T10 = T6 ^ T7; + T11 = U1 ^ U5; + T12 = U2 ^ U5; + T13 = T3 ^ T4; + T14 = T6 ^ T11; + T15 = T5 ^ T11; + T16 = T5 ^ T12; + T17 = T9 ^ T16; + T18 = U3 ^ U7; + T19 = T7 ^ T18; + T20 = T1 ^ T19; + T21 = U6 ^ U7; + T22 = T7 ^ T21; + T23 = T2 ^ T22; + T24 = T2 ^ T10; + T25 = T20 ^ T17; + T26 = T3 ^ T16; + T27 = T1 ^ T12; + D = U7; + } + + /* Non-linear transformation (shared between the forward and backward case) */ + M1 = T13 & T6; + M6 = T3 & T16; + M11 = T1 & T15; + M13 = (T4 & T27) ^ M11; + M15 = (T2 & T10) ^ M11; + M20 = T14 ^ M1 ^ (T23 & T8) ^ M13; + M21 = (T19 & D) ^ M1 ^ T24 ^ M15; + M22 = T26 ^ M6 ^ (T22 & T9) ^ M13; + M23 = (T20 & T17) ^ M6 ^ M15 ^ T25; + M25 = M22 & M20; + M37 = M21 ^ ((M20 ^ M21) & (M23 ^ M25)); + M38 = M20 ^ M25 ^ (M21 | (M20 & M23)); + M39 = M23 ^ ((M22 ^ M23) & (M21 ^ M25)); + M40 = M22 ^ M25 ^ (M23 | (M21 & M22)); + M41 = M38 ^ M40; + M42 = M37 ^ M39; + M43 = M37 ^ M38; + M44 = M39 ^ M40; + M45 = M42 ^ M41; + M46 = M44 & T6; + M47 = M40 & T8; + M48 = M39 & D; + M49 = M43 & T16; + M50 = M38 & T9; + M51 = M37 & T17; + M52 = M42 & T15; + M53 = M45 & T27; + M54 = M41 & T10; + M55 = M44 & T13; + M56 = M40 & T23; + M57 = M39 & T19; + M58 = M43 & T3; + M59 = M38 & T22; + M60 = M37 & T20; + M61 = M42 & T1; + M62 = M45 & T4; + M63 = M41 & T2; + + if (inv){ + /* Undo linear preprocessing */ + uint16_t P0 = M52 ^ M61; + uint16_t P1 = M58 ^ M59; + uint16_t P2 = M54 ^ M62; + uint16_t P3 = M47 ^ M50; + uint16_t P4 = M48 ^ M56; + uint16_t P5 = M46 ^ M51; + uint16_t P6 = M49 ^ M60; + uint16_t P7 = P0 ^ P1; + uint16_t P8 = M50 ^ M53; + uint16_t P9 = M55 ^ M63; + uint16_t P10 = M57 ^ P4; + uint16_t P11 = P0 ^ P3; + uint16_t P12 = M46 ^ M48; + uint16_t P13 = M49 ^ M51; + uint16_t P14 = M49 ^ M62; + uint16_t P15 = M54 ^ M59; + uint16_t P16 = M57 ^ M61; + uint16_t P17 = M58 ^ P2; + uint16_t P18 = M63 ^ P5; + uint16_t P19 = P2 ^ P3; + uint16_t P20 = P4 ^ P6; + uint16_t P22 = P2 ^ P7; + uint16_t P23 = P7 ^ P8; + uint16_t P24 = P5 ^ P7; + uint16_t P25 = P6 ^ P10; + uint16_t P26 = P9 ^ P11; + uint16_t P27 = P10 ^ P18; + uint16_t P28 = P11 ^ P25; + uint16_t P29 = P15 ^ P20; + s->slice[7] = P13 ^ P22; + s->slice[6] = P26 ^ P29; + s->slice[5] = P17 ^ P28; + s->slice[4] = P12 ^ P22; + s->slice[3] = P23 ^ P27; + s->slice[2] = P19 ^ P24; + s->slice[1] = P14 ^ P23; + s->slice[0] = P9 ^ P16; + } else { + /* Linear postprocessing */ + uint16_t L0 = M61 ^ M62; + uint16_t L1 = M50 ^ M56; + uint16_t L2 = M46 ^ M48; + uint16_t L3 = M47 ^ M55; + uint16_t L4 = M54 ^ M58; + uint16_t L5 = M49 ^ M61; + uint16_t L6 = M62 ^ L5; + uint16_t L7 = M46 ^ L3; + uint16_t L8 = M51 ^ M59; + uint16_t L9 = M52 ^ M53; + uint16_t L10 = M53 ^ L4; + uint16_t L11 = M60 ^ L2; + uint16_t L12 = M48 ^ M51; + uint16_t L13 = M50 ^ L0; + uint16_t L14 = M52 ^ M61; + uint16_t L15 = M55 ^ L1; + uint16_t L16 = M56 ^ L0; + uint16_t L17 = M57 ^ L1; + uint16_t L18 = M58 ^ L8; + uint16_t L19 = M63 ^ L4; + uint16_t L20 = L0 ^ L1; + uint16_t L21 = L1 ^ L7; + uint16_t L22 = L3 ^ L12; + uint16_t L23 = L18 ^ L2; + uint16_t L24 = L15 ^ L9; + uint16_t L25 = L6 ^ L10; + uint16_t L26 = L7 ^ L9; + uint16_t L27 = L8 ^ L10; + uint16_t L28 = L11 ^ L14; + uint16_t L29 = L11 ^ L17; + s->slice[7] = L6 ^ L24; + s->slice[6] = ~(L16 ^ L26); + s->slice[5] = ~(L19 ^ L28); + s->slice[4] = L6 ^ L21; + s->slice[3] = L20 ^ L22; + s->slice[2] = L25 ^ L29; + s->slice[1] = ~(L13 ^ L27); + s->slice[0] = ~(L6 ^ L23); + } +} + +#define BIT_RANGE(from,to) (((1 << ((to) - (from))) - 1) << (from)) + +#define BIT_RANGE_LEFT(x,from,to,shift) (((x) & BIT_RANGE((from), (to))) << (shift)) +#define BIT_RANGE_RIGHT(x,from,to,shift) (((x) & BIT_RANGE((from), (to))) >> (shift)) + +static void ShiftRows(AES_state* s) { + int i; + for (i = 0; i < 8; i++) { + uint16_t v = s->slice[i]; + s->slice[i] = + (v & BIT_RANGE(0, 4)) | + BIT_RANGE_LEFT(v, 4, 5, 3) | BIT_RANGE_RIGHT(v, 5, 8, 1) | + BIT_RANGE_LEFT(v, 8, 10, 2) | BIT_RANGE_RIGHT(v, 10, 12, 2) | + BIT_RANGE_LEFT(v, 12, 15, 1) | BIT_RANGE_RIGHT(v, 15, 16, 3); + } +} + +static void InvShiftRows(AES_state* s) { + int i; + for (i = 0; i < 8; i++) { + uint16_t v = s->slice[i]; + s->slice[i] = + (v & BIT_RANGE(0, 4)) | + BIT_RANGE_LEFT(v, 4, 7, 1) | BIT_RANGE_RIGHT(v, 7, 8, 3) | + BIT_RANGE_LEFT(v, 8, 10, 2) | BIT_RANGE_RIGHT(v, 10, 12, 2) | + BIT_RANGE_LEFT(v, 12, 13, 3) | BIT_RANGE_RIGHT(v, 13, 16, 1); + } +} + +#define ROT(x,b) (((x) >> ((b) * 4)) | ((x) << ((4-(b)) * 4))) + +static void MixColumns(AES_state* s, int inv) { + /* The MixColumns transform treats the bytes of the columns of the state as + * coefficients of a 3rd degree polynomial over GF(2^8) and multiplies them + * by the fixed polynomial a(x) = {03}x^3 + {01}x^2 + {01}x + {02}, modulo + * x^4 + {01}. + * + * In the inverse transform, we multiply by the inverse of a(x), + * a^-1(x) = {0b}x^3 + {0d}x^2 + {09}x + {0e}. This is equal to + * a(x) * ({04}x^2 + {05}), so we can reuse the forward transform's code + * (found in OpenSSL's bsaes-x86_64.pl, attributed to Jussi Kivilinna) + * + * In the bitsliced representation, a multiplication of every column by x + * mod x^4 + 1 is simply a right rotation. + */ + + /* Shared for both directions is a multiplication by a(x), which can be + * rewritten as (x^3 + x^2 + x) + {02}*(x^3 + {01}). + * + * First compute s into the s? variables, (x^3 + {01}) * s into the s?_01 + * variables and (x^3 + x^2 + x)*s into the s?_123 variables. + */ + uint16_t s0 = s->slice[0], s1 = s->slice[1], s2 = s->slice[2], s3 = s->slice[3]; + uint16_t s4 = s->slice[4], s5 = s->slice[5], s6 = s->slice[6], s7 = s->slice[7]; + uint16_t s0_01 = s0 ^ ROT(s0, 1), s0_123 = ROT(s0_01, 1) ^ ROT(s0, 3); + uint16_t s1_01 = s1 ^ ROT(s1, 1), s1_123 = ROT(s1_01, 1) ^ ROT(s1, 3); + uint16_t s2_01 = s2 ^ ROT(s2, 1), s2_123 = ROT(s2_01, 1) ^ ROT(s2, 3); + uint16_t s3_01 = s3 ^ ROT(s3, 1), s3_123 = ROT(s3_01, 1) ^ ROT(s3, 3); + uint16_t s4_01 = s4 ^ ROT(s4, 1), s4_123 = ROT(s4_01, 1) ^ ROT(s4, 3); + uint16_t s5_01 = s5 ^ ROT(s5, 1), s5_123 = ROT(s5_01, 1) ^ ROT(s5, 3); + uint16_t s6_01 = s6 ^ ROT(s6, 1), s6_123 = ROT(s6_01, 1) ^ ROT(s6, 3); + uint16_t s7_01 = s7 ^ ROT(s7, 1), s7_123 = ROT(s7_01, 1) ^ ROT(s7, 3); + /* Now compute s = s?_123 + {02} * s?_01. */ + s->slice[0] = s7_01 ^ s0_123; + s->slice[1] = s7_01 ^ s0_01 ^ s1_123; + s->slice[2] = s1_01 ^ s2_123; + s->slice[3] = s7_01 ^ s2_01 ^ s3_123; + s->slice[4] = s7_01 ^ s3_01 ^ s4_123; + s->slice[5] = s4_01 ^ s5_123; + s->slice[6] = s5_01 ^ s6_123; + s->slice[7] = s6_01 ^ s7_123; + if (inv) { + /* In the reverse direction, we further need to multiply by + * {04}x^2 + {05}, which can be written as {04} * (x^2 + {01}) + {01}. + * + * First compute (x^2 + {01}) * s into the t?_02 variables: */ + uint16_t t0_02 = s->slice[0] ^ ROT(s->slice[0], 2); + uint16_t t1_02 = s->slice[1] ^ ROT(s->slice[1], 2); + uint16_t t2_02 = s->slice[2] ^ ROT(s->slice[2], 2); + uint16_t t3_02 = s->slice[3] ^ ROT(s->slice[3], 2); + uint16_t t4_02 = s->slice[4] ^ ROT(s->slice[4], 2); + uint16_t t5_02 = s->slice[5] ^ ROT(s->slice[5], 2); + uint16_t t6_02 = s->slice[6] ^ ROT(s->slice[6], 2); + uint16_t t7_02 = s->slice[7] ^ ROT(s->slice[7], 2); + /* And then update s += {04} * t?_02 */ + s->slice[0] ^= t6_02; + s->slice[1] ^= t6_02 ^ t7_02; + s->slice[2] ^= t0_02 ^ t7_02; + s->slice[3] ^= t1_02 ^ t6_02; + s->slice[4] ^= t2_02 ^ t6_02 ^ t7_02; + s->slice[5] ^= t3_02 ^ t7_02; + s->slice[6] ^= t4_02; + s->slice[7] ^= t5_02; + } +} + +static void AddRoundKey(AES_state* s, const AES_state* round) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] ^= round->slice[b]; + } +} + +/** column_0(s) = column_c(a) */ +static void GetOneColumn(AES_state* s, const AES_state* a, int c) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] = (a->slice[b] >> c) & 0x1111; + } +} + +/** column_c1(r) |= (column_0(s) ^= column_c2(a)) */ +static void KeySetupColumnMix(AES_state* s, AES_state* r, const AES_state* a, int c1, int c2) { + int b; + for (b = 0; b < 8; b++) { + r->slice[b] |= ((s->slice[b] ^= ((a->slice[b] >> c2) & 0x1111)) & 0x1111) << c1; + } +} + +/** Rotate the rows in s one position upwards, and xor in r */ +static void KeySetupTransform(AES_state* s, const AES_state* r) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] = ((s->slice[b] >> 4) | (s->slice[b] << 12)) ^ r->slice[b]; + } +} + +/* Multiply the cells in s by x, as polynomials over GF(2) mod x^8 + x^4 + x^3 + x + 1 */ +static void MultX(AES_state* s) { + uint16_t top = s->slice[7]; + s->slice[7] = s->slice[6]; + s->slice[6] = s->slice[5]; + s->slice[5] = s->slice[4]; + s->slice[4] = s->slice[3] ^ top; + s->slice[3] = s->slice[2] ^ top; + s->slice[2] = s->slice[1]; + s->slice[1] = s->slice[0] ^ top; + s->slice[0] = top; +} + +/** Expand the cipher key into the key schedule. + * + * state must be a pointer to an array of size nrounds + 1. + * key must be a pointer to 4 * nkeywords bytes. + * + * AES128 uses nkeywords = 4, nrounds = 10 + * AES192 uses nkeywords = 6, nrounds = 12 + * AES256 uses nkeywords = 8, nrounds = 14 + */ +static void AES_setup(AES_state* rounds, const uint8_t* key, int nkeywords, int nrounds) +{ + int i; + + /* The one-byte round constant */ + AES_state rcon = {{1,0,0,0,0,0,0,0}}; + /* The number of the word being generated, modulo nkeywords */ + int pos = 0; + /* The column representing the word currently being processed */ + AES_state column; + + for (i = 0; i < nrounds + 1; i++) { + int b; + for (b = 0; b < 8; b++) { + rounds[i].slice[b] = 0; + } + } + + /* The first nkeywords round columns are just taken from the key directly. */ + for (i = 0; i < nkeywords; i++) { + int r; + for (r = 0; r < 4; r++) { + LoadByte(&rounds[i >> 2], *(key++), r, i & 3); + } + } + + GetOneColumn(&column, &rounds[(nkeywords - 1) >> 2], (nkeywords - 1) & 3); + + for (i = nkeywords; i < 4 * (nrounds + 1); i++) { + /* Transform column */ + if (pos == 0) { + SubBytes(&column, 0); + KeySetupTransform(&column, &rcon); + MultX(&rcon); + } else if (nkeywords > 6 && pos == 4) { + SubBytes(&column, 0); + } + if (++pos == nkeywords) pos = 0; + KeySetupColumnMix(&column, &rounds[i >> 2], &rounds[(i - nkeywords) >> 2], i & 3, (i - nkeywords) & 3); + } +} + +static void AES_encrypt(const AES_state* rounds, int nrounds, unsigned char* cipher16, const unsigned char* plain16) { + AES_state s = {{0}}; + int round; + + LoadBytes(&s, plain16); + AddRoundKey(&s, rounds++); + + for (round = 1; round < nrounds; round++) { + SubBytes(&s, 0); + ShiftRows(&s); + MixColumns(&s, 0); + AddRoundKey(&s, rounds++); + } + + SubBytes(&s, 0); + ShiftRows(&s); + AddRoundKey(&s, rounds); + + SaveBytes(cipher16, &s); +} + +static void AES_decrypt(const AES_state* rounds, int nrounds, unsigned char* plain16, const unsigned char* cipher16) { + /* Most AES decryption implementations use the alternate scheme + * (the Equivalent Inverse Cipher), which allows for more code reuse between + * the encryption and decryption code, but requires separate setup for both. + */ + AES_state s = {{0}}; + int round; + + rounds += nrounds; + + LoadBytes(&s, cipher16); + AddRoundKey(&s, rounds--); + + for (round = 1; round < nrounds; round++) { + InvShiftRows(&s); + SubBytes(&s, 1); + AddRoundKey(&s, rounds--); + MixColumns(&s, 1); + } + + InvShiftRows(&s); + SubBytes(&s, 1); + AddRoundKey(&s, rounds); + + SaveBytes(plain16, &s); +} + +void AES128_init(AES128_ctx* ctx, const unsigned char* key16) { + AES_setup(ctx->rk, key16, 4, 10); +} + +void AES128_encrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 10, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES128_decrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 10, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES192_init(AES192_ctx* ctx, const unsigned char* key24) { + AES_setup(ctx->rk, key24, 6, 12); +} + +void AES192_encrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 12, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } + +} + +void AES192_decrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 12, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES256_init(AES256_ctx* ctx, const unsigned char* key32) { + AES_setup(ctx->rk, key32, 8, 14); +} + +void AES256_encrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 14, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES256_decrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 14, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} diff --git a/src/crypto/ctaes/ctaes.h b/src/crypto/ctaes/ctaes.h new file mode 100644 index 000000000..eb9d24176 --- /dev/null +++ b/src/crypto/ctaes/ctaes.h @@ -0,0 +1,41 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or https://www.opensource.org/licenses/mit-license.php* + **********************************************************************/ + +#ifndef _CTAES_H_ +#define _CTAES_H_ 1 + +#include +#include + +typedef struct { + uint16_t slice[8]; +} AES_state; + +typedef struct { + AES_state rk[11]; +} AES128_ctx; + +typedef struct { + AES_state rk[13]; +} AES192_ctx; + +typedef struct { + AES_state rk[15]; +} AES256_ctx; + +void AES128_init(AES128_ctx* ctx, const unsigned char* key16); +void AES128_encrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES128_decrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +void AES192_init(AES192_ctx* ctx, const unsigned char* key24); +void AES192_encrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES192_decrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +void AES256_init(AES256_ctx* ctx, const unsigned char* key32); +void AES256_encrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES256_decrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +#endif diff --git a/src/crypto/ctaes/test.c b/src/crypto/ctaes/test.c new file mode 100644 index 000000000..f13d02685 --- /dev/null +++ b/src/crypto/ctaes/test.c @@ -0,0 +1,110 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or https://www.opensource.org/licenses/mit-license.php* + **********************************************************************/ + +#include "ctaes.h" + +#include +#include +#include + +typedef struct { + int keysize; + const char* key; + const char* plain; + const char* cipher; +} ctaes_test; + +static const ctaes_test ctaes_tests[] = { + /* AES test vectors from FIPS 197. */ + {128, "000102030405060708090a0b0c0d0e0f", "00112233445566778899aabbccddeeff", "69c4e0d86a7b0430d8cdb78070b4c55a"}, + {192, "000102030405060708090a0b0c0d0e0f1011121314151617", "00112233445566778899aabbccddeeff", "dda97ca4864cdfe06eaf70a0ec0d7191"}, + {256, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "00112233445566778899aabbccddeeff", "8ea2b7ca516745bfeafc49904b496089"}, + + /* AES-ECB test vectors from NIST sp800-38a. */ + {128, "2b7e151628aed2a6abf7158809cf4f3c", "6bc1bee22e409f96e93d7e117393172a", "3ad77bb40d7a3660a89ecaf32466ef97"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "ae2d8a571e03ac9c9eb76fac45af8e51", "f5d3d58503b9699de785895a96fdbaaf"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "30c81c46a35ce411e5fbc1191a0a52ef", "43b1cd7f598ece23881b00e3ed030688"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "f69f2445df4f9b17ad2b417be66c3710", "7b0c785e27e8ad3f8223207104725dd4"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "6bc1bee22e409f96e93d7e117393172a", "bd334f1d6e45f25ff712a214571fa5cc"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "ae2d8a571e03ac9c9eb76fac45af8e51", "974104846d0ad3ad7734ecb3ecee4eef"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "30c81c46a35ce411e5fbc1191a0a52ef", "ef7afd2270e2e60adce0ba2face6444e"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "f69f2445df4f9b17ad2b417be66c3710", "9a4b41ba738d6c72fb16691603c18e0e"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "6bc1bee22e409f96e93d7e117393172a", "f3eed1bdb5d2a03c064b5a7e3db181f8"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "ae2d8a571e03ac9c9eb76fac45af8e51", "591ccb10d410ed26dc5ba74a31362870"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "30c81c46a35ce411e5fbc1191a0a52ef", "b6ed21b99ca6f4f9f153e7b1beafed1d"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "f69f2445df4f9b17ad2b417be66c3710", "23304b7a39f9f3ff067d8d8f9e24ecc7"} +}; + +static void from_hex(unsigned char* data, int len, const char* hex) { + int p; + for (p = 0; p < len; p++) { + int v = 0; + int n; + for (n = 0; n < 2; n++) { + assert((*hex >= '0' && *hex <= '9') || (*hex >= 'a' && *hex <= 'f')); + if (*hex >= '0' && *hex <= '9') { + v |= (*hex - '0') << (4 * (1 - n)); + } else { + v |= (*hex - 'a' + 10) << (4 * (1 - n)); + } + hex++; + } + *(data++) = v; + } + assert(*hex == 0); +} + +int main(void) { + int i; + int fail = 0; + for (i = 0; i < sizeof(ctaes_tests) / sizeof(ctaes_tests[0]); i++) { + unsigned char key[32], plain[16], cipher[16], ciphered[16], deciphered[16]; + const ctaes_test* test = &ctaes_tests[i]; + assert(test->keysize == 128 || test->keysize == 192 || test->keysize == 256); + from_hex(plain, 16, test->plain); + from_hex(cipher, 16, test->cipher); + switch (test->keysize) { + case 128: { + AES128_ctx ctx; + from_hex(key, 16, test->key); + AES128_init(&ctx, key); + AES128_encrypt(&ctx, 1, ciphered, plain); + AES128_decrypt(&ctx, 1, deciphered, cipher); + break; + } + case 192: { + AES192_ctx ctx; + from_hex(key, 24, test->key); + AES192_init(&ctx, key); + AES192_encrypt(&ctx, 1, ciphered, plain); + AES192_decrypt(&ctx, 1, deciphered, cipher); + break; + } + case 256: { + AES256_ctx ctx; + from_hex(key, 32, test->key); + AES256_init(&ctx, key); + AES256_encrypt(&ctx, 1, ciphered, plain); + AES256_decrypt(&ctx, 1, deciphered, cipher); + break; + } + } + if (memcmp(cipher, ciphered, 16)) { + fprintf(stderr, "E(key=\"%s\", plain=\"%s\") != \"%s\"\n", test->key, test->plain, test->cipher); + fail++; + } + if (memcmp(plain, deciphered, 16)) { + fprintf(stderr, "D(key=\"%s\", cipher=\"%s\") != \"%s\"\n", test->key, test->cipher, test->plain); + fail++; + } + } + if (fail == 0) { + fprintf(stderr, "All tests successful\n"); + } else { + fprintf(stderr, "%i tests failed\n", fail); + } + return (fail != 0); +} diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp index 9a16fc085..aef2effa4 100644 --- a/src/crypto/equihash.cpp +++ b/src/crypto/equihash.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 Jack Grigg // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // Implementation of the Equihash Proof-of-Work algorithm. // diff --git a/src/crypto/equihash.h b/src/crypto/equihash.h index 57c434dae..3d04cc3f5 100644 --- a/src/crypto/equihash.h +++ b/src/crypto/equihash.h @@ -1,7 +1,7 @@ // Copyright (c) 2016 Jack Grigg // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_EQUIHASH_H #define BITCOIN_EQUIHASH_H @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/src/crypto/equihash.tcc b/src/crypto/equihash.tcc index 625749e47..a5fcbc4cc 100644 --- a/src/crypto/equihash.tcc +++ b/src/crypto/equihash.tcc @@ -1,7 +1,7 @@ // Copyright (c) 2016 Jack Grigg // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/crypto/hmac_sha256.cpp b/src/crypto/hmac_sha256.cpp index 3c791625d..6ce7721de 100644 --- a/src/crypto/hmac_sha256.cpp +++ b/src/crypto/hmac_sha256.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/hmac_sha256.h" diff --git a/src/crypto/hmac_sha256.h b/src/crypto/hmac_sha256.h index 1519c1457..502b72326 100644 --- a/src/crypto/hmac_sha256.h +++ b/src/crypto/hmac_sha256.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_HMAC_SHA256_H #define BITCOIN_CRYPTO_HMAC_SHA256_H diff --git a/src/crypto/hmac_sha512.cpp b/src/crypto/hmac_sha512.cpp index 5939c6ec4..c34dd1925 100644 --- a/src/crypto/hmac_sha512.cpp +++ b/src/crypto/hmac_sha512.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/hmac_sha512.h" diff --git a/src/crypto/hmac_sha512.h b/src/crypto/hmac_sha512.h index 17dee61ea..d53dcf1a2 100644 --- a/src/crypto/hmac_sha512.h +++ b/src/crypto/hmac_sha512.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_HMAC_SHA512_H #define BITCOIN_CRYPTO_HMAC_SHA512_H diff --git a/src/crypto/ripemd160.cpp b/src/crypto/ripemd160.cpp index 77c9acfc2..4b2574bc8 100644 --- a/src/crypto/ripemd160.cpp +++ b/src/crypto/ripemd160.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/ripemd160.h" diff --git a/src/crypto/ripemd160.h b/src/crypto/ripemd160.h index 687204fda..eafa7f131 100644 --- a/src/crypto/ripemd160.h +++ b/src/crypto/ripemd160.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_RIPEMD160_H #define BITCOIN_CRYPTO_RIPEMD160_H diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp index 0b895b33a..402bcfb1c 100644 --- a/src/crypto/sha1.cpp +++ b/src/crypto/sha1.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/sha1.h" diff --git a/src/crypto/sha1.h b/src/crypto/sha1.h index 7b2a21bc6..ed4c98146 100644 --- a/src/crypto/sha1.h +++ b/src/crypto/sha1.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_SHA1_H #define BITCOIN_CRYPTO_SHA1_H diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp index 0718d2d25..82c7fb579 100644 --- a/src/crypto/sha256.cpp +++ b/src/crypto/sha256.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/sha256.h" #include "crypto/common.h" diff --git a/src/crypto/sha256.h b/src/crypto/sha256.h index 24c9c666d..6d9ca1335 100644 --- a/src/crypto/sha256.h +++ b/src/crypto/sha256.h @@ -1,6 +1,6 @@ // Copyright (c) 2014-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_SHA256_H #define BITCOIN_CRYPTO_SHA256_H diff --git a/src/crypto/sha256_sse4.cpp b/src/crypto/sha256_sse4.cpp index 89f529a3a..a4eafef86 100644 --- a/src/crypto/sha256_sse4.cpp +++ b/src/crypto/sha256_sse4.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // This is a translation to GCC extended asm syntax from YASM code by Intel // (available at the bottom of this file). diff --git a/src/crypto/sha512.cpp b/src/crypto/sha512.cpp index 564127cc3..1e0de1317 100644 --- a/src/crypto/sha512.cpp +++ b/src/crypto/sha512.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/sha512.h" diff --git a/src/crypto/sha512.h b/src/crypto/sha512.h index f1f17caf9..a04e27f84 100644 --- a/src/crypto/sha512.h +++ b/src/crypto/sha512.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_SHA512_H #define BITCOIN_CRYPTO_SHA512_H diff --git a/src/cryptoconditions/Makefile.am b/src/cryptoconditions/Makefile.am index 787b11ac6..615ac5783 100644 --- a/src/cryptoconditions/Makefile.am +++ b/src/cryptoconditions/Makefile.am @@ -15,7 +15,7 @@ AM_CFLAGS = -I$(top_srcdir)/src/asn -I$(top_srcdir)/include -I$(top_srcdir)/src/ LIBSECP256K1=src/include/secp256k1/libsecp256k1.la $(LIBSECP256K1): $(wildcard src/secp256k1/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) -march:x86-64 -g + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) -g CRYPTOCONDITIONS_CORE=libcryptoconditions_core.la diff --git a/src/cryptoconditions/src/asn/OCTET_STRING.c b/src/cryptoconditions/src/asn/OCTET_STRING.c index 5420dedec..a886ff8fa 100644 --- a/src/cryptoconditions/src/asn/OCTET_STRING.c +++ b/src/cryptoconditions/src/asn/OCTET_STRING.c @@ -1714,7 +1714,9 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { OCTET_STRING_t *st = (OCTET_STRING_t *)sptr; asn_OCTET_STRING_specifics_t *specs; asn_struct_ctx_t *ctx; +#if !defined(__aarch64__) struct _stack *stck; +#endif if(!td || !st) return; @@ -1731,6 +1733,15 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { st->buf = 0; } +/* Attention !!! + * this is quick & dirty workaround for memory corruption bug on aarch64-linux-gnu + * - downside: allows memory leakage + * - issue description: On Raspberry Pi 4 @ 64bit linux, daemon crashes with "free(): invalid pointer" error + * - probable cause: misaligned memory access to nested structs containing pointers + * - TODO: use the latest asn1c compiler on CryptoConditions.asn, maybe generate cpp instead of c code... investigation in progress + */ + +#if !defined(__aarch64__) /* * Remove decode-time stack. */ @@ -1747,6 +1758,7 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { if(!contents_only) { FREEMEM(st); } +#endif } /* diff --git a/src/cryptoconditions/src/include/secp256k1/Makefile.am b/src/cryptoconditions/src/include/secp256k1/Makefile.am index 52303e4e4..13c83fe18 100644 --- a/src/cryptoconditions/src/include/secp256k1/Makefile.am +++ b/src/cryptoconditions/src/include/secp256k1/Makefile.am @@ -71,7 +71,7 @@ endif endif libsecp256k1_la_SOURCES = src/secp256k1.c -libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) -march=x86-64 -g +libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) -g libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS) $(COMMON_LIB) libsecp256k1_jni_la_SOURCES = src/java/org_bitcoin_NativeSecp256k1.c src/java/org_bitcoin_Secp256k1Context.c diff --git a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.c b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.c index 5b141a994..74acf8c4f 100644 --- a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.c +++ b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.h b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.h index 7eaf63bf6..9c5a51fbb 100644 --- a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.h +++ b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /**** diff --git a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.c b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.c index c2e63b4b8..3fadba3f4 100644 --- a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.c +++ b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014, 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.h b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.h index fece261fb..d5c2e7487 100644 --- a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.h +++ b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014, 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /**** diff --git a/src/cryptoconditions/src/include/secp256k1/src/asm/field_10x26_arm.s b/src/cryptoconditions/src/include/secp256k1/src/asm/field_10x26_arm.s index 5a9cc3ffc..e2029eb0c 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/asm/field_10x26_arm.s +++ b/src/cryptoconditions/src/include/secp256k1/src/asm/field_10x26_arm.s @@ -2,7 +2,7 @@ /********************************************************************** * Copyright (c) 2014 Wladimir J. van der Laan * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /* ARM implementation of field_10x26 inner loops. diff --git a/src/cryptoconditions/src/include/secp256k1/src/basic-config.h b/src/cryptoconditions/src/include/secp256k1/src/basic-config.h index fc588061c..a9adbda17 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/basic-config.h +++ b/src/cryptoconditions/src/include/secp256k1/src/basic-config.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_BASIC_CONFIG_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench.h b/src/cryptoconditions/src/include/secp256k1/src/bench.h index d5ebe0130..c8d038ff3 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench.h +++ b/src/cryptoconditions/src/include/secp256k1/src/bench.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_BENCH_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_ecdh.c b/src/cryptoconditions/src/include/secp256k1/src/bench_ecdh.c index 2de5126d6..95c44bb4a 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_ecdh.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_ecdh.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_internal.c b/src/cryptoconditions/src/include/secp256k1/src/bench_internal.c index 9b30c50d0..cae5f5d7e 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_internal.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_internal.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_recover.c b/src/cryptoconditions/src/include/secp256k1/src/bench_recover.c index 506fc1880..0288c1c79 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_recover.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_recover.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_sign.c b/src/cryptoconditions/src/include/secp256k1/src/bench_sign.c index 544b43963..266df9c79 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_sign.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_sign.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_verify.c b/src/cryptoconditions/src/include/secp256k1/src/bench_verify.c index 418defa0a..3f154ea17 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_verify.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_verify.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecdsa.h b/src/cryptoconditions/src/include/secp256k1/src/ecdsa.h index 80590c7cc..fea457c20 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecdsa.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecdsa.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECDSA_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecdsa_impl.h b/src/cryptoconditions/src/include/secp256k1/src/ecdsa_impl.h index c3400042d..a86fb9a44 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecdsa_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecdsa_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ diff --git a/src/cryptoconditions/src/include/secp256k1/src/eckey.h b/src/cryptoconditions/src/include/secp256k1/src/eckey.h index b621f1e6c..913f1215c 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/eckey.h +++ b/src/cryptoconditions/src/include/secp256k1/src/eckey.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECKEY_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/eckey_impl.h b/src/cryptoconditions/src/include/secp256k1/src/eckey_impl.h index 1ab9a68ec..0fccaffc6 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/eckey_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/eckey_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECKEY_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult.h index 6d44aba60..28b1b14b7 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h index 5a36ba40b..a3ab99007 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_H @@ -21,7 +21,7 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const_impl.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const_impl.h index 7d7a172b7..395ed9f00 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen.h index 7564b7015..486feb13e 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_GEN_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen_impl.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen_impl.h index 714f02e94..a316e1c2a 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_GEN_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_impl.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_impl.h index 93d3794cb..17b8541db 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field.h b/src/cryptoconditions/src/include/secp256k1/src/field.h index bb6692ad5..30b6e50f0 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_10x26.h b/src/cryptoconditions/src/include/secp256k1/src/field_10x26.h index 727c5267f..c93cd4c86 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_10x26.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_10x26.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_10x26_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_10x26_impl.h index 94f8132fc..29799b418 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_10x26_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_10x26_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_5x52.h b/src/cryptoconditions/src/include/secp256k1/src/field_5x52.h index bccd8feb4..e9446b859 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_5x52.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_5x52.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_asm_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_asm_impl.h index 1fc3171f6..759101d0e 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_asm_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_asm_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2014 Diederik Huys, Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /** diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_impl.h index 957c61b01..f5dc9dc9d 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_int128_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_int128_impl.h index 95a0d1791..a26fb3c16 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_int128_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_int128_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_INNER5X52_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_impl.h index 20428648a..34827651c 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/gen_context.c b/src/cryptoconditions/src/include/secp256k1/src/gen_context.c index 1835fd491..5cd725509 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/gen_context.c +++ b/src/cryptoconditions/src/include/secp256k1/src/gen_context.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Thomas Daede, Cory Fields * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #define USE_BASIC_CONFIG 1 diff --git a/src/cryptoconditions/src/include/secp256k1/src/group.h b/src/cryptoconditions/src/include/secp256k1/src/group.h index ea1302deb..3b8a24883 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/group.h +++ b/src/cryptoconditions/src/include/secp256k1/src/group.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_GROUP_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/group_impl.h b/src/cryptoconditions/src/include/secp256k1/src/group_impl.h index b31b6c12e..de6307c42 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/group_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/group_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_GROUP_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/hash.h b/src/cryptoconditions/src/include/secp256k1/src/hash.h index de26e4b89..991b38699 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/hash.h +++ b/src/cryptoconditions/src/include/secp256k1/src/hash.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_HASH_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/hash_impl.h b/src/cryptoconditions/src/include/secp256k1/src/hash_impl.h index c06db9e33..1f6dcc317 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/hash_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/hash_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_HASH_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/main_impl.h b/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/main_impl.h index bd8739eeb..e80ed4af3 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/main_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_ECDH_MAIN_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/tests_impl.h b/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/tests_impl.h index 0c53f8ee0..99c400365 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/tests_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_ECDH_TESTS_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/main_impl.h b/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/main_impl.h index 2f6691c5a..a63903ccb 100755 --- a/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/main_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_RECOVERY_MAIN_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/tests_impl.h b/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/tests_impl.h index 5c9bbe861..de2b0cab3 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/tests_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_RECOVERY_TESTS_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/num.h b/src/cryptoconditions/src/include/secp256k1/src/num.h index 49f2dd791..48cc43488 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/num.h +++ b/src/cryptoconditions/src/include/secp256k1/src/num.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/num_gmp.h b/src/cryptoconditions/src/include/secp256k1/src/num_gmp.h index 3619844bd..7c2f3387b 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/num_gmp.h +++ b/src/cryptoconditions/src/include/secp256k1/src/num_gmp.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/num_gmp_impl.h b/src/cryptoconditions/src/include/secp256k1/src/num_gmp_impl.h index 0ae2a8ba0..a18ecb969 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/num_gmp_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/num_gmp_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/num_impl.h b/src/cryptoconditions/src/include/secp256k1/src/num_impl.h index c45193b03..1ed66335b 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/num_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/num_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar.h b/src/cryptoconditions/src/include/secp256k1/src/scalar.h index 59304cb66..0b2393ff5 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64.h index 19c7495d1..3fc3f8fae 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64_impl.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64_impl.h index db1ebf94b..2a2a21f45 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32.h index 2c9a348e2..799c4806e 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32_impl.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32_impl.h index 4f9ed61fe..9e15725d2 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_impl.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_impl.h index fa790570f..2a98abf40 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_low.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_low.h index 5836febc5..016b4642b 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_low.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_low.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_low_impl.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_low_impl.h index c80e70c5a..7801a4a98 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_low_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_low_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/secp256k1.c b/src/cryptoconditions/src/include/secp256k1/src/secp256k1.c index cecb1550b..d0a7c0c4f 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/secp256k1.c +++ b/src/cryptoconditions/src/include/secp256k1/src/secp256k1.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/cryptoconditions/src/include/secp256k1/src/testrand.h b/src/cryptoconditions/src/include/secp256k1/src/testrand.h index f1f9be077..7b1acd16a 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/testrand.h +++ b/src/cryptoconditions/src/include/secp256k1/src/testrand.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_TESTRAND_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/testrand_impl.h b/src/cryptoconditions/src/include/secp256k1/src/testrand_impl.h index 30a91e529..bcdbd149c 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/testrand_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/testrand_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_TESTRAND_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/tests.c b/src/cryptoconditions/src/include/secp256k1/src/tests.c index f307b99d5..890e6c977 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/tests.c +++ b/src/cryptoconditions/src/include/secp256k1/src/tests.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #if defined HAVE_CONFIG_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/tests_exhaustive.c b/src/cryptoconditions/src/include/secp256k1/src/tests_exhaustive.c index b040bb073..4e439bac4 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/tests_exhaustive.c +++ b/src/cryptoconditions/src/include/secp256k1/src/tests_exhaustive.c @@ -1,7 +1,7 @@ /*********************************************************************** * Copyright (c) 2016 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #if defined HAVE_CONFIG_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/util.h b/src/cryptoconditions/src/include/secp256k1/src/util.h index b0441d8e3..617d5701d 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/util.h +++ b/src/cryptoconditions/src/include/secp256k1/src/util.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_UTIL_H diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index 47bbb0f05..7b7529a1f 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "dbwrapper.h" diff --git a/src/dbwrapper.h b/src/dbwrapper.h index a43383a0a..d967974cf 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -1,7 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_DBWRAPPER_H #define BITCOIN_DBWRAPPER_H diff --git a/src/deprecation.cpp b/src/deprecation.cpp index b32f24880..5ca2c0afa 100644 --- a/src/deprecation.cpp +++ b/src/deprecation.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/deprecation.h b/src/deprecation.h index eae3c92b9..e0d6d6cc3 100644 --- a/src/deprecation.h +++ b/src/deprecation.h @@ -1,7 +1,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/gtest/test_foundersreward.cpp b/src/gtest/test_foundersreward.cpp deleted file mode 100644 index 7e5a3cf05..000000000 --- a/src/gtest/test_foundersreward.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include - -#include "main.h" -#include "utilmoneystr.h" -#include "chainparams.h" -#include "utilstrencodings.h" -#include "zcash/Address.hpp" -#include "wallet/wallet.h" -#include "amount.h" -#include -#include -#include -#include -#include -#include "util.h" - -#ifndef disable_founders -// To run tests: -// ./zcash-gtest --gtest_filter="founders_reward_test.*" - -// -// Enable this test to generate and print 48 testnet 2-of-3 multisig addresses. -// The output can be copied into chainparams.cpp. -// The temporary wallet file can be renamed as wallet.dat and used for testing with zcashd. -// -#if 0 -TEST(founders_reward_test, create_testnet_2of3multisig) { - SelectParams(CBaseChainParams::TESTNET); - boost::filesystem::path pathTemp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); - boost::filesystem::create_directories(pathTemp); - mapArgs["-datadir"] = pathTemp.string(); - bool fFirstRun; - auto pWallet = std::make_shared("wallet.dat"); - ASSERT_EQ(DB_LOAD_OK, pWallet->LoadWallet(fFirstRun)); - pWallet->TopUpKeyPool(); - std::cout << "Test wallet and logs saved in folder: " << pathTemp.native() << std::endl; - - int numKeys = 48; - std::vector pubkeys; - pubkeys.resize(3); - CPubKey newKey; - std::vector addresses; - for (int i = 0; i < numKeys; i++) { - ASSERT_TRUE(pWallet->GetKeyFromPool(newKey)); - pubkeys[0] = newKey; - pWallet->SetAddressBook(newKey.GetID(), "", "receive"); - - ASSERT_TRUE(pWallet->GetKeyFromPool(newKey)); - pubkeys[1] = newKey; - pWallet->SetAddressBook(newKey.GetID(), "", "receive"); - - ASSERT_TRUE(pWallet->GetKeyFromPool(newKey)); - pubkeys[2] = newKey; - pWallet->SetAddressBook(newKey.GetID(), "", "receive"); - - CScript result = GetScriptForMultisig(2, pubkeys); - ASSERT_FALSE(result.size() > MAX_SCRIPT_ELEMENT_SIZE); - CScriptID innerID(result); - pWallet->AddCScript(result); - pWallet->SetAddressBook(innerID, "", "receive"); - - std::string address = EncodeDestination(innerID); - addresses.push_back(address); - } - - // Print out the addresses, 4 on each line. - std::string s = "vFoundersRewardAddress = {\n"; - int i=0; - int colsPerRow = 4; - ASSERT_TRUE(numKeys % colsPerRow == 0); - int numRows = numKeys/colsPerRow; - for (int row=0; rowFlush(true); -} -#endif - - -// Utility method to check the number of unique addresses from height 1 to maxHeight -void checkNumberOfUniqueAddresses(int nUnique) { - int maxHeight = Params().GetConsensus().GetLastFoundersRewardBlockHeight(); - std::set addresses; - for (int i = 1; i <= maxHeight; i++) { - addresses.insert(Params().GetFoundersRewardAddressAtHeight(i)); - } - ASSERT_TRUE(addresses.size() == nUnique); -} - - -TEST(founders_reward_test, general) { - SelectParams(CBaseChainParams::TESTNET); - - CChainParams params = Params(); - - // Fourth testnet reward: - // address = t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy - // script.ToString() = OP_HASH160 55d64928e69829d9376c776550b6cc710d427153 OP_EQUAL - // HexStr(script) = a91455d64928e69829d9376c776550b6cc710d42715387 - EXPECT_EQ(HexStr(params.GetFoundersRewardScriptAtHeight(1)), "a914ef775f1f997f122a062fff1a2d7443abd1f9c64287"); - EXPECT_EQ(params.GetFoundersRewardAddressAtHeight(1), "t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi"); - EXPECT_EQ(HexStr(params.GetFoundersRewardScriptAtHeight(53126)), "a914ac67f4c072668138d88a86ff21b27207b283212f87"); - EXPECT_EQ(params.GetFoundersRewardAddressAtHeight(53126), "t2NGQjYMQhFndDHguvUw4wZdNdsssA6K7x2"); - EXPECT_EQ(HexStr(params.GetFoundersRewardScriptAtHeight(53127)), "a91455d64928e69829d9376c776550b6cc710d42715387"); - EXPECT_EQ(params.GetFoundersRewardAddressAtHeight(53127), "t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy"); - - int maxHeight = params.GetConsensus().GetLastFoundersRewardBlockHeight(); - - // If the block height parameter is out of bounds, there is an assert. - EXPECT_DEATH(params.GetFoundersRewardScriptAtHeight(0), "nHeight"); - EXPECT_DEATH(params.GetFoundersRewardScriptAtHeight(maxHeight+1), "nHeight"); - EXPECT_DEATH(params.GetFoundersRewardAddressAtHeight(0), "nHeight"); - EXPECT_DEATH(params.GetFoundersRewardAddressAtHeight(maxHeight+1), "nHeight"); -} - - -#define NUM_MAINNET_FOUNDER_ADDRESSES 48 - -TEST(founders_reward_test, mainnet) { - SelectParams(CBaseChainParams::MAIN); - checkNumberOfUniqueAddresses(NUM_MAINNET_FOUNDER_ADDRESSES); -} - - -#define NUM_TESTNET_FOUNDER_ADDRESSES 48 - -TEST(founders_reward_test, testnet) { - SelectParams(CBaseChainParams::TESTNET); - checkNumberOfUniqueAddresses(NUM_TESTNET_FOUNDER_ADDRESSES); -} - - -#define NUM_REGTEST_FOUNDER_ADDRESSES 1 - -TEST(founders_reward_test, regtest) { - SelectParams(CBaseChainParams::REGTEST); - checkNumberOfUniqueAddresses(NUM_REGTEST_FOUNDER_ADDRESSES); -} - - - -// Test that 10% founders reward is fully rewarded after the first halving and slow start shift. -// On Mainnet, this would be 2,100,000 ZEC after 850,000 blocks (840,000 + 10,000). -TEST(founders_reward_test, slow_start_subsidy) { - SelectParams(CBaseChainParams::MAIN); - CChainParams params = Params(); - - int maxHeight = params.GetConsensus().GetLastFoundersRewardBlockHeight(); - CAmount totalSubsidy = 0; - for (int nHeight = 1; nHeight <= maxHeight; nHeight++) { - CAmount nSubsidy = GetBlockSubsidy(nHeight, params.GetConsensus()) / 5; - totalSubsidy += nSubsidy; - } - - ASSERT_TRUE(totalSubsidy == MAX_MONEY/10.0); -} - - -// For use with mainnet and testnet which each have 48 addresses. -// Verify the number of rewards each individual address receives. -void verifyNumberOfRewards() { - CChainParams params = Params(); - int maxHeight = params.GetConsensus().GetLastFoundersRewardBlockHeight(); - std::multiset ms; - for (int nHeight = 1; nHeight <= maxHeight; nHeight++) { - ms.insert(params.GetFoundersRewardAddressAtHeight(nHeight)); - } - - ASSERT_TRUE(ms.count(params.GetFoundersRewardAddressAtIndex(0)) == 17708); - for (int i = 1; i <= 46; i++) { - ASSERT_TRUE(ms.count(params.GetFoundersRewardAddressAtIndex(i)) == 17709); - } - ASSERT_TRUE(ms.count(params.GetFoundersRewardAddressAtIndex(47)) == 17677); -} - -// Verify the number of rewards going to each mainnet address -TEST(founders_reward_test, per_address_reward_mainnet) { - SelectParams(CBaseChainParams::MAIN); - verifyNumberOfRewards(); -} - -// Verify the number of rewards going to each testnet address -TEST(founders_reward_test, per_address_reward_testnet) { - SelectParams(CBaseChainParams::TESTNET); - verifyNumberOfRewards(); -} -#endif diff --git a/src/hash.cpp b/src/hash.cpp index 7471da8fb..5b528c417 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2013-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/hash.h b/src/hash.h index a062ea94c..a97fcac10 100644 --- a/src/hash.h +++ b/src/hash.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/httprpc.h b/src/httprpc.h index 6827a7063..13359c027 100644 --- a/src/httprpc.h +++ b/src/httprpc.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 603e1e6ae..407473ee3 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "httpserver.h" diff --git a/src/httpserver.h b/src/httpserver.h index f04a332ec..b8507a053 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_HTTPSERVER_H #define BITCOIN_HTTPSERVER_H diff --git a/src/hush-cli b/src/hush-cli index bf4511073..9cc47207a 100755 --- a/src/hush-cli +++ b/src/hush-cli @@ -1,5 +1,6 @@ #!/bin/bash -# Copyright (c) 2019 Hush developers +# Copyright (c) 2019-2020 Hush developers +# Released under the GPLv3 # set working directory to the location of this script # readlink -f does not always exist diff --git a/src/hush-tx b/src/hush-tx index 2152315ad..17f8bc6b8 100755 --- a/src/hush-tx +++ b/src/hush-tx @@ -1,5 +1,6 @@ #!/bin/bash -# Copyright (c) 2019 Hush developers +# Copyright (c) 2019-2020 Hush developers +# Released under the GPLv3 # set working directory to the location of this script DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/src/hushd b/src/hushd index b5b504ea4..ca3f28319 100755 --- a/src/hushd +++ b/src/hushd @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2019 Hush developers +# Copyright (c) 2019-2020 Hush developers # set working directory to the location of this script # readlink -f does not always exist @@ -8,31 +8,41 @@ cd $DIR DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )" cd $DIR +# Chain parameters NAME=HUSH3 + # this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac -# Chain parameters +# First Pure Sapling Zcash Protocol chain! +SAPLING=1 + +# We use 3 "eras" of different supply curves ERAS=3 -BLOCKTIME=150 -# 6250000 - (sprout pool at block 500,000) + +# 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 -REWARD=0,1125000000,562500000 -PERC=11111111 -HALVING=129,340000,840000 -# NOTE: keep in sync with komodo_bitcoind.h -END=128,340000,5422111 CLIENTNAME=GoldenSandtrout NODE1=188.165.212.101 # EU NODE2=64.120.113.130 # AR NODE3=209.58.144.205 # NA NODE4=94.130.35.94 # EU CCLIB=hush3 -# First Pure Sapling Zcash Protocol chain! -SAPLING=1 # 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 @@ -53,7 +63,6 @@ else fi fi - $KMD -ac_name=$NAME \ -ac_sapling=$SAPLING \ -ac_reward=$REWARD \ diff --git a/src/hushd-testnet b/src/hushd-testnet index c9da8c1ee..67d724fce 100755 --- a/src/hushd-testnet +++ b/src/hushd-testnet @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2019 Hush developers +# Copyright (c) 2019-2020 Hush developers # set working directory to the location of this script DIR="$( cd "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )" diff --git a/src/init.cpp b/src/init.cpp index c43c5b0b4..b401079d6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -84,10 +84,6 @@ #include "zmq/zmqnotificationinterface.h" #endif -#if ENABLE_PROTON -#include "amqp/amqpnotificationinterface.h" -#endif - #include "librustzcash.h" using namespace std; @@ -112,10 +108,6 @@ bool fFeeEstimatesInitialized = false; static CZMQNotificationInterface* pzmqNotificationInterface = NULL; #endif -#if ENABLE_PROTON -static AMQPNotificationInterface* pAMQPNotificationInterface = NULL; -#endif - #ifdef WIN32 // Win32 LevelDB doesn't use file descriptors, and the ones used for // accessing block files don't count towards the fd_set size limit @@ -285,14 +277,6 @@ void Shutdown() } #endif -#if ENABLE_PROTON - if (pAMQPNotificationInterface) { - UnregisterValidationInterface(pAMQPNotificationInterface); - delete pAMQPNotificationInterface; - pAMQPNotificationInterface = NULL; - } -#endif - #ifndef WIN32 try { boost::filesystem::remove(GetPidFile()); @@ -408,6 +392,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)")); #endif strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), 0)); + strUsage += HelpMessageOpt("-txsend=", _("Execute command to send a transaction instead of broadcasting (%s in cmd is replaced by transaction hex)")); strUsage += HelpMessageOpt("-addressindex", strprintf(_("Maintain a full address index, used to query for the balance, txids and unspent outputs for addresses (default: %u)"), DEFAULT_ADDRESSINDEX)); strUsage += HelpMessageOpt("-timestampindex", strprintf(_("Maintain a timestamp index for block hashes, used to query blocks hashes by a range of timestamps (default: %u)"), DEFAULT_TIMESTAMPINDEX)); strUsage += HelpMessageOpt("-spentindex", strprintf(_("Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX)); @@ -470,7 +455,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-maxtxfee=", strprintf(_("Maximum total fees (in %s) to use in a single wallet transaction; setting this too low may abort large transactions (default: %s)"), CURRENCY_UNIT, FormatMoney(maxTxFee))); strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format") + " " + _("on startup")); - strUsage += HelpMessageOpt("-wallet=", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), "wallet.dat")); + strUsage += HelpMessageOpt("-wallet=", _("Specify wallet file absolute path or a path relative to the data directory") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT)); strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), true)); strUsage += HelpMessageOpt("-walletnotify=", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)")); strUsage += HelpMessageOpt("-whitelistaddress=", _("Enable the wallet filter for notary nodes and add one Raddress to the whitelist of the wallet filter. If -whitelistaddress= is used, then the wallet filter is automatically activated. Several Raddresses can be defined using several -whitelistaddress= (similar to -addnode). The wallet filter will filter the utxo to only ones coming from my own Raddress (derived from pubkey) and each Raddress defined using -whitelistaddress= this option is mostly for Notary Nodes).")); @@ -486,14 +471,6 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-zmqpubrawtx=
", _("Enable publish raw transaction in
")); #endif -#if ENABLE_PROTON - strUsage += HelpMessageGroup(_("AMQP 1.0 notification options:")); - strUsage += HelpMessageOpt("-amqppubhashblock=
", _("Enable publish hash block in
")); - strUsage += HelpMessageOpt("-amqppubhashtx=
", _("Enable publish hash transaction in
")); - strUsage += HelpMessageOpt("-amqppubrawblock=
", _("Enable publish raw block in
")); - strUsage += HelpMessageOpt("-amqppubrawtx=
", _("Enable publish raw transaction in
")); -#endif - strUsage += HelpMessageGroup(_("Debugging/Testing options:")); if (showDebug) { @@ -1142,6 +1119,16 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) #endif } + if (mapArgs.count("-txsend")) { + if (GetBoolArg("-walletbroadcast", true)) { + if (SoftSetBoolArg("-walletbroadcast", false)) { + LogPrintf("%s: parameter interaction: -txsend= -> setting -walletbroadcast=0\n", __func__); + } else { + return InitError(_("Wallet transaction broadcasting is incompatible with -txsend (for privacy).")); + } + } + } + // ********************************************************* Step 3: parameter-to-internal-flags fZdebug=GetBoolArg("-zdebug", false); @@ -1624,21 +1611,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } #endif -#if ENABLE_PROTON - pAMQPNotificationInterface = AMQPNotificationInterface::CreateWithArguments(mapArgs); - - if (pAMQPNotificationInterface) { - - // AMQP support is currently an experimental feature, so fail if user configured AMQP notifications - // without enabling experimental features. - if (!fExperimentalMode) { - return InitError(_("AMQP support requires -experimentalfeatures.")); - } - - RegisterValidationInterface(pAMQPNotificationInterface); - } -#endif - if ( KOMODO_NSPV_SUPERLITE ) { std::vector vImportFiles; @@ -2078,7 +2050,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } #endif // ENABLE_MINING - // Start the thread that notifies listeners of transactions that have been + // Start the thread that notifies listeners of transactions that have been // recently added to the mempool, or have been added to or removed from the // chain. We perform this before step 10 (import blocks) so that the // original value of chainActive.Tip(), which corresponds with the wallet's diff --git a/src/init.h b/src/init.h index c68d59419..fcf188082 100644 --- a/src/init.h +++ b/src/init.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -23,8 +24,6 @@ #include -//#include "zcash/JoinSplit.hpp" - class CScheduler; class CWallet; @@ -34,7 +33,6 @@ class thread_group; } // namespace boost extern CWallet* pwalletMain; -//extern ZCJoinSplit* pzcashParams; void StartShutdown(); bool ShutdownRequested(); diff --git a/src/key.cpp b/src/key.cpp index 6e2370dc2..0f24f7fba 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2017 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/key.h b/src/key.h index 16492b151..a755dc15a 100644 --- a/src/key.h +++ b/src/key.h @@ -3,7 +3,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/key_io.cpp b/src/key_io.cpp index 2e0dfeb9a..185baf685 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2016-2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include diff --git a/src/key_io.h b/src/key_io.h index 567c9a2f2..6dc794920 100644 --- a/src/key_io.h +++ b/src/key_io.h @@ -3,7 +3,7 @@ // Copyright (c) 2016-2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_KEYIO_H #define BITCOIN_KEYIO_H diff --git a/src/keystore.cpp b/src/keystore.cpp index ca4fa3712..db0413ee0 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/keystore.h b/src/keystore.h index 6f34d9bc4..a6b078290 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/komodo-tx.cpp b/src/komodo-tx.cpp index 7e0477eb7..8b2e4a61d 100644 --- a/src/komodo-tx.cpp +++ b/src/komodo-tx.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/komodo.h b/src/komodo.h index 9816eb20b..1cfbd283b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e1748c191..9e2182104 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -15,12 +15,11 @@ * * ******************************************************************************/ -// komodo functions that interact with bitcoind C++ +// Hush + Komodo functions that interact with bitcoind C++ #include #include #include "consensus/params.h" -//#include "primitives/nonce.h" #include "komodo_defs.h" #include "script/standard.h" #include "cc/CCinclude.h" @@ -711,7 +710,7 @@ bool hush_hardfork_active(uint32_t time) uint32_t nHardForkHeight = GetArg("-hardfork-height", nHushHardforkHeight); bool isactive = chainActive.Height() > nHardForkHeight; if(fDebug) { - fprintf(stderr, "%s: active=%d at height=%d and forkheight=%d\n", __FUNCTION__, (int)isactive, chainActive.Height(), nHardForkHeight); + //fprintf(stderr, "%s: active=%d at height=%d and forkheight=%d\n", __FUNCTION__, (int)isactive, chainActive.Height(), nHardForkHeight); } return isactive; } @@ -1234,69 +1233,158 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); +// This function defines the Hush Founders Reward (AKA Dev Tax) +// 10% of all block rewards go towards Hush core team +// If you do not like this, you are encouraged to fork the chain +// or start your own Hush Smart Chain: https://github.com/myhush/hush-smart-chains +// HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. +// You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 +// but to tell the AC params, I need to say "11% of 11.25" is 1.25 +// 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually +// This must be kept in sync with hush_block_subsidy() in komoto_utils.h! +// Changing these functions are consensus changes! +// Here Be Dragons! -- Duke Leto +uint64_t hush_commission(int height) +{ + int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), + INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129; + uint64_t commission = 0; + + //TODO: Likely a bug hiding here or at the next halving :) + //if( height >= HALVING1) { + if( height > HALVING1) { + // Block time going from 150s to 75s (half) means the interval between halvings + // must be twice as often, i.e. 840000*2=1680000 + // 840000 is ~4 years worth of 150s blocks + // With 150s blocks, we have 210,000 blocks per year + // With 75s blocks, we have 420,000 blocks per year + INTERVAL = GetArg("-ac_halving2",1680000); // ~4 years worth of 75s blocks + fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL); + } + + // Block 128 had a miner subsidy but no FR!!! Discovered by Denio + if (height < TRANSITION) { + commission = 0; + } else { + // Just like BTC, BRs in the far future will be slightly less than + // they should be because exact values are not integers, causing + // slightly less coins to be actually mined and small deviations + // to the ideal FR/devtax + if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) + commission = starting_commission; + } else if (height < 2020000 ) { + commission = 31250000; + } else if (height < 3700000 ) { + commission = 15625000; + } else if (height < 5380000 ) { + commission = 7812500; + } else if (height < 7060000 ) { + commission = 3906250; + } else if (height < 8740000 ) { + commission = 1953125; + } else if (height < 10420000) { + commission = 976562; // 0.5 puposhi deviation, all further BRs have deviation from ideal + } else if (height < 12100000) { + commission = 488281; + } else if (height < 15460000) { + commission = 244140; + } else if (height < 17140000) { + commission = 122070; + } else if (height < 18820000) { + commission = 61035; + } else if (height < 23860000) { + commission = 30517; + } else if (height < 23860000) { + commission = 15258; + } else if (height < 25540000) { + commission = 7629; + } else if (height < 27220000) { + commission = 3814; + } else if (height < 27220000) { + commission = 1907; + } else if (height < 28900000) { + commission = 953; + } else if (height < 30580000) { + commission = 476; + } else if (height < 32260000) { + commission = 238; + } else if (height < 33940000) { + commission = 119; + } else if (height < 35620000) { + commission = 59; + } else if (height < 37300000) { + commission = 29; + } else if (height < 38980000) { + commission = 14; + } else if (height < 40660000) { + commission = 7; + } else if (height < 42340000) { + commission = 3; + } else if (height < 44020000) { + commission = 1; + } else if (height < 45700000) { + // FR goes to zero at Halving 26 + commission = 0; + } else if (height < 47380000) { + // FR still zero at Halving 27 + commission = 0; + } else if (height < 49060000) { + // FR still zero at Halving 28 + commission = 0; + } else if (height < 50740000) { + // FR still zero at Halving 29 + commission = 0; + } else { + // enforce FR=0 for all other heights + // This over-rides the -ac_end param via HUSH3 cli args + commission = 0; + } + } + + if(fDebug) + fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height); + return commission; +} + uint64_t komodo_commission(const CBlock *pblock,int32_t height) { - static bool didinit = false,ishush3 = false; - // LABS fungible chains, cannot have any block reward! - if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) - return(0); + //fprintf(stderr,"%s at height=%d\n",__func__,height); + static bool didinit = false, ishush3 = false; if (!didinit) { ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; didinit = true; + fprintf(stderr,"%s: didinit ishush3=%d\n", __func__, ishush3); } int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; if ( ASSETCHAINS_FOUNDERS != 0 ) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); - //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + if(fDebug) + fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if (ishush3) { - int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; - // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. - // You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 - // but to tell the AC params, I need to say "11% of 11.25" is 1.25 - // 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually - // Transition period of 128 blocks has BR=FR=0 - if (height < TRANSITION) { - commission = 0; - } else if (height < HALVING1) { - commission = starting_commission; - } else if (height < HALVING1+1*INTERVAL) { - commission = starting_commission / 2; - } else if (height < HALVING1+2*INTERVAL) { - commission = starting_commission / 4; - } else if (height < HALVING1+3*INTERVAL) { - commission = starting_commission / 8; - } else if (height < HALVING1+4*INTERVAL) { - commission = starting_commission / 16; - } else if (height < HALVING1+5*INTERVAL) { - commission = starting_commission / 32; - } else if (height < HALVING1+6*INTERVAL) { // Block 5380000 - // Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting - commission = starting_commission / 64; - } else if (height < HALVING1+7*INTERVAL) { - // Block reward will be zero before this is ever reached - commission = starting_commission / 128; // Block 6220000 - } + commission = hush_commission(height); } if ( ASSETCHAINS_FOUNDERS > 1 ) { if ( (height % ASSETCHAINS_FOUNDERS) == 0 ) { - if ( ASSETCHAINS_FOUNDERS_REWARD == 0 ) + if ( ASSETCHAINS_FOUNDERS_REWARD == 0 ) { commission = commission * ASSETCHAINS_FOUNDERS; - else + } else { commission = ASSETCHAINS_FOUNDERS_REWARD; + } + if(fDebug) + fprintf(stderr,"%s: set commission=%lu at height %d with\n",__func__,commission, height); + } else { + commission = 0; } - else commission = 0; } - } - else if ( pblock != 0 ) - { + } else if ( pblock != 0 ) { txn_count = pblock->vtx.size(); for (i=0; i %.8f\n",(double)commission/COIN); + if(fDebug) + fprintf(stderr,"%s: commission=%.8f at height=%d\n",__func__, (double)commission/COIN, height); return(commission); } @@ -1535,8 +1624,8 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh //fprintf(stderr,"blocktime.%u -> ",blocktime); if ( blocktime < prevtime+3 ) blocktime = prevtime+3; - if ( blocktime < GetAdjustedTime()-60 ) - blocktime = GetAdjustedTime()+30; + if ( blocktime < GetTime()-60 ) + blocktime = GetTime()+30; //fprintf(stderr,"blocktime.%u txtime.%u\n",blocktime,txtime); } if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) @@ -1968,20 +2057,22 @@ void GetKomodoEarlytxidScriptPub() int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { + if(fDebug) + fprintf(stderr,"%s at height=%d\n",__func__,height); int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false; if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) { checktoshis = komodo_commission(pblock,height); if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) { - //fprintf(stderr,"komodo_checkcommission vsize.%d height.%d commission %.8f\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); + fprintf(stderr,"ERROR: komodo_checkcommission vsize.%d height.%d commission %.8f has checktoshis=%lu <10000 or less than 2 vouts (vouts=%lu)\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN, checktoshis, pblock->vtx[0].vout.size() ); return(-1); } else if ( checktoshis != 0 ) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - if ( 0 ) + if ( fDebug ) { int32_t i; for (i=0; ivtx[0].vout[1].nValue != checktoshis ) { - fprintf(stderr,"ht.%d checktoshis %.8f vs actual vout[1] %.8f\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + fprintf(stderr,"ERROR: ht.%d checktoshis %.8f vs actual vout[1] %.8f !!!\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); return(-1); } } } + if(fDebug) + fprintf(stderr,"%s checktoshis=%li at height=%d\n",__func__,checktoshis, height); return(checktoshis); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0a1634348..2e4e679ca 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1534,24 +1534,122 @@ char *argv0names[] = (char *)"MNZ", (char *)"MNZ", (char *)"MNZ", (char *)"MNZ", (char *)"BTCH", (char *)"BTCH", (char *)"BTCH", (char *)"BTCH" }; + +// Large total supplies lead to numerical errors, beware! uint64_t komodo_max_money() { return komodo_current_supply(10000000); } + +// This implements the Hush Emission Curve, the miner subsidy part, +// and must be kept in sync with hush_commision() in komoto_bitcoind.h! +// Changing these functions are consensus changes! +// Here Be Dragons! -- Duke Leto +uint64_t hush_block_subsidy(int height) +{ + uint64_t subsidy = 0; + int32_t HALVING1 = GetArg("-z2zheight",340000); + //TODO: support INTERVAL :( + //int32_t INTERVAL = GetArg("-ac_halving1",840000); + int32_t TRANSITION = 128; + + if (height < TRANSITION) { + if(fDebug) + fprintf(stderr,"%s: setting subsidy=0 during transition at height=%d\n",__func__, height); + subsidy = 0; + } else { + // Just like BTC, BRs in the far future will be slightly less than + // they should be because exact values are not integers, causing + // slightly less coins to be actually mined and small deviations + // to the ideal FR/devtax + if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) + subsidy = 1125000000; + } else if (height < 2020000 ) { + subsidy = 281250000; + } else if (height < 3700000 ) { + subsidy = 140625000; + } else if (height < 5380000 ) { + subsidy = 70312500; + } else if (height < 7060000 ) { + subsidy = 35156250; + } else if (height < 8740000 ) { + subsidy = 17578125; + } else if (height < 10420000) { + subsidy = 8789062; + } else if (height < 12100000) { + subsidy = 4394531; + } else if (height < 15460000) { + subsidy = 2197265; + } else if (height < 17140000) { + subsidy = 1098632; + } else if (height < 18820000) { + subsidy = 549316; + } else if (height < 23860000) { + subsidy = 274658; + } else if (height < 23860000) { + subsidy = 137329; + } else if (height < 25540000) { + subsidy = 68664; + } else if (height < 27220000) { + subsidy = 34332; + } else if (height < 27220000) { + subsidy = 17166; + } else if (height < 28900000) { + subsidy = 8583; + } else if (height < 30580000) { + subsidy = 4291; + } else if (height < 32260000) { + subsidy = 2145; + } else if (height < 33940000) { + subsidy = 1072; + } else if (height < 35620000) { + subsidy = 536; + } else if (height < 37300000) { + subsidy = 268; + } else if (height < 38980000) { + subsidy = 134; + } else if (height < 40660000) { + subsidy = 67; + } else if (height < 42340000) { + subsidy = 33; + } else if (height < 44020000) { + subsidy = 16; + } else if (height < 45700000) { + subsidy = 8; + } else if (height < 47380000) { + subsidy = 4; + } else if (height < 49060000) { + subsidy = 2; + } else if (height < 50740000) { + subsidy = 1; + } else { + // HUSH Block Reward rounds down to 0 at Block 50740000 which is the 31st halving + // because Bitcoin/Zcash/Hush internals don't support 0.5 sat block reward yet ;) + subsidy = 0; + } + } + if(fDebug) + fprintf(stderr,"%s: subsidy=%lu at height=%d\n",__func__,subsidy,height); + return subsidy; +} + +// wrapper for more general supply curves of Hush Smart Chains uint64_t komodo_ac_block_subsidy(int nHeight) { - // we have to find our era, start from beginning reward, and determine current subsidy + //fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); + // Find current era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; - int32_t numhalvings, curEra = 0, sign = 1; + int32_t numhalvings = 0, curEra = 0, sign = 1; static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era; + bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; // check for backwards compat, older chains with no explicit rewards had 0.0001 block reward - if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) { + fprintf(stderr,"%s: defaulting to 0.0001 subsidy\n",__func__); subsidy = 10000; - else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) - { + } else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) { // if we have an end block in the first era, find our current era if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 ) { @@ -1561,26 +1659,32 @@ uint64_t komodo_ac_block_subsidy(int nHeight) break; } } + if ( curEra <= ASSETCHAINS_LASTERA ) { int64_t nStart = curEra ? ASSETCHAINS_ENDSUBSIDY[curEra - 1] : 0; subsidy = (int64_t)ASSETCHAINS_REWARD[curEra]; + if(fDebug) + fprintf(stderr,"%s: nStart.%ld subsidy.%ld curEra.%d\n",__func__,nStart,subsidy,curEra); + if ( subsidy || (curEra != ASSETCHAINS_LASTERA && ASSETCHAINS_REWARD[curEra + 1] != 0) ) { if ( ASSETCHAINS_HALVING[curEra] != 0 ) { - if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) - { - if ( ASSETCHAINS_DECAY[curEra] == 0 ) + if (ishush3) { + subsidy = hush_block_subsidy(nHeight); + if(fDebug) + fprintf(stderr,"%s: HUSH3 subsidy=%ld at height=%d\n",__func__,subsidy,nHeight); + } else if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) { + // The code below is not compatible with HUSH3 mainnet + if ( ASSETCHAINS_DECAY[curEra] == 0 ) { subsidy >>= numhalvings; - else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) - { + fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld nStart.%ld\n",__func__, numhalvings, curEra, subsidy, nStart); + } else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) { if ( curEra == ASSETCHAINS_LASTERA ) { subsidyDifference = subsidy; - } - else - { + } else { // Ex: -ac_eras=3 -ac_reward=0,384,24 -ac_end=1440,260640,0 -ac_halving=1,1440,2103840 -ac_decay 100000000,97750000,0 subsidyDifference = subsidy - ASSETCHAINS_REWARD[curEra + 1]; if (subsidyDifference < 0) @@ -1592,13 +1696,10 @@ uint64_t komodo_ac_block_subsidy(int nHeight) denominator = ASSETCHAINS_ENDSUBSIDY[curEra] - nStart; numerator = denominator - ((ASSETCHAINS_ENDSUBSIDY[curEra] - nHeight) + ((nHeight - nStart) % ASSETCHAINS_HALVING[curEra])); subsidy = subsidy - sign * ((subsidyDifference * numerator) / denominator); - } - else - { - if ( cached_subsidy > 0 && cached_era == curEra && cached_numhalvings == numhalvings ) + } else { + if ( cached_subsidy > 0 && cached_era == curEra && cached_numhalvings == numhalvings ) { subsidy = cached_subsidy; - else - { + } else { for (int i=0; i < numhalvings && subsidy != 0; i++) subsidy = (subsidy * ASSETCHAINS_DECAY[curEra]) / 100000000; cached_subsidy = subsidy; @@ -1609,28 +1710,28 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } } } + } else { + fprintf(stderr,"%s: curEra.%d > lastEra.%lu\n", __func__, curEra, ASSETCHAINS_LASTERA); } } uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion? { + fprintf(stderr,"%s: Detected supply over 10 billion, danger zone!\n",__func__); if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 ) { subsidy += (uint64_t)1000000000 * COIN; if ( nHeight == 1 ) subsidy += (ASSETCHAINS_SUPPLY % 1000000000)*COIN + magicExtra; } - } - else if ( nHeight == 1 ) - { + } else if ( nHeight == 1 ) { if ( ASSETCHAINS_LASTERA == 0 ) subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } - else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) - return(0); - // LABS fungible chains, cannot have any block reward! + if(fDebug) + fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,magicExtra); return(subsidy); } @@ -1798,6 +1899,8 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; + if(fDebug) + fprintf(stderr,"%s: lastEra=%lu maxEras=%d\n", __func__, ASSETCHAINS_LASTERA, ASSETCHAINS_MAX_ERAS); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); @@ -1805,13 +1908,33 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_TIMEUNLOCKFROM > ASSETCHAINS_TIMEUNLOCKTO ) { printf("ASSETCHAINS_TIMELOCKGTE - must specify valid ac_timeunlockfrom and ac_timeunlockto\n"); - ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; + ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; ASSETCHAINS_TIMEUNLOCKFROM = ASSETCHAINS_TIMEUNLOCKTO = 0; } Split(GetArg("-ac_end",""), sizeof(ASSETCHAINS_ENDSUBSIDY)/sizeof(*ASSETCHAINS_ENDSUBSIDY), ASSETCHAINS_ENDSUBSIDY, 0); - Split(GetArg("-ac_reward",""), sizeof(ASSETCHAINS_REWARD)/sizeof(*ASSETCHAINS_REWARD), ASSETCHAINS_REWARD, 0); 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(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + + if(ishush3) { + fprintf(stderr,"%s: Setting custom HUSH3 reward,halving,subsidy chain values...\n",__func__); + // Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things + ASSETCHAINS_REWARD[0] = 0; + ASSETCHAINS_REWARD[1] = 1125000000; + ASSETCHAINS_REWARD[2] = 281250000; // 2.8125 HUSH goes to miners per block after 1st halving at Block 340K + ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 + ASSETCHAINS_HALVING[0] = 129; + ASSETCHAINS_HALVING[1] = GetArg("-z2zheight",340000); + ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (1st halving block plus new halving interval) + ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; + ASSETCHAINS_ENDSUBSIDY[0] = 129; + ASSETCHAINS_ENDSUBSIDY[1] = GetArg("-z2zheight",340000); + ASSETCHAINS_ENDSUBSIDY[2] = 2*5422111; // TODO: Fix this, twice the previous end of rewards is an estimate + // TODO: fill in all possible values for each halving/reward interval + // based on simple halving schedule + } Split(GetArg("-ac_decay",""), sizeof(ASSETCHAINS_DECAY)/sizeof(*ASSETCHAINS_DECAY), ASSETCHAINS_DECAY, 0); Split(GetArg("-ac_notarypay",""), sizeof(ASSETCHAINS_NOTARY_PAY)/sizeof(*ASSETCHAINS_NOTARY_PAY), ASSETCHAINS_NOTARY_PAY, 0); diff --git a/src/limitedmap.h b/src/limitedmap.h index e8ea54965..843a68a20 100644 --- a/src/limitedmap.h +++ b/src/limitedmap.h @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_LIMITEDMAP_H #define BITCOIN_LIMITEDMAP_H diff --git a/src/main.cpp b/src/main.cpp index fb53e2c28..942c45cf8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -85,6 +85,7 @@ int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); //void komodo_broadcast(CBlock *pblock,int32_t limit); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); void komodo_setactivation(int32_t height); +void hush_changeblocktime(); void komodo_pricesupdate(int32_t height,CBlock *pblock); BlockMap mapBlockIndex; @@ -115,6 +116,7 @@ bool fAlerts = DEFAULT_ALERTS; */ int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; +int32_t nFirstHalvingHeight = 340000; unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; @@ -999,7 +1001,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) // However this changes once median past time-locks are enforced: const int64_t nBlockTime = (flags & LOCKTIME_MEDIAN_TIME_PAST) ? chainActive.Tip()->GetMedianTimePast() - : GetAdjustedTime(); + : GetTime(); return IsFinalTx(tx, nBlockHeight, nBlockTime); } @@ -1748,7 +1750,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // and edge cases. This empty mempool assures there will be no transactions involving taddrs // stuck in the mempool, when the z2z rule takes effect. // Thanks to jl777 for helping design this - fprintf(stderr,"%s: rejecting all tx's during z2z transition window at height=%d\n", __func__,nHeight); + fprintf(stderr,"%s: rejecting all tx's during z2z transition window. Please retry after Block %d !!!\n", __func__,nHeight); return false; } } @@ -2400,49 +2402,9 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) return true; } -//uint64_t komodo_moneysupply(int32_t height); - CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { - int32_t numhalvings,i; uint64_t numerator; CAmount nSubsidy = 3 * COIN; - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - if ( nHeight == 1 ) - return(100000000 * COIN); // ICO allocation - else if ( nHeight < KOMODO_ENDOFERA ) - return(3 * COIN); - else if ( nHeight < 2*KOMODO_ENDOFERA ) - return(2 * COIN); - else return(COIN); - } - else - { - return(komodo_ac_block_subsidy(nHeight)); - } - /* - // Mining slow start - // The subsidy is ramped up linearly, skipping the middle payout of - // MAX_SUBSIDY/2 to keep the monetary curve consistent with no slow start. - if (nHeight < consensusParams.nSubsidySlowStartInterval / 2) { - nSubsidy /= consensusParams.nSubsidySlowStartInterval; - nSubsidy *= nHeight; - return nSubsidy; - } else if (nHeight < consensusParams.nSubsidySlowStartInterval) { - nSubsidy /= consensusParams.nSubsidySlowStartInterval; - nSubsidy *= (nHeight+1); - return nSubsidy; - } - - assert(nHeight > consensusParams.SubsidySlowStartShift()); - int halvings = (nHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nSubsidyHalvingInterval;*/ - // Force block reward to zero when right shift is undefined. - //int halvings = nHeight / consensusParams.nSubsidyHalvingInterval; - //if (halvings >= 64) - // return 0; - - // Subsidy is cut in half every 840,000 blocks which will occur approximately every 4 years. - //nSubsidy >>= halvings; - //return nSubsidy; + return komodo_ac_block_subsidy(nHeight); } bool IsInitialBlockDownload() @@ -3227,6 +3189,17 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex // move best block pointer to prevout block view.SetBestBlock(pindex->pprev->GetBlockHash()); + // If disconnecting a block brings us back before our blocktime halving height, go back + // to our original blocktime so our DAA has the correct target for that height + int nHeight = pindex->pprev->GetHeight(); + nFirstHalvingHeight = GetArg("-z2zheight",340000); + if (ishush3 && (ASSETCHAINS_BLOCKTIME != 150) && (nHeight < nFirstHalvingHeight)) { + LogPrintf("%s: Setting blocktime to 150s at height %d!\n",__func__,nHeight); + ASSETCHAINS_BLOCKTIME = 150; + hush_changeblocktime(); + } + + if (pfClean) { *pfClean = fClean; return true; @@ -3287,7 +3260,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const if (bestHeader == NULL || initialDownloadCheck()) return; static int64_t lastAlertTime = 0; - int64_t now = GetAdjustedTime(); + int64_t now = GetTime(); if (lastAlertTime > now-60*60*24) return; // Alert at most once per day const int SPAN_HOURS=4; @@ -3297,7 +3270,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const boost::math::poisson_distribution poisson(BLOCKS_EXPECTED); std::string strWarning; - int64_t startTime = GetAdjustedTime()-SPAN_SECONDS; + int64_t startTime = GetTime()-SPAN_SECONDS; LOCK(cs); const CBlockIndex* i = bestHeader; @@ -3350,6 +3323,7 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); + bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3362,15 +3336,22 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin AssertLockHeld(cs_main); bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + + // At startup, HUSH3 doesn't know a block height yet and so we must wait until + // connecting a block to set our private/blocktime flags, which are height-dependent + nFirstHalvingHeight = GetArg("-z2zheight",340000); if(!ASSETCHAINS_PRIVATE && ishush3) { unsigned int nHeight = pindex->GetHeight(); - if(nHeight >= 340000) { - // At startup, HUSH3 doesn't know a block height yet and so we must wait until - // connecting a block - fprintf(stderr, "%s: Going full z2z at height %d!\n",__func__,nHeight); + if(nHeight >= nFirstHalvingHeight) { + fprintf(stderr, "%s: Going full z2z at height %d!\n",__func__,pindex->GetHeight()); ASSETCHAINS_PRIVATE = 1; } } + if (ishush3 && (ASSETCHAINS_BLOCKTIME != 75) && (chainActive.Height() >= nFirstHalvingHeight)) { + LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,pindex->GetHeight()); + ASSETCHAINS_BLOCKTIME = 75; + hush_changeblocktime(); + } bool fExpensiveChecks = true; if (fCheckpointsEnabled) { @@ -3964,8 +3945,17 @@ void static UpdateTip(CBlockIndex *pindexNew) { if ( ASSETCHAINS_SYMBOL[0] == 0 ) { progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.LastTip()); } else { - int32_t longestchain = komodo_longestchain(); - progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0; + int32_t longestchain = komodo_longestchain(); + progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0; + } + + nFirstHalvingHeight = GetArg("-z2zheight",340000); + if(ishush3) { + if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) { + LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height()); + ASSETCHAINS_BLOCKTIME = 75; + hush_changeblocktime(); + } } LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__, @@ -3976,33 +3966,6 @@ void static UpdateTip(CBlockIndex *pindexNew) { pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize()); cvBlockChange.notify_all(); - - /* - // https://github.com/zcash/zcash/issues/3992 -> https://github.com/zcash/zcash/commit/346d11d3eb2f8162df0cb00b1d1f49d542495198 - - // Check the version of the last 100 blocks to see if we need to upgrade: - static bool fWarned = false; - if (!IsInitialBlockDownload() && !fWarned) - { - int nUpgraded = 0; - const CBlockIndex* pindex = chainActive.Tip(); - for (int i = 0; i < 100 && pindex != NULL; i++) - { - if (pindex->nVersion > CBlock::CURRENT_VERSION) - ++nUpgraded; - pindex = pindex->pprev; - } - if (nUpgraded > 0) - LogPrintf("%s: %d of last 100 blocks above version %d\n", __func__, nUpgraded, (int)CBlock::CURRENT_VERSION); - if (nUpgraded > 100/2) - { - // strMiscWarning is read by GetWarnings(), called by the JSON-RPC code to warn the user: - strMiscWarning = _("Warning: This version is obsolete; upgrade required!"); - CAlert::Notify(strMiscWarning, true); - fWarned = true; - } - } - */ } /** @@ -4734,7 +4697,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl CAmount sproutValue = 0; CAmount saplingValue = 0; bool isShieldedTx = false; - unsigned int nShieldedSpends=0,nShieldedOutputs=0,nPayments=0, nShieldedOutputsInBlock=0; + unsigned int nShieldedSpends=0,nShieldedSpendsInBlock=0,nShieldedOutputs=0,nPayments=0,nShieldedOutputsInBlock=0; unsigned int nShieldedTx=0,nFullyShieldedTx=0,nDeshieldingTx=0,nShieldingTx=0; unsigned int nShieldedPayments=0,nFullyShieldedPayments=0,nShieldingPayments=0,nDeshieldingPayments=0; unsigned int nNotarizations=0; @@ -4822,9 +4785,14 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl // No shielded payments, add transparent payments minus a change address nPayments += tx.vout.size() > 1 ? tx.vout.size()-1 : tx.vout.size(); } - // To calculate the anonset we must track the sum of zouts in every tx, in every block. -- Duke + // To calculate the anonset we must track the sum of spends and zouts in every tx, in every block. -- Duke nShieldedOutputsInBlock += nShieldedOutputs; + nShieldedSpendsInBlock += nShieldedSpends; + if (fZdebug) { + fprintf(stderr,"%s: tx=%s has zspends=%d zouts=%d\n", __FUNCTION__, tx.GetHash().ToString().c_str(), nShieldedSpends, nShieldedOutputs ); + } } + fprintf(stderr,"%s: block %s has total zspends=%d zouts=%d\n", __FUNCTION__, block.GetHash().ToString().c_str(), nShieldedSpendsInBlock, nShieldedOutputsInBlock ); pindexNew->nSproutValue = sproutValue; pindexNew->nChainSproutValue = boost::none; @@ -4840,6 +4808,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl pindexNew->nPayments = nPayments; pindexNew->nShieldedTx = nShieldedTx; pindexNew->nShieldedOutputs = nShieldedOutputsInBlock; + pindexNew->nShieldedSpends = nShieldedSpendsInBlock; pindexNew->nFullyShieldedTx = nFullyShieldedTx; pindexNew->nDeshieldingTx = nDeshieldingTx; pindexNew->nShieldingTx = nShieldingTx; @@ -4862,12 +4831,15 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl queue.pop_front(); pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx; + // Update -zindex stats if (fZindex) { - if (fZdebug) - fprintf(stderr,"%s: setting blockchain zstats with zouts=%d\n", __FUNCTION__, nShieldedOutputsInBlock ); + if (fZdebug) { + //fprintf(stderr,"%s: setting blockchain zstats with zspends=%d, zouts=%d\n", __FUNCTION__, nShieldedSpendsInBlock, nShieldedOutputsInBlock ); + } pindex->nChainNotarizations = (pindex->pprev ? pindex->pprev->nChainNotarizations : 0) + pindex->nNotarizations; pindex->nChainShieldedTx = (pindex->pprev ? pindex->pprev->nChainShieldedTx : 0) + pindex->nShieldedTx; pindex->nChainShieldedOutputs = (pindex->pprev ? pindex->pprev->nChainShieldedOutputs : 0) + pindex->nShieldedOutputs; + pindex->nChainShieldedSpends = (pindex->pprev ? pindex->pprev->nChainShieldedSpends : 0) + pindex->nShieldedSpends; pindex->nChainFullyShieldedTx = (pindex->pprev ? pindex->pprev->nChainFullyShieldedTx : 0) + pindex->nFullyShieldedTx; pindex->nChainShieldingTx = (pindex->pprev ? pindex->pprev->nChainShieldingTx : 0) + pindex->nShieldingTx; pindex->nChainDeshieldingTx = (pindex->pprev ? pindex->pprev->nChainDeshieldingTx : 0) + pindex->nDeshieldingTx; @@ -5123,28 +5095,28 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, *futureblockp = 0; if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) { - if (blockhdr.GetBlockTime() > GetAdjustedTime() + 4) + if (blockhdr.GetBlockTime() > GetTime() + 4) { - //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); + //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetTime()); return false; } } - else if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60) + else if (blockhdr.GetBlockTime() > GetTime() + 60) { /*CBlockIndex *tipindex; - //fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetAdjustedTime()); - if ( (tipindex= chainActive.Tip()) != 0 && tipindex->GetBlockHash() == blockhdr.hashPrevBlock && blockhdr.GetBlockTime() < GetAdjustedTime() + 60 + 5 ) + //fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetTime()); + if ( (tipindex= chainActive.Tip()) != 0 && tipindex->GetBlockHash() == blockhdr.hashPrevBlock && blockhdr.GetBlockTime() < GetTime() + 60 + 5 ) { - //fprintf(stderr,"it is the next block, let's wait for %d seconds\n",GetAdjustedTime() + 60 - blockhdr.GetBlockTime()); - while ( blockhdr.GetBlockTime() > GetAdjustedTime() + 60 ) + //fprintf(stderr,"it is the next block, let's wait for %d seconds\n",GetTime() + 60 - blockhdr.GetBlockTime()); + while ( blockhdr.GetBlockTime() > GetTime() + 60 ) sleep(1); //fprintf(stderr,"now its valid\n"); } else*/ { - if (blockhdr.GetBlockTime() < GetAdjustedTime() + 300) + if (blockhdr.GetBlockTime() < GetTime() + 300) *futureblockp = 1; - //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); + //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetTime()); return false; //state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new"); } } @@ -5392,7 +5364,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta } // Check that timestamp is not too far in the future - if (block.GetBlockTime() > GetAdjustedTime() + consensusParams.nMaxFutureBlockTime) + if (block.GetBlockTime() > GetTime() + consensusParams.nMaxFutureBlockTime) { return state.Invalid(error("%s: block timestamp too far in the future", __func__), REJECT_INVALID, "time-too-new"); @@ -7410,9 +7382,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->nStartingHeight, addrMe.ToString(), pfrom->id, remoteAddr); - int64_t nTimeOffset = nTime - GetTime(); - pfrom->nTimeOffset = nTimeOffset; - AddTimeData(pfrom->addr, nTimeOffset); + //int64_t nTimeOffset = nTime - GetTime(); + //pfrom->nTimeOffset = nTimeOffset; + //AddTimeData(pfrom->addr, nTimeOffset); + pfrom->nTimeOffset = timeWarning.AddTimeData(pfrom->addr, nTime, GetTime()); } @@ -7488,7 +7461,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Store the new addresses vector vAddrOk; - int64_t nNow = GetAdjustedTime(); + int64_t nNow = GetTime(); int64_t nSince = nNow - 10 * 60; BOOST_FOREACH(CAddress& addr, vAddr) { @@ -7698,7 +7671,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // not a direct successor. pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexBestHeader), inv.hash); CNodeState *nodestate = State(pfrom->GetId()); - if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - chainparams.GetConsensus().nPowTargetSpacing * 20 && + if (chainActive.Tip()->GetBlockTime() > GetTime() - chainparams.GetConsensus().nPowTargetSpacing * 20 && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) { vToFetch.push_back(inv); // Mark block as in flight already, even though the actual "getdata" message only goes out @@ -8461,7 +8434,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pindexBestHeader!=0) { // Only actively request headers from a single peer, unless we're close to today. - if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { + if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; diff --git a/src/main.h b/src/main.h index 060b6b7cc..5f4a784cf 100644 --- a/src/main.h +++ b/src/main.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/memusage.h b/src/memusage.h index a3fd11b5f..7a6e28832 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp index db4ccfc96..2f48b7503 100644 --- a/src/merkleblock.cpp +++ b/src/merkleblock.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/merkleblock.h b/src/merkleblock.h index f970ee91d..c3f4221d4 100644 --- a/src/merkleblock.h +++ b/src/merkleblock.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/metrics.cpp b/src/metrics.cpp index adbef02f2..12fcc0375 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/metrics.h b/src/metrics.h index 84ea9ed51..3c1fbf92e 100644 --- a/src/metrics.h +++ b/src/metrics.h @@ -1,6 +1,7 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/miner.cpp b/src/miner.cpp index a91fa9527..edd3a04f4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1,8 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -126,8 +126,8 @@ extern int8_t ASSETCHAINS_ADAPTIVEPOW; void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev) { if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) - pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - else pblock->nTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); + pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); + else pblock->nTime = std::max((int64_t)(pindexPrev->nTime+1), GetTime()); // Updating time can change work required on testnet: if (ASSETCHAINS_ADAPTIVEPOW > 0 || consensusParams.nPowAllowMinDifficultyBlocksAfterHeight != boost::none) @@ -239,7 +239,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); - uint32_t proposedTime = GetAdjustedTime(); + uint32_t proposedTime = GetTime(); voutsum = GetBlockSubsidy(nHeight,consensusParams) + 10000*COIN; // approx fees if (proposedTime == nMedianTimePast) @@ -248,12 +248,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // forward as quickly as possible for (int i; i < 100; i++) { - proposedTime = GetAdjustedTime(); + proposedTime = GetTime(); if (proposedTime == nMedianTimePast) MilliSleep(10); } } - pblock->nTime = GetAdjustedTime(); + pblock->nTime = GetTime(); // Now we have the block time + height, we can get the active notaries. int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) @@ -603,14 +603,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nLastBlockTx = nBlockTx; nLastBlockSize = nBlockSize; if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) - blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); + blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); + else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetTime()); //pblock->nTime = blocktime + 1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); int32_t stakeHeight = chainActive.Height() + 1; - //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 stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); @@ -621,11 +621,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; - //fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); + fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) - txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - else txNew.nLockTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); + txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); + else txNew.nLockTime = std::max((int64_t)(pindexPrev->nTime+1), GetTime()); if ( ASSETCHAINS_SYMBOL[0] == 0 && IS_KOMODO_NOTARY != 0 && My_notaryid >= 0 ) @@ -1368,10 +1368,10 @@ void static BitcoinMiner() // MilliSleep(30); return false; } - if ( IS_KOMODO_NOTARY != 0 && B.nTime > GetAdjustedTime() ) + if ( IS_KOMODO_NOTARY != 0 && B.nTime > GetTime() ) { - //fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); - while ( GetAdjustedTime() < B.nTime-2 ) + //fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetTime())); + while ( GetTime() < B.nTime-2 ) { sleep(1); if ( chainActive.LastTip()->GetHeight() >= Mining_height ) diff --git a/src/miner.h b/src/miner.h index a3bedd292..cd4326074 100644 --- a/src/miner.h +++ b/src/miner.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/mruset.h b/src/mruset.h index cd3af8664..d95b182f9 100644 --- a/src/mruset.h +++ b/src/mruset.h @@ -1,6 +1,6 @@ // Copyright (c) 2012-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/net.cpp b/src/net.cpp index efb69bfe9..882192660 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1,8 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -193,7 +193,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer) ret = CAddress(addr); } ret.nServices = nLocalServices; - ret.nTime = GetAdjustedTime(); + ret.nTime = GetTime(); return ret; } @@ -393,7 +393,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest) /// debug print LogPrint("net", "trying connection %s lastseen=%.1fhrs\n", pszDest ? pszDest : addrConnect.ToString(), - pszDest ? 0.0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0); + pszDest ? 0.0 : (double)(GetTime() - addrConnect.nTime)/3600.0); // Connect SOCKET hSocket; @@ -458,7 +458,7 @@ void CNode::PushVersion() { int nBestHeight = g_signals.GetHeight().get_value_or(0); - int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime()); + int64_t nTime = (fInbound ? GetTime() : GetTime()); CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0))); CAddress addrMe = GetLocalAddress(&addr); GetRandBytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); @@ -1429,7 +1429,7 @@ void ThreadOpenConnections() } } - int64_t nANow = GetAdjustedTime(); + int64_t nANow = GetTime(); int nTries = 0; while (true) diff --git a/src/net.h b/src/net.h index 2fa4e31b1..70972759e 100644 --- a/src/net.h +++ b/src/net.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/netbase.cpp b/src/netbase.cpp index fa8b80435..24d5125b5 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/netbase.h b/src/netbase.h index 8eb40b6b7..bc5475bfe 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index db1696ed5..6bc458078 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -9,125 +9,30 @@ extern pthread_mutex_t staked_mutex; int8_t is_STAKED(const char *chain_name) { - static int8_t STAKED,doneinit; - if ( chain_name[0] == 0 ) - return(0); - if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) - return(STAKED); - else STAKED = 0; - if ( (strcmp(chain_name, "LABS") == 0) ) - STAKED = 1; // These chains are allowed coin emissions. - else if ( (strncmp(chain_name, "LABS", 4) == 0) ) - STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. - else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; // These chains have no speical rules at all. - else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. - else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) - STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. - doneinit = 1; + static int8_t STAKED=0; return(STAKED); }; int32_t STAKED_era(int timestamp) { - int8_t era = 0; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) - return(1); - for (int32_t i = 1; i < NUM_STAKED_ERAS; i++) - { - if (timestamp <= STAKED_NOTARIES_TIMESTAMP[i] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[i-1] + STAKED_ERA_GAP)) - return(i+1); - } - // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. return(0); }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - if ( STAKED_ERA != 0 ) - { - for (int8_t i = 0; i < num_notaries_STAKED[STAKED_ERA-1]; i++) { - if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { - notaryname.assign(notaries_STAKED[STAKED_ERA-1][i][0]); - return(i); - } - } - } return(-1); } int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int i; int8_t retval = 0; - static uint8_t staked_pubkeys[NUM_STAKED_ERAS][64][33],didinit[NUM_STAKED_ERAS]; - static char ChainName[65]; - - if ( ChainName[0] == 0 ) - { - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - strcpy(ChainName,"KMD"); - else - strcpy(ChainName,ASSETCHAINS_SYMBOL); - } - - if ( era == 0 ) - { - // era is zero so we need to null out the pubkeys. - memset(pubkeys,0,64 * 33); - printf("%s is a STAKED chain and is in an ERA GAP.\n",ChainName); - return(64); - } - else - { - if ( didinit[era-1] == 0 ) - { - for (i=0; iGetHeight() == 340000) { + LogPrintf("%s: Using blocktime=%d\n",__func__,ASSETCHAINS_BLOCKTIME); + } if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0) return lwmaGetNextWorkRequired(pindexLast, pblock, params); diff --git a/src/pow.h b/src/pow.h index 1de85d5cb..64badc4bd 100644 --- a/src/pow.h +++ b/src/pow.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 3243b4564..7b898df95 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/primitives/block.h b/src/primitives/block.h index 9a6ddf100..385eae880 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 53aeeda99..47cfcde09 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 7a46b9c00..43cf355f1 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/protocol.cpp b/src/protocol.cpp index 36ed63934..a006d407c 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/protocol.h b/src/protocol.h index b7ad483ac..c01bea400 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/pubkey.cpp b/src/pubkey.cpp index c714c8671..0d9096f61 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -1,7 +1,8 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -41,12 +42,12 @@ bool CPubKey::Verify(const uint256 &hash, const std::vector& vchS if (vchSig.size() == 0) { return false; } - /* Zcash, unlike Bitcoin, has always enforced strict DER signatures. */ + /* Hush, unlike Bitcoin, has always enforced strict DER signatures. */ if (!secp256k1_ecdsa_signature_parse_der(secp256k1_context_verify, &sig, &vchSig[0], vchSig.size())) { return false; } /* libsecp256k1's ECDSA verification requires lower-S signatures, which have - * not historically been enforced in Bitcoin or Zcash, so normalize them first. */ + * not historically been enforced in Bitcoin or Hush, so normalize them first. */ secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, &sig, &sig); return secp256k1_ecdsa_verify(secp256k1_context_verify, &sig, hash.begin(), &pubkey); } @@ -142,7 +143,7 @@ bool CExtPubKey::Derive(CExtPubKey &out, unsigned int nChild) const { /* static */ bool CPubKey::CheckLowS(const std::vector& vchSig) { secp256k1_ecdsa_signature sig; - /* Zcash, unlike Bitcoin, has always enforced strict DER signatures. */ + /* Hush, unlike Bitcoin, has always enforced strict DER signatures. */ if (!secp256k1_ecdsa_signature_parse_der(secp256k1_context_verify, &sig, &vchSig[0], vchSig.size())) { return false; } diff --git a/src/pubkey.h b/src/pubkey.h index 18e4dda8f..299866fa9 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2017 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/random.cpp b/src/random.cpp index f9aa7622d..8b0ca9c12 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/random.h b/src/random.h index b65c7e08a..9c0f4ffdf 100644 --- a/src/random.h +++ b/src/random.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rest.cpp b/src/rest.cpp index 72187f671..b62096a83 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/reverselock.h b/src/reverselock.h index dd79cf3da..3e0263808 100644 --- a/src/reverselock.h +++ b/src/reverselock.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index faed5b957..cdfe567ee 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -1440,7 +1440,7 @@ UniValue gettxout(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"reqSigs\" : n, (numeric) Number of required signatures\n" " \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n" " \"addresses\" : [ (array of string) array of Komodo addresses\n" - " \"komodoaddress\" (string) Komodo address\n" + " \"hushaddress\" (string) Hush address\n" " ,...\n" " ]\n" " },\n" @@ -1904,6 +1904,7 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk " \"nullifiers\": xxxxx, (numeric) The total number of shielded nullifiers in the chain up to that point.\n" " \"shielded_txcount\": xxxxx, (numeric) The total number of shielded (containing a zaddr) transactions in the chain up to that point.\n" " \"shielded_outputs\": xxxxx, (numeric) The total number of shielded outputs in the chain up to that point.\n" + " \"shielded_spends\": xxxxx, (numeric) The total number of shielded spends in the chain up to that point.\n" " \"shielded_pool_size\": xxxxx, (numeric) The total number of unspent shielded outputs, i.e. the Shielded Pool or Anonymity Set (anonset).\n" " \"shielding_txcount\": xxxxx, (numeric) The total number of shielding (containing a zaddr output) transactions in the chain up to that point.\n" " \"deshielding_txcount\": xxxxx, (numeric) The total number of deshielding (containing a zaddr input) transactions in the chain up to that point.\n" @@ -2003,9 +2004,11 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk ret.pushKV("shielding_payments", (int64_t)pindex->nChainShieldingPayments); int64_t nullifierCount = pwalletMain->NullifierCount(); + //TODO: this is unreliable, is only a cache or subset of total nullifiers ret.pushKV("nullifiers", (int64_t)nullifierCount); - ret.pushKV("shielded_pool_size", (int64_t)pindex->nChainShieldedOutputs - nullifierCount); + ret.pushKV("shielded_pool_size", (int64_t)(pindex->nChainShieldedOutputs - pindex->nChainShieldedSpends)); ret.pushKV("shielded_outputs", (int64_t)pindex->nChainShieldedOutputs); + ret.pushKV("shielded_spends", (int64_t)pindex->nChainShieldedSpends); } if (blockcount > 0) { diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 4f11a476f..5acaf5931 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -169,11 +169,11 @@ static const CRPCConvertParam vRPCConvertParams[] = { "z_listsentbyaddress", 3}, { "z_listsentbyaddress", 4}, { "z_listsentbyaddress", 5}, - { "z_listreceivedbyaddress", 1}, - { "z_listreceivedbyaddress", 2}, - { "z_listreceivedbyaddress", 3}, - { "z_listreceivedbyaddress", 4}, - { "z_listreceivedbyaddress", 5}, + { "z_listreceivedaddress", 1}, + { "z_listreceivedaddress", 2}, + { "z_listreceivedaddress", 3}, + { "z_listreceivedaddress", 4}, + { "z_listreceivedaddress", 5}, // crosschain { "assetchainproof", 1}, diff --git a/src/rpc/client.h b/src/rpc/client.h index 79527b7be..51a3f0d9f 100644 --- a/src/rpc/client.h +++ b/src/rpc/client.h @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 5262b1b1f..3659398da 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1,8 +1,8 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -681,9 +681,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp, const CPubKey& myp throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Cannot get a block template while no peers are connected or chain not in sync!"); } - //if (IsInitialBlockDownload()) - // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks..."); - static unsigned int nTransactionsUpdatedLast; if (!lpval.isNull()) @@ -1021,8 +1018,8 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp, const CPubKey& mypk "1. height (numeric, optional) The block height. If not provided, defaults to the current height of the chain.\n" "\nResult:\n" "{\n" - " \"miner\" : x.xxx (numeric) The mining reward amount in KMD.\n" - " \"ac_pubkey\" : x.xxx (numeric) The mining reward amount in KMD.\n" + " \"miner\" : x.xxx (numeric) The mining reward amount in HUSH.\n" + " \"ac_pubkey\" : x.xxx (numeric) The mining reward amount in HUSH.\n" "}\n" "\nExamples:\n" + HelpExampleCli("getblocksubsidy", "1000") diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a41a8169d..bc3ff3a74 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -206,7 +206,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"walletversion\": xxxxx, (numeric) the wallet version\n" " \"balance\": xxxxxxx, (numeric) the total Hush balance of the wallet\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" - " \"timeoffset\": xxxxx, (numeric) the time offset\n" + " \"timeoffset\": xxxxx, (numeric) the time offset (deprecated, always 0)\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" @@ -286,7 +286,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) #endif obj.push_back(Pair("sapling", ASSETCHAINS_SAPLING)); } - obj.push_back(Pair("timeoffset", GetTimeOffset())); + obj.push_back(Pair("timeoffset", 0)); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 39e080d86..e869e02e4 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -108,7 +109,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"bytessent\": n, (numeric) The total bytes sent\n" " \"bytesrecv\": n, (numeric) The total bytes received\n" " \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n" - " \"timeoffset\": ttt, (numeric) The time offset in seconds\n" + " \"timeoffset\": ttt, (numeric) The time offset in seconds (deprecated, always 0)\n" " \"pingtime\": n, (numeric) ping time\n" " \"pingwait\": n, (numeric) ping wait\n" " \"version\": v, (numeric) The peer version, such as 170002\n" @@ -151,7 +152,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) obj.push_back(Pair("bytessent", stats.nSendBytes)); obj.push_back(Pair("bytesrecv", stats.nRecvBytes)); obj.push_back(Pair("conntime", stats.nTimeConnected)); - obj.push_back(Pair("timeoffset", stats.nTimeOffset)); + obj.push_back(Pair("timeoffset", 0)); obj.push_back(Pair("pingtime", stats.dPingTime)); if (stats.dPingWait > 0.0) obj.push_back(Pair("pingwait", stats.dPingWait)); @@ -320,7 +321,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp, const CPubKey& myp " \"connected\" : true|false, (boolean) If connected\n" " \"addresses\" : [\n" " {\n" - " \"address\" : \"192.168.0.201:8233\", (string) The Komodo server host and port\n" + " \"address\" : \"192.168.0.201:8233\", (string) The Hush server host and port\n" " \"connected\" : \"outbound\" (string) connection, inbound or outbound\n" " }\n" " ,...\n" @@ -502,7 +503,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"subversion\": \"/MagicBean:x.y.z[-v]/\", (string) the server subversion string\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n" - " \"timeoffset\": xxxxx, (numeric) the time offset\n" + " \"timeoffset\": xxxxx, (numeric) the time offset (deprecated, always 0)\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"networks\": [ (array) information per network\n" " {\n" @@ -536,7 +537,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) obj.push_back(Pair("subversion", strSubVersion)); obj.push_back(Pair("protocolversion",PROTOCOL_VERSION)); obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices))); - obj.push_back(Pair("timeoffset", GetTimeOffset())); + obj.push_back(Pair("timeoffset", 0)); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("networks", GetNetworksInfo())); obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); diff --git a/src/rpc/protocol.cpp b/src/rpc/protocol.cpp index 2366fca14..d001d329b 100644 --- a/src/rpc/protocol.cpp +++ b/src/rpc/protocol.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/protocol.h b/src/rpc/protocol.h index 91a14c023..98fae3efc 100644 --- a/src/rpc/protocol.h +++ b/src/rpc/protocol.h @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 71b28c642..15fe89729 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2015 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -45,7 +45,10 @@ #include +#include + #include +#include #include @@ -82,65 +85,6 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud out.push_back(Pair("addresses", a)); } -UniValue TxJoinSplitToJSON(const CTransaction& tx) { - bool useGroth = tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION; - UniValue vjoinsplit(UniValue::VARR); - for (unsigned int i = 0; i < tx.vjoinsplit.size(); i++) { - const JSDescription& jsdescription = tx.vjoinsplit[i]; - UniValue joinsplit(UniValue::VOBJ); - - joinsplit.push_back(Pair("vpub_old", ValueFromAmount(jsdescription.vpub_old))); - joinsplit.push_back(Pair("vpub_oldZat", jsdescription.vpub_old)); - joinsplit.push_back(Pair("vpub_new", ValueFromAmount(jsdescription.vpub_new))); - joinsplit.push_back(Pair("vpub_newZat", jsdescription.vpub_new)); - - joinsplit.push_back(Pair("anchor", jsdescription.anchor.GetHex())); - - { - UniValue nullifiers(UniValue::VARR); - BOOST_FOREACH(const uint256 nf, jsdescription.nullifiers) { - nullifiers.push_back(nf.GetHex()); - } - joinsplit.push_back(Pair("nullifiers", nullifiers)); - } - - { - UniValue commitments(UniValue::VARR); - BOOST_FOREACH(const uint256 commitment, jsdescription.commitments) { - commitments.push_back(commitment.GetHex()); - } - joinsplit.push_back(Pair("commitments", commitments)); - } - - joinsplit.push_back(Pair("onetimePubKey", jsdescription.ephemeralKey.GetHex())); - joinsplit.push_back(Pair("randomSeed", jsdescription.randomSeed.GetHex())); - - { - UniValue macs(UniValue::VARR); - BOOST_FOREACH(const uint256 mac, jsdescription.macs) { - macs.push_back(mac.GetHex()); - } - joinsplit.push_back(Pair("macs", macs)); - } - - CDataStream ssProof(SER_NETWORK, PROTOCOL_VERSION); - auto ps = SproutProofSerializer(ssProof, useGroth); - boost::apply_visitor(ps, jsdescription.proof); - joinsplit.push_back(Pair("proof", HexStr(ssProof.begin(), ssProof.end()))); - - { - UniValue ciphertexts(UniValue::VARR); - for (const ZCNoteEncryption::Ciphertext ct : jsdescription.ciphertexts) { - ciphertexts.push_back(HexStr(ct.begin(), ct.end())); - } - joinsplit.push_back(Pair("ciphertexts", ciphertexts)); - } - - vjoinsplit.push_back(joinsplit); - } - return vjoinsplit; -} - uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); UniValue TxShieldedSpendsToJSON(const CTransaction& tx) { @@ -306,9 +250,6 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& } entry.push_back(Pair("vout", vout)); - UniValue vjoinsplit = TxJoinSplitToJSON(tx); - entry.push_back(Pair("vjoinsplit", vjoinsplit)); - if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) { entry.push_back(Pair("valueBalance", ValueFromAmount(tx.valueBalance))); UniValue vspenddesc = TxShieldedSpendsToJSON(tx); @@ -390,9 +331,6 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) } entry.push_back(Pair("vout", vout)); - UniValue vjoinsplit = TxJoinSplitToJSON(tx); - entry.push_back(Pair("vjoinsplit", vjoinsplit)); - if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) { entry.push_back(Pair("valueBalance", ValueFromAmount(tx.valueBalance))); UniValue vspenddesc = TxShieldedSpendsToJSON(tx); @@ -471,40 +409,13 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp, const CPubKey& my " \"reqSigs\" : n, (numeric) The required sigs\n" " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" " \"addresses\" : [ (json array of string)\n" - " \"komodoaddress\" (string) Komodo address\n" + " \"hushaddress\" (string) Hush address\n" " ,...\n" " ]\n" " }\n" " }\n" " ,...\n" " ],\n" - " \"vjoinsplit\" : [ (array of json objects, only for version >= 2)\n" - " {\n" - " \"vpub_old\" : x.xxx, (numeric) public input value in KMD\n" - " \"vpub_new\" : x.xxx, (numeric) public output value in KMD\n" - " \"anchor\" : \"hex\", (string) the anchor\n" - " \"nullifiers\" : [ (json array of string)\n" - " \"hex\" (string) input note nullifier\n" - " ,...\n" - " ],\n" - " \"commitments\" : [ (json array of string)\n" - " \"hex\" (string) output note commitment\n" - " ,...\n" - " ],\n" - " \"onetimePubKey\" : \"hex\", (string) the onetime public key used to encrypt the ciphertexts\n" - " \"randomSeed\" : \"hex\", (string) the random seed\n" - " \"macs\" : [ (json array of string)\n" - " \"hex\" (string) input note MAC\n" - " ,...\n" - " ],\n" - " \"proof\" : \"hex\", (string) the zero-knowledge proof\n" - " \"ciphertexts\" : [ (json array of string)\n" - " \"hex\" (string) output note ciphertext\n" - " ,...\n" - " ]\n" - " }\n" - " ,...\n" - " ],\n" " \"blockhash\" : \"hash\", (string) the block hash\n" " \"confirmations\" : n, (numeric) The number of notarized DPoW confirmations\n" " \"rawconfirmations\" : n, (numeric) The number of raw confirmations\n" @@ -862,7 +773,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp, const CPubKey& } } else { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Komodo address or script: ") + name_); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Hush address or script: ") + name_); } if (!(fExperimentalMode && IS_KOMODO_NOTARY)) { @@ -933,33 +844,6 @@ UniValue decoderawtransaction(const UniValue& params, bool fHelp, const CPubKey& " }\n" " ,...\n" " ],\n" - " \"vjoinsplit\" : [ (array of json objects, only for version >= 2)\n" - " {\n" - " \"vpub_old\" : x.xxx, (numeric) public input value in KMD\n" - " \"vpub_new\" : x.xxx, (numeric) public output value in KMD\n" - " \"anchor\" : \"hex\", (string) the anchor\n" - " \"nullifiers\" : [ (json array of string)\n" - " \"hex\" (string) input note nullifier\n" - " ,...\n" - " ],\n" - " \"commitments\" : [ (json array of string)\n" - " \"hex\" (string) output note commitment\n" - " ,...\n" - " ],\n" - " \"onetimePubKey\" : \"hex\", (string) the onetime public key used to encrypt the ciphertexts\n" - " \"randomSeed\" : \"hex\", (string) the random seed\n" - " \"macs\" : [ (json array of string)\n" - " \"hex\" (string) input note MAC\n" - " ,...\n" - " ],\n" - " \"proof\" : \"hex\", (string) the zero-knowledge proof\n" - " \"ciphertexts\" : [ (json array of string)\n" - " \"hex\" (string) output note ciphertext\n" - " ,...\n" - " ]\n" - " }\n" - " ,...\n" - " ],\n" "}\n" "\nExamples:\n" @@ -996,7 +880,7 @@ UniValue decodescript(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"type\":\"type\", (string) The output type\n" " \"reqSigs\": n, (numeric) The required signatures\n" " \"addresses\": [ (json array of string)\n" - " \"address\" (string) Komodo address\n" + " \"address\" (string) Hush address\n" " ,...\n" " ],\n" " \"p2sh\",\"address\" (string) script address\n" @@ -1373,6 +1257,19 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPubKey& m const CCoins* existingCoins = view.AccessCoins(hashTx); bool fHaveMempool = mempool.exists(hashTx); bool fHaveChain = existingCoins && existingCoins->nHeight < 1000000000; + + // If we are configured to send transactions via an + // external service instead of broadcasting, do that + std::string strCmd = GetArg("-txsend", ""); + if (!strCmd.empty()) { + if (fHaveChain) { + throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain"); + } + boost::replace_all(strCmd, "%s", EncodeHexTx(tx)); + boost::thread t(runCommand, strCmd); // thread runs free + // Return here so we don't add to our mempool or broadcast to peers + return hashTx.GetHex(); + } if (!fHaveMempool && !fHaveChain) { // push to local node and sync with wallets CValidationState state; diff --git a/src/rpc/register.h b/src/rpc/register.h index 245f76e22..11bdeef7e 100644 --- a/src/rpc/register.h +++ b/src/rpc/register.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 56c038596..42af7b39c 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -652,6 +652,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "walletpassphrasechange", &walletpassphrasechange, true }, { "wallet", "walletpassphrase", &walletpassphrase, true }, { "wallet", "z_listreceivedbyaddress",&z_listreceivedbyaddress,false }, + { "wallet", "z_listreceivedaddress", &z_listreceivedaddress, false }, { "wallet", "z_getbalance", &z_getbalance, false }, { "wallet", "z_gettotalbalance", &z_gettotalbalance, false }, { "wallet", "z_mergetoaddress", &z_mergetoaddress, false }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 6568977d7..37d4a16e9 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush Developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -480,6 +480,7 @@ extern UniValue z_listnullifiers(const UniValue& params, bool fHelp, const CPubK extern UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp extern UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp extern UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp +extern UniValue z_listreceivedaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_getbalance(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp diff --git a/src/rpc/testtransactions.cpp b/src/rpc/testtransactions.cpp index c41e97e10..33a92200d 100644 --- a/src/rpc/testtransactions.cpp +++ b/src/rpc/testtransactions.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 08aba3225..b3f6aecfc 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -66,9 +66,10 @@ void CScheduler::serviceQueue() // Some boost versions have a conflicting overload of wait_until that returns void. // Explicitly use a template here to avoid hitting that overload. - while (!shouldStop() && !taskQueue.empty() && - newTaskScheduled.wait_until<>(lock, taskQueue.begin()->first) != boost::cv_status::timeout) { - // Keep waiting until timeout + while (!shouldStop() && !taskQueue.empty()) { + boost::chrono::system_clock::time_point timeToWaitFor = taskQueue.begin()->first; + if (newTaskScheduled.wait_until<>(lock, timeToWaitFor) == boost::cv_status::timeout) + break; // Exit loop after timeout, it means we reached the time of the event } // If there are multiple threads, the queue can empty while we're waiting (another diff --git a/src/scheduler.h b/src/scheduler.h index af1d7a24c..5faa8f83b 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 64d98d783..21c8d3135 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/interpreter.h b/src/script/interpreter.h index 11812b6e3..f73b26d4d 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/script.cpp b/src/script/script.cpp index 475acdfd5..1ee2a4673 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/script.h b/src/script/script.h index b1294ab25..026771f4f 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/script_error.cpp b/src/script/script_error.cpp index 199161364..6ce0d15b3 100644 --- a/src/script/script_error.cpp +++ b/src/script/script_error.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/script_error.h b/src/script/script_error.h index 85fe1cff3..bd2f6539e 100644 --- a/src/script/script_error.h +++ b/src/script/script_error.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/serverchecker.cpp b/src/script/serverchecker.cpp index 9fc470e14..2d7d393fb 100644 --- a/src/script/serverchecker.cpp +++ b/src/script/serverchecker.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/serverchecker.h b/src/script/serverchecker.h index 08f3acc6c..94cc63cf0 100644 --- a/src/script/serverchecker.h +++ b/src/script/serverchecker.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/sigcache.cpp b/src/script/sigcache.cpp index b78fc3ce3..07a2a686f 100644 --- a/src/script/sigcache.cpp +++ b/src/script/sigcache.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/sigcache.h b/src/script/sigcache.h index e9169eab6..c5a7b7cc6 100644 --- a/src/script/sigcache.h +++ b/src/script/sigcache.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/sign.cpp b/src/script/sign.cpp index d1d24b3d0..32abc327a 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/sign.h b/src/script/sign.h index 4455d4281..468d5019e 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/standard.cpp b/src/script/standard.cpp index d38c0a351..9175b16cc 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/standard.h b/src/script/standard.h index ae7336e2f..b4505932d 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/zcashconsensus.cpp b/src/script/zcashconsensus.cpp index dc4ec7dc1..cea92bbaa 100644 --- a/src/script/zcashconsensus.cpp +++ b/src/script/zcashconsensus.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/zcashconsensus.h b/src/script/zcashconsensus.h index e01a50421..f73e14d5e 100644 --- a/src/script/zcashconsensus.h +++ b/src/script/zcashconsensus.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/secp256k1/contrib/lax_der_parsing.c b/src/secp256k1/contrib/lax_der_parsing.c index 5b141a994..74acf8c4f 100644 --- a/src/secp256k1/contrib/lax_der_parsing.c +++ b/src/secp256k1/contrib/lax_der_parsing.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/contrib/lax_der_parsing.h b/src/secp256k1/contrib/lax_der_parsing.h index 7eaf63bf6..9c5a51fbb 100644 --- a/src/secp256k1/contrib/lax_der_parsing.h +++ b/src/secp256k1/contrib/lax_der_parsing.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /**** diff --git a/src/secp256k1/contrib/lax_der_privatekey_parsing.c b/src/secp256k1/contrib/lax_der_privatekey_parsing.c index c2e63b4b8..3fadba3f4 100644 --- a/src/secp256k1/contrib/lax_der_privatekey_parsing.c +++ b/src/secp256k1/contrib/lax_der_privatekey_parsing.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014, 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/contrib/lax_der_privatekey_parsing.h b/src/secp256k1/contrib/lax_der_privatekey_parsing.h index fece261fb..d5c2e7487 100644 --- a/src/secp256k1/contrib/lax_der_privatekey_parsing.h +++ b/src/secp256k1/contrib/lax_der_privatekey_parsing.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014, 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /**** diff --git a/src/secp256k1/src/asm/field_10x26_arm.s b/src/secp256k1/src/asm/field_10x26_arm.s index 5a9cc3ffc..e2029eb0c 100644 --- a/src/secp256k1/src/asm/field_10x26_arm.s +++ b/src/secp256k1/src/asm/field_10x26_arm.s @@ -2,7 +2,7 @@ /********************************************************************** * Copyright (c) 2014 Wladimir J. van der Laan * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /* ARM implementation of field_10x26 inner loops. diff --git a/src/secp256k1/src/basic-config.h b/src/secp256k1/src/basic-config.h index fc588061c..a9adbda17 100644 --- a/src/secp256k1/src/basic-config.h +++ b/src/secp256k1/src/basic-config.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_BASIC_CONFIG_H diff --git a/src/secp256k1/src/bench.h b/src/secp256k1/src/bench.h index d5ebe0130..c8d038ff3 100644 --- a/src/secp256k1/src/bench.h +++ b/src/secp256k1/src/bench.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_BENCH_H diff --git a/src/secp256k1/src/bench_ecdh.c b/src/secp256k1/src/bench_ecdh.c index 2de5126d6..95c44bb4a 100644 --- a/src/secp256k1/src/bench_ecdh.c +++ b/src/secp256k1/src/bench_ecdh.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/src/bench_internal.c b/src/secp256k1/src/bench_internal.c index 9b30c50d0..cae5f5d7e 100644 --- a/src/secp256k1/src/bench_internal.c +++ b/src/secp256k1/src/bench_internal.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/src/bench_recover.c b/src/secp256k1/src/bench_recover.c index 506fc1880..0288c1c79 100644 --- a/src/secp256k1/src/bench_recover.c +++ b/src/secp256k1/src/bench_recover.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/secp256k1/src/bench_sign.c b/src/secp256k1/src/bench_sign.c index 544b43963..266df9c79 100644 --- a/src/secp256k1/src/bench_sign.c +++ b/src/secp256k1/src/bench_sign.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/secp256k1/src/bench_verify.c b/src/secp256k1/src/bench_verify.c index 418defa0a..3f154ea17 100644 --- a/src/secp256k1/src/bench_verify.c +++ b/src/secp256k1/src/bench_verify.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/src/ecdsa.h b/src/secp256k1/src/ecdsa.h index 80590c7cc..fea457c20 100644 --- a/src/secp256k1/src/ecdsa.h +++ b/src/secp256k1/src/ecdsa.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECDSA_H diff --git a/src/secp256k1/src/ecdsa_impl.h b/src/secp256k1/src/ecdsa_impl.h index c3400042d..a86fb9a44 100644 --- a/src/secp256k1/src/ecdsa_impl.h +++ b/src/secp256k1/src/ecdsa_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ diff --git a/src/secp256k1/src/eckey.h b/src/secp256k1/src/eckey.h index b621f1e6c..913f1215c 100644 --- a/src/secp256k1/src/eckey.h +++ b/src/secp256k1/src/eckey.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECKEY_H diff --git a/src/secp256k1/src/eckey_impl.h b/src/secp256k1/src/eckey_impl.h index 1ab9a68ec..0fccaffc6 100644 --- a/src/secp256k1/src/eckey_impl.h +++ b/src/secp256k1/src/eckey_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECKEY_IMPL_H diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index 3ed2e435a..5f1ddfd2a 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_H @@ -36,7 +36,7 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej /********************************************************************** * Copyright (c) 2013, 2014, 2017 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_H diff --git a/src/secp256k1/src/ecmult_const.h b/src/secp256k1/src/ecmult_const.h index 0d32fa389..166005b96 100644 --- a/src/secp256k1/src/ecmult_const.h +++ b/src/secp256k1/src/ecmult_const.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_H @@ -20,7 +20,7 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_H diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index 28636290d..a12477ec9 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_IMPL_H @@ -246,7 +246,7 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_IMPL_H diff --git a/src/secp256k1/src/ecmult_gen.h b/src/secp256k1/src/ecmult_gen.h index 7564b7015..486feb13e 100644 --- a/src/secp256k1/src/ecmult_gen.h +++ b/src/secp256k1/src/ecmult_gen.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_GEN_H diff --git a/src/secp256k1/src/ecmult_gen_impl.h b/src/secp256k1/src/ecmult_gen_impl.h index 714f02e94..a316e1c2a 100644 --- a/src/secp256k1/src/ecmult_gen_impl.h +++ b/src/secp256k1/src/ecmult_gen_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_GEN_IMPL_H diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index b761304cf..5a45d0ff1 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -4,7 +4,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_IMPL_H @@ -413,7 +413,7 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej /***************************************************************************** * Copyright (c) 2013, 2014, 2017 Pieter Wuille, Andrew Poelstra, Jonas Nick * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php. * + * file COPYING or https://www.opensource.org/licenses/mit-license.php * *****************************************************************************/ #ifndef SECP256K1_ECMULT_IMPL_H diff --git a/src/secp256k1/src/field.h b/src/secp256k1/src/field.h index bb6692ad5..30b6e50f0 100644 --- a/src/secp256k1/src/field.h +++ b/src/secp256k1/src/field.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_H diff --git a/src/secp256k1/src/field_10x26.h b/src/secp256k1/src/field_10x26.h index 727c5267f..c93cd4c86 100644 --- a/src/secp256k1/src/field_10x26.h +++ b/src/secp256k1/src/field_10x26.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_H diff --git a/src/secp256k1/src/field_10x26_impl.h b/src/secp256k1/src/field_10x26_impl.h index 94f8132fc..29799b418 100644 --- a/src/secp256k1/src/field_10x26_impl.h +++ b/src/secp256k1/src/field_10x26_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_IMPL_H diff --git a/src/secp256k1/src/field_5x52.h b/src/secp256k1/src/field_5x52.h index bccd8feb4..e9446b859 100644 --- a/src/secp256k1/src/field_5x52.h +++ b/src/secp256k1/src/field_5x52.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_H diff --git a/src/secp256k1/src/field_5x52_asm_impl.h b/src/secp256k1/src/field_5x52_asm_impl.h index 1fc3171f6..759101d0e 100644 --- a/src/secp256k1/src/field_5x52_asm_impl.h +++ b/src/secp256k1/src/field_5x52_asm_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2014 Diederik Huys, Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /** diff --git a/src/secp256k1/src/field_5x52_impl.h b/src/secp256k1/src/field_5x52_impl.h index 957c61b01..f5dc9dc9d 100644 --- a/src/secp256k1/src/field_5x52_impl.h +++ b/src/secp256k1/src/field_5x52_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_IMPL_H diff --git a/src/secp256k1/src/field_5x52_int128_impl.h b/src/secp256k1/src/field_5x52_int128_impl.h index 95a0d1791..a26fb3c16 100644 --- a/src/secp256k1/src/field_5x52_int128_impl.h +++ b/src/secp256k1/src/field_5x52_int128_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_INNER5X52_IMPL_H diff --git a/src/secp256k1/src/field_impl.h b/src/secp256k1/src/field_impl.h index 20428648a..34827651c 100644 --- a/src/secp256k1/src/field_impl.h +++ b/src/secp256k1/src/field_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_IMPL_H diff --git a/src/secp256k1/src/gen_context.c b/src/secp256k1/src/gen_context.c index 1835fd491..5cd725509 100644 --- a/src/secp256k1/src/gen_context.c +++ b/src/secp256k1/src/gen_context.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Thomas Daede, Cory Fields * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #define USE_BASIC_CONFIG 1 diff --git a/src/secp256k1/src/group.h b/src/secp256k1/src/group.h index ea1302deb..3b8a24883 100644 --- a/src/secp256k1/src/group.h +++ b/src/secp256k1/src/group.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_GROUP_H diff --git a/src/secp256k1/src/group_impl.h b/src/secp256k1/src/group_impl.h index b31b6c12e..de6307c42 100644 --- a/src/secp256k1/src/group_impl.h +++ b/src/secp256k1/src/group_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_GROUP_IMPL_H diff --git a/src/secp256k1/src/hash.h b/src/secp256k1/src/hash.h index de26e4b89..991b38699 100644 --- a/src/secp256k1/src/hash.h +++ b/src/secp256k1/src/hash.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_HASH_H diff --git a/src/secp256k1/src/hash_impl.h b/src/secp256k1/src/hash_impl.h index c06db9e33..1f6dcc317 100644 --- a/src/secp256k1/src/hash_impl.h +++ b/src/secp256k1/src/hash_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_HASH_IMPL_H diff --git a/src/secp256k1/src/modules/ecdh/main_impl.h b/src/secp256k1/src/modules/ecdh/main_impl.h index 74332ba1d..91be6a5d8 100644 --- a/src/secp256k1/src/modules/ecdh/main_impl.h +++ b/src/secp256k1/src/modules/ecdh/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_ECDH_MAIN_H diff --git a/src/secp256k1/src/modules/ecdh/tests_impl.h b/src/secp256k1/src/modules/ecdh/tests_impl.h index 0c53f8ee0..99c400365 100644 --- a/src/secp256k1/src/modules/ecdh/tests_impl.h +++ b/src/secp256k1/src/modules/ecdh/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_ECDH_TESTS_H diff --git a/src/secp256k1/src/modules/musig/example.c b/src/secp256k1/src/modules/musig/example.c index 70d183e7d..ecce75ff2 100644 --- a/src/secp256k1/src/modules/musig/example.c +++ b/src/secp256k1/src/modules/musig/example.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2018 Jonas Nick * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /** diff --git a/src/secp256k1/src/modules/musig/main_impl.h b/src/secp256k1/src/modules/musig/main_impl.h index 8bd2f1831..fee1d084f 100644 --- a/src/secp256k1/src/modules/musig/main_impl.h +++ b/src/secp256k1/src/modules/musig/main_impl.h @@ -2,7 +2,7 @@ /********************************************************************** * Copyright (c) 2018 Andrew Poelstra, Jonas Nick * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_MODULE_MUSIG_MAIN_ diff --git a/src/secp256k1/src/modules/musig/tests_impl.h b/src/secp256k1/src/modules/musig/tests_impl.h index c58ae95af..b45b0be4d 100644 --- a/src/secp256k1/src/modules/musig/tests_impl.h +++ b/src/secp256k1/src/modules/musig/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2018 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_MODULE_MUSIG_TESTS_ diff --git a/src/secp256k1/src/modules/recovery/main_impl.h b/src/secp256k1/src/modules/recovery/main_impl.h index 2f6691c5a..a63903ccb 100755 --- a/src/secp256k1/src/modules/recovery/main_impl.h +++ b/src/secp256k1/src/modules/recovery/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_RECOVERY_MAIN_H diff --git a/src/secp256k1/src/modules/recovery/tests_impl.h b/src/secp256k1/src/modules/recovery/tests_impl.h index 5c9bbe861..de2b0cab3 100644 --- a/src/secp256k1/src/modules/recovery/tests_impl.h +++ b/src/secp256k1/src/modules/recovery/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_RECOVERY_TESTS_H diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index f2b418159..ea98edbf2 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2018 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_MODULE_SCHNORRSIG_MAIN_ diff --git a/src/secp256k1/src/modules/schnorrsig/tests_impl.h b/src/secp256k1/src/modules/schnorrsig/tests_impl.h index de84992a9..9273cf62a 100644 --- a/src/secp256k1/src/modules/schnorrsig/tests_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2018 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_MODULE_SCHNORRSIG_TESTS_ diff --git a/src/secp256k1/src/num.h b/src/secp256k1/src/num.h index 49f2dd791..48cc43488 100644 --- a/src/secp256k1/src/num.h +++ b/src/secp256k1/src/num.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_H diff --git a/src/secp256k1/src/num_gmp.h b/src/secp256k1/src/num_gmp.h index 3619844bd..7c2f3387b 100644 --- a/src/secp256k1/src/num_gmp.h +++ b/src/secp256k1/src/num_gmp.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_REPR_H diff --git a/src/secp256k1/src/num_gmp_impl.h b/src/secp256k1/src/num_gmp_impl.h index 0ae2a8ba0..a18ecb969 100644 --- a/src/secp256k1/src/num_gmp_impl.h +++ b/src/secp256k1/src/num_gmp_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_REPR_IMPL_H diff --git a/src/secp256k1/src/num_impl.h b/src/secp256k1/src/num_impl.h index c45193b03..1ed66335b 100644 --- a/src/secp256k1/src/num_impl.h +++ b/src/secp256k1/src/num_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_IMPL_H diff --git a/src/secp256k1/src/scalar.h b/src/secp256k1/src/scalar.h index d83ccc22a..ca388eefe 100644 --- a/src/secp256k1/src/scalar.h +++ b/src/secp256k1/src/scalar.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_H @@ -112,7 +112,7 @@ static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_H diff --git a/src/secp256k1/src/scalar_4x64.h b/src/secp256k1/src/scalar_4x64.h index 68096f2a9..82ecaf20e 100644 --- a/src/secp256k1/src/scalar_4x64.h +++ b/src/secp256k1/src/scalar_4x64.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H @@ -24,7 +24,7 @@ typedef struct { /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h index 04f1da85d..a3c8cdcab 100644 --- a/src/secp256k1/src/scalar_4x64_impl.h +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H @@ -955,7 +955,7 @@ SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/secp256k1/src/scalar_8x32.h b/src/secp256k1/src/scalar_8x32.h index 8a630ac40..fc548d1b2 100644 --- a/src/secp256k1/src/scalar_8x32.h +++ b/src/secp256k1/src/scalar_8x32.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H @@ -24,7 +24,7 @@ typedef struct { /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/secp256k1/src/scalar_8x32_impl.h b/src/secp256k1/src/scalar_8x32_impl.h index f1429b162..381bec319 100644 --- a/src/secp256k1/src/scalar_8x32_impl.h +++ b/src/secp256k1/src/scalar_8x32_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H @@ -726,7 +726,7 @@ SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/secp256k1/src/scalar_impl.h b/src/secp256k1/src/scalar_impl.h index d69a94880..e6205339b 100644 --- a/src/secp256k1/src/scalar_impl.h +++ b/src/secp256k1/src/scalar_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_IMPL_H @@ -339,7 +339,7 @@ static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_IMPL_H diff --git a/src/secp256k1/src/scalar_low.h b/src/secp256k1/src/scalar_low.h index 16b167f9c..0c7823ce7 100644 --- a/src/secp256k1/src/scalar_low.h +++ b/src/secp256k1/src/scalar_low.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H @@ -20,7 +20,7 @@ typedef uint32_t secp256k1_scalar; /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/secp256k1/src/scalar_low_impl.h b/src/secp256k1/src/scalar_low_impl.h index 956cccd04..1bd50279e 100644 --- a/src/secp256k1/src/scalar_low_impl.h +++ b/src/secp256k1/src/scalar_low_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H @@ -119,7 +119,7 @@ SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/secp256k1/src/scratch.h b/src/secp256k1/src/scratch.h index 04faa9f0a..85f9faf40 100644 --- a/src/secp256k1/src/scratch.h +++ b/src/secp256k1/src/scratch.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2017 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_SCRATCH_ diff --git a/src/secp256k1/src/scratch_impl.h b/src/secp256k1/src/scratch_impl.h index 1ce3ff9b0..677d90ce0 100644 --- a/src/secp256k1/src/scratch_impl.h +++ b/src/secp256k1/src/scratch_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2017 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_SCRATCH_IMPL_H_ diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 7861a5f79..3b627b3e9 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "../include/secp256k1.h" diff --git a/src/secp256k1/src/testrand.h b/src/secp256k1/src/testrand.h index f1f9be077..7b1acd16a 100644 --- a/src/secp256k1/src/testrand.h +++ b/src/secp256k1/src/testrand.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_TESTRAND_H diff --git a/src/secp256k1/src/testrand_impl.h b/src/secp256k1/src/testrand_impl.h index 30a91e529..bcdbd149c 100644 --- a/src/secp256k1/src/testrand_impl.h +++ b/src/secp256k1/src/testrand_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_TESTRAND_IMPL_H diff --git a/src/secp256k1/src/tests.c b/src/secp256k1/src/tests.c index 345fb0bdf..ab02e88cc 100644 --- a/src/secp256k1/src/tests.c +++ b/src/secp256k1/src/tests.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #if defined HAVE_CONFIG_H diff --git a/src/secp256k1/src/tests_exhaustive.c b/src/secp256k1/src/tests_exhaustive.c index 1e58c3b5f..4f6959382 100644 --- a/src/secp256k1/src/tests_exhaustive.c +++ b/src/secp256k1/src/tests_exhaustive.c @@ -1,7 +1,7 @@ /*********************************************************************** * Copyright (c) 2016 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #if defined HAVE_CONFIG_H diff --git a/src/secp256k1/src/util.h b/src/secp256k1/src/util.h index b0441d8e3..617d5701d 100644 --- a/src/secp256k1/src/util.h +++ b/src/secp256k1/src/util.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_UTIL_H diff --git a/src/sendalert.cpp b/src/sendalert.cpp index 7b8ca4589..b626f5b05 100644 --- a/src/sendalert.cpp +++ b/src/sendalert.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2016 The Zcash developers // Original code from: https://gist.github.com/laanwj/0e689cfa37b52bcbbb44 @@ -74,9 +75,9 @@ void ThreadSendAlert() if (!mapArgs.count("-sendalert") && !mapArgs.count("-printalert")) return; + //TODO: wait until KOMODO_IN_SYNC MilliSleep(60*1000); // Wait a minute so we get connected - // // Alerts are relayed around the network until nRelayUntil, flood // filling to every node. // After the relay time is past, new nodes are told about alerts @@ -87,7 +88,7 @@ void ThreadSendAlert() CAlert alert; alert.nRelayUntil = GetTime() + 15 * 60; alert.nExpiration = GetTime() + 10 * 365 * 24 * 60 * 60; - alert.nID = 1005; // use https://github.com/zcash/zcash/wiki/specification#assigned-numbers to keep track of alert IDs + alert.nID = 1005; // HUSH3 has never had any alert id's alert.nCancel = 1004; // cancels previous messages up to this ID number // These versions are protocol versions @@ -103,12 +104,12 @@ void ThreadSendAlert() // 4000 or higher will put the RPC into safe mode alert.nPriority = 4000; alert.strComment = ""; - alert.strStatusBar = "Your client version has degraded networking behavior. Please update to the most recent version of Hush (3.2.0 or later)."; + alert.strStatusBar = "Your client version has degraded networking behavior. Please update to the most recent version of Hush (3.5.0 or later)."; alert.strRPCError = alert.strStatusBar; // Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done: // alert.setSubVer.insert(std::string("/MagicBean:0.7.2/")); - const std::vector useragents = {}; //{"MagicBean", "BeanStalk", "AppleSeed", "EleosZcash"}; + const std::vector useragents = {}; //{"MagicBean", "BeanStalk", "AppleSeed" }; BOOST_FOREACH(const std::string& useragent, useragents) { } diff --git a/src/serialize.h b/src/serialize.h index 9d23b469c..d68752a98 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2009-2014 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/sietch.h b/src/sietch.h index 64a4fe0ce..d68716bb1 100644 --- a/src/sietch.h +++ b/src/sietch.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright © 2019-2020 The Hush developers * + * Copyright © 2019-2020 The Hush developers * * * * See the AUTHORS and LICENSE files at * * the top-level directory of this distribution for the individual copyright * @@ -10,228 +10,39 @@ * or distributed except according to the terms contained in the GPLv3 * * * * Removal or modification of this copyright notice is prohibited. * + * https://myhush.org * * * ******************************************************************************/ #ifndef SIETCH_H #define SIETCH_H -// The network essentially DoS's these addresses and reduces their privacy slightly -// by making them public, but in return, the rest of the shielded pool benefits -// and so it's a large benefit for a small cost. -string randomSietchZaddr() { - std::vector SietchShieldedPool1 = { - "zs1qqj4aw35ku9yn72g3tha588mxk66mhl5smnn99as40887xvdg49d4yqf43hhqnj9rpsq7qaqqhx", - "zs1qywzq2cutvg6rkynjljtssz246easagumg3hlwjluz4g7qttg9kqrld7s43ewutpph56jmn2zu6", - "zs1qx7swmw28dj992f6zs0aqucds9kag88mnca5u73dddeqek4m97pg7h9qsaxxwwkgqxht6zujaxc", - "zs1q82pkqu58uemrm2749x6g2ta5shnsra9p5jgk0qqzxd3e08ke6vyeezz7lhldj32jxtsuemskk7", - "zs1qvah5w05qq4yhrsqrt73ckgntkmwdv9mntxep8clnxqfph8xggqad96a5nvwg4evfr9pc5ruvc8", - "zs1qwrkjcmnrwrqqkz3dyfjvdvdppe0ndnm8fhhpsz8stje4qcfc54jtuygz2jfwc3aag69wsjcm8h", - "zs1q5pd7h4x7dtnpa4ace7tytye5sd0j4043t4f3jdntyxvg9ex258nu6pw9tthn6t5gmjq5gv0lhc", - "zs1q6vjrpsuf468an545q7fh9cx0xlkwh75a7qjpemjh3ymuqqzxz5ts2n2dcth3yfnlv6vqpjyglr", - "zs1qmsvwtxkwlh3tkh0lqtwqv2mxy94jt778f7j74a8067nejkt4j3m2rkmypccju7cfuw7xyg0gg8", - "zs1qu3jxrw5qwuvl7zfvnsdvywr4a9cn4h00me65te29platx5agek072f5rvxgt8kdt630qs4tgtr", - "zs1qamxwddwrl5xn56alffruk69p304cqf7uf5nhqpwfc374l9ph00m78xv2kzwymyz0fhxcku7v5k", - "zs1q7gv479e6q7d8fxc35v5s27em66mmm5gz50excudf95rzjgnwdy5pnwdfytvm7gt8kt6wpkfphq", - "zs1pqvxd9a2zcsh2v8gaswh3jp2qkzz5umrucl5k4gx0rkvmq68krpx3jesavxftd8t0z56v8whllj", - "zs1ppn2mdznaa2pd9mavfnxrcjtv0c9un8pg6jaa9ww4wy6wdfs8xxwquqk5umtcjwm6vr4zrqy5x7", - "zs1pz9c9ydyrm7e876cvae9ha45ww77ru5fhys2yz33kjy8ej9230wjy8yupfxkynwqr6nfupgmf94", - "zs1p83g95avpsgr847eu3rm3xcmgurt9hc77wtndnmpypa046n529aqdc9ptz04ugsuhvum2ztzwe3", - "zs1p83jle2p8awu4peevq389y5kyrs5tqxxyrk32zy0t98d4cfepmme0myxp68nrq60xwzc5teulvg", - "zs1pg5ggzwx4yaa7g83yuhay8kzh78nahxfe7cgavn88f7rxlnuckhl2vznv0f33yuqhhs3sh62vl6", - "zs1p2nrefmqfhnwrxqfsz4ruvu8wl7742j5rv2fmwlpmpudwqpdn2yrha9rwsu5gc0fdv2j73tfk6a", - "zs1pw29hkrvszxpe2e4tjpj5h9pszjhql2p4tzcj2c5lf67m7d8jtgc22vehftxdnqze33mgtjc25k", - "zs1p0ggg024alu2l5x8df8ucu4lz8r453su56w2mmshru49uh9a0p6ufy3qfj8a9n7xeu8dxxjrk4p", - "zs1psaydszvszu4mar7ef9gk8atmwpnfjjsh8plajn6ttlgdk44jfud5zv8l3uyq73qk3eskec96ut", - "zs1pjf3kczvrwduuy4x99t03wfrgwstueyw0ypvwa44fz2tukux8kqqqs48uag4y39ed4rux8etvv0", - "zs1pnwzzh4mhehkvf4ys9x70q6meq9mgqj6mgl9ddzwvf8excswrj54lfgu4m9slmc90s37q8e63du", - "zs1pnndevupuakjcqyqzu4sfcgdmdzrhutp8ygxwsl5wvq5hgu20u55auu8p08wphvz9mu3k8ynyr5", - "zs1pmy6tvt9p3xxp5edt70mkwfqk0ljgaranzdnluh5ln36g9g3v2udquleuz5974q2mamywmrxl7j", - "zs1pau6lddk3uapms7v7rsmxvxeekqh52z795kzy9z3dv9qvzq3jwh4pr2adg5cf8fw2e3mzqmgstq", - "zs1zpy6wuvy3jlrfmj0363tx6cuume6j0mqfakk7ydw4f6zvn4s7plewk0gtm7r34pjtppvkp8rzl0", - "zs1zpvkccety206ww6c344ehughuyklc3v02q07j4p72pqewxl0n50zugtje6lclj3m292t6vs56fl", - "zs1zzucdg9kalcjnnknt98gpg42qm9aqpkc6qf5ewgr29udu55r0zt862z3zt23sd4mj9t47k7k6w4", - "zs1z9agq4vq7eswwynhmzdsy58nxq3azhn66y853yw9kvercmve8vv6d5pawpwwpwpuyedmzpcqk8q", - "zs1zvddl2e0pve5kl0hu7fcum30lyhx4pdq64jztq2vp09lqtu5gclfg4fe9fqvnm8k2d5svydg7s4", - "zs1zvsmkn6a4celtcg8ece6exnkvnr2u06ej8kjt6mrpm0983e86dr9al6gd5g73k24j0a0zkpjs3w", - "zs1zv33kglx4n5572dg2pez2k3m7tgtz08a70ndpfj6x204pphlm0pzcppetsnjlat3qflswqfmu83", - "zs1zsz5c9xua7arkvd60vsl559d4dvnjz8ejq4rlmmm9cnz942fdmjmvsgrdl7d5ddxh4y9258jk2l", - "zs1z5n6qvch0wfymumxjflezekxa2j5t978eqzh9ldxsl39h2jjrlzdv9rf00wdrvg0t6afq7mq0us", - "zs1z4ymm3gt22f3pcj9p9l2yg00e2m39kfexgaz99s9y4nsuxhlk6u0sl9lsx9awzywumxyuxv9vuw", - "zs1zkjnhz96xepc97rfyven23epymd5s558yqhp488gcxcj794z6p37h5ej5m5waqxfupmc538mej3", - "zs1zcqdekyq656yj2y86lh08u8zpetfanj5u4rhfpcphne9xw7esce8asux2rdr4yjxzds56fuda5r", - "zs1zceru3jt9m3jqzacnffetvrg8zch6le0zactl7ssfky2vwy7pcffkg3pmauqqpkv5v7nv3uzc5a", - "zs1zellp4tdmxdsd6hmg2c4qlx96m39c0cjlqupw085z87lvzcnx2r0gs7plc0wp4m4upk3zcs35e8", - "zs1zm2pcg2d3hnyxufn8cyshjn742gmffwaqdc0nt5uf9gsytdjywsqaasfdxf4sysfu0sgxjwjp0g", - "zs1za9nk7fpgnfetjulq6t8jgfyks06xg4q8rfwpgsfrkn49k34nc7xhm27dnjuzztgnwkww28ztyw", - "zs1zaaz6j6z7z748mck4v55s3fd4htl4f478kulnwr84m8vn4m0r227juddyq0ncu3cyvc765z9gm4", - "zs1zlz59lgwc8pqq33508v5ygk9e58f7fs4rpj3achhwnkcyn2dku44yfjghdf5l2v50nu2gjzgl2l", - "zs1zlgenma0yuqxmqgns2avpnauclxgfvgd6rf0jt09fmfyaflwlhsscem9ypmrvewl9l356dn3jtr", - "zs1rzu2yg2328l2wlfstu27dl024ucqsjx6g635yxmyhs0wr3lduutkc3peuhqe83uueh5n5q624rd", - "zs1rr9jpeemn9ek30x4h65rx0ddul7xet6cc8atwrjftmq9sdrvj9f5zdc9xg7amtc6dv5fxjyhu54", - "zs1rrgccr0yvfn5fdek39x09y2ylyf42xkydcwzq67wdrzyjj2mv874easa4h4tymz5gj852aqpffk", - "zs1rynh7vl05weafzwkp0p5eafuzzqph04prgg74emqq0sx6xudtrs2380v3ycxgp5lzudw6tmc2zd", - "zs1rxqz0a59zx3yduncc3azyzexwu8xl6cc0zu83hfd28mksrgahhvx8604uhf0u5mna9m4znnj4gr", - "zs1rxr2xff2vcv0y9s6ux6c6t9y7r3zvcvrqmwkvsnxj39t0qv7qwyhncnykhzcqg0ggpu423ykzxe", - "zs1r8chvye5uzlskv8jvt6j8nxnyz4lshy3u46yjhc8w9ekhjhneg402knft3t943t5nrhs6d0d5um", - "zs1rgu6mz58xrqxpyl5xw7ss2szz29cg98s8xl25hu7fy4lcxw58zr93a8rgyha52vwxx7hxj2emkw", - "zs1rveutz8ftruljrlctum42kakjqk4cm8dm2807nqm974dz0rptlxcs999ttsvwp65vc9e59vv9fe", - "zs1rwfqhlezm5ln7kq8wp8hkl08ddn74ryr8cs4cu8qc23spdx79xgfqj4lju4u2yqdrkxkwfvk3ed", - "zs1rwklllsk9jwhhf0fedvlzsqfqdkwer05zh8c8hwypl4tls2hdal54lexhca7kghhum5hycurvfe", - "zs1r0ulehrcg9xz0lfdcukjm3qlvqy74t0u8raqf4zn88vdsta8mzp8t8p9ul8jragssvs9qaqpw2e", - "zs1r3t0cve050wufwl8r2tly05vn7w79v53fe6dagjtt2ese0qm6vgjp3rrsfu4n0am840sq5thn72", - "zs1rnd8zwan2xlrnfwylm9khkeutnzg2v9vjdnyellyuzkwmed94uvd2dq8ceumxwspz037zp2ctqa", - "zs1r4tphfnf3zy34dqyjuld2kgtyg88hrxpv756pkkkmrfdeun0cqzpepac4ma9qrjrvdqxg2z5fuv", - "zs1rcpywy0v4sfej85wdaslfwsp4pe9sa87xgzv24ywhps2l4c9jlrqttv0wl9zkc5e7rsekf42wvp", - "zs1r66et0z9xw3qqhzyc2aht294y7yqyz8wx2l2t63unca4k4zh4v9t44kpmg52z9va5968y45fdkx", - "zs1rat3szdulwxwmx7y4rdphvlpjj5phadvz0fsvj7mtg9ggzwd22sn30hzsh27h7t6cvca6a8wu2n", - "zs1rau4jcth66jsg098ucclp9tfa5qe6jmtmfkcluaqnyj3uatkt9dsrgx44xtmxr3e9xuxv6sy208", - "zs1ypf2v2yu4p4mnlmw0wd3mpztpjlhl39jnn6hkvf77ell0h5u6yg2pgeusvku5y5sykyy6kk6yyh", - "zs1yzkt8catgk6slwj7azu79tvwv6tkd6agcykvvht4rxlevtsh99u036jf5503pju3h05w7x02cm8", - "zs1yrty5fmnyaartpcyjnpal0w44g4mt2ey5tyzcmgq4g6qtsfjmxae7fvy2zsw7t0zvseuwcfwt2e", - "zs1y9p5gazcx04kke96xudep0edzkqr06gdjnr5vm99a6qxzatqz5katput4q9nx95e8965sg7d3pl", - "zs1y9vpfgkxwh3xm3j9d38zkeqql2lh8w3ucgerkww2asdv89p87emdavkzurnqpkrmu7e3xv5myue", - "zs1yfa9gwmn0xe4myrg0rf8kmu36243u8773ukeev0set2yv0z9vpxm6ratee52e9zmpvvx7w2xy28", - "zs1ytpjrujfsgs69smqerxeaf8m38jwxc4ejgxxe4pzc5qu4auqrgy8tf7zxc402pxf9uku646kc0q", - "zs1ytvtdwmcn8tnka6w6wa8n3ghnkf7gp2qaudd4233y6m509ntm59rr0n8eudhre0md7m0zedpcsq", - "zs1yjmeu09mzrt8rgehv2gcfhxx6ddqz7ww87ssfapndvc94hxfrfsdkkgm8f8nr36xm8p7q462qy2", - "zs1ynqghdu0r0c20csp3ygrxdw9hk2l89j3g59q8zhht9jyxycpcc9ccvhyyn2f9j0ehp4pk5wkhqs", - "zs1y5ny4jpjm05vp5awjd6muaqqypdv0y9tr6pz0m5t82cwtrearxwf7km4aznydpcjeuzxqvk0z9m", - "zs1yh2vd5usfsyv4pscjrxg9wdy3gnnyuh8vky27ln3u9jspadmpqsjmyvxmvfyyq3nv4deudvygxa", - "zs1yclvhy57hngs7d233e4x8ywfreswslz2gvn0f8epcs0wrzuqqau3hkrvf7ru6jhh0zmsyn5jkj6", - "zs1yunkgwzf0m5suz380j7xqge6rd9e6acjc5wp22z0jhalqdpspdjey7jfjvgrckgsk9ydc9yrnq3", - "zs19p94fnry6p88ms3yh60nl4kxlxmu7uxv9aafmf5pc4nyd64vslaqgmj30nxe3l5j7cxu5kqeqpm", - "zs19x2df6qmd4c9whrgj6m4mssz22x9qj9x8lmcnexnhw32pey24xy9sws5ts2q7guunm7mx9wmllj", - "zs198a984na6qt2z3uyhdkmj7sfevt794dl3mum3782kddjy4uawr2teznpuxvnzc4dvs3c6zyqxey", - "zs192ld62azpypesveqsat6m63sqaw95ejlqfcjsal5t0fea9zjzqnurmpnl6074zdms0amw83rw0x", - "zs19vsx09xmzlj9vr3s3vu8z4237gpcgrl7qs0vapzzawgnu7gxngeaxlgwqf0ppu0f7us9cfe3cqz", - "zs19wfwd8zufu27zugan77wf2g790egdw7vkulf6f375ylq0arnv2nv94l84nl8lp3tpccv763wetn", - "zs19wcqtqqjj0mnrn90ntcmyq5x8qr2wsaslqwt0fysz4xh2mmjy0z9jjh4sj86sjrgen0axx04zt4", - "zs19jypvpjpvhv5et5wq2ny09skt72hxz9adfgk2ev7nza5jyxr6gss5qelygnxn0szmjqyke2h8a7", - "zs195kll03d43her83a65y7z0zsetynlnft4pjxdspegvun0m7cwtx0vsxfm89mv50vxr90qhvcqpz", - "zs195e2g52jpyly7t9vjpfcegt87g7lpa4rm74nxn0zvmtzjhvg7f5gjnskc5ax5skvwprcshenyqs", - "zs194e84mfxc4vn4ssce7hkvgrcm3c8j7vehcetkdf78rele2lwkx9tzcfnrwhykdqa2nmwx5qcr0j", - "zs19cxqspj63ksk6uwtynj0la72zuvh8rxfh0e0pr2y5vuuvw35sm78juzh5gxcuqa8jggv703rplf", - "zs19e04k24qrca0sx5z47dxmtx0swcx2ywxqjt5594gu95rjaeyxrpa2vyylvzxpau5spt2v529me6", - "zs19707gmdvc4hfwg4lgvxg55695gltx3jwye8l2gjekrx4zqz7yr6grq8s8hpfqwggrywx509ln5y", - "zs1xrw8nwla7yrz8l3d7y3rxlhamel2ly4kdmxlc6w4cztxhd6l8wufqv2pcsvtl3d7s6awvjatyx9", - "zs1xymrgyhle6dcvjk5f62k4xygr0vrr2wckqy7sp6wc6cttn29hra77dzhwxst7z9rxqxkz08jd7g", - "zs1x9c8tetxgauxh474hlhnlscuhgzww8vnvxfwm0p8589x73t5yl2fph8q8r8qpl8sh0wfwx0vg62", - "zs1xxcpzsfpyekhvvum3erxjpt34pw3h70ma8vxwecg85tze380f4srlg8zlgxty8yqhutt234nk9q", - "zs1xx6pd3vtj78tg0zpwtc0jjkdxlfy48vegzd6cng4m9w0gtcya8ck7pqgf4l5sxf9ml5zvzru5xg", - "zs1x8qre6x5d8e3tt2m4l9q2tujw8ajun70qelp8tfynyw390rm6vhjtmpf58dmx4hccef9xe50az0", - "zs1x88vjduckqarz2j8tp2me08ya4dgd6pw7j4j98j5jynrze3xy2jjptzye7eftjxd6dn4sj03v7m", - }; +string newSietchZaddr() { + bool addToWallet = false; + auto zaddr = EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey(addToWallet)); + return zaddr; +} - std::vector SietchShieldedPool2 = { - "zs1ehrs7hetemzsmfz9xwt8xetxag33j3xzj8mhdgywdnvkk4dmtvw6eqys6gm3vr679y865jz7rth", - "zs1ehyr6w0c4mwp0wlp6w5letgm3rjk32rxa9kkkur86e5x8lutr9mwzey0hsesnz0yaarmxra7w2z", - "zs1ec793pjf3anee0qq9ex5u2qygjzk9llmwfygev563l89quc3u8wxvtz9kctlmv2dtjgqwn7krcg", - "zs1eclpgnqy7qll0l5z0gy7m4ew86yjvp397yxyau9y2y43x5mqfdw2sll95l83ux6h8mppzsx3xnp", - "zs1eexedkctuzhjysl00m0j3ekknd32635yd8rejx9ykjp6zz77fyzf5388env642ja2qlg6mrwgsc", - "zs1e77uz8yaj998arp56d0fm4p827wchlf2w09hve6rgkmavhzeyhke8qsk3l7s5k6yh2jwjheqpup", - "zs1elj4qvy42jpts2cu22tcwt0kmwzafpmrjgztwf2xcqaycrlr4rpfxfpswx63e6agvhz96gps9yf", - "zs16q0fzcvf25fh70ysn38v7qkpfspakmelnljgnyrpu7rvllyew57n5cpqjqe0wmy5j57au47j6x8", - "zs16pnkw3mucdef34jjk6q28zd7ghhatdcqn598vs3g70qev234uc5uw6xxxjnzef3pt2t567qev8v", - "zs16rmnl4hd6c226u3v6eekk68y59u0x7v37n8pmytt9xw6drugjml7ryhd243nf3l2pvafw42rnxc", - "zs16ruwvwmetmnnns0rxwtx2kss23da2pccares0tehzw3v3nxd483qn49c9apdfua0hpm8xdecdt4", - "zs16ymafsjd7fp9zdl9vtyvfedecvn7q2vcs7emeglwy7hpuphve97d3j87v2evqs0xm3jrx44nwfe", - "zs1697ggm9zqp4rh0fv4r9hnh9uy6gg4hk7r2lm33tp2we4ry5azpxq6nwuzscha0g2nx03x4sstq8", - "zs168t8u6at9k6kt748dv749dxahnk8rv8yn32z8gcgvc9rkhkewscgu8r8vuzv0zecnq26w9p7x0c", - "zs16gnyx6f8vql24cepamfquhr3jjt7wgmzjcvwtct4lwy9p2studln6ut9kjzf6empwqjtxqmddqy", - "zs1622ra8snywvxufsunk97pccr7k0j32p960evl9yqjadhju22m4sk48md84q5u238gej8xnm4xm5", - "zs162stv8m0udzy4c6ff5kqva2g7pqth2rrdn7rjjgw29dcx7lj3vs4dnj8fz0gczsat3u3q5axgva", - "zs16t78376h9ledgt50k2dmwssuhyy4hn94wfgd8vzegvqy9k9kauuvpe8xz0f3va65l8ufqhgv4gv", - "zs16vxrghgv7mth6k9unzdude9cyt9vl76ms5hm9ce4py92rk69j4p9u570974nh8kqh8e2stqknj5", - "zs1654eafn589g2ujzcasa8caz8exag742tra2dd6mjkp22axh27hda6sy9exh3wkp4c6f5vztafr0", - "zs164u3ntsnn7s3zrp6c5gsqfrwr0ywhspynvunq3fhvr9crwz5eme706j5awwvuatqwh7m2qqkqm9", - "zs16cpqwm4yml5x8j5r3q5j0xljam68pf56xt40hylzn69w45venwdvd4h8drys5t380mspkvt7h8r", - "zs16c6m9aqs0q9kadm4nk6hugmqw6p0lf2h6v5d9ccwszssyecq35sm6284c3uqx2u40da4s2mr2ap", - "zs16u7rc066566j9ux73dcq0m7cq4qdmtd3gefrnhhrpjww3z00j4za7m5mcutmj6qcezkzys87mpp", - "zs1673rm5d5z9sh2k9uc2cvgwk2e44z0sekx6ezt9n4fvgnky5yxa2tc306dw7n2dg5vwfn7ppwr5s", - "zs167nvq5ahvu4s26447rem9j37qglgtle4fghsgpksumkz34g2q9x783pak5jgdhhzylmgs9wemg8", - "zs16lluayez28xevxg0rawxxcd7yx5t7qaraet256sxe8ac69lj7n7ppncsx3m2tddxlzptzyxv0qr", - "zs1mydlmczamey4ydc79n8gj5wtgs79zge4nwhcg8g640r6fvwu6wpt70970p7ptkcrzg6r6frqh0u", - "zs1my6tgqmy3kgdlqncyd5dv9s727x9hcrmj8h06e5whn4hkn5t2x46j84276yd8pw0p6ysx53u38u", - "zs1mte528eue8smvjwpe9cs8qz3wud9735rnk7vrtefu9lhyvh5pyeyenpaq5fa08jpwrl4x7sz069", - "zs1mvmu20syf3u5yzd6hpdd29xfej8237x2k0pcmf7pvra46qem5g0jralrmdcvncgf5j0y5varzr2", - "zs1mw86y6g2c8972a2ndw57648p9qcx2jppxr9g5k24df8hl3rgfzfsfe2xyesemdfmasutk88duht", - "zs1mwca7dqjq0r2mzmn4qarw8acmt4rjk26lyyar35sssqe2fky2nmv3kmf0lfxs2a9htugsadg027", - "zs1m0rpcrkfagzpex9mlw2htyrwpxe48v47pj8zg96l9wm5k8xkj3kev3xca6wumv5avkgsjtygush", - "zs1mjgyju3jnyxjhekv72y448edq3j2cvtk5s4wrej790zzpv3uc20dvewt7nhjdqryuecmykfm0je", - "zs1mjlfwyma3fv45yg50j73wcswnap2s4lsh5c9km6lcem73wky9lej7vy8wrlkr75sy6z2g0agtmw", - "zs1mkh9s9gdfxx4dkug47dqnc98g76dhm09zty779pm6gqc5aye4gvxvduqm5j56nq4lncx5ygqu90", - "zs1mm7tesf30r56l8xmnxjyxvgmnsny2zntsxahllrd930q8ycahz8npdxt7lqwu3k8ljs9sw7uzs8", - "zs1mu34v9wtyhtlr22phfxkp670wt0gj4z8czumx0m4u05elg7kjzu0dzveq5jn28xg5a2wqr6cywd", - "zs1ma3xy4fj0vm0w37a4kur3ghe72f8nstmqmmvh0u48kurtlwg50rqqlw39j6ng8lrxgam2dh0zyr", - "zs1m7yauj7694wjz92m5sxds8udp43z6kclarqwzc22wn2q6svkkk4lpzx53kwctwfn6jqcu4yww5u", - "zs1m77qqksfvuqmjmwdm22xr2u99z3uz4glenk02md4tq5z066gc7jkdayhf2txspqggv29quacpy4", - "zs1uq88d69zrnksytnquejpksdvdlp9e5y3xec3eyf0rrya8zap623zpwjs5mfzadrp7twawkpennl", - "zs1uq0zzag2cmekwn9a35vkf2q45sary5v8nt2adukhej9ydq3qpegskg5naysl3wvvxtzuyv5lu8w", - "zs1uqs3n3j8kfgurz8tj0ea5g2ny200c69rwwpq50kkup8sxntdne6h9uhx3wc2y5jjkcggvpvcl4g", - "zs1uqmnl793xh4cskxjherwlpt7xfnt6fy2sp2l3n58hpmd4msj2g3fjsks02069tqgzzvn77mpfg7", - "zs1uz73f8arfahrvgtxcjwya33ql5w8mwkmyrvxvjrjx5rla07hv3ax49hkeqg3aqynxx39z4y4vtt", - "zs1urzuwedq4qgnqjsjwjeauzyyjwxvs27mau6zmpretn37my92h3jqc0waad4r8s7zeeczq6jfas6", - "zs1urfls60sjxpnla4hhe736qu54w7047akw2p9cksx054y8e8gdyknkhwv6spwzgstf7z2wrsdapw", - "zs1u9jum0rl3959ay3qqxskkak5emv0fpceuhuhcj9rnkzfy6gpe2uv6ny29c399nrc68fx6fffg6c", - "zs1u8fdxg8lu08p6s5z9qe6jf6fkvd74a99yg3n5exlm6wm8paypygy82ue2smf0qqlhdhjzy2jxq4", - "zs1u8u44rlv4ay27248807fqwyf6lw2w76v8evn26nvwv887caqlenjgsw0nqlajzw9equn7phhs95", - "zs1u4jhx25fghqzn2az7he7lrv7xj23xd8spcl660g9kzqa3wyykm5gucuu5wwxvum6l6spq4u4e5s", - "zs1uh85d43vr4wwqnq6e7akxtlwkzx2y8cmdm3wrxzj6m42pzj3xs2heqey79hgxrhwhapwu8tt73g", - "zs1uhwgwkg2y3xex7e34dvnx97d0jdnhmchevcvg54tg4dg00ay9sjucr82py4jqx0kkf7cz5dytad", - "zs1uhkhsv3c3m5r8z7unmceg4zln6edwfr25wjauv5u8fxdqhdflj7vuc2xnkm9028y802w2pyf07g", - "zs1uhuwuzu89j05p9y48nseklu7gfhw4mrwv68f9s66csafrkpsmpsh23zzgxm24nspmsgrvtpttzg", - "zs1ucetuz8ysvz42uvuwndjfnphrtsfgekgef228meuhfrqtm97gql87rsvhxmxplw2xmj27p9jemj", - "zs1ucm95fgyy72rf6x5rwl5m5pldt38lulzqf9ueepel4gvd4cqjhk8xrf4kvl2lnn5ge9fwyfrfva", - "zs1um3pu2u0eu0zpx4czj9dufvxnud2zd0x5lygepp6maz96j572r6mh8gpmlm3w6jhmxxz2sepdfh", - "zs1ulkw8j488xuhhlewedj9dr7atm5jatmlwsxz83lquhz42ln78utqmtqsmhagcquq6uqszk23g9d", - "zs1az03j8f46n2600z47xnf5y28j34rpxljh3j6w5p3xgsmqt2fuklmhyd383aljxf4mx4pcfv0xm8", - "zs1ayal4wq4crwj70u6hae82h6r4jpk7ptycfhs9v5y83lxc7u4gadegu2r5ggsgt95n0rjk284fzj", - "zs1a984wux9sr2594lr24yal43zq6pstczyevj7yr8pn403643zuge88ekrc0cj8n2fk6z6xrxjpsz", - "zs1a95ptq9d6nauwtvgdj2lnct9y6g4cmm258jzyuqhsk4m3gqmaz62t4klqe42eu83n27jcpgz0ed", - "zs1a8xdhdzpjqx0alrjg43enszjnf6nn6nhf6c3xd77ecrvp4kfarvux4u4lcttv3rgyhmgzxukw2q", - "zs1afqnaljmvzunvjhr3m8yf2g4r0pe66kkxkm6ldjhylyjfsclk3nf88u29pskdqx76szdz48tt3m", - "zs1avx0j6mrcqrhp9903xrysptm6gefcyv6uqltta92hsgjpp2f8h8rz8suwxgjkp2f8366y6n6dj8", - "zs1a036amk3q8azryytah2zpdhyazeruq2q7zq2c06l0845kl0v2rmg0h8cdjvta4alxj0my4kcfad", - "zs1ahy2sja2ala03wrc79xx2ks3ujxxnsm44uh6yucmy5p5l0xcfa3g90cdgs4l9rhy975zvd4uzts", - "zs1aeyqta7xs8edzq2c0z6e9v3vjep55e4lg9fp9ls6d55x2mel6snxud6kqcaz8nl7zgrxxj96d6a", - "zs1aap3thj9xna07vlg3yz389c34v9mgd06g234d3htyq667286phjsf98nndm8frts7frmcyjfa90", - "zs17qdqrdgwcafkpgchc4rvk22e4u86alhnmzne5xzantpecwrxf3c6jxqk7xgzanzjj4kmxd2tuwg", - "zs17z3fmn6e84ypzpzn0p0j9nddptrj2nwhk9lhaw952j0lzxslrp24cj0ltuem9g5dustakcq4dsp", - "zs17zut2398dst3hnmnslnk0jv9w4q9yn8akelymvs8ewurdytxushp92nyqv30quqhy0yju7rn7lw", - "zs17r4fuv9ldl3kzwk5stv59exusc7jlsmtcz4t2uzjnrgrr6aj6tvnp04wc9jq2n3eh6fsyqe2ru5", - "zs17rajftxlkcywcenl0cn3fqw4lh2un5lpfegjdz06j3vl9gjmay2d5pk7uequ02vw6tmtzz6jrst", - "zs179rvu8endcr48sft7zg4w6uvxwu4ps94r06uwk7e606yffkgtx7epaamlfdqnc6xa4l9scqcv4v", - "zs178dr2z7zgqrsg5ul3sxx05qky2kemfequf08dxr332n9f5fq9cj98jttssz97lzmf2k22xpn54m", - "zs172zz77ds82urqmsa9pgyz65k04euw7uuk58k4ardcxectjc4t4yjekxm8xxmgd7gqs8k6jupypk", - "zs172eamykp6sl4vx4tsgmg2t0p482hnn3gg4my9y4frd4tl5zgsyrsvjvlxc9zjtqpve6e6djdc4x", - "zs17v4xqdu83fkvrjxrpnjksuanj0pung2kqn9ys533nnm8kq8ad8xv9kd48e4utrz947pejg55p46", - "zs17dgakqvwzgh4dgfe70cjulju698cs50zvchsze2e3zvdp68wytqdcvj4suh4vq2acdg7wuvs7ar", - "zs17snaqr6vukwp4apsdf44h6w3flgphzrnpmdjly662tgqtvkgs72lpz7m7tnkksdmt5uzjgmpg2e", - "zs173ad7l6u8dr90e2t5jkrnw0gc9u2mppv9vjeh8l6q2jdvgnq6tq4anxxltwuxm3wssfzgg6hfcy", - "zs17nez6jn8tnse243f5uf72d8y000ynmjnm6vsrpzpd2fj75wq4u4lu7xc8fmtn2e5v0r7uknphs3", - "zs174c6x8u2yagjnsq2kswnd6fh8u2f3g5dkrk7r7ja5n30zwjm4ke3x84syt9qklqyk0m7vekcx9f", - "zs174mlfm6snsmgj4usez3e6xtd5nkwwl24vgg96srpnv7ulz4de6n4lx6cmxaqszqnk7p9y6wcl8q", - "zs17h5lnrnpprdtkjwq09ax94qetryf65qm5jqv0gpyeesw4wujytks9qljvlry863flf242arvx8f", - "zs1lp07e40usxenrznuuf2nzn5v7tx9pzp9r6eaw6upnm4t9cer8l5fckzm7jr58j5l77tzjrprv8v", - "zs1ly5u5sqeeax9g3uafva7fl35r3wv0nm2aka9m940graqjh0zlw7rrcgay0a7f29j3ar4wrj4uzu", - "zs1lgqckcp2uqx5c6gdm5zklzrxz8ygva9kxtxc4u4dlzpg68m9prga5q3ur3uqutkcy4ztuhclrxw", - "zs1lgz7ychnnhe58hk2e379zhqdxynp30e6fdh6xjxx8u9ga9rmwzdrdvqcq5kps2uetyf6gzeqdn2", - "zs1l2ghymesqwrfw89pqnw08u346es6wn86r77a55n7d7xky2rc58jfhn7man9kjjesnegec3frxeh", - "zs1ls3lyaqhm39zgz3528ereaa48vzsw4cw99k536524a6ruxmdqyvqnv4pl477q7rwptrzx8dhhzu", - "zs1lsnr42d2ez0w55pxws4qn70f68vxllv92wppu24n75y7a0wrmkw6qgup0md5jhjmkwhzu742zx4", - "zs1ljzwlum9nme83hhvkjkxl323u0ezm4sgnk84nzkyu5acum0kxf0s6g06gy78w0hl66f5263g7ha", - "zs1l5kfev0dpl8swjlyvyms5t9yhhnvg0590jfgpxw7zxx6eh29vd7453q9d0ne75x7gsm42j65l3v", - "zs1lhpxmvxmfpdfa5myd35wf24pmacrgdhrcpxydrcwz3qvmfvpt9x78nf2ne3kkqh40m0nvhhd3uj", - "zs1lhkhftvpkvcuyhwgcz4gq9y9l3ly5esglk2g0sgdctrz2cd63lgss2gtn8eedsvtuh8f6shpwww", - }; - //TODO: Assumes pools of 100 - int randIndex = GetRandInt(100); // random int between 0 and 99 - if(randIndex % 2) { - return SietchShieldedPool1[randIndex]; - } else { - return SietchShieldedPool2[randIndex]; +SendManyRecipient newSietchRecipient(string zaddr) { + int nAmount = 0; + // TODO: Should we randomize length of data, perhaps into buckets? + // Sietch zouts have random data in their memos so they are indistinguishable from + // encrypted data being stored in the memo field + char hex[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; + // memo field is 512 bytes or 1024 hex chars + char str[1024]; + for(int i=0;i<1024;i++) { + str[i] = hex[GetRandInt(16)]; } + str[1024] = 0; + return SendManyRecipient( zaddr, nAmount, string(str) ); +} + +string randomSietchZaddr() { + auto sk = libzcash::SaplingSpendingKey::random(); + auto expsk = sk.expanded_spending_key(); + auto zdust = sk.default_address(); + return EncodePaymentAddress(zdust); } #endif diff --git a/src/spentindex.h b/src/spentindex.h index f8bd3f961..5cb3b3599 100644 --- a/src/spentindex.h +++ b/src/spentindex.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SPENTINDEX_H #define BITCOIN_SPENTINDEX_H diff --git a/src/streams.h b/src/streams.h index 83c90cd39..fadb058fc 100644 --- a/src/streams.h +++ b/src/streams.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/support/allocators/secure.h b/src/support/allocators/secure.h index 5e7bb66ea..af3828a83 100644 --- a/src/support/allocators/secure.h +++ b/src/support/allocators/secure.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_ALLOCATORS_SECURE_H #define BITCOIN_SUPPORT_ALLOCATORS_SECURE_H diff --git a/src/support/allocators/zeroafterfree.h b/src/support/allocators/zeroafterfree.h index 41e23392e..c7351d1c4 100644 --- a/src/support/allocators/zeroafterfree.h +++ b/src/support/allocators/zeroafterfree.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_ALLOCATORS_ZEROAFTERFREE_H #define BITCOIN_SUPPORT_ALLOCATORS_ZEROAFTERFREE_H diff --git a/src/support/cleanse.cpp b/src/support/cleanse.cpp index a2141b244..c92d43849 100644 --- a/src/support/cleanse.cpp +++ b/src/support/cleanse.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "cleanse.h" diff --git a/src/support/cleanse.h b/src/support/cleanse.h index 3e02aa8fd..e9fc9625f 100644 --- a/src/support/cleanse.h +++ b/src/support/cleanse.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_CLEANSE_H #define BITCOIN_SUPPORT_CLEANSE_H diff --git a/src/support/events.h b/src/support/events.h index 4f2f3cf9e..662966ce8 100644 --- a/src/support/events.h +++ b/src/support/events.h @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_EVENTS_H #define BITCOIN_SUPPORT_EVENTS_H diff --git a/src/support/pagelocker.cpp b/src/support/pagelocker.cpp index d0b0d4dd8..ed9148fe1 100644 --- a/src/support/pagelocker.cpp +++ b/src/support/pagelocker.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "support/pagelocker.h" diff --git a/src/support/pagelocker.h b/src/support/pagelocker.h index 7385bc444..df5d98903 100644 --- a/src/support/pagelocker.h +++ b/src/support/pagelocker.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_PAGELOCKER_H #define BITCOIN_SUPPORT_PAGELOCKER_H diff --git a/src/sync.cpp b/src/sync.cpp index 31c3301bd..8322a6383 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2011-2012 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// Copyright (c) 2019-2020 The Hush developers +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/sync.h b/src/sync.h index a8f29eb66..729952a4d 100644 --- a/src/sync.h +++ b/src/sync.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/test/Checkpoints_tests.cpp b/src/test/Checkpoints_tests.cpp index 32b14cb93..9bc17acbb 100644 --- a/src/test/Checkpoints_tests.cpp +++ b/src/test/Checkpoints_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // Unit tests for block-chain checkpoints diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index 6044b221f..086b2f4d3 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // Unit tests for denial-of-service detection/prevention code diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp index 0c2ade48d..e6e3f77d9 100644 --- a/src/test/accounting_tests.cpp +++ b/src/test/accounting_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "wallet/wallet.h" #include "wallet/walletdb.h" diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index fc0600dfc..10b3031ad 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "addrman.h" #include "test/test_bitcoin.h" #include @@ -345,15 +345,15 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr) BOOST_CHECK(vAddr1.size() == 0); CAddress addr1 = CAddress(CService("250.250.2.1", 8333)); - addr1.nTime = GetAdjustedTime(); // Set time so isTerrible = false + addr1.nTime = GetTime(); // Set time so isTerrible = false CAddress addr2 = CAddress(CService("250.251.2.2", 9999)); - addr2.nTime = GetAdjustedTime(); + addr2.nTime = GetTime(); CAddress addr3 = CAddress(CService("251.252.2.3", 8333)); - addr3.nTime = GetAdjustedTime(); + addr3.nTime = GetTime(); CAddress addr4 = CAddress(CService("252.253.3.4", 8333)); - addr4.nTime = GetAdjustedTime(); + addr4.nTime = GetTime(); CAddress addr5 = CAddress(CService("252.254.4.5", 8333)); - addr5.nTime = GetAdjustedTime(); + addr5.nTime = GetTime(); CNetAddr source1 = CNetAddr("250.1.2.1"); CNetAddr source2 = CNetAddr("250.2.3.3"); @@ -381,7 +381,7 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr) CAddress addr = CAddress(CService(strAddr)); // Ensure that for all addrs in addrman, isTerrible == false. - addr.nTime = GetAdjustedTime(); + addr.nTime = GetTime(); addrman.Add(addr, CNetAddr(strAddr)); if (i % 8 == 0) addrman.Good(addr); diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index 533b8f1ef..638340815 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // Unit tests for alert system diff --git a/src/test/allocator_tests.cpp b/src/test/allocator_tests.cpp index 2108efece..954793171 100644 --- a/src/test/allocator_tests.cpp +++ b/src/test/allocator_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "util.h" diff --git a/src/test/arith_uint256_tests.cpp b/src/test/arith_uint256_tests.cpp index 17d6bed6d..e7355427f 100644 --- a/src/test/arith_uint256_tests.cpp +++ b/src/test/arith_uint256_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/test/base32_tests.cpp b/src/test/base32_tests.cpp index 0b883fbef..c6aa39842 100644 --- a/src/test/base32_tests.cpp +++ b/src/test/base32_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "utilstrencodings.h" #include "test/test_bitcoin.h" diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index 80b2bb1dc..f7a2fefdd 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "base58.h" diff --git a/src/test/base64_tests.cpp b/src/test/base64_tests.cpp index b134e49ca..e2eebf0b5 100644 --- a/src/test/base64_tests.cpp +++ b/src/test/base64_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "utilstrencodings.h" #include "test/test_bitcoin.h" diff --git a/src/test/bctest.py b/src/test/bctest.py index 86724241b..50311cfea 100644 --- a/src/test/bctest.py +++ b/src/test/bctest.py @@ -1,6 +1,6 @@ # Copyright 2014 BitPay, Inc. # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import subprocess import json diff --git a/src/test/bech32_tests.cpp b/src/test/bech32_tests.cpp index 02252bcbf..ac8ab33eb 100644 --- a/src/test/bech32_tests.cpp +++ b/src/test/bech32_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2017 Pieter Wuille // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "bech32.h" #include "test/test_bitcoin.h" diff --git a/src/test/bignum.h b/src/test/bignum.h index a7fb18953..5c530dda2 100644 --- a/src/test/bignum.h +++ b/src/test/bignum.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_TEST_BIGNUM_H #define BITCOIN_TEST_BIGNUM_H diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp index 8815d1c54..9702b26bf 100644 --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include diff --git a/src/test/bitcoin-util-test.py b/src/test/bitcoin-util-test.py index 6551eb6f2..0f0204ae2 100755 --- a/src/test/bitcoin-util-test.py +++ b/src/test/bitcoin-util-test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Copyright 2014 BitPay, Inc. # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import os import bctest diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp index 9189e4af8..51e3096ec 100644 --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "bloom.h" diff --git a/src/test/checkblock_tests.cpp b/src/test/checkblock_tests.cpp index c813c9af9..3a5b6229c 100644 --- a/src/test/checkblock_tests.cpp +++ b/src/test/checkblock_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "clientversion.h" #include "consensus/validation.h" diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 8067b42b9..897c38117 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "coins.h" #include "random.h" diff --git a/src/test/compress_tests.cpp b/src/test/compress_tests.cpp index 92fe4728e..6a3934fc5 100644 --- a/src/test/compress_tests.cpp +++ b/src/test/compress_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "compressor.h" #include "util.h" diff --git a/src/test/convertbits_tests.cpp b/src/test/convertbits_tests.cpp index a8908ebfc..85fb924d0 100644 --- a/src/test/convertbits_tests.cpp +++ b/src/test/convertbits_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2018 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index aeb2a5caa..4fe7f4da6 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/ripemd160.h" #include "crypto/sha1.h" diff --git a/src/test/data/README.md b/src/test/data/README.md index 2463daa42..49fc3a6b4 100644 --- a/src/test/data/README.md +++ b/src/test/data/README.md @@ -8,5 +8,5 @@ License The data files in this directory are distributed under the MIT software license, see the accompanying file COPYING or -http://www.opensource.org/licenses/mit-license.php. +https://www.opensource.org/licenses/mit-license.php diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp index a047938db..7cef1e05d 100644 --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2012-2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "dbwrapper.h" #include "uint256.h" diff --git a/src/test/equihash_tests.cpp b/src/test/equihash_tests.cpp index 6f2f0b858..213022421 100644 --- a/src/test/equihash_tests.cpp +++ b/src/test/equihash_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 Jack Grigg // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index a0c5592a9..8fbbf04d8 100644 --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "util.h" #include "test/test_bitcoin.h" diff --git a/src/test/hash_tests.cpp b/src/test/hash_tests.cpp index e5d2e5a43..549d5dcc1 100644 --- a/src/test/hash_tests.cpp +++ b/src/test/hash_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "hash.h" #include "utilstrencodings.h" diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index 390b2bc7b..4c659b6ed 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "key.h" diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index ec02352e8..ef3b2c32c 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "chainparams.h" #include "main.h" diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index a82f5bce6..e7c509b8f 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "consensus/upgrades.h" #include "main.h" diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 277b726c8..49e307f3b 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "arith_uint256.h" #include "consensus/validation.h" diff --git a/src/test/mruset_tests.cpp b/src/test/mruset_tests.cpp index 2b68f8899..59e173404 100644 --- a/src/test/mruset_tests.cpp +++ b/src/test/mruset_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "mruset.h" diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index a7e48ee4c..6bd6060d2 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "consensus/upgrades.h" #include "key.h" diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp index 40b32a7b3..65a079c31 100644 --- a/src/test/netbase_tests.cpp +++ b/src/test/netbase_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "netbase.h" #include "test/test_bitcoin.h" diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index 3975dff2e..b70ec9f5d 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "merkleblock.h" #include "serialize.h" diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp index a530749e7..159171199 100644 --- a/src/test/policyestimator_tests.cpp +++ b/src/test/policyestimator_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "policy/fees.h" #include "txmempool.h" diff --git a/src/test/pow_tests.cpp b/src/test/pow_tests.cpp index 8837a43c8..ca24fb449 100644 --- a/src/test/pow_tests.cpp +++ b/src/test/pow_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "main.h" #include "pow.h" diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index 01a45b540..fa475e3d2 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include "prevector.h" diff --git a/src/test/raii_event_tests.cpp b/src/test/raii_event_tests.cpp index 0f40874f5..2cf13950c 100644 --- a/src/test/raii_event_tests.cpp +++ b/src/test/raii_event_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include diff --git a/src/test/reverselock_tests.cpp b/src/test/reverselock_tests.cpp index 8bdff9700..189db4ae2 100644 --- a/src/test/reverselock_tests.cpp +++ b/src/test/reverselock_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "reverselock.h" #include "test/test_bitcoin.h" diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index d0e94ab5d..ab7000a33 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "rpc/server.h" #include "rpc/client.h" diff --git a/src/test/sanity_tests.cpp b/src/test/sanity_tests.cpp index f5f7f381d..fdb57c455 100644 --- a/src/test/sanity_tests.cpp +++ b/src/test/sanity_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "compat/sanity.h" #include "key.h" diff --git a/src/test/scheduler_tests.cpp b/src/test/scheduler_tests.cpp index d6c93ef3b..6c0087bf3 100644 --- a/src/test/scheduler_tests.cpp +++ b/src/test/scheduler_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "random.h" #include "scheduler.h" diff --git a/src/test/script_P2PKH_tests.cpp b/src/test/script_P2PKH_tests.cpp index 8fbb054b9..cc3868138 100644 --- a/src/test/script_P2PKH_tests.cpp +++ b/src/test/script_P2PKH_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "script/script.h" #include "test/test_bitcoin.h" diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp index fac63dbf5..6ab9380ae 100644 --- a/src/test/script_P2SH_tests.cpp +++ b/src/test/script_P2SH_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "consensus/upgrades.h" #include "core_io.h" diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 4e8388358..46b82c80b 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "data/script_invalid.json.h" #include "data/script_valid.json.h" diff --git a/src/test/scriptnum_tests.cpp b/src/test/scriptnum_tests.cpp index d95724dbe..736f24397 100644 --- a/src/test/scriptnum_tests.cpp +++ b/src/test/scriptnum_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "bignum.h" #include "script/script.h" diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index eaf69f175..230d74c65 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "serialize.h" #include "streams.h" diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index f7ecfe5c8..fa8c60240 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "consensus/upgrades.h" #include "consensus/validation.h" diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp index ea2b9b795..1d3131dd9 100644 --- a/src/test/sigopcount_tests.cpp +++ b/src/test/sigopcount_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "pubkey.h" #include "key.h" diff --git a/src/test/skiplist_tests.cpp b/src/test/skiplist_tests.cpp index 3c33db168..fd389d7d1 100644 --- a/src/test/skiplist_tests.cpp +++ b/src/test/skiplist_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "main.h" #include "random.h" diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 176d90848..96b13e083 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #define BOOST_TEST_MODULE Bitcoin Test Suite diff --git a/src/test/timedata_tests.cpp b/src/test/timedata_tests.cpp index 887cfb476..e1566007e 100644 --- a/src/test/timedata_tests.cpp +++ b/src/test/timedata_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // #include "timedata.h" #include "test/test_bitcoin.h" diff --git a/src/test/torcontrol_tests.cpp b/src/test/torcontrol_tests.cpp index b7affaacd..8c1488003 100644 --- a/src/test/torcontrol_tests.cpp +++ b/src/test/torcontrol_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2017 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // #include "test/test_bitcoin.h" #include "torcontrol.cpp" diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index eb948f92d..4a56e71f2 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "data/tx_invalid.json.h" #include "data/tx_valid.json.h" diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp index a6501faa1..8e7b12494 100644 --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "arith_uint256.h" #include "uint256.h" #include "version.h" diff --git a/src/test/univalue_tests.cpp b/src/test/univalue_tests.cpp index f3bbfaef1..ef5937d7f 100644 --- a/src/test/univalue_tests.cpp +++ b/src/test/univalue_tests.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay, Inc. // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 0fcdd6530..fa26c005e 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "util.h" diff --git a/src/test/wallet-utility.py b/src/test/wallet-utility.py index c0a7bfb9e..bb32b5a4f 100644 --- a/src/test/wallet-utility.py +++ b/src/test/wallet-utility.py @@ -1,7 +1,7 @@ #!/usr/bin/python # Copyright 2014 BitPay, Inc. # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import subprocess import os diff --git a/src/threadsafety.h b/src/threadsafety.h index d01c50abb..21fb50975 100644 --- a/src/threadsafety.h +++ b/src/threadsafety.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_THREADSAFETY_H #define BITCOIN_THREADSAFETY_H diff --git a/src/timedata.cpp b/src/timedata.cpp index 64a3955ff..246159a50 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -1,10 +1,11 @@ // Copyright (c) 2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers +// Copyright (c) 2020 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * + * Copyright © 2014-2020 The SuperNET Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright * @@ -26,114 +27,56 @@ #include "util.h" #include "utilstrencodings.h" -#include - -using namespace std; - -static CCriticalSection cs_nTimeOffset; -static int64_t nTimeOffset = 0; -#define KOMODO_ASSETCHAIN_MAXLEN 65 -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +CTimeWarning timeWarning; /** - * "Never go to sea with two chronometers; take one or three." - * Our three time sources are: - * - System clock - * - Median of other nodes clocks - * - The user (asking the user to fix the system clock if the first two disagree) + * Warn if we have seen TIMEDATA_WARNING_SAMPLES peer times, in the version messages of the + * first TIMEDATA_MAX_SAMPLES unique (by IP address) peers that connect, that are more than + * TIMEDATA_WARNING_THRESHOLD seconds but less than TIMEDATA_IGNORE_THRESHOLD seconds away + * from local time. */ -int64_t GetTimeOffset() + +int64_t CTimeWarning::AddTimeData(const CNetAddr& ip, int64_t nTime, int64_t now) { - LOCK(cs_nTimeOffset); + assert(now >= 0 && now <= INT64_MAX - TIMEDATA_IGNORE_THRESHOLD); + + if (nTime <= now - TIMEDATA_IGNORE_THRESHOLD || nTime >= now + TIMEDATA_IGNORE_THRESHOLD) { + return 0; + } + + int64_t nTimeOffset = nTime - now; + + LOCK(cs); + // Ignore duplicate IPs. + if (setKnown.size() == TIMEDATA_MAX_SAMPLES || !setKnown.insert(ip).second) { + return nTimeOffset; + } + + LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", setKnown.size(), nTimeOffset, nTimeOffset/60); + + if (nPeersBehind + nPeersAhead < TIMEDATA_WARNING_SAMPLES) { + if (nTimeOffset < -TIMEDATA_WARNING_THRESHOLD) { + nPeersBehind++; + } else if (nTimeOffset > TIMEDATA_WARNING_THRESHOLD) { + nPeersAhead++; + } + if (nPeersBehind + nPeersAhead == TIMEDATA_WARNING_SAMPLES) { + Warn(nPeersAhead, nPeersBehind); + } + } return nTimeOffset; } -int64_t GetAdjustedTime() +void CTimeWarning::Warn(size_t peersAhead, size_t peersBehind) { - return GetTime() + GetTimeOffset(); -} - -static int64_t abs64(int64_t n) -{ - return (n >= 0 ? n : -n); -} - -#define BITCOIN_TIMEDATA_MAX_SAMPLES 200 - -void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) -{ - LOCK(cs_nTimeOffset); - // Ignore duplicates - static set setKnown; - if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES) - return; - if (!setKnown.insert(ip).second) - return; - - // Add data - static CMedianFilter vTimeOffsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0); - vTimeOffsets.input(nOffsetSample); - LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); - - // There is a known issue here (see issue #4521): - // - // - The structure vTimeOffsets contains up to 200 elements, after which - // any new element added to it will not increase its size, replacing the - // oldest element. - // - // - The condition to update nTimeOffset includes checking whether the - // number of elements in vTimeOffsets is odd, which will never happen after - // there are 200 elements. - // - // But in this case the 'bug' is protective against some attacks, and may - // actually explain why we've never seen attacks which manipulate the - // clock offset. - // - // So we should hold off on fixing this and clean it up as part of - // a timing cleanup that strengthens it in a number of other ways. - // - if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1) - { - int64_t nMedian = vTimeOffsets.median(); - std::vector vSorted = vTimeOffsets.sorted(); - // Only let other nodes change our time by so much - if (abs64(nMedian) < 30) // thanks to zawy for pointing this out!! zcash issues 4021 //70 * 60) - { - nTimeOffset = nMedian; - } - else - { - nTimeOffset = 0; - - static bool fDone; - if (!fDone) - { - // If nobody has a time different than ours but within 5 minutes of ours, give a warning - bool fMatch = false; - BOOST_FOREACH(int64_t nOffset, vSorted) - if (nOffset != 0 && abs64(nOffset) < 5 * 60) - fMatch = true; - - if (!fMatch) - { - fDone = true; - string strMessage; - if( strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ) { - strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Hush will not work properly."); - } else { - strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Komodo will not work properly."); - } - strMiscWarning = strMessage; - LogPrintf("*** %s\n", strMessage); - uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); - } - } - } - if (fDebug) { - BOOST_FOREACH(int64_t n, vSorted) - LogPrintf("%+d ", n); - LogPrintf("| "); - } - LogPrintf("nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); + std::string strMessage; + if (peersBehind >= TIMEDATA_WARNING_MAJORITY) { + strMessage = _("Warning: Your computer's date and time may be ahead of the rest of the network! If your clock is wrong Hush will not work properly."); + } else if (peersAhead >= TIMEDATA_WARNING_MAJORITY) { + strMessage = _("Warning: Your computer's date and time may be behind the rest of the network! If your clock is wrong Hush will not work properly."); + } else { + strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Hush will not work properly."); } + LogPrintf("*** %s\n", strMessage); + uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); } diff --git a/src/timedata.h b/src/timedata.h index 13cff12b3..4ced093b6 100644 --- a/src/timedata.h +++ b/src/timedata.h @@ -1,77 +1,39 @@ // Copyright (c) 2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers +// Copyright (c) 2020 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_TIMEDATA_H #define BITCOIN_TIMEDATA_H -#include -#include +#include #include -#include +#include "netbase.h" +#include "sync.h" -class CNetAddr; - -/** - * Median filter over a stream of values. - * Returns the median of the last N numbers - */ -template -class CMedianFilter +class CTimeWarning { private: - std::vector vValues; - std::vector vSorted; - unsigned int nSize; + CCriticalSection cs; + std::set setKnown; + size_t nPeersAhead; + size_t nPeersBehind; public: - CMedianFilter(unsigned int size, T initial_value) : nSize(size) - { - vValues.reserve(size); - vValues.push_back(initial_value); - vSorted = vValues; - } + static const size_t TIMEDATA_WARNING_SAMPLES = 8; + static const size_t TIMEDATA_WARNING_MAJORITY = 6; + static const size_t TIMEDATA_MAX_SAMPLES = 20; + static const int64_t TIMEDATA_WARNING_THRESHOLD = 10 * 60; + static const int64_t TIMEDATA_IGNORE_THRESHOLD = 10 * 24 * 60 * 60; - void input(T value) - { - if (vValues.size() == nSize) { - vValues.erase(vValues.begin()); - } - vValues.push_back(value); + CTimeWarning() : nPeersBehind(0), nPeersAhead(0) {} + virtual ~CTimeWarning() {} - vSorted.resize(vValues.size()); - std::copy(vValues.begin(), vValues.end(), vSorted.begin()); - std::sort(vSorted.begin(), vSorted.end()); - } - - T median() const - { - int size = vSorted.size(); - assert(size > 0); - if (size & 1) // Odd number of elements - { - return vSorted[size / 2]; - } else // Even number of elements - { - return (vSorted[size / 2 - 1] + vSorted[size / 2]) / 2; - } - } - - int size() const - { - return vValues.size(); - } - - std::vector sorted() const - { - return vSorted; - } + int64_t AddTimeData(const CNetAddr& ip, int64_t nTime, int64_t now); + virtual void Warn(size_t peersAhead, size_t peersBehind); }; -/** Functions to keep track of adjusted P2P time */ -int64_t GetTimeOffset(); -int64_t GetAdjustedTime(); -void AddTimeData(const CNetAddr& ip, int64_t nTime); +extern CTimeWarning timeWarning; #endif // BITCOIN_TIMEDATA_H diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index c2eb490da..a2efb9fa1 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "torcontrol.h" #include "utilstrencodings.h" diff --git a/src/torcontrol.h b/src/torcontrol.h index 44611c7b6..f3d3c504a 100644 --- a/src/torcontrol.h +++ b/src/torcontrol.h @@ -1,7 +1,7 @@ // Copyright (c) 2015 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /** * Functionality for communicating with Tor. diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index e1879e1d4..da9a220fa 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "transaction_builder.h" diff --git a/src/transaction_builder.h b/src/transaction_builder.h index 39225433a..716166a85 100644 --- a/src/transaction_builder.h +++ b/src/transaction_builder.h @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef TRANSACTION_BUILDER_H #define TRANSACTION_BUILDER_H diff --git a/src/txdb.cpp b/src/txdb.cpp index 6fe8bd575..bb1d5d60d 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -3,7 +3,7 @@ // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -723,6 +723,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nPayments = diskindex.nPayments; pindexNew->nShieldedTx = diskindex.nShieldedTx; pindexNew->nShieldedOutputs = diskindex.nShieldedOutputs; + pindexNew->nShieldedSpends = diskindex.nShieldedSpends; pindexNew->nShieldedPayments = diskindex.nShieldedPayments; pindexNew->nShieldingTx = diskindex.nShieldingTx; pindexNew->nShieldingPayments = diskindex.nShieldingPayments; diff --git a/src/txdb.h b/src/txdb.h index 81c0bb3ad..374e834da 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 2f10856d4..10cd053f8 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -3,7 +3,7 @@ // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/txmempool.h b/src/txmempool.h index 59eeb0d98..aeccdea85 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/ui_interface.h b/src/ui_interface.h index 59a549a9d..fa48f67f9 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2012 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_UI_INTERFACE_H #define BITCOIN_UI_INTERFACE_H diff --git a/src/uint256.cpp b/src/uint256.cpp index c238490b8..dad9c616b 100644 --- a/src/uint256.cpp +++ b/src/uint256.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/uint256.h b/src/uint256.h index d819dc630..360f1963c 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/undo.h b/src/undo.h index fbb350e60..d670be812 100644 --- a/src/undo.h +++ b/src/undo.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_UNDO_H #define BITCOIN_UNDO_H diff --git a/src/univalue/gen/gen.cpp b/src/univalue/gen/gen.cpp index 17f361941..55e60e418 100644 --- a/src/univalue/gen/gen.cpp +++ b/src/univalue/gen/gen.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay Inc. // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // To re-create univalue_escapes.h: diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h index dfc84f921..7cba19bd4 100644 --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -1,7 +1,7 @@ // Copyright 2014 BitPay Inc. // Copyright 2015 Bitcoin Core Developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef UNIVALUE_H__ #define UNIVALUE_H__ diff --git a/src/univalue/lib/univalue.cpp b/src/univalue/lib/univalue.cpp index 0e8005f23..8901cd5de 100644 --- a/src/univalue/lib/univalue.cpp +++ b/src/univalue/lib/univalue.cpp @@ -1,7 +1,7 @@ // Copyright 2014 BitPay Inc. // Copyright 2015 Bitcoin Core Developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/univalue/lib/univalue_read.cpp b/src/univalue/lib/univalue_read.cpp index e0a5b44ab..bbaa2d32b 100644 --- a/src/univalue/lib/univalue_read.cpp +++ b/src/univalue/lib/univalue_read.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay Inc. // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/univalue/lib/univalue_utffilter.h b/src/univalue/lib/univalue_utffilter.h index b4a9ddc0a..d4329af8a 100644 --- a/src/univalue/lib/univalue_utffilter.h +++ b/src/univalue/lib/univalue_utffilter.h @@ -1,6 +1,6 @@ // Copyright 2016 Wladimir J. van der Laan // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef UNIVALUE_UTFFILTER_H #define UNIVALUE_UTFFILTER_H diff --git a/src/univalue/lib/univalue_write.cpp b/src/univalue/lib/univalue_write.cpp index cf2783599..c0f9fd9a4 100644 --- a/src/univalue/lib/univalue_write.cpp +++ b/src/univalue/lib/univalue_write.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay Inc. // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/univalue/test/unitester.cpp b/src/univalue/test/unitester.cpp index 27cf1d845..edd3eec81 100644 --- a/src/univalue/test/unitester.cpp +++ b/src/univalue/test/unitester.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay Inc. // Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/util.cpp b/src/util.cpp index d6ceb1997..1edced4bc 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -512,7 +512,7 @@ static std::string FormatException(const std::exception* pex, const char* pszThr char pszModule[MAX_PATH] = ""; GetModuleFileNameA(NULL, pszModule, sizeof(pszModule)); #else - const char* pszModule = "Komodo"; + const char* pszModule = "Hush"; #endif if (pex) return strprintf( @@ -1036,7 +1036,7 @@ std::string LicenseInfo() "\n" + FormatParagraph(_("This is experimental software!!!")) + "\n" + "\n" + - FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or .")) + "\n" + + FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or .")) + "\n" + "\n" + FormatParagraph(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written by Eric Young.")) + "\n"; diff --git a/src/util.h b/src/util.h index d1bbdd26d..e742ef975 100644 --- a/src/util.h +++ b/src/util.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/utilmoneystr.cpp b/src/utilmoneystr.cpp index 0f3203432..b5e692e1b 100644 --- a/src/utilmoneystr.cpp +++ b/src/utilmoneystr.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "utilmoneystr.h" diff --git a/src/utilmoneystr.h b/src/utilmoneystr.h index 99c3ba830..5b36a7b5a 100644 --- a/src/utilmoneystr.h +++ b/src/utilmoneystr.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /** * Money parsing/formatting utilities. diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index 132ae82ab..6d9475e89 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "utilstrencodings.h" diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index 2d851093f..b31464b23 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /** * Utilities for converting data from/to strings. diff --git a/src/utiltime.cpp b/src/utiltime.cpp index f1a408a31..7918254ce 100644 --- a/src/utiltime.cpp +++ b/src/utiltime.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/utiltime.h b/src/utiltime.h index 900992f87..91d344ec1 100644 --- a/src/utiltime.h +++ b/src/utiltime.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_UTILTIME_H #define BITCOIN_UTILTIME_H diff --git a/src/validationinterface.h b/src/validationinterface.h index bc5477c99..d01bc271a 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_VALIDATIONINTERFACE_H #define BITCOIN_VALIDATIONINTERFACE_H diff --git a/src/version.h b/src/version.h index 4056f105d..5cf912492 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -24,7 +25,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170008; +static const int PROTOCOL_VERSION = 170009; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.h b/src/wallet/asyncrpcoperation_mergetoaddress.h index 69150161e..00a4feffa 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -2,7 +2,7 @@ // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 0c6cae7c1..855df3835 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2019 CryptoForge // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "assert.h" #include "boost/variant/static_visitor.hpp" @@ -78,7 +78,7 @@ void AsyncRPCOperation_saplingconsolidation::main() { bool AsyncRPCOperation_saplingconsolidation::main_impl() { bool status=true; auto opid=getId(); - LogPrint("zrpcunsafe", "%s: Beginning AsyncRPCOperation_saplingconsolidation.\n", opid); + LogPrintf("%s: Beginning AsyncRPCOperation_saplingconsolidation.\n", __func__, opid); auto consensusParams = Params().GetConsensus(); auto nextActivationHeight = NextActivationHeight(targetHeight_, consensusParams); if (nextActivationHeight && targetHeight_ + CONSOLIDATION_EXPIRY_DELTA >= nextActivationHeight.get()) { @@ -161,7 +161,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { auto builder = TransactionBuilder(consensusParams, targetHeight_, pwalletMain); //builder.SetExpiryHeight(targetHeight_ + CONSOLIDATION_EXPIRY_DELTA); auto actualAmountToSend = amountToSend < fConsolidationTxFee ? 0 : amountToSend - fConsolidationTxFee; - LogPrint("zrpcunsafe", "%s: Beginning to create transaction with Sapling output amount=%s\n", opid, FormatMoney(actualAmountToSend)); + LogPrintf("%s: %s Beginning to create transaction with Sapling output amount=%s\n", __func__, opid, FormatMoney(actualAmountToSend)); // Select Sapling notes std::vector ops; diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.h b/src/wallet/asyncrpcoperation_saplingconsolidation.h index 5d14b9335..7124cea98 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.h +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.h @@ -1,7 +1,7 @@ // Copyright (c) 2020 The Hush developers // Copyright (c) 2019 CryptoForge // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "amount.h" #include "asyncrpcoperation.h" diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 1b709b142..46a556080 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -62,23 +62,6 @@ bool hush_hardfork_active(uint32_t time); extern UniValue signrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); -int find_output(UniValue obj, int n) { - UniValue outputMapValue = find_value(obj, "outputmap"); - if (!outputMapValue.isArray()) { - throw JSONRPCError(RPC_WALLET_ERROR, "Missing outputmap for JoinSplit operation"); - } - - UniValue outputMap = outputMapValue.get_array(); - assert(outputMap.size() == ZC_NUM_JS_OUTPUTS); - for (size_t i = 0; i < outputMap.size(); i++) { - if (outputMap[i].get_int() == n) { - return i; - } - } - - throw std::logic_error("n is not present in outputmap"); -} - AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany( boost::optional builder, CMutableTransaction contextualTx, @@ -473,14 +456,13 @@ bool AsyncRPCOperation_sendmany::main_impl() { // Add Sapling outputs for (auto r : z_outputs_) { auto address = std::get<0>(r); - auto value = std::get<1>(r); + auto value = std::get<1>(r); auto hexMemo = std::get<2>(r); - - auto addr = DecodePaymentAddress(address); + auto addr = DecodePaymentAddress(address); assert(boost::get(&addr) != nullptr); auto to = boost::get(addr); if(fZdebug) - LogPrintf("%s: Adding Sapling output to address %s\n", __FUNCTION__, to.GetHash().ToString().c_str()); + LogPrintf("%s: Adding Sapling output to address %s\n", __FUNCTION__, address.c_str()); auto memo = get_memo_from_hex_string(hexMemo); @@ -556,6 +538,8 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj) throw JSONRPCError(RPC_WALLET_ERROR, "Missing hex data for raw transaction"); } std::string rawtxn = rawtxnValue.get_str(); + if(fZdebug) + LogPrintf("%s: Signing raw txid=%s\n", __FUNCTION__, rawtxn.c_str()); UniValue params = UniValue(UniValue::VARR); params.push_back(rawtxn); @@ -567,12 +551,16 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj) // TODO: #1366 Maybe get "errors" and print array vErrors into a string throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Failed to sign transaction"); } + if(fZdebug) + LogPrintf("%s: Signed raw txid correctly %s\n", __FUNCTION__); UniValue hexValue = find_value(signResultObject, "hex"); if (hexValue.isNull()) { throw JSONRPCError(RPC_WALLET_ERROR, "Missing hex data for signed transaction"); } std::string signedtxn = hexValue.get_str(); + if(fZdebug) + LogPrintf("%s: Found hex data\n", __FUNCTION__, rawtxn.c_str()); // Send the signed transaction if (!testmode) { @@ -585,6 +573,8 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj) } std::string txid = sendResultValue.get_str(); + if(fZdebug) + LogPrintf("%s: sendrawtransction on txid=%s completed\n", __FUNCTION__, txid.c_str()); UniValue o(UniValue::VOBJ); o.push_back(Pair("txid", txid)); @@ -614,7 +604,8 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { std::set destinations; destinations.insert(fromtaddr_); - //printf("Looking for %s\n", boost::apply_visitor(AddressVisitorString(), fromtaddr_).c_str()); + if(fZdebug) + LogPrintf("%s: Looking for %s\n", boost::apply_visitor(AddressVisitorString(), fromtaddr_).c_str()); vector vecOutputs; @@ -678,6 +669,9 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { bool AsyncRPCOperation_sendmany::find_unspent_notes() { + if(fZdebug) + LogPrintf("%s: For address %s depth=%d\n", __FUNCTION__, fromaddress_.c_str(), mindepth_); + std::vector saplingEntries; { LOCK2(cs_main, pwalletMain->cs_wallet); diff --git a/src/wallet/asyncrpcoperation_sendmany.h b/src/wallet/asyncrpcoperation_sendmany.h index 86e6ef775..8839805c2 100644 --- a/src/wallet/asyncrpcoperation_sendmany.h +++ b/src/wallet/asyncrpcoperation_sendmany.h @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index de56ba3bc..22964b835 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -51,23 +51,6 @@ using namespace libzcash; extern uint64_t ASSETCHAINS_TIMELOCKGTE; -static int find_output(UniValue obj, int n) { - UniValue outputMapValue = find_value(obj, "outputmap"); - if (!outputMapValue.isArray()) { - throw JSONRPCError(RPC_WALLET_ERROR, "Missing outputmap for JoinSplit operation"); - } - - UniValue outputMap = outputMapValue.get_array(); - assert(outputMap.size() == ZC_NUM_JS_OUTPUTS); - for (size_t i = 0; i < outputMap.size(); i++) { - if (outputMap[i].get_int() == n) { - return i; - } - } - - throw std::logic_error("n is not present in outputmap"); -} - AsyncRPCOperation_shieldcoinbase::AsyncRPCOperation_shieldcoinbase( TransactionBuilder builder, CMutableTransaction contextualTx, diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.h b/src/wallet/asyncrpcoperation_shieldcoinbase.h index 3eb1a6cfc..7dfd0842f 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.h +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.h @@ -1,7 +1,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/crypter.h b/src/wallet/crypter.h index 8a7de32b4..5d441770d 100644 --- a/src/wallet/crypter.h +++ b/src/wallet/crypter.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 1814e9209..6a9579b12 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/db.h b/src/wallet/db.h index 31ba88f11..18d6462ad 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 72af5d930..d1af21da7 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -100,7 +100,7 @@ UniValue convertpassphrase(const UniValue& params, bool fHelp, const CPubKey& my "1. \"agamapassphrase\" (string, required) Agama passphrase\n" "\nResult:\n" "\"agamapassphrase\": \"agamapassphrase\", (string) Agama passphrase you entered\n" - "\"address\": \"komodoaddress\", (string) Address corresponding to your passphrase\n" + "\"address\": \"hushaddress\", (string) Address corresponding to your passphrase\n" "\"pubkey\": \"publickeyhex\", (string) The hex value of the raw public key\n" "\"privkey\": \"privatekeyhex\", (string) The hex value of the raw private key\n" "\"wif\": \"wif\" (string) The private key in WIF format to use with 'importprivkey'\n" @@ -200,7 +200,7 @@ UniValue importprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk) "2. \"label\" (string, optional, default=\"\") An optional label\n" "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" "4. height (integer, optional, default=0) start at block height?\n" - "5. secret_key (integer, optional, default=188) used to import WIFs of other coins\n" + "5. secret_key (integer, optional, default=188) decimal value used to import WIFs of other coins\n" "\nNote: This call can take minutes to complete if rescan is true.\n" "\nExamples:\n" "\nDump a private key\n" diff --git a/src/wallet/rpchushwallet.cpp b/src/wallet/rpchushwallet.cpp index 64cd0e4a5..36d35d952 100644 --- a/src/wallet/rpchushwallet.cpp +++ b/src/wallet/rpchushwallet.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2019 Cryptoforge // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "init.h" #include "key_io.h" @@ -134,6 +134,9 @@ void zsTxSpendsToJSON(const CWalletTx& wtx, UniValue& spends, CAmount& totalSpen void zsTxReceivedToJSON(const CWalletTx& wtx, UniValue& received, CAmount& totalReceived, const std::string& strAddress, bool filterByAddress) { + if(fZdebug) + fprintf(stderr,"%s: txid=%s\n", __func__, wtx.GetHash().ToString().c_str() ); + LOCK2(cs_main, pwalletMain->cs_wallet); //Check address @@ -401,6 +404,10 @@ void zsWalletTxJSON(const CWalletTx& wtx, UniValue& ret, const std::string strAd //Begin Compiling the Decrypted Transaction tx.push_back(Pair("txid", wtx.GetHash().ToString())); + + if(fZdebug) + fprintf(stderr,"%s: txid=%s\n", __func__, wtx.GetHash().ToString().c_str() ); + if (wtx.IsCoinBase()) { tx.push_back(Pair("coinbase", true)); diff --git a/src/wallet/rpchushwallet.h b/src/wallet/rpchushwallet.h index b9a6d6f6f..33915caeb 100644 --- a/src/wallet/rpchushwallet.h +++ b/src/wallet/rpchushwallet.h @@ -1,7 +1,7 @@ // Copyright (c) 2020 The Hush developers // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_WALLET_RPCHUSHWALLET_H #define BITCOIN_WALLET_RPCHUSHWALLET_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 867de51a7..f4066c547 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -72,7 +72,7 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; const std::string ADDR_TYPE_SAPLING = "sapling"; -extern UniValue TxJoinSplitToJSON(const CTransaction& tx); +const std::string ADDR_TYPE_AMNESIA = "amnesia"; extern int32_t KOMODO_INSYNC; uint32_t komodo_segid32(char *coinaddr); int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); @@ -81,6 +81,9 @@ CBlockIndex *komodo_getblockindex(uint256 hash); extern string randomSietchZaddr(); extern CAmount fConsolidationTxFee; extern bool fZindex; +extern string randomSietchZaddr(); +extern SendManyRecipient newSietchRecipient(string zaddr); +extern string newSietchZaddr(); int64_t nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; @@ -166,7 +169,6 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue) entry.push_back(Pair(item.first, item.second)); - entry.push_back(Pair("vjoinsplit", TxJoinSplitToJSON(wtx))); } string AccountFromValue(const UniValue& value) @@ -1345,7 +1347,7 @@ UniValue movecmd(const UniValue& params, bool fHelp, const CPubKey& mypk) if (!walletdb.TxnBegin()) throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); - int64_t nNow = GetAdjustedTime(); + int64_t nNow = GetTime(); // Debit CAccountingEntry debit; @@ -2812,6 +2814,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) LOCK2(cs_main, pwalletMain->cs_wallet); + const CHDChain& hdChain = pwalletMain->GetHDChain(); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); @@ -2820,6 +2823,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size())); obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + obj.push_back(Pair("saplingAccountCounter", (int)hdChain.saplingAccountCounter)); if (pwalletMain->IsCrypted()) obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); @@ -3346,8 +3350,8 @@ UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey& if (fHelp || params.size() > 5 || params.size() == 3) throw runtime_error( - "z_listreceivedbyaddress\n" - "\nReturns received outputs for a single address.\n" + "z_listreceivedaddress\n" + "\nReturns received outputs.\n" "\n" "This function only returns information on addresses with full spending keys." "\n" @@ -3405,8 +3409,8 @@ UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey& " }],\n" " },\n" "\nExamples:\n" - + HelpExampleCli("z_listreceivedbyaddress", "R...") - + HelpExampleRpc("z_listreceivedbyaddress", "R...") + + HelpExampleCli("z_listreceivedaddress", "\"*\"") + + HelpExampleRpc("z_listreceivedaddress", "RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -3889,15 +3893,16 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk throw runtime_error( "z_getnewaddress ( type )\n" "\nReturns a new shielded address for receiving payments.\n" - "\nWith no arguments, returns a Sapling address.\n" + "\nWith no arguments, returns a Sapling address (zaddr).\n" + "\nBe very careful with 'amnesia' address type, the address is not stored in wallet.dat and if you send funds to it THEY WILL BE LOST FOREVER\n" "\nArguments:\n" - "1. \"type\" (string, optional, default=\"" + defaultType + "\") The type of address. One of [\"" - + ADDR_TYPE_SAPLING + "\"].\n" + "1. \"type\" (string, optional, default=\"" + defaultType + "\") The type of address. Either "+ ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_AMNESIA + " .\n" "\nResult:\n" "\"" + strprintf("%s",komodo_chainname()) + "_address\" (string) The new shielded address.\n" "\nExamples:\n" + HelpExampleCli("z_getnewaddress", "") + HelpExampleCli("z_getnewaddress", ADDR_TYPE_SAPLING) + + HelpExampleCli("z_getnewaddress", ADDR_TYPE_AMNESIA) ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -3908,11 +3913,16 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk if (params.size() > 0) { addrType = params[0].get_str(); } - if (addrType == ADDR_TYPE_SAPLING) { return EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey()); + } else if (addrType == ADDR_TYPE_AMNESIA) { + auto zaddr = randomSietchZaddr(); + if(fZdebug) { + fprintf(stderr,"%s: Sietch zaddr=%s created, not stored in wallet.dat!\n", __FUNCTION__, zaddr.c_str() ); + } + return zaddr; } else { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid address type!"); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid address type! Try " + ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_AMNESIA); } } @@ -4073,7 +4083,8 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK " \"txid\": xxxxx, (string) the transaction id\n" " \"amount\": xxxxx, (numeric) the amount of value in the note\n" " \"memo\": xxxxx, (string) hexadecimal string representation of memo field\n" - " \"confirmations\" : n, (numeric) the number of confirmations\n" + " \"confirmations\" : n, (numeric) the number of notarized confirmations (dpowconfs)\n" + " \"rawconfirmations\" : n, (numeric) the number of raw confirmations\n" " \"outindex\" (sapling) : n, (numeric) the output index\n" " \"change\": true|false, (boolean) true if the address that received the note is also one of the sending addresses\n" "}\n" @@ -4118,7 +4129,6 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK if (boost::get(&zaddr) != nullptr) { for (SaplingNoteEntry & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); - int nHeight = tx_height(entry.op.hash); int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); // Only return notarized results when minconf>1 @@ -4139,6 +4149,10 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK } obj.push_back(Pair("outindex", (int)entry.op.n)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); + auto wtx = pwalletMain->mapWallet.at(entry.op.hash); //.ToString()); + //fprintf(stderr,"%s: txid=%s not found in wallet!\n", __func__, entry.op.hash.ToString().c_str()); + obj.push_back(Pair("time", wtx.GetTxTime())); + obj.push_back(Pair("confirmations", dpowconfs)); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSaplingChange(nullifierSet, entry.address, entry.op))); @@ -4164,7 +4178,7 @@ UniValue z_getbalance(const UniValue& params, bool fHelp, const CPubKey& mypk) "1. \"address\" (string) The selected address. It may be a transparent or private address.\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "\nResult:\n" - "amount (numeric) The total amount in KMD received for this address.\n" + "amount (numeric) The total amount received for this address.\n" "\nExamples:\n" "\nThe total amount received by address \"myaddress\"\n" + HelpExampleCli("z_getbalance", "\"myaddress\"") + @@ -4264,6 +4278,7 @@ UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& my "\nResult:\n" "{\n" " \"transparent\": xxxxx, (numeric) the total balance of transparent funds\n" + " \"private\": xxxxx, (numeric) the total balance of shielded funds\n" " \"private\": xxxxx, (numeric) the total balance of private funds\n" " \"total\": xxxxx, (numeric) the total balance of both transparent and private funds\n" "}\n" @@ -4608,7 +4623,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) "2. \"amounts\" (array, required) An array of json objects representing the amounts to send.\n" " [{\n" " \"address\":address (string, required) The address is a taddr or zaddr\n" - " \"amount\":amount (numeric, required) The numeric amount in KMD is the value\n" + " \"amount\":amount (numeric, required) The amount to send this address\n" " \"memo\":memo (string, optional) If the address is a zaddr, raw data represented in hexadecimal string format\n" " }, ... ]\n" "3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n" @@ -4725,33 +4740,30 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // SIETCH: Sprinkle our cave with some magic privacy zdust // End goal is to have this be as large as possible without slowing xtns down too much // A value of 7 will provide much stronger linkability privacy versus pre-Sietch operations - unsigned int DEFAULT_MIN_ZOUTS=7; - unsigned int MAX_ZOUTS=25; + unsigned int MAX_ZOUTS=50; unsigned int MIN_ZOUTS=GetArg("--sietch-min-zouts", DEFAULT_MIN_ZOUTS); - if((MIN_ZOUTS<2) || (MIN_ZOUTS>MAX_ZOUTS)) { - fprintf(stderr,"%s: Sietch min zouts must be >=2 and <= 25, setting to default value of %d\n", __FUNCTION__, DEFAULT_MIN_ZOUTS ); + if((MIN_ZOUTS<3) || (MIN_ZOUTS>MAX_ZOUTS)) { + fprintf(stderr,"%s: Sietch min zouts must be >= 3 and <= %d, setting to default value of %d\n", __FUNCTION__, MAX_ZOUTS, DEFAULT_MIN_ZOUTS ); MIN_ZOUTS=DEFAULT_MIN_ZOUTS; } + int nAmount = 0; while (zaddrRecipients.size() < MIN_ZOUTS) { // OK, we identify this xtn as needing privacy zdust, we must decide how much, non-deterministically - int nAmount = 0; int decider = 1 + GetRandInt(100); // random int between 1 and 100 - string memo = "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - string zdust1, zdust2; - // Which zaddr we send to is non-deterministically chosen from two zpools... + // Which zaddr we send to is randomly generated zdust1 = randomSietchZaddr(); // And their ordering when given to internals is also non-deterministic, which // helps breaks assumptions blockchain analysts may use from z_sendmany internals if (decider % 2) { - zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust1, nAmount, memo) ); + zaddrRecipients.insert(std::begin(zaddrRecipients), newSietchRecipient(zdust1) ); } else { - zaddrRecipients.push_back( SendManyRecipient(zdust1, nAmount, memo) ); + zaddrRecipients.push_back( newSietchRecipient(zdust1) ); } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust1.c_str()); @@ -4759,10 +4771,11 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) //50% chance of adding another zout if (decider % 2) { zdust2 = randomSietchZaddr(); + // 50% chance of adding it to the front or back since all odd numbers are 1 or 3 mod 4 if(decider % 4 == 3) { - zaddrRecipients.push_back( SendManyRecipient(zdust2, nAmount, memo) ); + zaddrRecipients.push_back( newSietchRecipient(zdust2) ); } else { - zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust2, nAmount, memo) ); + zaddrRecipients.insert(std::begin(zaddrRecipients), newSietchRecipient(zdust2) ); } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust2.c_str()); diff --git a/src/wallet/rpcwallet.h b/src/wallet/rpcwallet.h index 7739e94a2..00d7897e2 100644 --- a/src/wallet/rpcwallet.h +++ b/src/wallet/rpcwallet.h @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 01482e08e..c70d7a8ca 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "wallet/wallet.h" diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ae845cb21..4ead8000c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -49,7 +49,9 @@ #include #include +#if defined(__GLIBC__) #include +#endif using namespace std; using namespace libzcash; @@ -57,6 +59,7 @@ using namespace libzcash; /** * Settings */ +const char * DEFAULT_WALLET_DAT = "wallet.dat"; CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE); CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE; unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET; @@ -116,7 +119,7 @@ const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const // Generate a new Sapling spending key and return its public payment address -SaplingPaymentAddress CWallet::GenerateNewSaplingZKey() +SaplingPaymentAddress CWallet::GenerateNewSaplingZKey(bool addToWallet) { AssertLockHeld(cs_wallet); // mapSaplingZKeyMetadata @@ -157,7 +160,7 @@ SaplingPaymentAddress CWallet::GenerateNewSaplingZKey() mapSaplingZKeyMetadata[ivk] = metadata; auto addr = xsk.DefaultAddress(); - if (!AddSaplingZKey(xsk, addr)) { + if (addToWallet && !AddSaplingZKey(xsk, addr)) { throw std::runtime_error("CWallet::GenerateNewSaplingZKey(): AddSaplingZKey failed"); } // return default sapling payment address. @@ -472,18 +475,19 @@ void CWallet::ChainTip(const CBlockIndex *pindex, boost::optional> added) { if (added) { - // Prevent witness cache building && consolidation transactions + bool initialDownloadCheck = IsInitialBlockDownload(); + // Prevent witness cache building && consolidation transactions // from being created when node is syncing after launch, // and also when node wakes up from suspension/hibernation and incoming blocks are old. - bool initialDownloadCheck = IsInitialBlockDownload(); + // 144 blocks = 3hrs @ 75s blocktime if (!initialDownloadCheck && - pblock->GetBlockTime() > GetAdjustedTime() - 8640) //Last 144 blocks 2.4 * 60 * 60 + pblock->GetBlockTime() > GetTime() - 144*ASSETCHAINS_BLOCKTIME) { BuildWitnessCache(pindex, false); RunSaplingConsolidation(pindex->GetHeight()); DeleteWalletTransactions(pindex); } else { - //Build intial witnesses on every block + //Build initial witnesses on every block BuildWitnessCache(pindex, true); if (initialDownloadCheck && pindex->GetHeight() % fDeleteInterval == 0) { DeleteWalletTransactions(pindex); @@ -499,12 +503,18 @@ void CWallet::RunSaplingConsolidation(int blockHeight) { if (!NetworkUpgradeActive(blockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { return; } - LOCK(cs_wallet); + + LOCK(cs_wallet); + if (!fSaplingConsolidationEnabled) { return; } int consolidateInterval = rand() % 5 + 5; + + if(fZdebug) + fprintf(stderr,"%s: height=%d interval=%d\n", __func__, blockHeight, consolidateInterval); + if (blockHeight % consolidateInterval == 0) { std::shared_ptr q = getAsyncRPCQueue(); std::shared_ptr lastOperation = q->getOperationForId(saplingConsolidationOperationId); @@ -665,6 +675,25 @@ void CWallet::Flush(bool shutdown) bool CWallet::Verify(const string& walletFile, string& warningString, string& errorString) { + LogPrintf("Using wallet %s\n", walletFile); + uiInterface.InitMessage(_("Verifying wallet...")); + + if (walletFile != boost::filesystem::basename(walletFile) + boost::filesystem::extension(walletFile)) { + boost::filesystem::path path(walletFile); + if (path.is_absolute()) { + if (!boost::filesystem::exists(path.parent_path())) { + LogPrintf("Absolute path %s does not exist!", walletFile); + return false; + } + } else { + boost::filesystem::path full_path = GetDataDir() / path; + if (!boost::filesystem::exists(full_path.parent_path())) { + LogPrintf("Relative path %s does not exist!", walletFile); + return false; + } + } + } + if (!bitdb.Open(GetDataDir())) { // try moving the database env out of the way @@ -866,14 +895,10 @@ int64_t CWallet::NullifierCount() { LOCK(cs_wallet); if(fZdebug) { - // this is our *local* nullifier count - fprintf(stderr,"%s:mapTxSaplingNullifers.size=%d\n",__FUNCTION__,(int)mapTxSaplingNullifiers.size() ); - // here be dragons - fprintf(stderr,"%s:mempool.getNullifiers.size=%d\n",__FUNCTION__,(int)mempool.getNullifiers().size() ); - // this is the global nullifier count - fprintf(stderr,"%s:cacheSaplingNullifiers.size=%d\n",__FUNCTION__,(int)pcoinsTip->getNullifiers().size() ); + //fprintf(stderr,"%s:mapTxSaplingNullifers.size=%d\n",__FUNCTION__,(int)mapTxSaplingNullifiers.size() ); + //fprintf(stderr,"%s:mempool.getNullifiers.size=%d\n",__FUNCTION__,(int)mempool.getNullifiers().size() ); + //fprintf(stderr,"%s:cacheSaplingNullifiers.size=%d\n",__FUNCTION__,(int)pcoinsTip->getNullifiers().size() ); } - // TODO: expose local nullifier stats, for now global only return pcoinsTip->getNullifiers().size(); } @@ -1373,10 +1398,9 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD bool fInsertedNew = ret.second; if (fInsertedNew) { - wtx.nTimeReceived = GetAdjustedTime(); - wtx.nOrderPos = IncOrderPosNext(pwalletdb); - - wtx.nTimeSmart = wtx.nTimeReceived; + wtx.nTimeReceived = GetTime(); + wtx.nOrderPos = IncOrderPosNext(pwalletdb); + wtx.nTimeSmart = wtx.nTimeReceived; if (!wtxIn.hashBlock.IsNull()) { if (mapBlockIndex.count(wtxIn.hashBlock)) @@ -1385,7 +1409,6 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD int64_t latestEntry = 0; { // Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future - // TODO: this is 2 blocktimes, which will become 150? int64_t latestTolerated = latestNow + 300; std::list acentries; TxItems txOrdered = OrderedTxItems(acentries); @@ -1507,6 +1530,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { + if(fDebug) + fprintf(stderr,"%s: tx=%s\n", __func__, tx.GetHash().ToString().c_str() ); + { AssertLockHeld(cs_wallet); if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) @@ -1589,6 +1615,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock) { LOCK(cs_wallet); + if(fDebug) + fprintf(stderr,"%s: tx=%s\n", __func__, tx.GetHash().ToString().c_str() ); if (!AddToWalletIfInvolvingMe(tx, pblock, true)) return; // Not one of ours @@ -1597,6 +1625,8 @@ void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock) void CWallet::MarkAffectedTransactionsDirty(const CTransaction& tx) { + if(fDebug) + fprintf(stderr,"%s: tx=%s\n", __func__, tx.GetHash().ToString().c_str() ); // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be // recomputed, also: @@ -1613,6 +1643,8 @@ void CWallet::MarkAffectedTransactionsDirty(const CTransaction& tx) mapWallet[mapSaplingNullifiersToNotes[nullifier].hash].MarkDirty(); } } + if(fDebug) + fprintf(stderr,"%s: finished marking dirty transactions\n", __func__); } void CWallet::EraseFromWallet(const uint256 &hash) @@ -1651,12 +1683,14 @@ std::pair CWallet::FindMySap { LOCK(cs_SpendingKeyStore); uint256 hash = tx.GetHash(); + uint32_t nZouts = tx.vShieldedOutput.size(); + LogPrintf("%s: zouts=%d in tx=%s\n",__func__,nZouts, hash.ToString().c_str()); mapSaplingNoteData_t noteData; SaplingIncomingViewingKeyMap viewingKeysToAdd; // Protocol Spec: 4.19 Block Chain Scanning (Sapling) - for (uint32_t i = 0; i < tx.vShieldedOutput.size(); ++i) { + for (uint32_t i = 0; i < nZouts; ++i) { const OutputDescription output = tx.vShieldedOutput[i]; bool found = false; for (auto it = mapSaplingFullViewingKeys.begin(); it != mapSaplingFullViewingKeys.end(); ++it) { @@ -2361,26 +2395,29 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, void CWallet::ReorderWalletTransactions(std::map, CWalletTx*> &mapSorted, int64_t &maxOrderPos) { LOCK2(cs_main, cs_wallet); + if(fZdebug) + fprintf(stderr,"%s: maxOrderPos=%li\n",__func__, maxOrderPos); int maxSortNumber = chainActive.Tip()->GetHeight() + 1; for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { CWalletTx* pwtx = &(it->second); - int confirms = pwtx->GetDepthInMainChain(); - maxOrderPos = max(maxOrderPos, pwtx->nOrderPos); + int confirms = pwtx->GetDepthInMainChain(); + maxOrderPos = max(maxOrderPos, pwtx->nOrderPos); if (confirms > 0) { int wtxHeight = mapBlockIndex[pwtx->hashBlock]->GetHeight(); auto key = std::make_pair(wtxHeight, pwtx->nIndex); mapSorted.insert(make_pair(key, pwtx)); - } - else { + } else { auto key = std::make_pair(maxSortNumber, 0); mapSorted.insert(std::make_pair(key, pwtx)); maxSortNumber++; } } + if(fZdebug) + fprintf(stderr,"%s: mapSorted.size=%lu\n",__func__, mapSorted.size()); } /**Update the nOrderPos with passed in ordered map. */ @@ -2391,35 +2428,46 @@ void CWallet::UpdateWalletTransactionOrder(std::map, CWalletT int64_t previousPosition = 0; std::map mapUpdatedTxs; - //Check the postion of each transaction relative to the previous one. -for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != mapSorted.end(); ++it) { - CWalletTx* pwtx = it->second; + if(fZdebug) + fprintf(stderr,"%s: maxSorted.size=%li resetOrder=%d\n",__func__, mapSorted.size(),resetOrder); + + //Check the position of each transaction relative to the previous one. + for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != mapSorted.end(); ++it) { + CWalletTx* pwtx = it->second; const uint256 wtxid = pwtx->GetHash(); if (pwtx->nOrderPos <= previousPosition || resetOrder) { previousPosition++; pwtx->nOrderPos = previousPosition; mapUpdatedTxs.insert(std::make_pair(wtxid, pwtx)); - } - else { + } else { previousPosition = pwtx->nOrderPos; } } + if(fZdebug) + fprintf(stderr,"%s: updating %li changed transactions\n",__func__, mapUpdatedTxs.size() ); + //Update transactions nOrderPos for transactions that changed CWalletDB walletdb(strWalletFile, "r+", false); for (map::iterator it = mapUpdatedTxs.begin(); it != mapUpdatedTxs.end(); ++it) { CWalletTx* pwtx = it->second; - LogPrint("deletetx","Reorder Tx - Updating Positon to %i for Tx %s\n ", pwtx->nOrderPos, pwtx->GetHash().ToString()); - pwtx->WriteToDisk(&walletdb); + LogPrintf("%s: Updating Position to %i for Tx %s\n ", __func__, pwtx->nOrderPos, pwtx->GetHash().ToString()); + bool ret = pwtx->WriteToDisk(&walletdb); + if(fZdebug) + fprintf(stderr,"%s: wrote data to disk at %s for tx=%s ret=%d\n",__func__, strWalletFile.c_str(), pwtx->GetHash().ToString().c_str(), ret ); + mapWallet[pwtx->GetHash()].nOrderPos = pwtx->nOrderPos; } + if(fZdebug) + fprintf(stderr,"%s: updated nOrderPos on %lu transactions\n",__func__, mapUpdatedTxs.size() ); - //Update Next Wallet Tx Positon + //Update Next Wallet Tx Position nOrderPosNext = previousPosition++; CWalletDB(strWalletFile).WriteOrderPosNext(nOrderPosNext); - LogPrint("deletetx","Reorder Tx - Total Transactions Reordered %i, Next Position %i\n ", mapUpdatedTxs.size(), nOrderPosNext); - + if(fZdebug) + fprintf(stderr,"%s: wrote data to disk at %s nOrderPosNext=%li\n",__func__, strWalletFile.c_str(), nOrderPosNext ); + LogPrintf("%s: Total Transactions Reordered %i, Next Position %i\n ", __func__, mapUpdatedTxs.size(), nOrderPosNext); } /** @@ -2428,34 +2476,42 @@ for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != void CWallet::DeleteTransactions(std::vector &removeTxs) { LOCK(cs_wallet); + int numTx = removeTxs.size(); + if(fZdebug) + fprintf(stderr,"%s: removeTxs.size=%d\n", __func__, numTx); + CWalletDB walletdb(strWalletFile, "r+", false); - for (int i = 0; i< removeTxs.size(); i++) { + for (int i = 0; i< numTx; i++) { if (mapWallet.erase(removeTxs[i])) { walletdb.EraseTx(removeTxs[i]); - LogPrint("deletetx","Delete Tx - Deleting tx %s, %i.\n", removeTxs[i].ToString(),i); + LogPrintf("%s: Deleted tx %s, %i.\n", __func__, removeTxs[i].ToString(),i); } else { - LogPrint("deletetx","Delete Tx - Deleting tx %failed.\n", removeTxs[i].ToString()); + LogPrintf("%s: Deleting tx %s failed.\n", __func__, removeTxs[i].ToString()); return; } } -#if defined(__unix__) || defined(_WIN64) - // Miodrag: release memory back to the OS +//TODO: the build system should check for malloc_trim support +#if defined(__unix__) malloc_trim(0); #else - //TODO: This doesn't work on Mac + // On Mac and Win memory isn't kept back upon vector or list member erase, different garbage collector strategy. No need to force trimming. #endif + + if(fZdebug) + fprintf(stderr,"%s: finished deleting %d transactions\n", __func__, numTx); } void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { - LOCK2(cs_main, cs_wallet); int nDeleteAfter = (int)fDeleteTransactionsAfterNBlocks; bool runCompact = false; - if (pindex && fTxDeleteEnabled) { + if(fZdebug) + fprintf(stderr,"%s: nDeleteAfter=%d\n",__func__,nDeleteAfter); + if (pindex && fTxDeleteEnabled) { //Check for acentries - exit function if found { std::list acentries; @@ -2475,10 +2531,9 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { if (maxOrderPos > int64_t(mapSorted.size())*10) { //reset the postion when the max postion is 10x bigger than the //number of transactions in the wallet - LogPrint("deletetx","Reorder Tx - maxOrderPos %i mapSorted Size %i\n", maxOrderPos, int64_t(mapSorted.size())*10); + LogPrintf("%s: Reorder Tx - maxOrderPos %i mapSorted Size %i\n", __func__, maxOrderPos, int64_t(mapSorted.size())*10); UpdateWalletTransactionOrder(mapSorted, true); - } - else { + } else { UpdateWalletTransactionOrder(mapSorted, false); } @@ -2503,14 +2558,16 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { txUnConfirmed++; if (wtxDepth < nDeleteAfter && wtxDepth >= 0) { - LogPrint("deletetx","DeleteTx - Transaction above minimum depth, tx %s\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Transaction above minimum depth, tx %s\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; txSaveCount++; continue; } else if (wtxDepth == -1) { //Enabled by default if (!fTxConflictDeleteEnabled) { - LogPrint("deletetx","DeleteTx - Conflict delete is not enabled tx %s\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Conflict delete is not enabled tx %s\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; txSaveCount++; continue; @@ -2518,12 +2575,12 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { txConflictCount++; } } else { - //Check for unspent inputs or spend less than N Blocks ago. (Sapling) for (auto & pair : pwtx->mapSaplingNoteData) { SaplingNoteData nd = pair.second; if (!nd.nullifier || pwalletMain->GetSaplingSpendDepth(*nd.nullifier) <= fDeleteTransactionsAfterNBlocks) { - LogPrint("deletetx","DeleteTx - Unspent sapling input tx %s\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Unspent sapling input tx %s\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; continue; } @@ -2534,6 +2591,9 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { continue; } + if(fZdebug) + LogPrintf("%s: Unspent sapling input tx %s\n", __func__, pwtx->GetHash().ToString()); + //Check for outputs that no longer have parents in the wallet. Exclude parents that are in the same transaction. (Sapling) for (int i = 0; i < pwtx->vShieldedSpend.size(); i++) { const SpendDescription& spendDesc = pwtx->vShieldedSpend[i]; @@ -2541,7 +2601,8 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { const uint256& parentHash = pwalletMain->mapSaplingNullifiersToNotes[spendDesc.nullifier].hash; const CWalletTx* parent = pwalletMain->GetWalletTx(parentHash); if (parent != NULL && parentHash != wtxid) { - LogPrint("deletetx","DeleteTx - Parent of sapling tx %s found\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Parent of sapling tx %s found\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; continue; } @@ -2553,23 +2614,16 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { continue; } - if (!deleteTx) { - txSaveCount++; - continue; - } + if(fZdebug) + LogPrintf("%s: Checking for unspent transparent inputs or spends less than %d Blocks ago\n",__func__, fDeleteTransactionsAfterNBlocks); - if (!deleteTx) { - txSaveCount++; - continue; - } - - //Check for unspent inputs or spend less than N Blocks ago. (Transparent) for (unsigned int i = 0; i < pwtx->vout.size(); i++) { CTxDestination address; ExtractDestination(pwtx->vout[i].scriptPubKey, address); if(IsMine(pwtx->vout[i])) { if (pwalletMain->GetSpendDepth(pwtx->GetHash(), i) <= fDeleteTransactionsAfterNBlocks) { - LogPrint("deletetx","DeleteTx - Unspent transparent input tx %s\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Unspent transparent input tx %s\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; continue; } @@ -2581,13 +2635,15 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { continue; } - //Chcek for output with that no longer have parents in the wallet. (Transparent) + if(fZdebug) + LogPrintf("%s: Checking for transparent outputs that no longer have parents in the wallet\n",__func__); for (int i = 0; i < pwtx->vin.size(); i++) { const CTxIn& txin = pwtx->vin[i]; const uint256& parentHash = txin.prevout.hash; const CWalletTx* parent = pwalletMain->GetWalletTx(txin.prevout.hash); if (parent != NULL && parentHash != wtxid) { - LogPrint("deletetx","DeleteTx - Parent of transparent tx %s found\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Parent of transparent tx %s found\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; continue; } @@ -2600,7 +2656,8 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { //Keep Last N Transactions if (mapSorted.size() - txCount < fKeepLastNTransactions + txConflictCount + txUnConfirmed) { - LogPrint("deletetx","DeleteTx - Transaction set position %i, tx %s\n", mapSorted.size() - txCount, wtxid.ToString()); + if(fZdebug) + LogPrint("%s: Transaction set position %i, tx %s\n", __func__, mapSorted.size() - txCount, wtxid.ToString()); deleteTx = false; txSaveCount++; continue; @@ -2616,11 +2673,14 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { //Delete Transactions from wallet DeleteTransactions(removeTxs); - LogPrintf("Delete Tx - Total Transaction Count %i, Transactions Deleted %i\n ", txCount, int(removeTxs.size())); + LogPrintf("%s: Total Transaction Count %i, Transactions Deleted %i\n ", __func__, txCount, int(removeTxs.size())); //Compress Wallet - if (runCompact) - CWalletDB::Compact(bitdb,strWalletFile); + if (runCompact) { + if(fZdebug) + fprintf(stderr,"%s: compacting wallet\n",__func__); + CWalletDB::Compact(bitdb,strWalletFile); + } } } @@ -2634,9 +2694,10 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) int ret = 0; int64_t nNow = GetTime(); const CChainParams& chainParams = Params(); + if(fZdebug) + LogPrintf("%s: fUpdate=%d now=%li\n",__func__,fUpdate,nNow); CBlockIndex* pindex = pindexStart; - { LOCK2(cs_main, cs_wallet); @@ -2662,18 +2723,16 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) } } - //SproutMerkleTree sproutTree; SaplingMerkleTree saplingTree; // This should never fail: we should always be able to get the tree // state on the path to the tip of our chain - //assert(pcoinsTip->GetSproutAnchorAt(pindex->hashSproutAnchor, sproutTree)); if (pindex->pprev) { if (NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, saplingTree)); } } - // Build inital witness caches + // Build initial witness caches BuildWitnessCache(pindex, true); //Delete Transactions @@ -2697,6 +2756,10 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) void CWallet::ReacceptWalletTransactions() { + int64_t nNow = GetTime(); + if(fZdebug) + LogPrintf("%s: now=%li\n",__func__,nNow); + if ( IsInitialBlockDownload() ) return; // If transactions aren't being broadcasted, don't let them into local mempool either @@ -2739,7 +2802,7 @@ void CWallet::ReacceptWalletTransactions() if (!wtx.IsCoinBase() && invalid && nDoS > 0 && state.GetRejectReason() != "tx-overwinter-expired") { - LogPrintf("erasing transaction %s\n", wtx.GetHash().GetHex().c_str()); + LogPrintf("%s: erasing transaction %s\n", __func__, wtx.GetHash().GetHex().c_str()); vwtxh.push_back(wtx.GetHash()); } } @@ -2752,6 +2815,9 @@ void CWallet::ReacceptWalletTransactions() bool CWalletTx::RelayWalletTransaction() { + int64_t nNow = GetTime(); + if(fZdebug) + LogPrintf("%s: now=%li\n",__func__,nNow); if ( pwallet == 0 ) { //fprintf(stderr,"unexpected null pwallet in RelayWalletTransaction\n"); @@ -3932,6 +3998,8 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) // Track how many getdata requests our transaction gets mapRequestCount[wtxNew.GetHash()] = 0; + std::string strCmd = GetArg("-txsend", ""); + if (fBroadcastTransactions) { // Broadcast @@ -3944,6 +4012,12 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) } wtxNew.RelayWalletTransaction(); } + // If we are configured to send transactions via an + // external service instead of broadcasting, do that + else if (!strCmd.empty()) { + boost::replace_all(strCmd, "%s", EncodeHexTx(wtxNew)); + boost::thread t(runCommand, strCmd); // thread runs free + } } return true; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index f6e6274d1..5a8ee7012 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -100,6 +100,8 @@ static const unsigned int DEFAULT_TX_RETENTION_LASTTX = 200; //Amount of transactions to delete per run while syncing static const int MAX_DELETE_TX_SIZE = 50000; +extern const char * DEFAULT_WALLET_DAT; + class CBlockIndex; class CCoinControl; class COutput; @@ -1071,7 +1073,8 @@ public: * Sapling ZKeys */ //! Generates new Sapling key - libzcash::SaplingPaymentAddress GenerateNewSaplingZKey(); + // Sietch uses addToWallet=false + libzcash::SaplingPaymentAddress GenerateNewSaplingZKey(bool addToWallet=true); //! Adds Sapling spending key to the store, and saves it to disk bool AddSaplingZKey( const libzcash::SaplingExtendedSpendingKey &key, diff --git a/src/wallet/wallet_ismine.cpp b/src/wallet/wallet_ismine.cpp index 692d0280d..ed260125a 100644 --- a/src/wallet/wallet_ismine.cpp +++ b/src/wallet/wallet_ismine.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/wallet_ismine.h b/src/wallet/wallet_ismine.h index 409def1ef..57b0a164b 100644 --- a/src/wallet/wallet_ismine.h +++ b/src/wallet/wallet_ismine.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 71331ed93..6fb3e543e 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/zcash/zip32.cpp b/src/zcash/zip32.cpp index 615c5896d..820c99fa2 100644 --- a/src/zcash/zip32.cpp +++ b/src/zcash/zip32.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "zip32.h" diff --git a/src/zcash/zip32.h b/src/zcash/zip32.h index 1521dddd1..88095f981 100644 --- a/src/zcash/zip32.h +++ b/src/zcash/zip32.h @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef ZCASH_ZIP32_H #define ZCASH_ZIP32_H diff --git a/src/zmq/zmqabstractnotifier.cpp b/src/zmq/zmqabstractnotifier.cpp index 3562a8824..75bb7b505 100644 --- a/src/zmq/zmqabstractnotifier.cpp +++ b/src/zmq/zmqabstractnotifier.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "zmqabstractnotifier.h" #include "util.h" diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h index 8873b71d8..090b0b8f5 100644 --- a/src/zmq/zmqabstractnotifier.h +++ b/src/zmq/zmqabstractnotifier.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H #define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H diff --git a/src/zmq/zmqconfig.h b/src/zmq/zmqconfig.h index 6057f5d1a..d382071df 100644 --- a/src/zmq/zmqconfig.h +++ b/src/zmq/zmqconfig.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ZMQ_ZMQCONFIG_H #define BITCOIN_ZMQ_ZMQCONFIG_H diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp index 0d8c36ad2..0745890b4 100644 --- a/src/zmq/zmqnotificationinterface.cpp +++ b/src/zmq/zmqnotificationinterface.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "zmqnotificationinterface.h" #include "zmqpublishnotifier.h" diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h index e0fe3b570..0fe2f4bab 100644 --- a/src/zmq/zmqnotificationinterface.h +++ b/src/zmq/zmqnotificationinterface.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H #define BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp index e3fd635f2..14ff40f08 100644 --- a/src/zmq/zmqpublishnotifier.cpp +++ b/src/zmq/zmqpublishnotifier.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "zmqpublishnotifier.h" #include "main.h" diff --git a/src/zmq/zmqpublishnotifier.h b/src/zmq/zmqpublishnotifier.h index 627c8af96..d5b752eda 100644 --- a/src/zmq/zmqpublishnotifier.h +++ b/src/zmq/zmqpublishnotifier.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H #define BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H diff --git a/zcutil/build-arm.sh b/zcutil/build-arm.sh index 2131fa7cb..838607c7e 100644 --- a/zcutil/build-arm.sh +++ b/zcutil/build-arm.sh @@ -51,7 +51,7 @@ PREFIX="$(pwd)/depends/aarch64-unknown-linux-gnu/" HOST=aarch64-unknown-linux-gnu BUILD=aarch64-unknown-linux-gnu make "$@" -C ./depends/ V=1 NO_QT=1 ./autogen.sh -CONFIG_SITE="$(pwd)/depends/aarch64-unknown-linux-gnu/share/config.site" ./configure --prefix="${PREFIX}" --host=aarch64-unknown-linux-gnu --build=aarch64-unknown-linux-gnu --with-gui=no --enable-rust=no --disable-proton "$HARDENING_ARG" "$LCOV_ARG" CXXFLAGS='-fwrapv -fno-strict-aliasing -g' +CONFIG_SITE="$(pwd)/depends/aarch64-unknown-linux-gnu/share/config.site" ./configure --prefix="${PREFIX}" --host=aarch64-unknown-linux-gnu --build=aarch64-unknown-linux-gnu --with-gui=no --enable-rust=no "$HARDENING_ARG" "$LCOV_ARG" CXXFLAGS='-fwrapv -fno-strict-aliasing -g' #BUILD CCLIB diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index 096ca96e4..12e426e71 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -43,7 +43,7 @@ fi TRIPLET=`./depends/config.guess` PREFIX="$(pwd)/depends/$TRIPLET" -make "$@" -C ./depends/ V=1 NO_QT=1 NO_PROTON=1 +make "$@" -C ./depends/ V=1 NO_QT=1 #BUILD CCLIB diff --git a/zcutil/build.sh b/zcutil/build.sh index 76980476b..6b90c0e01 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -58,12 +58,11 @@ Welcome To The Hush Build System, Here Be Dragons! Usage: $0 --help Show this help message and exit. -$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --enable-proton ] [ --disable-libs ] [ MAKEARGS... ] +$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --disable-libs ] [ MAKEARGS... ] Build Hush and most of its transitive dependencies from source. MAKEARGS are applied to both dependencies and Hush itself. If --enable-lcov is passed, Hush is configured to add coverage instrumentation, thus enabling "make cov" to work. If --disable-tests is passed instead, the Hush tests are not built. If --disable-mining is passed, Hush is configured to not build any mining code. It must be passed after the test arguments, if present. - If --enable-proton is passed, Hush is configured to build the Apache Qpid Proton library required for AMQP support. This library is not built by default. It must be passed after the test/mining arguments, if present. EOF exit 0 @@ -94,25 +93,17 @@ then shift fi -# If --enable-proton is the next argument, enable building Proton code: -PROTON_ARG='--enable-proton=no' -if [ "x${1:-}" = 'x--enable-proton' ] -then - PROTON_ARG='' - shift -fi - # Just show the useful info eval "$MAKE" --version | head -n2 as --version | head -n1 as --version | tail -n1 ld -v -HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 +HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh -CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' +CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' #BUILD CCLIB