diff --git a/qa/hush/create_benchmark_archive.py b/qa/hush/create_benchmark_archive.py index 84bd236de..b9cc314ab 100644 --- a/qa/hush/create_benchmark_archive.py +++ b/qa/hush/create_benchmark_archive.py @@ -1,3 +1,6 @@ +# Copyright (c) 2016-2020 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html import binascii import calendar import json @@ -10,13 +13,13 @@ import sys import tarfile import time -ZCASH_CLI = './src/zcash-cli' +HUSH_CLI = './src/hush-cli' USAGE = """ Requirements: - find - xz -- %s (edit ZCASH_CLI in this script to alter the path) -- A running mainnet zcashd using the default datadir with -txindex=1 +- %s (edit HUSH_CLI in this script to alter the path) +- A running mainnet hushd using the default datadir with -txindex=1 Example usage: @@ -25,11 +28,11 @@ virtualenv venv . venv/bin/activate pip install --global-option=build_ext --global-option="-L$(pwd)/src/leveldb/" --global-option="-I$(pwd)/src/leveldb/include/" plyvel pip install progressbar2 -LD_LIBRARY_PATH=src/leveldb python qa/zcash/create_benchmark_archive.py -""" % ZCASH_CLI +LD_LIBRARY_PATH=src/leveldb python qa/hush/create_benchmark_archive.py +""" % HUSH_CLI def check_deps(): - if subprocess.call(['which', 'find', 'xz', ZCASH_CLI], stdout=subprocess.PIPE): + if subprocess.call(['which', 'find', 'xz', HUSH_CLI], stdout=subprocess.PIPE): print USAGE sys.exit() @@ -154,15 +157,15 @@ def deterministic_filter(tarinfo): return tarinfo def create_benchmark_archive(blk_hash): - blk = json.loads(subprocess.check_output([ZCASH_CLI, 'getblock', blk_hash])) + blk = json.loads(subprocess.check_output([HUSH_CLI, 'getblock', blk_hash])) print 'Height: %d' % blk['height'] print 'Transactions: %d' % len(blk['tx']) os.mkdir('benchmark') with open('benchmark/block-%d.dat' % blk['height'], 'wb') as f: - f.write(binascii.unhexlify(subprocess.check_output([ZCASH_CLI, 'getblock', blk_hash, 'false']).strip())) + f.write(binascii.unhexlify(subprocess.check_output([HUSH_CLI, 'getblock', blk_hash, 'false']).strip())) - txs = [json.loads(subprocess.check_output([ZCASH_CLI, 'getrawtransaction', tx, '1']) + txs = [json.loads(subprocess.check_output([HUSH_CLI, 'getrawtransaction', tx, '1']) ) for tx in blk['tx']] js_txs = len([tx for tx in txs if len(tx['vjoinsplit']) > 0]) @@ -187,7 +190,7 @@ def create_benchmark_archive(blk_hash): bar = progressbar.ProgressBar(redirect_stdout=True) print 'Collecting input coins for block' for tx in bar(unique_inputs.keys()): - rawtx = json.loads(subprocess.check_output([ZCASH_CLI, 'getrawtransaction', tx, '1'])) + rawtx = json.loads(subprocess.check_output([HUSH_CLI, 'getrawtransaction', tx, '1'])) mask_size = 0 mask_code = 0 @@ -235,7 +238,7 @@ def create_benchmark_archive(blk_hash): binascii.unhexlify(rawtx['vout'][i]['scriptPubKey']['hex']))) # - VARINT(nHeight) coins.extend(encode_varint(json.loads( - subprocess.check_output([ZCASH_CLI, 'getblockheader', rawtx['blockhash']]) + subprocess.check_output([HUSH_CLI, 'getblockheader', rawtx['blockhash']]) )['height'])) db_key = b'c' + bytes(binascii.unhexlify(tx)[::-1]) diff --git a/qa/hush/create_wallet_200k_utxos.py b/qa/hush/create_wallet_200k_utxos.py index ee0139950..ea0b057bf 100644 --- a/qa/hush/create_wallet_200k_utxos.py +++ b/qa/hush/create_wallet_200k_utxos.py @@ -1,9 +1,8 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2017 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - -# # Create a large wallet # # To use: @@ -11,7 +10,6 @@ # - Add wallet_large.py to RPC tests list # - ./qa/pull-tester/rpc-tests.sh wallet_large --nocleanup # - Archive the resulting /tmp/test###### directory -# from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( diff --git a/qa/hush/full-test-suite.sh b/qa/hush/full-test-suite.sh index f8ebbb895..d046741c9 100755 --- a/qa/hush/full-test-suite.sh +++ b/qa/hush/full-test-suite.sh @@ -1,7 +1,8 @@ #!/usr/bin/env python2 # Copyright (c) 2016-2020 The Hush developers -# Released under the GPLv3 # Execute all of the automated tests related to Hush +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html import argparse import os diff --git a/qa/hush/full_test_suite.py b/qa/hush/full_test_suite.py index 754884092..ec6a8d19a 100755 --- a/qa/hush/full_test_suite.py +++ b/qa/hush/full_test_suite.py @@ -1,9 +1,8 @@ #!/usr/bin/env python2 # Copyright (c) 2016-2020 The Hush developers -# Released under the GPLv3 -# +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # Execute all of the automated tests related to Hush -# import argparse from glob import glob diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md index f5f3da760..472c38874 100644 --- a/qa/rpc-tests/README.md +++ b/qa/rpc-tests/README.md @@ -20,10 +20,9 @@ Possible options: ``` -h, --help show this help message and exit - --nocleanup Leave komodods and test.* datadir on exit or error - --noshutdown Don't stop komodods after the test execution - --srcdir=SRCDIR Source directory containing hushd/hush-cli (default: - ../../src) + --nocleanup Leave binaries and test.* datadir on exit or error + --noshutdown Don't stop full node after the test execution + --srcdir=SRCDIR Source directory containing hushd/hush-cli (default: ../../src) --tmpdir=TMPDIR Root directory for datadirs --tracerpc Print out all RPC calls as they are made ``` @@ -39,8 +38,7 @@ After the first run, the cache/ blockchain and wallets are copied into a temporary directory and used as the initial test state. -If you get into a bad state, you should be able -to recover with: +If you get into a bad state, you should be able to recover with: ```bash rm -rf cache diff --git a/qa/rpc-tests/ac_private.py b/qa/rpc-tests/ac_private.py index 9d4e376f5..5c871d49c 100755 --- a/qa/rpc-tests/ac_private.py +++ b/qa/rpc-tests/ac_private.py @@ -1,8 +1,6 @@ #!/usr/bin/env python2 -# Copyright (c) 2018-2020 The Hush developers +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers -# Released under the GPLv3 - # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/addressindex.py b/qa/rpc-tests/addressindex.py index c0fbc107f..9b321cd6d 100755 --- a/qa/rpc-tests/addressindex.py +++ b/qa/rpc-tests/addressindex.py @@ -1,11 +1,9 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers +# Copyright (c) 2016-2020 The Hush developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - -# # Test addressindex generation and fetching -# import time from test_framework.test_framework import BitcoinTestFramework @@ -346,4 +344,4 @@ class AddressIndexTest(BitcoinTestFramework): if __name__ == '__main__': - AddressIndexTest().main() \ No newline at end of file + AddressIndexTest().main() diff --git a/qa/rpc-tests/bip65-cltv-p2p.py b/qa/rpc-tests/bip65-cltv-p2p.py index c0665777a..8aef7fe0e 100755 --- a/qa/rpc-tests/bip65-cltv-p2p.py +++ b/qa/rpc-tests/bip65-cltv-p2p.py @@ -1,8 +1,7 @@ #!/usr/bin/env python2 -# -# Distributed under the GPLv3/X11 software license, see the accompanying +# Copyright (c) 2016-2020 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -# from test_framework.test_framework import ComparisonTestFramework from test_framework.util import start_nodes diff --git a/qa/rpc-tests/bipdersig-p2p.py b/qa/rpc-tests/bipdersig-p2p.py index 595e23180..d03dcf004 100755 --- a/qa/rpc-tests/bipdersig-p2p.py +++ b/qa/rpc-tests/bipdersig-p2p.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -# +# Copyright (c) 2016-2020 The Hush developers # Distributed under the GPLv3/X11 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # diff --git a/qa/rpc-tests/blockchain.py b/qa/rpc-tests/blockchain.py index affd50a37..59acb737c 100755 --- a/qa/rpc-tests/blockchain.py +++ b/qa/rpc-tests/blockchain.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions.py b/qa/rpc-tests/cryptoconditions.py index cfed77a4b..44bd89001 100755 --- a/qa/rpc-tests/cryptoconditions.py +++ b/qa/rpc-tests/cryptoconditions.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 086eb2eb8..1158f0cc7 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 3a4e87333..e2622ffaf 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index 99cf673a4..ecbaa6ae6 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py index 52d5a2ab4..824219586 100755 --- a/qa/rpc-tests/cryptoconditions_gateways.py +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py index 9e07e283a..ddce32bc9 100755 --- a/qa/rpc-tests/cryptoconditions_heir.py +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index e916d5002..36e4169da 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 86ee97753..b2136c903 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index e2da04f41..1799739dd 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 SuperNET developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/decodescript.py b/qa/rpc-tests/decodescript.py index 0a46413f9..309af1712 100755 --- a/qa/rpc-tests/decodescript.py +++ b/qa/rpc-tests/decodescript.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/disablewallet.py b/qa/rpc-tests/disablewallet.py index db7260741..d07724842 100755 --- a/qa/rpc-tests/disablewallet.py +++ b/qa/rpc-tests/disablewallet.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/finalsaplingroot.py b/qa/rpc-tests/finalsaplingroot.py index 491bdbc4b..75933abf9 100755 --- a/qa/rpc-tests/finalsaplingroot.py +++ b/qa/rpc-tests/finalsaplingroot.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/forknotify.py b/qa/rpc-tests/forknotify.py index c571d1243..4499dda3a 100755 --- a/qa/rpc-tests/forknotify.py +++ b/qa/rpc-tests/forknotify.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py index dd19b267e..4daf95f13 100755 --- a/qa/rpc-tests/fundrawtransaction.py +++ b/qa/rpc-tests/fundrawtransaction.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/getblocktemplate.py b/qa/rpc-tests/getblocktemplate.py index 77517d6b3..d72142963 100755 --- a/qa/rpc-tests/getblocktemplate.py +++ b/qa/rpc-tests/getblocktemplate.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2016 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/getblocktemplate_longpoll.py b/qa/rpc-tests/getblocktemplate_longpoll.py index a078f0c2d..753d9aed6 100755 --- a/qa/rpc-tests/getblocktemplate_longpoll.py +++ b/qa/rpc-tests/getblocktemplate_longpoll.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/getblocktemplate_proposals.py b/qa/rpc-tests/getblocktemplate_proposals.py index 3687e3c23..6c935f95a 100755 --- a/qa/rpc-tests/getblocktemplate_proposals.py +++ b/qa/rpc-tests/getblocktemplate_proposals.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/getchaintips.py b/qa/rpc-tests/getchaintips.py index 121be3fb5..cfd19ee47 100755 --- a/qa/rpc-tests/getchaintips.py +++ b/qa/rpc-tests/getchaintips.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/hardforkdetection.py b/qa/rpc-tests/hardforkdetection.py index dbfb5cd34..a2bf39f77 100755 --- a/qa/rpc-tests/hardforkdetection.py +++ b/qa/rpc-tests/hardforkdetection.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # # Test hard fork detection diff --git a/qa/rpc-tests/httpbasics.py b/qa/rpc-tests/httpbasics.py index e739428df..96578d106 100755 --- a/qa/rpc-tests/httpbasics.py +++ b/qa/rpc-tests/httpbasics.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/invalidateblock.py b/qa/rpc-tests/invalidateblock.py index 45623e2a7..a0aa2c278 100755 --- a/qa/rpc-tests/invalidateblock.py +++ b/qa/rpc-tests/invalidateblock.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/invalidblockrequest.py b/qa/rpc-tests/invalidblockrequest.py index 1bb85c905..71ef3a325 100755 --- a/qa/rpc-tests/invalidblockrequest.py +++ b/qa/rpc-tests/invalidblockrequest.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # # Distributed under the GPLv3/X11 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/ivk_import_export.py b/qa/rpc-tests/ivk_import_export.py index 30765744d..b7834ce8d 100755 --- a/qa/rpc-tests/ivk_import_export.py +++ b/qa/rpc-tests/ivk_import_export.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2019 Bartlomiej Lisiecki # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/key_import_export.py b/qa/rpc-tests/key_import_export.py index 1e4afe9a7..1a799f488 100755 --- a/qa/rpc-tests/key_import_export.py +++ b/qa/rpc-tests/key_import_export.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2017 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/keypool.py b/qa/rpc-tests/keypool.py index e3cdf203a..c663fe752 100755 --- a/qa/rpc-tests/keypool.py +++ b/qa/rpc-tests/keypool.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/listtransactions.py b/qa/rpc-tests/listtransactions.py index 808578f8c..90eae5f55 100755 --- a/qa/rpc-tests/listtransactions.py +++ b/qa/rpc-tests/listtransactions.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/maxblocksinflight.py b/qa/rpc-tests/maxblocksinflight.py index a083bcaa8..04780139c 100755 --- a/qa/rpc-tests/maxblocksinflight.py +++ b/qa/rpc-tests/maxblocksinflight.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # # Distributed under the GPLv3/X11 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/mempool_nu_activation.py b/qa/rpc-tests/mempool_nu_activation.py index d45b3e430..50d9a2ce9 100755 --- a/qa/rpc-tests/mempool_nu_activation.py +++ b/qa/rpc-tests/mempool_nu_activation.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/mempool_reorg.py b/qa/rpc-tests/mempool_reorg.py index 57e06f0bd..98b61a70a 100755 --- a/qa/rpc-tests/mempool_reorg.py +++ b/qa/rpc-tests/mempool_reorg.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/mempool_resurrect_test.py b/qa/rpc-tests/mempool_resurrect_test.py index b5a9f8704..8e7ffacd5 100755 --- a/qa/rpc-tests/mempool_resurrect_test.py +++ b/qa/rpc-tests/mempool_resurrect_test.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/mempool_spendcoinbase.py b/qa/rpc-tests/mempool_spendcoinbase.py index 53c3625ca..335d94187 100755 --- a/qa/rpc-tests/mempool_spendcoinbase.py +++ b/qa/rpc-tests/mempool_spendcoinbase.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/mempool_tx_expiry.py b/qa/rpc-tests/mempool_tx_expiry.py index f96055386..d28944a83 100755 --- a/qa/rpc-tests/mempool_tx_expiry.py +++ b/qa/rpc-tests/mempool_tx_expiry.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/mempool_tx_input_limit.py b/qa/rpc-tests/mempool_tx_input_limit.py index 7f6ed446a..ace5ac59d 100755 --- a/qa/rpc-tests/mempool_tx_input_limit.py +++ b/qa/rpc-tests/mempool_tx_input_limit.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2017 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/merkle_blocks.py b/qa/rpc-tests/merkle_blocks.py index 9a593afe5..065d46fd1 100755 --- a/qa/rpc-tests/merkle_blocks.py +++ b/qa/rpc-tests/merkle_blocks.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/nodehandling.py b/qa/rpc-tests/nodehandling.py index e26c9da83..1aea66eb0 100755 --- a/qa/rpc-tests/nodehandling.py +++ b/qa/rpc-tests/nodehandling.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/nspv_client_test.py b/qa/rpc-tests/nspv_client_test.py index 26f88cf5a..9bb0f293f 100755 --- a/qa/rpc-tests/nspv_client_test.py +++ b/qa/rpc-tests/nspv_client_test.py @@ -1,7 +1,11 @@ +#!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html import sys -sys.path.append('../../src/tui') - -from lib import tuilib +# tuilib was removed, tests left here as inspiration +#sys.path.append('../../src/tui') +#from lib import tuilib import unittest import time @@ -11,17 +15,17 @@ change chain parameters if needed or add a new chain to test below added 1 second sleep after each case to surely not face the nSPV server limitation (1 call/second) ''' -wif = '' +wif = '' dest_address = '' -amount = '0.01' -chain = 'ILN' +amount = '0.01' +chain = 'HUSH3' if not wif or not dest_address: raise Exception("Please set test wif and address to send transactions to") rpc_proxy = tuilib.def_credentials(chain) -chain_params = {"KMD": { +chain_params = {"HUSH3": { 'tx_list_address': 'RGShWG446Pv24CKzzxjA23obrzYwNbs1kA', 'min_chain_height': 1468080, 'notarization_height': '1468000', @@ -33,19 +37,6 @@ chain_params = {"KMD": { 'tx_proof_id': 'f7beb36a65bc5bcbc9c8f398345aab7948160493955eb4a1f05da08c4ac3784f', 'tx_spent_height': 1456212, 'tx_proof_height': '1468520', - }, - "ILN": { - 'tx_list_address': 'RUp3xudmdTtxvaRnt3oq78FJBjotXy55uu', - 'min_chain_height': 3689, - 'notarization_height': '2000', - 'prev_notarization_h': 1998, - 'next_notarization_h': 2008, - 'hdrs_proof_low': '2000', - 'hdrs_proof_high': '2100', - 'numhdrs_expected': 113, - 'tx_proof_id': '67ffe0eaecd6081de04675c492a59090b573ee78955c4e8a85b8ac0be0e8e418', - 'tx_spent_height': 2681, - 'tx_proof_height': '2690', } } @@ -98,7 +89,7 @@ class TestNspvClient(unittest.TestCase): print("testing nspv_login") result = rpc_proxy.nspv_login(wif) self.assertEqual(result["result"], "success") - self.assertEqual(result["status"], "wif will expire in 777 seconds") + self.assertEqual(result["status"], "wif will expire in 555 seconds") time.sleep(1) def test_nspv_listunspent(self): @@ -156,9 +147,9 @@ class TestNspvClient(unittest.TestCase): time.sleep(1) def test_nspv_login_timout(self): - print("testing auto-logout in 777 seconds") + print("testing auto-logout in 555 seconds") rpc_proxy.nspv_login(wif) - time.sleep(778) + time.sleep(556) result = rpc_proxy.nspv_spend(dest_address, amount) self.assertEqual(result["result"], "error") self.assertEqual(result["error"], "wif expired") diff --git a/qa/rpc-tests/p2p-acceptblock.py b/qa/rpc-tests/p2p-acceptblock.py index 4fd47cf33..77895df7c 100755 --- a/qa/rpc-tests/p2p-acceptblock.py +++ b/qa/rpc-tests/p2p-acceptblock.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # # Distributed under the GPLv3/X11 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/p2p_node_bloom.py b/qa/rpc-tests/p2p_node_bloom.py index fac89cb6c..9bb9e9f71 100755 --- a/qa/rpc-tests/p2p_node_bloom.py +++ b/qa/rpc-tests/p2p_node_bloom.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/p2p_txexpiry_dos.py b/qa/rpc-tests/p2p_txexpiry_dos.py index 582cafd6b..ca72c3baa 100755 --- a/qa/rpc-tests/p2p_txexpiry_dos.py +++ b/qa/rpc-tests/p2p_txexpiry_dos.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/prioritisetransaction.py b/qa/rpc-tests/prioritisetransaction.py index 09647ebd1..8572bf195 100755 --- a/qa/rpc-tests/prioritisetransaction.py +++ b/qa/rpc-tests/prioritisetransaction.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2017 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/proxy_test.py b/qa/rpc-tests/proxy_test.py index 31b96f594..897ff369e 100755 --- a/qa/rpc-tests/proxy_test.py +++ b/qa/rpc-tests/proxy_test.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/pruning.py b/qa/rpc-tests/pruning.py index c6a61f6c4..7e85a9853 100755 --- a/qa/rpc-tests/pruning.py +++ b/qa/rpc-tests/pruning.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/rawtransactions.py b/qa/rpc-tests/rawtransactions.py index d70352e2a..88cf55f93 100755 --- a/qa/rpc-tests/rawtransactions.py +++ b/qa/rpc-tests/rawtransactions.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/receivedby.py b/qa/rpc-tests/receivedby.py index 0374381cf..a630d65d3 100755 --- a/qa/rpc-tests/receivedby.py +++ b/qa/rpc-tests/receivedby.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py index aee67ffa1..3943af911 100755 --- a/qa/rpc-tests/rest.py +++ b/qa/rpc-tests/rest.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/rewind_index.py b/qa/rpc-tests/rewind_index.py index de2ed966c..e7b9d4e44 100755 --- a/qa/rpc-tests/rewind_index.py +++ b/qa/rpc-tests/rewind_index.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py index 09fb630f3..6e8180fe3 100755 --- a/qa/rpc-tests/rpcbind_test.py +++ b/qa/rpc-tests/rpcbind_test.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/script_test.py b/qa/rpc-tests/script_test.py index ea61a04d0..d1e6064f1 100755 --- a/qa/rpc-tests/script_test.py +++ b/qa/rpc-tests/script_test.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # # Distributed under the GPLv3/X11 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/signrawtransaction_offline.py b/qa/rpc-tests/signrawtransaction_offline.py index 0d7def43b..0318b8663 100755 --- a/qa/rpc-tests/signrawtransaction_offline.py +++ b/qa/rpc-tests/signrawtransaction_offline.py @@ -1,4 +1,7 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_true, initialize_chain_clean, start_node @@ -54,4 +57,4 @@ class SignOfflineTest (BitcoinTestFramework): assert_true(len(online_tx_hash) > 0) if __name__ == '__main__': - SignOfflineTest().main() \ No newline at end of file + SignOfflineTest().main() diff --git a/qa/rpc-tests/signrawtransactions.py b/qa/rpc-tests/signrawtransactions.py index 4508784d6..a92a4a7eb 100755 --- a/qa/rpc-tests/signrawtransactions.py +++ b/qa/rpc-tests/signrawtransactions.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/smartfees.py b/qa/rpc-tests/smartfees.py index b072f224f..caf879564 100755 --- a/qa/rpc-tests/smartfees.py +++ b/qa/rpc-tests/smartfees.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/spentindex.py b/qa/rpc-tests/spentindex.py index a2ce5f2b8..090fa7920 100755 --- a/qa/rpc-tests/spentindex.py +++ b/qa/rpc-tests/spentindex.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html @@ -136,4 +137,4 @@ class SpentIndexTest(BitcoinTestFramework): if __name__ == '__main__': - SpentIndexTest().main() \ No newline at end of file + SpentIndexTest().main() diff --git a/qa/rpc-tests/test_framework/authproxy.py b/qa/rpc-tests/test_framework/authproxy.py index 28b33e286..553d6fc89 100644 --- a/qa/rpc-tests/test_framework/authproxy.py +++ b/qa/rpc-tests/test_framework/authproxy.py @@ -1,3 +1,6 @@ +# Copyright (c) 2016-2020 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html """ Copyright 2011 Jeff Garzik @@ -47,10 +50,8 @@ try: except ImportError: import urlparse -USER_AGENT = "AuthServiceProxy/0.1" - +USER_AGENT = "FUCKjl777LULZ" HTTP_TIMEOUT = 600 - log = logging.getLogger("BitcoinRPC") class JSONRPCException(Exception): diff --git a/qa/rpc-tests/test_framework/bignum.py b/qa/rpc-tests/test_framework/bignum.py index 7343ac920..799b1929f 100644 --- a/qa/rpc-tests/test_framework/bignum.py +++ b/qa/rpc-tests/test_framework/bignum.py @@ -1,12 +1,7 @@ -# -# -# bignum.py -# -# This file is copied from python-bitcoinlib. -# +# Copyright (c) 2016-2020 The Hush developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -# +# This file is from python-bitcoinlib. """Bignum routines""" diff --git a/qa/rpc-tests/test_framework/blockstore.py b/qa/rpc-tests/test_framework/blockstore.py index fc157f718..5f1aa3752 100644 --- a/qa/rpc-tests/test_framework/blockstore.py +++ b/qa/rpc-tests/test_framework/blockstore.py @@ -1,3 +1,6 @@ +# Copyright (c) 2016-2020 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # BlockStore: a helper class that keeps a map of blocks and implements # helper functions for responding to getheaders and getdata, # and for constructing a getheaders message diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py index c546e63eb..0c0e09230 100644 --- a/qa/rpc-tests/test_framework/blocktools.py +++ b/qa/rpc-tests/test_framework/blocktools.py @@ -1,9 +1,7 @@ -# blocktools.py - utilities for manipulating blocks and transactions -# +# Copyright (c) 2016-2020 The Hush developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -# - +# blocktools.py - utilities for manipulating blocks and transactions from mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint from script import CScript, OP_0, OP_EQUAL, OP_HASH160 diff --git a/qa/rpc-tests/test_framework/comptool.py b/qa/rpc-tests/test_framework/comptool.py index b956690dd..45034ec47 100755 --- a/qa/rpc-tests/test_framework/comptool.py +++ b/qa/rpc-tests/test_framework/comptool.py @@ -1,8 +1,7 @@ #!/usr/bin/env python2 -# +# Copyright (c) 2016-2020 The Hush developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -# from mininode import CBlock, CTransaction, CInv, NodeConn, NodeConnCB, \ msg_inv, msg_getheaders, msg_ping, msg_mempool, mininode_lock, MAX_INV_SZ diff --git a/qa/rpc-tests/test_framework/equihash.py b/qa/rpc-tests/test_framework/equihash.py index e40451978..15c3d2ebb 100755 --- a/qa/rpc-tests/test_framework/equihash.py +++ b/qa/rpc-tests/test_framework/equihash.py @@ -1,3 +1,6 @@ +# Copyright (c) 2016-2020 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html from operator import itemgetter import struct diff --git a/qa/rpc-tests/test_framework/mininode.py b/qa/rpc-tests/test_framework/mininode.py index dab40a39d..74909baaf 100755 --- a/qa/rpc-tests/test_framework/mininode.py +++ b/qa/rpc-tests/test_framework/mininode.py @@ -1,6 +1,7 @@ -# mininode.py - Bitcoin P2P network half-a-node # Copyright (c) 2016-2020 The Hush developers -# Lovingly maintained and released under the GPLv3 +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html +# mininode.py - Bitcoin P2P network half-a-node # # This python code was modified from ArtForz' public domain half-a-node, as # found in the mini-node branch of http://github.com/jgarzik/pynode. @@ -40,18 +41,14 @@ from .equihash import ( zcash_person, ) -OVERWINTER_PROTO_VERSION = 170003 -BIP0031_VERSION = 60000 -SPROUT_PROTO_VERSION = 170002 # past bip-31 for ping/pong -SAPLING_PROTO_VERSION = 170006 -MY_SUBVERSION = "/python-mininode-hush-tester:3.3.0/" - +OVERWINTER_PROTO_VERSION = 170003 +BIP0031_VERSION = 60000 +SPROUT_PROTO_VERSION = 170002 # past bip-31 for ping/pong +SAPLING_PROTO_VERSION = 1987420 +MY_SUBVERSION = "/SpicySand/" OVERWINTER_VERSION_GROUP_ID = 0x03C48270 - -MAX_INV_SZ = 50000 - - -COIN = 100000000 # 1 HUSH in puposhis +MAX_INV_SZ = 50000 +COIN = 100000000 # 1 HUSH in puposhis # Keep our own socket map for asyncore, so that we can track disconnects # ourselves (to workaround an issue with closing an asyncore socket when @@ -417,14 +414,14 @@ ZC_NOTEPLAINTEXT_LEADING = 1 ZC_V_SIZE = 8 ZC_RHO_SIZE = 32 ZC_R_SIZE = 32 -ZC_MEMO_SIZE = 512 +HUSH_MEMO_SIZE = 512 ZC_NOTEPLAINTEXT_SIZE = ( ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + - ZC_MEMO_SIZE + HUSH_MEMO_SIZE ) NOTEENCRYPTION_AUTH_BYTES = 16 diff --git a/qa/rpc-tests/test_framework/netutil.py b/qa/rpc-tests/test_framework/netutil.py index 59ffe9fc0..125cfebf8 100644 --- a/qa/rpc-tests/test_framework/netutil.py +++ b/qa/rpc-tests/test_framework/netutil.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/test_framework/script.py b/qa/rpc-tests/test_framework/script.py index 93c161162..023be7679 100644 --- a/qa/rpc-tests/test_framework/script.py +++ b/qa/rpc-tests/test_framework/script.py @@ -1,15 +1,11 @@ -# -# script.py -# -# This file is modified from python-bitcoinlib. -# +# Copyright (c) 2016-2020 The Hush developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -# +# This file is modified from python-bitcoinlib. """Scripts -Functionality to build scripts, as well as SignatureHash(). +Functionality to build Bitcoin style Scripts, as well as SignatureHash(). """ from __future__ import absolute_import, division, print_function, unicode_literals @@ -29,13 +25,11 @@ import binascii from test_framework import bignum -MAX_SCRIPT_SIZE = 10000 +MAX_SCRIPT_SIZE = 10000 MAX_SCRIPT_ELEMENT_SIZE = 520 -MAX_SCRIPT_OPCODES = 201 - -OPCODE_NAMES = {} - -_opcode_instances = [] +MAX_SCRIPT_OPCODES = 201 +OPCODE_NAMES = {} +_opcode_instances = [] class CScriptOp(int): """A single script opcode""" __slots__ = [] diff --git a/qa/rpc-tests/test_framework/socks5.py b/qa/rpc-tests/test_framework/socks5.py index 1ec159d05..f361b4bb7 100644 --- a/qa/rpc-tests/test_framework/socks5.py +++ b/qa/rpc-tests/test_framework/socks5.py @@ -1,3 +1,4 @@ +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/test_framework/test_framework.py b/qa/rpc-tests/test_framework/test_framework.py index a85541449..d54bb49e4 100755 --- a/qa/rpc-tests/test_framework/test_framework.py +++ b/qa/rpc-tests/test_framework/test_framework.py @@ -1,14 +1,12 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2016-2020 The Hush developers -# Released under the GPLv3 - +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # Base class for RPC testing - # Add python-bitcoinrpc to module search path: import os import sys - import shutil import tempfile import traceback @@ -19,7 +17,6 @@ from util import assert_equal, check_json_precision, \ start_nodes, connect_nodes_bi, stop_nodes, \ sync_blocks, sync_mempools, wait_bitcoinds - class BitcoinTestFramework(object): # These may be over-ridden by subclasses: diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 0d1eb40f3..a0b409970 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -1,12 +1,9 @@ +# Copyright (c) 2018-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2018-2019 The SuperNET developers -# Copyright (c) 2018-2020 The Hush developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -# # Helpful routines for regression testing -# - # Add python-bitcoinrpc to module search path: import os import sys diff --git a/qa/rpc-tests/timestampindex.py b/qa/rpc-tests/timestampindex.py index 13c89d74b..9bf213db2 100755 --- a/qa/rpc-tests/timestampindex.py +++ b/qa/rpc-tests/timestampindex.py @@ -1,17 +1,14 @@ #!/usr/bin/env python2 -# Copyright (c) 2014-2015 The Bitcoin Core developers # Copyright (c) 2016-2020 The Hush developers -# Released under the GPLv3 -# +# Copyright (c) 2014-2015 The Bitcoin Core developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # Test timestampindex generation and fetching -# import time - from test_framework.test_framework import HushTestFramework from test_framework.util import * - class TimestampIndexTest(HushTestFramework): def setup_chain(self): diff --git a/qa/rpc-tests/txindex.py b/qa/rpc-tests/txindex.py index 587766fdd..c04ebc817 100755 --- a/qa/rpc-tests/txindex.py +++ b/qa/rpc-tests/txindex.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html @@ -70,4 +71,4 @@ class TxIndexTest(BitcoinTestFramework): if __name__ == '__main__': - TxIndexTest().main() \ No newline at end of file + TxIndexTest().main() diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py index adb24787b..2a5e5481e 100755 --- a/qa/rpc-tests/txn_doublespend.py +++ b/qa/rpc-tests/txn_doublespend.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py index 3c891396c..1d60d35b0 100755 --- a/qa/rpc-tests/wallet.py +++ b/qa/rpc-tests/wallet.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_1941.py b/qa/rpc-tests/wallet_1941.py index cc741caa7..03188daad 100755 --- a/qa/rpc-tests/wallet_1941.py +++ b/qa/rpc-tests/wallet_1941.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2016 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_addresses.py b/qa/rpc-tests/wallet_addresses.py index 479c42157..d0392b26a 100755 --- a/qa/rpc-tests/wallet_addresses.py +++ b/qa/rpc-tests/wallet_addresses.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_anchorfork.py b/qa/rpc-tests/wallet_anchorfork.py index 2ef372e9a..397f3e07e 100755 --- a/qa/rpc-tests/wallet_anchorfork.py +++ b/qa/rpc-tests/wallet_anchorfork.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_changeindicator.py b/qa/rpc-tests/wallet_changeindicator.py index 61a15be8f..7a66b52d3 100755 --- a/qa/rpc-tests/wallet_changeindicator.py +++ b/qa/rpc-tests/wallet_changeindicator.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_import_export.py b/qa/rpc-tests/wallet_import_export.py index 21a06e737..9e5f6d9fb 100755 --- a/qa/rpc-tests/wallet_import_export.py +++ b/qa/rpc-tests/wallet_import_export.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html @@ -81,4 +82,4 @@ def parse_wallet_file_lines(file_lines, i): return ("".join(keys), i) if __name__ == '__main__': - WalletImportExportTest().main() \ No newline at end of file + WalletImportExportTest().main() diff --git a/qa/rpc-tests/wallet_listreceived.py b/qa/rpc-tests/wallet_listreceived.py index 8a6b67e96..c2b3d175e 100755 --- a/qa/rpc-tests/wallet_listreceived.py +++ b/qa/rpc-tests/wallet_listreceived.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_mergetoaddress.py b/qa/rpc-tests/wallet_mergetoaddress.py index e084d7815..b00714bdd 100755 --- a/qa/rpc-tests/wallet_mergetoaddress.py +++ b/qa/rpc-tests/wallet_mergetoaddress.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2017 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_nullifiers.py b/qa/rpc-tests/wallet_nullifiers.py index f4288fb31..5ea6ca70e 100755 --- a/qa/rpc-tests/wallet_nullifiers.py +++ b/qa/rpc-tests/wallet_nullifiers.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2016 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_overwintertx.py b/qa/rpc-tests/wallet_overwintertx.py index f02beab75..22fd573fd 100755 --- a/qa/rpc-tests/wallet_overwintertx.py +++ b/qa/rpc-tests/wallet_overwintertx.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_persistence.py b/qa/rpc-tests/wallet_persistence.py index 8f3f10ddc..930276227 100755 --- a/qa/rpc-tests/wallet_persistence.py +++ b/qa/rpc-tests/wallet_persistence.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_protectcoinbase.py b/qa/rpc-tests/wallet_protectcoinbase.py index 62dbdc579..26268ae6a 100755 --- a/qa/rpc-tests/wallet_protectcoinbase.py +++ b/qa/rpc-tests/wallet_protectcoinbase.py @@ -1,9 +1,9 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2016 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException from test_framework.mininode import COIN @@ -217,7 +217,7 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework): # UTXO selection in z_sendmany sorts in ascending order, so smallest utxos are consumed first. # At this point in time, unspent notes all have a value of 10.0 and standard z_sendmany fee is 0.0001. recipients = [] - amount = Decimal('10.0') - Decimal('0.00010000') - Decimal('0.00000001') # this leaves change at 1 zatoshi less than dust threshold + amount = Decimal('10.0') - Decimal('0.00010000') - Decimal('0.00000001') # this leaves change at 1 puposhi less than dust threshold recipients.append({"address":self.nodes[0].getnewaddress(), "amount":amount }) myopid = self.nodes[0].z_sendmany(mytaddr, recipients) wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Insufficient transparent funds, have 10.00, need 0.00000053 more to avoid creating invalid change output 0.00000001 (dust threshold is 0.00000054)") diff --git a/qa/rpc-tests/wallet_sapling.py b/qa/rpc-tests/wallet_sapling.py index ea9bdb080..927bebc9d 100755 --- a/qa/rpc-tests/wallet_sapling.py +++ b/qa/rpc-tests/wallet_sapling.py @@ -1,7 +1,8 @@ #!/usr/bin/env python2 -# Copyright (c) 2018 The Zcash developers # Copyright (c) 2016-2020 The Hush developers -# Released under the GPLv3 +# Copyright (c) 2018 The Zcash developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/wallet_shieldcoinbase.py b/qa/rpc-tests/wallet_shieldcoinbase.py index 4cb6893e8..5f43d733e 100755 --- a/qa/rpc-tests/wallet_shieldcoinbase.py +++ b/qa/rpc-tests/wallet_shieldcoinbase.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2017 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/wallet_shieldcoinbase_sapling.py b/qa/rpc-tests/wallet_shieldcoinbase_sapling.py index beb06e672..4754fce73 100755 --- a/qa/rpc-tests/wallet_shieldcoinbase_sapling.py +++ b/qa/rpc-tests/wallet_shieldcoinbase_sapling.py @@ -1,6 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016-2020 The Hush developers -# Released under the GPLv3 +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html import inspect import os diff --git a/qa/rpc-tests/wallet_treestate.py b/qa/rpc-tests/wallet_treestate.py index d8f7aaf74..ec09be052 100755 --- a/qa/rpc-tests/wallet_treestate.py +++ b/qa/rpc-tests/wallet_treestate.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2016 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/walletbackup.py b/qa/rpc-tests/walletbackup.py index 99f1cc4e1..2b93c6dc1 100755 --- a/qa/rpc-tests/walletbackup.py +++ b/qa/rpc-tests/walletbackup.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/zapwallettxes.py b/qa/rpc-tests/zapwallettxes.py index a8db2eb4c..cb0475ef7 100755 --- a/qa/rpc-tests/zapwallettxes.py +++ b/qa/rpc-tests/zapwallettxes.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/zkey_import_export.py b/qa/rpc-tests/zkey_import_export.py index 49927107f..643497d58 100755 --- a/qa/rpc-tests/zkey_import_export.py +++ b/qa/rpc-tests/zkey_import_export.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2017 The Zcash developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html diff --git a/qa/rpc-tests/zmq_test.py b/qa/rpc-tests/zmq_test.py index 6725a2778..0d0bc50a1 100755 --- a/qa/rpc-tests/zmq_test.py +++ b/qa/rpc-tests/zmq_test.py @@ -1,11 +1,9 @@ #!/usr/bin/env python2 +# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - -# # Test ZMQ interface -# from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, bytes_to_hex_str, start_nodes diff --git a/src/alert.cpp b/src/alert.cpp index 5669186ed..4473de0c8 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -3,7 +3,6 @@ // Copyright (c) 2016-2020 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -18,20 +17,16 @@ * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ - #include "alert.h" - #include "clientversion.h" #include "net.h" #include "pubkey.h" #include "timedata.h" #include "ui_interface.h" #include "util.h" - #include #include #include - #include #include #include @@ -118,7 +113,7 @@ uint256 CAlert::GetHash() const bool CAlert::IsInEffect() const { - return (GetTime() < nExpiration); + return false; } bool CAlert::Cancels(const CAlert& alert) const @@ -138,146 +133,31 @@ bool CAlert::AppliesTo(int nVersion, const std::string& strSubVerIn) const bool CAlert::AppliesToMe() const { - return AppliesTo(PROTOCOL_VERSION, FormatSubVersion(GetArg("-clientname","MagicBean"), CLIENT_VERSION, std::vector())); + return false; } bool CAlert::RelayTo(CNode* pnode) const { - if (!IsInEffect()) - return false; - // don't relay to nodes which haven't sent their version message - if (pnode->nVersion == 0) - return false; - // returns true if wasn't already contained in the set - if (pnode->setKnown.insert(GetHash()).second) - { - if (AppliesTo(pnode->nVersion, pnode->strSubVer) || - AppliesToMe() || - GetTime() < nRelayUntil) - { - pnode->PushMessage("alert", *this); - return true; - } - } return false; } bool CAlert::CheckSignature(const std::vector& alertKey) const { - CPubKey key(alertKey); - if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig)) - return error("CAlert::CheckSignature(): verify signature failed"); - - // Now unserialize the data - CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION); - sMsg >> *(CUnsignedAlert*)this; - return true; + return false; } CAlert CAlert::getAlertByHash(const uint256 &hash) { CAlert retval; - { - LOCK(cs_mapAlerts); - map::iterator mi = mapAlerts.find(hash); - if(mi != mapAlerts.end()) - retval = mi->second; - } return retval; } bool CAlert::ProcessAlert(const std::vector& alertKey, bool fThread) { - if (!CheckSignature(alertKey)) - return false; - if (!IsInEffect()) - return false; - - // alert.nID=max is reserved for if the alert key is - // compromised. It must have a pre-defined message, - // must never expire, must apply to all versions, - // and must cancel all previous - // alerts or it will be ignored (so an attacker can't - // send an "everything is OK, don't panic" version that - // cannot be overridden): - int maxInt = std::numeric_limits::max(); - if (nID == maxInt) - { - if (!( - nExpiration == maxInt && - nCancel == (maxInt-1) && - nMinVer == 0 && - nMaxVer == maxInt && - setSubVer.empty() && - nPriority == maxInt && - strStatusBar == "URGENT: Alert key compromised, upgrade required" - )) - return false; - } - - { - LOCK(cs_mapAlerts); - // Cancel previous alerts - for (map::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();) - { - const CAlert& alert = (*mi).second; - if (Cancels(alert)) - { - LogPrint("alert", "cancelling alert %d\n", alert.nID); - uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED); - mapAlerts.erase(mi++); - } - else if (!alert.IsInEffect()) - { - LogPrint("alert", "expiring alert %d\n", alert.nID); - uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED); - mapAlerts.erase(mi++); - } - else - mi++; - } - - // Check if this alert has been cancelled - BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) - { - const CAlert& alert = item.second; - if (alert.Cancels(*this)) - { - LogPrint("alert", "alert already cancelled by %d\n", alert.nID); - return false; - } - } - - // Add to mapAlerts - mapAlerts.insert(make_pair(GetHash(), *this)); - // Notify UI and -alertnotify if it applies to me - if(AppliesToMe()) - { - uiInterface.NotifyAlertChanged(GetHash(), CT_NEW); - Notify(strStatusBar, fThread); - } - } - - LogPrint("alert", "accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe()); return true; } -void -CAlert::Notify(const std::string& strMessage, bool fThread) +void CAlert::Notify(const std::string& strMessage, bool fThread) { - std::string strCmd = GetArg("-alertnotify", ""); - if (strCmd.empty()) return; - - // Alert text should be plain ascii coming from a trusted source, but to - // be safe we first strip anything not in safeChars, then add single quotes around - // the whole string before passing it to the shell: - std::string singleQuote("'"); - std::string safeStatus = SanitizeString(strMessage); - safeStatus = singleQuote+safeStatus+singleQuote; - boost::replace_all(strCmd, "%s", safeStatus); - - if (fThread) - boost::thread t(runCommand, strCmd); // thread runs free - else - runCommand(strCmd); + return; } diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index f82f7d550..bb413cabc 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -25,7 +25,7 @@ int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); extern void GetKomodoEarlytxidScriptPub(); -extern CScript KOMODO_EARLYTXID_SCRIPTPUB; +extern CScript HUSH_EARLYTXID_SCRIPTPUB; // #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) // defined in hush_defs.h #define PRICES_TXFEE 10000 diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 6ff5c1d40..058ac6fc5 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -15,7 +15,6 @@ * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ - #ifndef CC_INCLUDE_H #define CC_INCLUDE_H @@ -32,7 +31,7 @@ Details. /// this script's hash is what the p2sh address was. /// All of the above are the standard bitcoin vout types and there should be plenty of materials about it. /// -/// What I did with the cryptoconditions (CC) contracts (now rebranded as Antara modules) is created a fourth type of vout, the CC vout. This is using the cryptoconditions standard and it is even a different signature mechanism, +/// Cryptoconditions (CC) contracts created a fourth type of vout, the CC vout. This is using the cryptoconditions standard and it is even a different signature mechanism, /// ed25519 instead of secp256k1. It is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script. /// /// But it gets more interesting. Each CC script has an evalcode. @@ -49,7 +48,7 @@ Details. /// However, it is a CC output, so in addition to the signature, whatever constraints a CC contract implements must also be satistifed. /// This allows funds to be locked and yet anybody is able to spend it, assuming they satisfy the CC's rules. /// -/// One other technical note is that komodod has the insight-explorer extensions built in +/// One other technical note is that Hush has the insight-explorer extensions built in /// so it can lookup directly all transactions to any address. /// This is a key performance boosting thing as if it wasnt there, trying to get all the utxo for an address not in the wallet is quite time consuming. /// @@ -101,12 +100,12 @@ Details. enum opretid : uint8_t { // cc contracts data: OPRETID_NONFUNGIBLEDATA = 0x11, //!< NFT data id - OPRETID_ASSETSDATA = 0x12, //!< assets contract data id - OPRETID_GATEWAYSDATA = 0x13, //!< gateways contract data id - OPRETID_CHANNELSDATA = 0x14, //!< channels contract data id - OPRETID_HEIRDATA = 0x15, //!< heir contract data id - OPRETID_ROGUEGAMEDATA = 0x16, //!< rogue contract data id - OPRETID_PEGSDATA = 0x17, //!< pegs contract data id + OPRETID_ASSETSDATA = 0x12, //!< assets contract data id + OPRETID_GATEWAYSDATA = 0x13, //!< gateways contract data id + OPRETID_CHANNELSDATA = 0x14, //!< channels contract data id + OPRETID_HEIRDATA = 0x15, //!< heir contract data id + OPRETID_ROGUEGAMEDATA = 0x16, //!< rogue contract data id + OPRETID_PEGSDATA = 0x17, //!< pegs contract data id /*! \cond INTERNAL */ // non cc contract data: @@ -138,8 +137,6 @@ struct CC_utxo /// \endcond /// \cond INTERNAL -// these are the parameters stored after Verus crypto-condition vouts. new versions may change -// the format struct CC_meta { std::vector version; @@ -774,7 +771,7 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); /// @returns true if success bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t taddr,uint8_t prefix,uint8_t prefix2); -/// Returns my pubkey, that is set by -pubkey komodod parameter +/// Returns my pubkey, that is set by -pubkey hushd parameter /// @returns public key as byte array std::vector Mypubkey(); @@ -825,7 +822,7 @@ std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTr /// FinalizeCCTx is a very useful function that will properly sign both CC and normal inputs, adds normal change and might add an opreturn output. /// This allows for Antara module transaction creation rpc functions to create an CMutableTransaction object, add the appropriate vins and vouts to it and use FinalizeCCTx to properly sign the transaction. -/// By using -addressindex=1 of komodod daemon, it allows tracking of all the CC addresses. +/// By using -addressindex=1 of hushd daemon, it allows tracking of all the CC addresses. /// /// For signing the vins the function builds several default probe scriptPubKeys and checks them against the referred previous transactions (vintx) vouts. /// For cryptocondition vins the function creates a basic set of probe cryptconditions with mypk and module global pubkey, both for coins and tokens cases. @@ -893,7 +890,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); /// AddNormalinputs2 adds normal (not cc) inputs to the transaction object vin array for the specified total amount using utxos on my pubkey's TX_PUBKEY address (my pubkey is set by -pubkey command line parameter), to fund the transaction. -/// 'My pubkey' is the -pubkey parameter of komodod. +/// 'My pubkey' is the -pubkey parameter of hushd. /// @param mtx mutable transaction object /// @param total amount of inputs to add. If total equals to 0 the function does not add inputs but returns amount of all available normal inputs in the wallet /// @param maxinputs maximum number of inputs to add @@ -972,7 +969,7 @@ void CCLogPrintStream(const char *category, int level, const char *functionName, } /// Macro for logging messages using bitcoin LogAcceptCategory and LogPrintStr functions. /// Supports error, info and three levels of debug messages. -/// Logging category is set by -debug=category komodod param. +/// Logging category is set by -debug=category hushd param. /// To set debug level pass -debug=category-1, -debug=category-2 or -debug=category-3 param. If some level is enabled lower level messages also will be printed. /// To print info-level messages pass just -debug=category parameter, with no level. /// Error-level messages will always be printed, even if -debug parameter is not set diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 7f21f6e9f..8f41d0cde 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -39,7 +39,7 @@ extern std::string ASSETCHAINS_SELFIMPORT; extern uint16_t ASSETCHAINS_CODAPORT,ASSETCHAINS_BEAMPORT; extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; -extern uint256 KOMODO_EARLYTXID; +extern uint256 HUSH_EARLYTXID; // utilities from gateways.cpp uint256 BitcoinGetProofMerkleRoot(const std::vector &proofData, std::vector &txids); @@ -364,9 +364,9 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string std::vector > unspentOutputs; // ASSETCHAINS_SELFIMPORT is coin - if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID) + if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID) { - LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport invalid import gateway. On this chain only valid import gateway is " << KOMODO_EARLYTXID.GetHex() << std::endl); + LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport invalid import gateway. On this chain only valid import gateway is " << HUSH_EARLYTXID.GetHex() << std::endl); return(-1); } // check for valid burn from external coin blockchain and if valid return(0); diff --git a/src/cc/importgateway.cpp b/src/cc/importgateway.cpp index fc2f9e22b..901621535 100644 --- a/src/cc/importgateway.cpp +++ b/src/cc/importgateway.cpp @@ -28,7 +28,7 @@ #define KMD_TADDR 0 #define CC_MARKER_VALUE 10000 -extern uint256 KOMODO_EARLYTXID; +extern uint256 HUSH_EARLYTXID; CScript EncodeImportGatewayBindOpRet(uint8_t funcid,std::string coin,uint256 oracletxid,uint8_t M,uint8_t N,std::vector importgatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2,uint8_t wiftype) { @@ -570,9 +570,9 @@ std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height, int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::string coin; struct CCcontract_info *cp,C; std::vector pubkeys,publishers; std::vector txids; char str[128],burnaddr[64]; - if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID) + if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID) { - CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex()); + CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex()); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -649,9 +649,9 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re std::vector msigpubkeys; char burnaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C; std::vector > unspentOutputs; - if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID) + if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID) { - CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex()); + CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex()); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -748,9 +748,9 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID) + else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID) { - CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex()); + CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex()); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -795,9 +795,9 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID) + else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID) { - CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex()); + CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex()); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -866,9 +866,9 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID) + else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID) { - CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex()); + CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex()); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -912,9 +912,9 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID) + else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID) { - CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex()); + CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex()); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } @@ -990,9 +990,9 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID) + else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID) { - CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex()); + CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex()); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 9b593b248..f5b5586a1 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -363,7 +363,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t { if ( str != 0 ) { - if ( slen < IGUANA_MAXSCRIPTSIZE && offset+slen <= datalen ) + if ( slen < DRAGON_MAXSCRIPTSIZE && offset+slen <= datalen ) { for (i=0; i eg: mine the chain past block 100, preventing anyone else, creating another payments plan on chain before block 100. We call the following in Validation and RPC where the address is needed. -if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 ) +if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0 ) GetKomodoEarlytxidScriptPub(); This will fetch the op_return, calculate the scriptPubKey and save it to the global. @@ -244,7 +244,7 @@ static bool ValidateBetTx(struct CCcontract_info *cp, Eval *eval, const CTransac std::vector vec; // check payment cc config: - if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 ) + if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0 ) GetKomodoEarlytxidScriptPub(); if (bettx.vout.size() < 6 || bettx.vout.size() > 7) @@ -263,7 +263,7 @@ static bool ValidateBetTx(struct CCcontract_info *cp, Eval *eval, const CTransac if (MakeCC1vout(cp->evalcode, bettx.vout[2].nValue, pricespk) != bettx.vout[2] ) return eval->Invalid("cannot validate vout2 in bet tx with pk from opreturn"); // This should be all you need to verify it, maybe also check amount? - if ( bettx.vout[4].scriptPubKey != KOMODO_EARLYTXID_SCRIPTPUB ) + if ( bettx.vout[4].scriptPubKey != HUSH_EARLYTXID_SCRIPTPUB ) return eval->Invalid("the fee was paid to wrong address."); int64_t betamount = bettx.vout[2].nValue; @@ -297,7 +297,7 @@ static bool ValidateAddFundingTx(struct CCcontract_info *cp, Eval *eval, const C vscript_t vintxOpret; // check payment cc config: - if (ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0) + if (ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0) GetKomodoEarlytxidScriptPub(); if (addfundingtx.vout.size() < 4 || addfundingtx.vout.size() > 5) @@ -323,7 +323,7 @@ static bool ValidateAddFundingTx(struct CCcontract_info *cp, Eval *eval, const C return eval->Invalid("cannot validate vout1 in add funding tx with global pk"); // This should be all you need to verify it, maybe also check amount? - if (addfundingtx.vout[2].scriptPubKey != KOMODO_EARLYTXID_SCRIPTPUB) + if (addfundingtx.vout[2].scriptPubKey != HUSH_EARLYTXID_SCRIPTPUB) return eval->Invalid("the fee was paid to wrong address."); int64_t betamount = addfundingtx.vout[1].nValue; @@ -1505,14 +1505,14 @@ UniValue PricesBet(int64_t txfee, int64_t amount, int16_t leverage, std::vector< mtx.vout.push_back(MakeCC1vout(cp->evalcode, txfee, pricespk)); // vout1 cc marker (NVOUT_CCMARKER) mtx.vout.push_back(MakeCC1vout(cp->evalcode, betamount, pricespk)); // vout2 betamount mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(pricespk)) << OP_CHECKSIG)); // vout3 normal marker NVOUT_NORMALMARKER - TODO: remove it as we have cc marker now, when move to the new chain - if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 ) + if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0 ) { // Lock here, as in validation we cannot call lock in the function itself. // may not be needed as the validation call to update the global, is called in a LOCK already, and it can only update there and here. LOCK(cs_main); GetKomodoEarlytxidScriptPub(); } - mtx.vout.push_back(CTxOut(amount-betamount, KOMODO_EARLYTXID_SCRIPTPUB)); + mtx.vout.push_back(CTxOut(amount-betamount, HUSH_EARLYTXID_SCRIPTPUB)); //test: mtx.vout.push_back(CTxOut(amount - betamount, CScript() << ParseHex("037c803ec82d12da939ac04379bbc1130a9065c53d8244a61eece1db942cf0efa7") << OP_CHECKSIG)); // vout4 test revshare fee rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, prices_betopret(mypk, nextheight - 1, amount, leverage, firstprice, vec, zeroid)); @@ -1576,14 +1576,14 @@ UniValue PricesAddFunding(int64_t txfee, uint256 bettxid, int64_t amount) mtx.vout.push_back(MakeCC1vout(cp->evalcode, txfee, mypk)); // vout0 baton for total funding mtx.vout.push_back(MakeCC1vout(cp->evalcode, betamount, pricespk)); // vout1 added amount - if (ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0) + if (ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0) { // Lock here, as in validation we cannot call lock in the function itself. // may not be needed as the validation call to update the global, is called in a LOCK already, and it can only update there and here. LOCK(cs_main); GetKomodoEarlytxidScriptPub(); } - mtx.vout.push_back(CTxOut(amount - betamount, KOMODO_EARLYTXID_SCRIPTPUB)); + mtx.vout.push_back(CTxOut(amount - betamount, HUSH_EARLYTXID_SCRIPTPUB)); // test: mtx.vout.push_back(CTxOut(amount - betamount, CScript() << ParseHex("037c803ec82d12da939ac04379bbc1130a9065c53d8244a61eece1db942cf0efa7") << OP_CHECKSIG)); //vout2 test revshare fee rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, prices_addopret(bettxid, mypk, amount)); diff --git a/src/crosschain.cpp b/src/crosschain.cpp index ab3093769..d015c210a 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -15,7 +15,6 @@ * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ - #include "cc/eval.h" #include "crosschain.h" #include "importcoin.h" @@ -23,15 +22,14 @@ #include "notarizationdb.h" #include "merkleblock.h" #include "cc/CCinclude.h" - /* * The crosschain workflow. * * 3 chains, A, B, and HUSH. We would like to prove TX on B. - * There is a notarisation, nA0, which will include TX via an MoM. - * The notarisation nA0 must fall between 2 notarisations of B, + * There is a notarization, nA0, which will include TX via an MoM. + * The notarization nA0 must fall between 2 notarizations of B, * ie, nB0 and nB1. An MoMoM including this range is propagated to - * B in notarisation receipt (backnotarisation) bnB2. + * B in notarization receipt (backnotarization) bnB2. * * A: TX bnA0 * \ / @@ -42,10 +40,8 @@ // XXX: There are potential crashes wherever we access chainActive without a lock, // because it might be disconnecting blocks at the same time. - - -// TODO: this assumes a blocktime of 60 seconds and limiting of 1 day of blocks -int NOTARISATION_SCAN_LIMIT_BLOCKS = 1440; +// TODO: this assumes a blocktime of 75 seconds for HUSH and 60 seconds for other chains +int NOTARISATION_SCAN_LIMIT_BLOCKS = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? 1152 : 1440; CBlockIndex *komodo_getblockindex(uint256 hash); /* On HUSH */ @@ -53,12 +49,12 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig std::vector &moms, uint256 &destNotarizationTxid) { /* - * Notaries don't wait for confirmation on HUSH before performing a backnotarisation, + * Notaries don't wait for confirmation on HUSH before performing a backnotarization, * but we need a determinable range that will encompass all merkle roots. Include MoMs - * including the block height of the last notarisation until the height before the - * previous notarisation. + * including the block height of the last notarization until the height before the + * previous notarization. * - * hushHeight notarisations-0 notarisations-1 + * hushHeight notarizations-0 notarizations-1 * *********************| * > scan backwards > */ @@ -76,13 +72,13 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig for (i=0; i hushHeight) break; - NotarizationsInBlock notarisations; + NotarizationsInBlock notarizations; uint256 blockHash = *chainActive[hushHeight-i]->phashBlock; - if (!GetBlockNotarizations(blockHash, notarisations)) + if (!GetBlockNotarizations(blockHash, notarizations)) continue; - // See if we have an own notarisation in this block - BOOST_FOREACH(Notarization& nota, notarisations) { + // See if we have an own notarization in this block + BOOST_FOREACH(Notarization& nota, notarizations) { if (strcmp(nota.second.symbol, symbol) == 0) { seenOwnNotarizations++; @@ -95,7 +91,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig } if (seenOwnNotarizations >= 1) { - BOOST_FOREACH(Notarization& nota, notarisations) { + BOOST_FOREACH(Notarization& nota, notarizations) { if (GetSymbolAuthority(nota.second.symbol) == authority) if (nota.second.ccId == targetCCid) { tmp_moms.insert(nota.second.MoM); @@ -105,7 +101,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig } } - // Not enough own notarisations found to return determinate MoMoM + // Not enough own notarizations found to return determinate MoMoM destNotarizationTxid = uint256(); moms.clear(); return uint256(); @@ -120,9 +116,9 @@ end: /* - * Get a notarisation from a given height + * Get a notarization from a given height * - * Will scan notarisations leveldb up to a limit + * Will scan notarizations leveldb up to a limit */ template int ScanNotarizationsFromHeight(int nHeight, const IsTarget f, Notarization &found) @@ -131,12 +127,12 @@ int ScanNotarizationsFromHeight(int nHeight, const IsTarget f, Notarization &fou int start = std::max(nHeight, 1); for (int h=start; hphashBlock, notarisations)) + if (!GetBlockNotarizations(*chainActive[h]->phashBlock, notarizations)) continue; - BOOST_FOREACH(found, notarisations) { + BOOST_FOREACH(found, notarizations) { if (f(found)) { return h; } @@ -152,14 +148,14 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ { /* * Here we are given a proof generated by an assetchain A which goes from given txid to - * an assetchain MoM. We need to go from the notarisationTxid for A to the MoMoM range of the - * backnotarisation for B (given by hushHeight of notarisation), find the MoM within the MoMs for + * an assetchain MoM. We need to go from the notarizationTxid for A to the MoMoM range of the + * backnotarization for B (given by hushHeight of notarization), find the MoM within the MoMs for * that range, and finally extend the proof to lead to the MoMoM (proof root). */ EvalRef eval; uint256 MoM = assetChainProof.second.Exec(txid); - // Get a Hush height for given notarisation Txid + // Get a Hush height for given notarization Txid int hushHeight; { CTransaction sourceNotarization; @@ -170,11 +166,11 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ hushHeight = blockIdx.GetHeight(); } - // We now have a hushHeight of the notarisation from chain A. So we know that a MoM exists + // We now have a hushHeight of the notarization from chain A. So we know that a MoM exists // at that height. // If we call CalculateProofRoot with that height, it'll scan backwards, until it finds - // a notarisation from B, and it might not include our notarisation from A - // at all. So, the thing we need to do is scan forwards to find the notarisation for B, + // a notarization from B, and it might not include our notarization from A + // at all. So, the thing we need to do is scan forwards to find the notarization for B, // that is inclusive of A. Notarization nota; auto isTarget = [&](Notarization ¬a) { @@ -182,7 +178,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ }; hushHeight = ScanNotarizationsFromHeight(hushHeight, isTarget, nota); if (!hushHeight) - throw std::runtime_error("Cannot find notarisation for target inclusive of source"); + throw std::runtime_error("Cannot find notarization for target inclusive of source"); if ( offset != 0 ) hushHeight += offset; @@ -257,38 +253,36 @@ bool IsSameAssetChain(const Notarization ¬a) { return strcmp(nota.second.symbol, SMART_CHAIN_SYMBOL) == 0; }; - /* On assetchain */ -bool GetNextBacknotarisation(uint256 hushNotarizationTxid, Notarization &out) +bool GetNextBacknotarization(uint256 hushNotarizationTxid, Notarization &out) { /* * Here we are given a txid, and a proof. - * We go from the HUSH notarisation txid to the backnotarisation, - * then jump to the next backnotarisation, which contains the corresponding MoMoM. + * We go from the HUSH notarization txid to the backnotarization, + * then jump to the next backnotarization, which contains the corresponding MoMoM. */ Notarization bn; if (!GetBackNotarization(hushNotarizationTxid, bn)) return false; - // Need to get block height of that backnotarisation + // Need to get block height of that backnotarization EvalRef eval; CBlockIndex block; CTransaction tx; if (!eval->GetTxConfirmed(bn.first, tx, block)){ - fprintf(stderr, "Can't get height of backnotarisation, this should not happen\n"); + fprintf(stderr, "Can't get height of backnotarization, this should not happen\n"); return false; } return (bool) ScanNotarizationsFromHeight(block.GetHeight()+1, &IsSameAssetChain, out); } - bool CheckMoMoM(uint256 hushNotarizationHash, uint256 momom) { /* - * Given a notarisation hash and an MoMoM. Backnotarisations may arrive out of order - * or multiple in the same block. So dereference the notarisation hash to the corresponding - * backnotarisation and scan around the hushheight to see if the MoMoM is a match. + * Given a notarization hash and an MoMoM. Backnotarizations may arrive out of order + * or multiple in the same block. So dereference the notarization hash to the corresponding + * backnotarization and scan around the hushheight to see if the MoMoM is a match. * This is a sledgehammer approach... */ @@ -296,12 +290,12 @@ bool CheckMoMoM(uint256 hushNotarizationHash, uint256 momom) if (!GetBackNotarization(hushNotarizationHash, bn)) return false; - // Need to get block height of that backnotarisation + // Need to get block height of that backnotarization EvalRef eval; CBlockIndex block; CTransaction tx; if (!eval->GetTxConfirmed(bn.first, tx, block)){ - fprintf(stderr, "Can't get height of backnotarisation, this should not happen\n"); + fprintf(stderr, "Can't get height of backnotarization, this should not happen\n"); return false; } @@ -423,7 +417,7 @@ bool CheckNotariesApproval(uint256 burntxid, const std::vector & notary /* * On assetchain * in: txid - * out: pair + * out: pair */ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx) @@ -443,15 +437,15 @@ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx) blockIndex = komodo_getblockindex(blockHash); int h = blockIndex->GetHeight(); - // The assumption here is that the first notarisation for a height GTE than + // The assumption here is that the first notarization for a height GTE than // the transaction block height will contain the corresponding MoM. If there - // are sequence issues with the notarisations this may fail. + // are sequence issues with the notarizations this may fail. auto isTarget = [&](Notarization ¬a) { if (!IsSameAssetChain(nota)) return false; return nota.second.height >= blockIndex->GetHeight(); }; if (!ScanNotarizationsFromHeight(blockIndex->GetHeight(), isTarget, nota)) - throw std::runtime_error("backnotarisation not yet confirmed"); + throw std::runtime_error("backnotarization not yet confirmed"); // index of block in MoM leaves nIndex = nota.second.height - blockIndex->GetHeight(); diff --git a/src/gtest/test_noteencryption.cpp b/src/gtest/test_noteencryption.cpp index a760e8007..0e187c3ff 100644 --- a/src/gtest/test_noteencryption.cpp +++ b/src/gtest/test_noteencryption.cpp @@ -31,8 +31,8 @@ TEST(noteencryption, NotePlaintext) auto ivk = fvk.in_viewing_key(); SaplingPaymentAddress addr = *ivk.address({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); - std::array memo; - for (size_t i = 0; i < ZC_MEMO_SIZE; i++) { + std::array memo; + for (size_t i = 0; i < HUSH_MEMO_SIZE; i++) { // Fill the message with dummy data memo[i] = (unsigned char) i; } diff --git a/src/hush.h b/src/hush.h index 3f25c47de..380674a7e 100644 --- a/src/hush.h +++ b/src/hush.h @@ -359,7 +359,7 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie struct hush_state *sp; char fname[512],symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t retval,ht,func; uint8_t num,pubkeys[64][33]; if ( didinit == 0 ) { - portable_mutex_init(&KOMODO_KV_mutex); + portable_mutex_init(&HUSH_KV_mutex); portable_mutex_init(&KOMODO_CC_mutex); didinit = 1; } diff --git a/src/hush_defs.h b/src/hush_defs.h index 952b81a7b..0ac0eeff2 100644 --- a/src/hush_defs.h +++ b/src/hush_defs.h @@ -20,14 +20,14 @@ #include "arith_uint256.h" #include "chain.h" #include "hush_nk.h" -#define KOMODO_EARLYTXID_HEIGHT 100 +#define HUSH_EARLYTXID_HEIGHT 100 #define ASSETCHAINS_MINHEIGHT 128 #define ASSETCHAINS_MAX_ERAS 7 #define KOMODO_ELECTION_GAP 2000 #define ROUNDROBIN_DELAY 61 #define HUSH_SMART_CHAIN_MAXLEN 65 #define KOMODO_LIMITED_NETWORKSIZE 4 -#define IGUANA_MAXSCRIPTSIZE 10001 +#define DRAGON_MAXSCRIPTSIZE 10001 #define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus #define CRYPTO555_PUBSECPSTR "038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac" #define CRYPTO555_HUSHADDR "RFetqf8WUfWnwNeXdknkm8ojk7EXnYFzrv" @@ -513,7 +513,7 @@ extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTP extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; extern std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; -extern uint256 KOMODO_EARLYTXID; +extern uint256 HUSH_EARLYTXID; extern int32_t HUSH_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; @@ -529,7 +529,6 @@ extern char NOTARYADDRS[64][64]; extern char NOTARY_ADDRESSES[NUM_HUSH_SEASONS][64][64]; extern int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL; extern int32_t ASSETCHAINS_EARLYTXIDCONTRACT; -extern int32_t ASSETCHAINS_STAKED_SPLIT_PERCENTAGE; int tx_height( const uint256 &hash ); extern std::vector vWhiteListAddress; extern std::map mapHeightEvalActivate; @@ -537,9 +536,9 @@ void komodo_netevent(std::vector payload); int32_t getacseason(uint32_t timestamp); int32_t gethushseason(int32_t height); -#define IGUANA_MAXSCRIPTSIZE 10001 -#define KOMODO_KVDURATION 1440 -#define KOMODO_KVBINARY 2 +#define DRAGON_MAXSCRIPTSIZE 10001 +#define HUSH_KVDURATION 1440 +#define HUSH_KVBINARY 2 #define PRICES_SMOOTHWIDTH 1 #define PRICES_MAXDATAPOINTS 8 uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); @@ -547,7 +546,7 @@ int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *bas int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width); -int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); +int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); uint32_t komodo_blocktime(uint256 hash); int32_t hush_longestchain(); diff --git a/src/hush_globals.h b/src/hush_globals.h index 1204b336b..cc86e50b2 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -45,7 +45,7 @@ struct hush_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; -uint256 KOMODO_EARLYTXID; +uint256 HUSH_EARLYTXID; int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,KOMODO_PAX,HUSH_EXCHANGEWALLET,HUSH_REWIND,HUSH_CONNECTING = -1,KOMODO_DEALERNODE,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,HUSH_NSPV; int32_t HUSH_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; @@ -101,11 +101,11 @@ uint64_t PENDING_KOMODO_TX; extern int32_t HUSH_LOADINGBLOCKS; unsigned int MAX_BLOCK_SIGOPS = 20000; int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL; -CScript KOMODO_EARLYTXID_SCRIPTPUB; +CScript HUSH_EARLYTXID_SCRIPTPUB; int32_t ASSETCHAINS_EARLYTXIDCONTRACT; std::map mapHeightEvalActivate; -struct komodo_kv *KOMODO_KV; -pthread_mutex_t KOMODO_KV_mutex,KOMODO_CC_mutex; +struct komodo_kv *HUSH_KV; +pthread_mutex_t HUSH_KV_mutex,KOMODO_CC_mutex; #define MAX_CURRENCIES 32 char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies diff --git a/src/hush_structs.h b/src/hush_structs.h index fc7f1b2b8..c47eabbd9 100644 --- a/src/hush_structs.h +++ b/src/hush_structs.h @@ -45,9 +45,9 @@ #define KOMODO_OPRETURN_WITHDRAW 'W' // assetchain #define KOMODO_OPRETURN_REDEEMED 'X' -#define KOMODO_KVPROTECTED 1 -#define KOMODO_KVBINARY 2 -#define KOMODO_KVDURATION 1440 +#define HUSH_KVPROTECTED 1 +#define HUSH_KVBINARY 2 +#define HUSH_KVDURATION 1440 #define HUSH_SMART_CHAIN_MAXLEN 65 #ifndef _BITS256 diff --git a/src/hush_utils.h b/src/hush_utils.h index 665338716..6776c300b 100644 --- a/src/hush_utils.h +++ b/src/hush_utils.h @@ -1860,7 +1860,7 @@ void hush_args(char *argv0) { printf("HUSH_REWIND %d\n",HUSH_REWIND); } - KOMODO_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str()); + HUSH_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str()); ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0); if ( name.c_str()[0] != 0 ) { diff --git a/src/komodo_cJSON.h b/src/komodo_cJSON.h index e80ce98a2..a08957499 100644 --- a/src/komodo_cJSON.h +++ b/src/komodo_cJSON.h @@ -1,3 +1,6 @@ +// Copyright (c) 2016-2020 The Hush developers +// Distributed under the GPLv3 software license, see the accompanying +// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html /* Copyright (c) 2009 Dave Gamble @@ -19,7 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -34,10 +36,8 @@ * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ - #ifndef komodo_cJSON__h #define komodo_cJSON__h - #include #include #include @@ -45,9 +45,7 @@ #include #include #include - #include "cJSON.h" - //#include "../crypto555/OS_portable.h" #define MAX_JSON_FIELD 4096 // on the big side diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 891717855..c4cd51e73 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -42,7 +42,7 @@ int32_t komodo_kvnumdays(uint32_t flags) int32_t komodo_kvduration(uint32_t flags) { - return(komodo_kvnumdays(flags) * KOMODO_KVDURATION); + return(komodo_kvnumdays(flags) * HUSH_KVDURATION); } uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen) @@ -56,21 +56,21 @@ uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen) return(fee); } -int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen) +int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen) { struct komodo_kv *ptr; int32_t duration,retval = -1; *heightp = -1; *flagsp = 0; memset(pubkeyp,0,sizeof(*pubkeyp)); - portable_mutex_lock(&KOMODO_KV_mutex); - HASH_FIND(hh,KOMODO_KV,key,keylen,ptr); + portable_mutex_lock(&HUSH_KV_mutex); + HASH_FIND(hh,HUSH_KV,key,keylen,ptr); if ( ptr != 0 ) { duration = komodo_kvduration(ptr->flags); //fprintf(stderr,"duration.%d flags.%d current.%d ht.%d keylen.%d valuesize.%d\n",duration,ptr->flags,current_height,ptr->height,ptr->keylen,ptr->valuesize); if ( current_height > (ptr->height + duration) ) { - HASH_DELETE(hh,KOMODO_KV,ptr); + HASH_DELETE(hh,HUSH_KV,ptr); if ( ptr->value != 0 ) free(ptr->value); if ( ptr->key != 0 ) @@ -92,7 +92,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp memcpy(value,ptr->value,retval); } } //else fprintf(stderr,"couldnt find (%s)\n",(char *)key); - portable_mutex_unlock(&KOMODO_KV_mutex); + portable_mutex_unlock(&HUSH_KV_mutex); if ( retval < 0 ) { // search rawmempool @@ -103,7 +103,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) { static uint256 zeroes; - uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[IGUANA_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee; + uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[DRAGON_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee; if ( SMART_CHAIN_SYMBOL[0] == 0 ) // disable KV for KMD return; dragon_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen); @@ -150,12 +150,12 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) } } } - portable_mutex_lock(&KOMODO_KV_mutex); - HASH_FIND(hh,KOMODO_KV,key,keylen,ptr); + portable_mutex_lock(&HUSH_KV_mutex); + HASH_FIND(hh,HUSH_KV,key,keylen,ptr); if ( ptr != 0 ) { //fprintf(stderr,"(%s) already there\n",(char *)key); - //if ( (ptr->flags & KOMODO_KVPROTECTED) != 0 ) + //if ( (ptr->flags & HUSH_KVPROTECTED) != 0 ) { tstr = (char *)"transfer:"; transferpubstr = (char *)&valueptr[strlen(tstr)]; @@ -174,10 +174,10 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) ptr->keylen = keylen; memcpy(ptr->key,key,keylen); newflag = 1; - HASH_ADD_KEYPTR(hh,KOMODO_KV,ptr->key,ptr->keylen,ptr); + HASH_ADD_KEYPTR(hh,HUSH_KV,ptr->key,ptr->keylen,ptr); //fprintf(stderr,"KV add.(%s) (%s)\n",ptr->key,valueptr); } - if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 ) + if ( newflag != 0 || (ptr->flags & HUSH_KVPROTECTED) == 0 ) { if ( ptr->value != 0 ) free(ptr->value), ptr->value = 0; @@ -186,7 +186,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) ptr->value = (uint8_t *)calloc(1,valuesize); memcpy(ptr->value,valueptr,valuesize); } - } else fprintf(stderr,"newflag.%d zero or protected %d\n",newflag,(ptr->flags & KOMODO_KVPROTECTED)); + } else fprintf(stderr,"newflag.%d zero or protected %d\n",newflag,(ptr->flags & HUSH_KVPROTECTED)); /*for (i=0; i<32; i++) printf("%02x",((uint8_t *)&ptr->pubkey)[i]); printf(" <- "); @@ -196,7 +196,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) memcpy(&ptr->pubkey,&pubkey,sizeof(ptr->pubkey)); ptr->height = height; ptr->flags = flags; // jl777 used to or in KVPROTECTED - portable_mutex_unlock(&KOMODO_KV_mutex); + portable_mutex_unlock(&HUSH_KV_mutex); } else fprintf(stderr,"KV update size mismatch %d vs %d\n",opretlen,coresize); } else fprintf(stderr,"not enough fee\n"); } diff --git a/src/main.cpp b/src/main.cpp index 73bab32a1..28cfcf1e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -837,7 +837,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRE bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) { bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); - bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); + bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); if (saplingActive) { // Sapling standard rules apply @@ -891,7 +891,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) if (whichType == TX_NULL_DATA) { - if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE ) + if ( txout.scriptPubKey.size() > DRAGON_MAXSCRIPTSIZE ) { reason = "opreturn too big"; return(false); @@ -1098,17 +1098,10 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in return nSigOps; } -/** - * Ensure that a coinbase transaction is structured according to the consensus rules of the - * chain - */ +// Ensure that a coinbase transaction is structured according to the consensus rules of the chain bool ContextualCheckCoinbaseTransaction(int32_t slowflag,const CBlock *block,CBlockIndex * const previndex,const CTransaction& tx, const int nHeight,int32_t validateprices) { - if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) - { - - } - else if ( slowflag != 0 && ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 ) + if ( slowflag != 0 && ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 ) { if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) return(false); @@ -1133,8 +1126,8 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde bool (*isInitBlockDownload)(),int32_t validateprices) { bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); - bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); - bool isSprout = !overwinterActive; + bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); + bool isSprout = !overwinterActive; // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond if (isSprout && tx.fOverwintered) { @@ -1361,21 +1354,19 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState return true; } -int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime) // from ac_private chains only -{ +int32_t hush_isnotaryvout(char *coinaddr,uint32_t tiptime) { int32_t season = getacseason(tiptime); - if ( NOTARY_ADDRESSES[season-1][0][0] == 0 ) - { + if ( NOTARY_ADDRESSES[season-1][0][0] == 0 ) { uint8_t pubkeys[64][33]; hush_notaries(pubkeys,0,tiptime); } if ( strcmp(coinaddr,CRYPTO555_HUSHADDR) == 0 ) return(1); - for (int32_t i = 0; i < NUM_HUSH_NOTARIES; i++) - { - if ( strcmp(coinaddr,NOTARY_ADDRESSES[season-1][i]) == 0 ) - { - //fprintf(stderr, "coinaddr.%s notaryaddress[%i].%s\n",coinaddr,i,NOTARY_ADDRESSES[season-1][i]); + for (int32_t i = 0; i < NUM_HUSH_NOTARIES; i++) { + if ( strcmp(coinaddr,NOTARY_ADDRESSES[season-1][i]) == 0 ) { + if(fDebug) { + fprintf(stderr, "%s: coinaddr.%s notaryaddress[%i].%s\n",__func__, coinaddr,i,NOTARY_ADDRESSES[season-1][i]); + } return(1); } } @@ -1471,14 +1462,14 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio // char destaddr[65]; Getscriptaddress(destaddr,txout.scriptPubKey); - if ( komodo_isnotaryvout(destaddr,tiptime) == 0 ) + if ( hush_isnotaryvout(destaddr,tiptime) == 0 ) { invalid_private_taddr = 1; //return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain"); } } } - if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE ) + if ( txout.scriptPubKey.size() > DRAGON_MAXSCRIPTSIZE ) return state.DoS(100, error("CheckTransaction(): txout.scriptPubKey.size() too big"),REJECT_INVALID, "bad-txns-opret-too-big"); nValueOut += txout.nValue; if (!MoneyRange(nValueOut)) @@ -2886,14 +2877,13 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const CO void ConnectNotarizations(const CBlock &block, int height) { - NotarizationsInBlock notarisations = ScanBlockNotarizations(block, height); - if (notarisations.size() > 0) { + NotarizationsInBlock notarizations = ScanBlockNotarizations(block, height); + if (notarizations.size() > 0) { CDBBatch batch = CDBBatch(*pnotarizations); - batch.Write(block.GetHash(), notarisations); - WriteBackNotarizations(notarisations, batch); + batch.Write(block.GetHash(), notarizations); + WriteBackNotarizations(notarizations, batch); pnotarizations->WriteBatch(batch, true); - LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n", - notarisations.size(), block.GetHash().GetHex().data()); + LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n", notarizations.size(), block.GetHash().GetHex().data()); } } @@ -2905,8 +2895,7 @@ void DisconnectNotarizations(const CBlock &block) batch.Erase(block.GetHash()); EraseBackNotarizations(nibs, batch); pnotarizations->WriteBatch(batch, true); - LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n", - nibs.size(), block.GetHash().GetHex().data()); + LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n", nibs.size(), block.GetHash().GetHex().data()); } } @@ -3268,22 +3257,21 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Do this here before the block is moved to the main block files. if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) { - // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. - // if notarisation in the block, must be position 1 and the coinbase must pay notaries. - int32_t notarisationTx = hush_connectblock(true,pindex,*(CBlock *)&block); + // do a full block scan to get ntz position and to enforce a valid notarization is in position 1. + // if ntz in the block, must be position 1 and the coinbase must pay notaries. + int32_t notarizationTx = hush_connectblock(true,pindex,*(CBlock *)&block); // -1 means that the valid notarization isnt in position 1 or there are too many notarizations in this block. - if ( notarisationTx == -1 ) + if ( notarizationTx == -1 ) return state.DoS(100, error("ConnectBlock(): Notarization is not in TX position 1 or block contains more than 1 notarization! Invalid Block!"), REJECT_INVALID, "bad-notarization-position"); - // 1 means this block contains a valid notarisation and its in position 1. + // 1 means this block contains a valid notarization and its in position 1. // its no longer possible for any attempted notarization to be in a block with a valid one! - // if notaries create a notarisation even if its not in this chain it will need to be mined inside its own block! - if ( notarisationTx == 1 ) + // if notaries create a notarization even if its not in this chain it will need to be mined inside its own block! + if ( notarizationTx == 1 ) { // Check if the notaries have been paid. if ( block.vtx[0].vout.size() == 1 ) - return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"), - REJECT_INVALID, "bad-cb-amount"); + return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"), REJECT_INVALID, "bad-cb-amount"); // calculate the notaries compensation and validate the amounts and pubkeys are correct. notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); //fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); @@ -3294,6 +3282,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin REJECT_INVALID, "bad-cb-amount"); } } + // Move the block to the main block file, we need this to create the TxIndex in the following loop. if ( (pindex->nStatus & BLOCK_IN_TMPFILE) != 0 ) { @@ -3626,7 +3615,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin setDirtyBlockIndex.insert(pindex); } - ConnectNotarizations(block, pindex->GetHeight()); // MoMoM notarisation DB. + ConnectNotarizations(block, pindex->GetHeight()); // MoMoM notarization DB. if (fTxIndex) if (!pblocktree->WriteTxIndex(vPos)) @@ -7161,12 +7150,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } - // Relay alerts + // Do Not Relay alerts + /* { LOCK(cs_mapAlerts); BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) item.second.RelayTo(pfrom); } + */ pfrom->fSuccessfullyConnected = true; @@ -7183,17 +7174,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, //pfrom->nTimeOffset = nTimeOffset; //AddTimeData(pfrom->addr, nTimeOffset); pfrom->nTimeOffset = timeWarning.AddTimeData(pfrom->addr, nTime, GetTime()); - } - - - else if (pfrom->nVersion == 0) - { + } else if (pfrom->nVersion == 0) { // Must have a version message before anything else Misbehaving(pfrom->GetId(), 1); return false; - } - else if ( strCommand == "events" ) - { + } else if ( strCommand == "events" ) { if ( ASSETCHAINS_CCLIB != "gamescc" ) { Misbehaving(pfrom->GetId(), 1); @@ -7203,9 +7188,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, vRecv >> payload; komodo_netevent(payload); return(true); - } - else if (strCommand == "verack") - { + } else if (strCommand == "verack") { pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); if ( HUSH_NSPV_SUPERLITE ) @@ -7224,26 +7207,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } - // Disconnect existing peer connection when: // 1. The version message has been received // 2. Peer version is below the minimum version for the current epoch - else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[ - CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion) - { - LogPrintf("peer=%d using obsolete version %i vs %d; disconnecting\n", pfrom->id, pfrom->nVersion,(int32_t)chainparams.GetConsensus().vUpgrades[ - CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion); + else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion) { + LogPrintf("peer=%d using obsolete version %i vs %d; disconnecting\n", pfrom->id, pfrom->nVersion,(int32_t)chainparams.GetConsensus().vUpgrades[CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion); pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", chainparams.GetConsensus().vUpgrades[ CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion)); pfrom->fDisconnect = true; return false; - } - - - else if (strCommand == "addr") - { + } else if (strCommand == "addr") { vector vAddr; vRecv >> vAddr; @@ -7490,11 +7465,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (!vToFetch.empty()) pfrom->PushMessage("getdata", vToFetch); - } - - - else if (strCommand == "getdata") - { + } else if (strCommand == "getdata") { vector vInv; vRecv >> vInv; if (vInv.size() > MAX_INV_SZ) @@ -7511,11 +7482,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end()); ProcessGetData(pfrom); - } - - - else if (strCommand == "getblocks") - { + } else if (strCommand == "getblocks") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; @@ -7547,11 +7514,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, break; } } - } - - - else if (strCommand == "getheaders") - { + } else if (strCommand == "getheaders") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; @@ -7574,9 +7537,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } pindex = (*mi).second; - } - else - { + } else { // Find the last block the caller has in the main chain pindex = FindForkInGlobalIndex(chainActive, locator); if (pindex) @@ -7607,11 +7568,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if ( counter++ < 3 ) fprintf(stderr,"you can ignore redundant getheaders from peer.%d %d prev.%d\n",(int32_t)pfrom->id,(int32_t)(pindex ? pindex->GetHeight() : -1),pfrom->lasthdrsreq); }*/ - } - - - else if (strCommand == "tx") - { + } else if (strCommand == "tx") { if (IsInitialBlockDownload()) return true; @@ -7696,7 +7653,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, BOOST_FOREACH(uint256 hash, vEraseQueue) EraseOrphanTx(hash); } - // TODO: currently, prohibit joinsplits and shielded spends/outputs from entering mapOrphans + // TODO: currently, prohibit shielded spends/outputs from entering mapOrphans else if (fMissingInputs && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty() && @@ -7707,7 +7664,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // DoS prevention: do not allow mapOrphanTransactions to grow unbounded unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS)); - unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx); + unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx); if (nEvicted > 0) LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted); } else { @@ -7744,9 +7701,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (nDoS > 0) Misbehaving(pfrom->GetId(), nDoS); } - } - - else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing + } else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing { std::vector headers; @@ -7809,9 +7764,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } CheckBlockIndex(); - } - - else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing + } else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing { CBlock block; vRecv >> block; @@ -7838,11 +7791,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } - } - - - else if (strCommand == "mempool") - { + } else if (strCommand == "mempool") { LOCK2(cs_main, pfrom->cs_filter); std::vector vtxid; @@ -7864,17 +7813,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } if (vInv.size() > 0) pfrom->PushMessage("inv", vInv); - } - else if (fAlerts && strCommand == "alert") - { + } else if (fAlerts && strCommand == "alert") { + //TODO: probably completely ignore this CAlert alert; vRecv >> alert; uint256 alertHash = alert.GetHash(); - if (pfrom->setKnown.count(alertHash) == 0) - { - if (alert.ProcessAlert(Params().AlertKey())) - { + if (pfrom->setKnown.count(alertHash) == 0) { + if (alert.ProcessAlert(Params().AlertKey())) { // Relay pfrom->setKnown.insert(alertHash); { @@ -7882,8 +7828,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, BOOST_FOREACH(CNode* pnode, vNodes) alert.RelayTo(pnode); } - } - else { + } else { // Small DoS penalty so peers that send us lots of // duplicate/expired/invalid-signature/whatever alerts // eventually get banned. @@ -7893,12 +7838,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 10); } } - } - - else if (!(nLocalServices & NODE_BLOOM) && + } else if (!(nLocalServices & NODE_BLOOM) && (strCommand == "filterload" || - strCommand == "filteradd")) - { + strCommand == "filteradd")) { if (pfrom->nVersion >= NO_BLOOM_VERSION) { Misbehaving(pfrom->GetId(), 100); return false; @@ -7906,11 +7848,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return false; } - } - - - else if (strCommand == "filterload") - { + } else if (strCommand == "filterload") { CBloomFilter filter; vRecv >> filter; @@ -7925,11 +7863,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->pfilter->UpdateEmptyFull(); } pfrom->fRelayTxes = true; - } - - - else if (strCommand == "filteradd") - { + } else if (strCommand == "filteradd") { vector vData; vRecv >> vData; @@ -7945,22 +7879,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else Misbehaving(pfrom->GetId(), 100); } - } - - - else if (strCommand == "filterclear") - { + } else if (strCommand == "filterclear") { LOCK(pfrom->cs_filter); if (nLocalServices & NODE_BLOOM) { delete pfrom->pfilter; pfrom->pfilter = new CBloomFilter(); } pfrom->fRelayTxes = true; - } - - - else if (strCommand == "reject") - { + } else if (strCommand == "reject") { if (fDebug) { try { string strMsg; unsigned char ccode; string strReason; @@ -7981,19 +7907,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrint("net", "Unparseable reject message received\n"); } } - } - else if (strCommand == "notfound") { + } else if (strCommand == "notfound") { // We do not care about the NOTFOUND message, but logging an Unknown Command // message would be undesirable as we transmit it ourselves. - } - - else { + } else { // Ignore unknown commands for extensibility LogPrint("net", "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id); } - - return true; } @@ -8117,7 +8038,6 @@ bool ProcessMessages(CNode* pfrom) return fOk; } - bool SendMessages(CNode* pto, bool fSendTrickle) { const Consensus::Params& consensusParams = Params().GetConsensus(); @@ -8375,8 +8295,6 @@ std::string CBlockFileInfo::ToString() const { return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast)); } - - static class CMainCleanup { public: diff --git a/src/miner.cpp b/src/miner.cpp index 0d6e16023..bc78a2bc7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -47,12 +47,9 @@ #ifdef ENABLE_WALLET #include "wallet/wallet.h" #endif - #include "zcash/Address.hpp" #include "transaction_builder.h" - #include "sodium.h" - #include #include #ifdef ENABLE_MINING @@ -145,7 +142,7 @@ int32_t komodo_baseid(char *origbase); int32_t hush_longestchain(); int64_t komodo_block_unlocktime(uint32_t nHeight); uint64_t the_commission(const CBlock *block,int32_t height); -int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *ptr); +int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *ptr); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); @@ -364,7 +361,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 ) { - // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. + // We can add the index of each notary to vector, and clear it if this notarization is not valid later on. TMP_NotarizationNotaries.push_back(i); } } @@ -373,11 +370,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } if ( numSN != 0 && notarypubkeys[0][0] != 0 && TMP_NotarizationNotaries.size() >= numSN / 5 ) { - // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) + // check a notary didnt sign twice (this would be an invalid notarization later on and cause problems) std::set checkdupes( TMP_NotarizationNotaries.begin(), TMP_NotarizationNotaries.end() ); if ( checkdupes.size() != TMP_NotarizationNotaries.size() ) { - fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); + fprintf(stderr, "%s: WTFBBQ! possible notarization is signed multiple times by same notary, passed as normal transaction.\n", __func__); } else fNotarization = true; } nTotalIn += tx.GetShieldedValueIn(); @@ -394,12 +391,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if ( fNotarization ) - { + if ( fNotarization ) { // Special miner for notary pay chains. Can only enter this if numSN/notarypubkeys is set higher up. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { - // Get the OP_RETURN for the notarisation + // Get the OP_RETURN for the notarization uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) @@ -422,33 +418,29 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } } } - } - else if ( dPriority == 1e16 ) - { + } else if ( dPriority == 1e16 ) { dPriority -= 10; - // make sure notarisation is tx[1] in block. + // make sure notarization is tx[1] in block. } - if (porphan) - { + if (porphan) { porphan->dPriority = dPriority; porphan->feeRate = feeRate; - } - else + } else { vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + } } // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); + uint64_t nBlockSize = 1000; + uint64_t nBlockTx = 0; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); TxPriorityCompare comparer(fSortedByFee); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - while (!vecPriority.empty()) - { + while (!vecPriority.empty()) { // Take highest priority transaction off the priority queue: double dPriority = vecPriority.front().get<0>(); CFeeRate feeRate = vecPriority.front().get<1>(); @@ -625,7 +617,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { static bool didinit = false; - if ( !didinit && nHeight > KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() ) + if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && komodo_appendACscriptpub() ) { fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str()); didinit = true; @@ -637,9 +629,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].scriptPubKey.resize(len); ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); - } - else - { + } else { txNew.vout[1].scriptPubKey.resize(35); ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; ptr[0] = 33; @@ -652,17 +642,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } //printf("autocreate commision vout\n"); - } - else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) - { + } else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { fprintf(stderr,"timelocked chains not supported in this code!\n"); LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(mempool.cs); return(0); - } - else if ( fNotarizationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) - { - // Get the OP_RETURN for the notarisation + } else if ( fNotarizationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) { + // Get the OP_RETURN for the notarization uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0]; int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) @@ -679,7 +665,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 return(0); } //fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); - } else fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); + } else fprintf(stderr, "vout 2 of notarization is not OP_RETURN scriptlen.%i\n", scriptlen); } if ( ASSETCHAINS_CBOPRET != 0 ) { @@ -733,7 +719,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 memcpy(&r,&randvals,sizeof(r)); pblock->nTime += (r % (33 - gpucount)*(33 - gpucount)); } - if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33,ptr) > 0 ) + if ( hush_notaryvin(txNotary,NOTARY_PUBKEY33,ptr) > 0 ) { CAmount txfees = 5000; pblock->vtx.push_back(txNotary); diff --git a/src/notarizationdb.cpp b/src/notarizationdb.cpp index 80009f950..470513fa4 100644 --- a/src/notarizationdb.cpp +++ b/src/notarizationdb.cpp @@ -12,16 +12,15 @@ NotarizationDB *pnotarizations; NotarizationDB::NotarizationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "notarizations", nCacheSize, fMemory, fWipe, false, 64) { } -NotarizationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight) -{ +NotarizationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight) { EvalRef eval; NotarizationsInBlock vNotarizations; int timestamp = block.nTime; bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; // No valid ntz's before this height - int minheight = ishush3 ? 360000 : 1; - if(ishush3 && (nHeight <= GetArg("-dpow_height",minheight))) { + int minheight = ishush3 ? 365420 : 1; + if(ishush3 && (nHeight <= GetArg("-dpow-start-height",minheight))) { return vNotarizations; } @@ -48,28 +47,26 @@ NotarizationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight) printf("Parsed a notarization for: %s, txid:%s, ccid:%i, momdepth:%i\n", data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); } - } else + } else { LogPrintf("WARNING: Couldn't parse notarization for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight); + } } return vNotarizations; } -bool GetBlockNotarizations(uint256 blockHash, NotarizationsInBlock &nibs) -{ +bool GetBlockNotarizations(uint256 blockHash, NotarizationsInBlock &nibs) { return pnotarizations->Read(blockHash, nibs); } -bool GetBackNotarization(uint256 notarisationHash, Notarization &n) -{ - return pnotarizations->Read(notarisationHash, n); +bool GetBackNotarization(uint256 notarizationHash, Notarization &n) { + return pnotarizations->Read(notarizationHash, n); } -// Write an index of HUSH notarisation id -> backnotarisation -void WriteBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch) -{ +// Write an index of HUSH notarization id -> backnotarization +void WriteBackNotarizations(const NotarizationsInBlock notarizations, CDBBatch &batch) { int wrote = 0; - BOOST_FOREACH(const Notarization &n, notarisations) + BOOST_FOREACH(const Notarization &n, notarizations) { if (!n.second.txHash.IsNull()) { batch.Write(n.second.txHash, n); @@ -78,30 +75,28 @@ void WriteBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch & } } -void EraseBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch) -{ - BOOST_FOREACH(const Notarization &n, notarisations) +void EraseBackNotarizations(const NotarizationsInBlock notarizations, CDBBatch &batch) { + BOOST_FOREACH(const Notarization &n, notarizations) { if (!n.second.txHash.IsNull()) batch.Erase(n.second.txHash); } } -// Scan notarisationsdb backwards for blocks containing a notarisation -// for given symbol. Return height of matched notarisation or 0. -int ScanNotarizationsDB(int height, std::string symbol, int scanLimitBlocks, Notarization& out) -{ +// Scan notarizationsdb backwards for blocks containing a notarization +// for given symbol. Return height of matched notarization or 0. +int ScanNotarizationsDB(int height, std::string symbol, int scanLimitBlocks, Notarization& out) { if (height < 0 || height > chainActive.Height()) return false; for (int i=0; i height) break; - NotarizationsInBlock notarisations; + NotarizationsInBlock notarizations; uint256 blockHash = *chainActive[height-i]->phashBlock; - if (!GetBlockNotarizations(blockHash, notarisations)) + if (!GetBlockNotarizations(blockHash, notarizations)) continue; - BOOST_FOREACH(Notarization& nota, notarisations) { + BOOST_FOREACH(Notarization& nota, notarizations) { if (strcmp(nota.second.symbol, symbol.data()) == 0) { out = nota; return height-i; diff --git a/src/pow.cpp b/src/pow.cpp index a8b449246..032ca29fe 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -509,14 +509,12 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead // changes consensus. Have fun -- Duke int64_t AveragingWindowTimespan(int32_t height) { int64_t AWT = 2550; - if (height >= 340000) { - //trying to emulate 3.5.0 behavior - //AWT = 1275; + /* + int32_t forkHeight = 0; + if (height >= forkHeight) { + AWT = 1275; } - // TODO: - //if (height >= XXX){ - // AWT = 1275; - //} + */ return AWT; } @@ -703,48 +701,10 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t memset(blocktimes,0,sizeof(blocktimes)); tiptime = komodo_chainactive_timestamp(); bnTarget.SetCompact(blkHeader.nBits, &fNegative, &fOverflow); - if ( height == 0 ) - { + if ( height == 0 ) { height = komodo_currentheight() + 1; //fprintf(stderr,"set height to %d\n",height); } - if ( height > 34000 && SMART_CHAIN_SYMBOL[0] == 0 ) // 0 -> non-special notary - { - special = hush_chosennotary(¬aryid,height,pubkey33,tiptime); - for (i=0; i<33; i++) - { - if ( pubkey33[i] != 0 ) - nonz++; - } - if ( nonz == 0 ) - { - //fprintf(stderr,"ht.%d null pubkey checkproof return\n",height); - return(true); // will come back via different path with pubkey set - } - flag = komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,height); - special2 = komodo_is_special(pubkeys,mids,blocktimes,height,pubkey33,blkHeader.nTime); - if ( notaryid >= 0 ) - { - if ( height > 10000 && height < 80000 && (special != 0 || special2 > 0) ) - flag = 1; - else if ( height >= 80000 && height < 108000 && special2 > 0 ) - flag = 1; - else if ( height >= 108000 && special2 > 0 ) - flag = (height > 1000000 || (height % KOMODO_ELECTION_GAP) > 64 || (height % KOMODO_ELECTION_GAP) == 0); - else if ( height == 790833 ) - flag = 1; - else if ( special2 < 0 ) - { - if ( height > 792000 ) - flag = 0; - else fprintf(stderr,"ht.%d notaryid.%d special.%d flag.%d special2.%d\n",height,notaryid,special,flag,special2); - } - if ( (flag != 0 || special2 > 0) && special2 != -2 ) - { - bnTarget.SetCompact(HUSH_MINDIFF_NBITS,&fNegative,&fOverflow); - } - } - } arith_uint256 bnLimit = (height <= 1 || ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) ? UintToArith256(params.powLimit) : UintToArith256(params.powAlternate); if (fNegative || bnTarget == 0 || fOverflow || bnTarget > bnLimit) return error("CheckProofOfWork(): nBits below minimum work"); @@ -760,9 +720,9 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t if ( HUSH_LOADINGBLOCKS != 0 ) return true; + /* if ( SMART_CHAIN_SYMBOL[0] != 0 || height > 792000 ) { - //if ( 0 && height > 792000 ) if ( Params().NetworkIDString() != "regtest" ) { for (i=31; i>=0; i--) @@ -780,6 +740,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t } return false; } + */ } /*for (i=31; i>=0; i--) fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index f83567595..8c3330d9d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -859,7 +859,7 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp, const CPubKey& mypk UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk) { - UniValue ret(UniValue::VOBJ); uint32_t flags; uint8_t value[IGUANA_MAXSCRIPTSIZE*8],key[IGUANA_MAXSCRIPTSIZE*8]; int32_t duration,j,height,valuesize,keylen; uint256 refpubkey; static uint256 zeroes; + UniValue ret(UniValue::VOBJ); uint32_t flags; uint8_t value[DRAGON_MAXSCRIPTSIZE*8],key[DRAGON_MAXSCRIPTSIZE*8]; int32_t duration,j,height,valuesize,keylen; uint256 refpubkey; static uint256 zeroes; if (fHelp || params.size() != 1 ) throw runtime_error( "kvsearch key\n" @@ -902,7 +902,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk) if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 ) ret.push_back(Pair("owner",refpubkey.GetHex())); ret.push_back(Pair("height",height)); - duration = ((flags >> 2) + 1) * KOMODO_KVDURATION; + duration = ((flags >> 2) + 1) * HUSH_KVDURATION; ret.push_back(Pair("expiration", (int64_t)(height+duration))); ret.push_back(Pair("flags",(int64_t)flags)); ret.push_back(Pair("value",val)); diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index a4750b1e6..edf5cb1fc 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -2,17 +2,13 @@ // Copyright (c) 2016-2020 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - -// // Unit tests for alert system -// #include "alert.h" #include "chain.h" #include "chainparams.h" #include "clientversion.h" #include "data/alertTests.raw.h" - #include "main.h" #include "rpc/protocol.h" #include "rpc/server.h" @@ -20,15 +16,11 @@ #include "streams.h" #include "util.h" #include "utilstrencodings.h" - #include "test/test_bitcoin.h" - #include - #include #include #include - #include "key.h" #include "alertkeys.h" #include diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index f30e4b2fc..563ef18bd 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -910,8 +910,8 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters) "1 50.00000001" ), runtime_error); - // memo bigger than allowed length of ZC_MEMO_SIZE - std::vector v (2 * (ZC_MEMO_SIZE+1)); // x2 for hexadecimal string format + // memo bigger than allowed length of HUSH_MEMO_SIZE + std::vector v (2 * (HUSH_MEMO_SIZE+1)); // x2 for hexadecimal string format std::fill(v.begin(),v.end(), 'A'); std::string badmemo(v.begin(), v.end()); auto pa = pwalletMain->GenerateNewSproutZKey(); @@ -1035,17 +1035,17 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr); std::string memo = "DEADBEEF"; - std::array array = proxy.get_memo_from_hex_string(memo); + std::array array = proxy.get_memo_from_hex_string(memo); BOOST_CHECK_EQUAL(array[0], 0xDE); BOOST_CHECK_EQUAL(array[1], 0xAD); BOOST_CHECK_EQUAL(array[2], 0xBE); BOOST_CHECK_EQUAL(array[3], 0xEF); - for (int i=4; i v (2 * (ZC_MEMO_SIZE+1)); + std::vector v (2 * (HUSH_MEMO_SIZE+1)); std::fill(v.begin(),v.end(), 'A'); std::string bigmemo(v.begin(), v.end()); @@ -1697,8 +1697,8 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters) "0.0001 100 -1" ), runtime_error); - // memo bigger than allowed length of ZC_MEMO_SIZE - std::vector v (2 * (ZC_MEMO_SIZE+1)); // x2 for hexadecimal string format + // memo bigger than allowed length of HUSH_MEMO_SIZE + std::vector v (2 * (HUSH_MEMO_SIZE+1)); // x2 for hexadecimal string format std::fill(v.begin(),v.end(), 'A'); std::string badmemo(v.begin(), v.end()); auto pa = pwalletMain->GenerateNewSproutZKey(); @@ -1806,17 +1806,17 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals) TEST_FRIEND_AsyncRPCOperation_mergetoaddress proxy(ptr); std::string memo = "DEADBEEF"; - std::array array = proxy.get_memo_from_hex_string(memo); + std::array array = proxy.get_memo_from_hex_string(memo); BOOST_CHECK_EQUAL(array[0], 0xDE); BOOST_CHECK_EQUAL(array[1], 0xAD); BOOST_CHECK_EQUAL(array[2], 0xBE); BOOST_CHECK_EQUAL(array[3], 0xEF); - for (int i=4; i v (2 * (ZC_MEMO_SIZE+1)); + std::vector v (2 * (HUSH_MEMO_SIZE+1)); std::fill(v.begin(),v.end(), 'A'); std::string bigmemo(v.begin(), v.end()); diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index 8da3012c9..fc980d58a 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -53,7 +53,7 @@ void TransactionBuilder::AddSaplingOutput( uint256 ovk, libzcash::SaplingPaymentAddress to, CAmount value, - std::array memo) + std::array memo) { auto note = libzcash::SaplingNote(to, value); outputs.emplace_back(ovk, note, memo); diff --git a/src/transaction_builder.h b/src/transaction_builder.h index adee59765..4185b248f 100644 --- a/src/transaction_builder.h +++ b/src/transaction_builder.h @@ -36,12 +36,12 @@ struct SpendDescriptionInfo { struct OutputDescriptionInfo { uint256 ovk; libzcash::SaplingNote note; - std::array memo; + std::array memo; OutputDescriptionInfo( uint256 ovk, libzcash::SaplingNote note, - std::array memo) : ovk(ovk), note(note), memo(memo) {} + std::array memo) : ovk(ovk), note(note), memo(memo) {} }; struct TransparentInputInfo { @@ -90,7 +90,7 @@ public: uint256 ovk, libzcash::SaplingPaymentAddress to, CAmount value, - std::array memo = {{0}}); + std::array memo = {{0}}); // Assumes that the value correctly corresponds to the provided UTXO. void AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t nSequence = 0xffffffff); diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 67a502ee0..d867caf10 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -333,7 +333,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() } else { std::string zaddr = std::get<0>(recipient_); std::string memo = std::get<1>(recipient_); - std::array hexMemo = get_memo_from_hex_string(memo); + std::array hexMemo = get_memo_from_hex_string(memo); auto saplingPaymentAddress = boost::get(&toPaymentAddress_); if (saplingPaymentAddress == nullptr) { // This should never happen as we have already determined that the payment is to sapling @@ -486,9 +486,9 @@ void AsyncRPCOperation_mergetoaddress::sign_send_raw_transaction(UniValue obj) tx_ = tx; } -std::array AsyncRPCOperation_mergetoaddress::get_memo_from_hex_string(std::string s) +std::array AsyncRPCOperation_mergetoaddress::get_memo_from_hex_string(std::string s) { - std::array memo = {{0x00}}; + std::array memo = {{0x00}}; std::vector rawMemo = ParseHex(s.c_str()); @@ -498,13 +498,13 @@ std::array AsyncRPCOperation_mergetoaddress::get_me throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo must be in hexadecimal format"); } - if (rawMemo.size() > ZC_MEMO_SIZE) { - throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Memo size of %d is too big, maximum allowed is %d", rawMemo.size(), ZC_MEMO_SIZE)); + if (rawMemo.size() > HUSH_MEMO_SIZE) { + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Memo size of %d is too big, maximum allowed is %d", rawMemo.size(), HUSH_MEMO_SIZE)); } // copy vector into boost array int lenMemo = rawMemo.size(); - for (int i = 0; i < ZC_MEMO_SIZE && i < lenMemo; i++) { + for (int i = 0; i < HUSH_MEMO_SIZE && i < lenMemo; i++) { memo[i] = rawMemo[i]; } return memo; diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.h b/src/wallet/asyncrpcoperation_mergetoaddress.h index aa8831fd3..b1eeae82d 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -99,7 +99,7 @@ private: TransactionBuilder builder_; CTransaction tx_; - std::array get_memo_from_hex_string(std::string s); + std::array get_memo_from_hex_string(std::string s); bool main_impl(); void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error @@ -135,7 +135,7 @@ public: // Delegated methods - std::array get_memo_from_hex_string(std::string s) + std::array get_memo_from_hex_string(std::string s) { return delegate->get_memo_from_hex_string(s); } diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 63fcc676e..b9029b2e6 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -2,7 +2,6 @@ // Copyright (c) 2016-2020 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -17,7 +16,6 @@ * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ - #include "asyncrpcoperation_sendmany.h" #include "asyncrpcqueue.h" #include "amount.h" @@ -40,15 +38,12 @@ #include "zcash/IncrementalMerkleTree.hpp" #include "sodium.h" #include "miner.h" - #include - #include #include #include #include #include - #include using namespace libzcash; @@ -199,11 +194,16 @@ bool AsyncRPCOperation_sendmany::main_impl() { assert(isfromtaddr_ != isfromzaddr_); - bool isSingleZaddrOutput = (t_outputs_.size()==0 && z_outputs_.size()==1); + if(t_outputs_.size() > 0) { + throw JSONRPCError(RPC_WALLET_ERROR, "Extreme Privacy! You cannot send to a transparent address."); + } + + bool isSingleZaddrOutput = (t_outputs_.size()==0 && z_outputs_.size()==1); bool isMultipleZaddrOutput = (t_outputs_.size()==0 && z_outputs_.size()>=1); - bool isPureTaddrOnlyTx = (isfromtaddr_ && z_outputs_.size() == 0); + bool isPureTaddrOnlyTx = (isfromtaddr_ && z_outputs_.size() == 0); CAmount minersFee = fee_; + // TODO: fix this garbage ZEC prisoner mindset bullshit // When spending coinbase utxos, you can only specify a single zaddr as the change must go somewhere // and if there are multiple zaddrs, we don't know where to send it. if (isfromtaddr_) { @@ -243,12 +243,13 @@ bool AsyncRPCOperation_sendmany::main_impl() { t_outputs_total += std::get<1>(t); } + CAmount z_outputs_total = 0; for (SendManyRecipient & t : z_outputs_) { z_outputs_total += std::get<1>(t); } - CAmount sendAmount = z_outputs_total + t_outputs_total; + CAmount sendAmount = z_outputs_total + t_outputs_total; CAmount targetAmount = sendAmount + minersFee; assert(!isfromtaddr_ || z_inputs_total == 0); @@ -302,7 +303,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { FormatMoney(t_inputs_total), FormatMoney(dustThreshold - dustChange), FormatMoney(dustChange), FormatMoney(dustThreshold))); } - t_inputs_ = selectedTInputs; + t_inputs_ = selectedTInputs; t_inputs_total = selectedUTXOAmount; // Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects @@ -331,15 +332,8 @@ bool AsyncRPCOperation_sendmany::main_impl() { CAmount amount = std::get<2>(t); builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount); } - // for Komodo, set lock time to accure interest, for other chains, set - // locktime to spend time locked coinbases - if (SMART_CHAIN_SYMBOL[0] == 0) - { - if ( !hush_hardfork_active((uint32_t)chainActive.LastTip()->nTime) ) - builder_.SetLockTime((uint32_t)time(NULL) - 60); // set lock time for Komodo interest - else - builder_.SetLockTime((uint32_t)chainActive.Tip()->GetMedianTimePast()); - } + // for other chains, set locktime to spend time locked coinbases + //builder_.SetLockTime((uint32_t)chainActive.Tip()->GetMedianTimePast()); } else { CMutableTransaction rawTx(tx_); for (SendManyInputUTXO & t : t_inputs_) { @@ -349,13 +343,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { CTxIn in(COutPoint(txid, vout)); rawTx.vin.push_back(in); } - if (SMART_CHAIN_SYMBOL[0] == 0) - { - if ( !hush_hardfork_active((uint32_t)chainActive.LastTip()->nTime) ) - rawTx.nLockTime = (uint32_t)time(NULL) - 60; // jl777 - else - rawTx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast(); - } + //rawTx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast(); tx_ = CTransaction(rawTx); } } @@ -370,8 +358,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { /** - * SCENARIO #0 - * + * SCENARIO #0 (All HUSH and Hush Smart Chains) * Sprout not involved, so we just use the TransactionBuilder and we're done. * We added the transparent inputs to the builder earlier. */ @@ -516,14 +503,11 @@ bool AsyncRPCOperation_sendmany::main_impl() { return true; } - /** - * END SCENARIO #0 - */ - + // END SCENARIO #0 + // No other scenarios, because Hush developers are elite. return false; } - /** * Sign and send a raw transaction. * Raw transaction as hex string should be in object field "rawtxn" @@ -579,7 +563,6 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj) set_result(o); } else { // Test mode does not send the transaction to the network. - CDataStream stream(ParseHex(signedtxn), SER_NETWORK, PROTOCOL_VERSION); CTransaction tx; stream >> tx; @@ -751,9 +734,9 @@ void AsyncRPCOperation_sendmany::add_taddr_change_output_to_tx(CBitcoinAddress * tx_ = CTransaction(rawTx); } -std::array AsyncRPCOperation_sendmany::get_memo_from_hex_string(std::string s) { +std::array AsyncRPCOperation_sendmany::get_memo_from_hex_string(std::string s) { // initialize to default memo (no_memo), see section 5.5 of the protocol spec - std::array memo = {{0xF6}}; + std::array memo = {{0xF6}}; std::vector rawMemo = ParseHex(s.c_str()); @@ -763,21 +746,19 @@ std::array AsyncRPCOperation_sendmany::get_memo_fro throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo must be in hexadecimal format"); } - if (rawMemo.size() > ZC_MEMO_SIZE) { - throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Memo size of %d is too big, maximum allowed is %d", rawMemo.size(), ZC_MEMO_SIZE)); + if (rawMemo.size() > HUSH_MEMO_SIZE) { + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Memo size of %d is too big, maximum allowed is %d", rawMemo.size(), HUSH_MEMO_SIZE)); } // copy vector into boost array int lenMemo = rawMemo.size(); - for (int i = 0; i < ZC_MEMO_SIZE && i < lenMemo; i++) { + for (int i = 0; i < HUSH_MEMO_SIZE && i < lenMemo; i++) { memo[i] = rawMemo[i]; } return memo; } -/** - * Override getStatus() to append the operation's input parameters to the default status object. - */ +// Override getStatus() to append the operation's input parameters to the default status object. UniValue AsyncRPCOperation_sendmany::getStatus() const { UniValue v = AsyncRPCOperation::getStatus(); if (contextinfo_.isNull()) { diff --git a/src/wallet/asyncrpcoperation_sendmany.h b/src/wallet/asyncrpcoperation_sendmany.h index a789749bd..a524c970c 100644 --- a/src/wallet/asyncrpcoperation_sendmany.h +++ b/src/wallet/asyncrpcoperation_sendmany.h @@ -112,7 +112,7 @@ private: void add_taddr_outputs_to_tx(); bool find_unspent_notes(); bool find_utxos(bool fAcceptCoinbase); - std::array get_memo_from_hex_string(std::string s); + std::array get_memo_from_hex_string(std::string s); bool main_impl(); void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error @@ -152,7 +152,7 @@ public: return delegate->find_utxos(fAcceptCoinbase); } - std::array get_memo_from_hex_string(std::string s) { + std::array get_memo_from_hex_string(std::string s) { return delegate->get_memo_from_hex_string(s); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 91addcd93..11c27f5ad 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -64,7 +64,7 @@ const std::string ADDR_TYPE_AMNESIA = "amnesia"; extern int32_t HUSH_INSYNC; uint32_t komodo_segid32(char *coinaddr); int32_t hush_dpowconfs(int32_t height,int32_t numconfs); -int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only +int32_t hush_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only CBlockIndex *komodo_getblockindex(uint256 hash); extern string randomSietchZaddr(); extern CAmount fConsolidationTxFee; @@ -83,7 +83,7 @@ UniValue z_getoperationstatus_IMPL(const UniValue&, bool); #define PLAN_NAME_MAX 8 #define VALID_PLAN_NAME(x) (strlen(x) <= PLAN_NAME_MAX) -#define THROW_IF_SYNCING(INSYNC) if (INSYNC == 0) { throw runtime_error(strprintf("%s: Chain still syncing at height %d, aborting to prevent linkability analysis!",__FUNCTION__,chainActive.Tip()->GetHeight())); } +#define THROW_IF_SYNCING(INSYNC) if (INSYNC == 0) { throw runtime_error(strprintf("%s: Extreme Privacy! Chain still syncing at height %d, aborting to prevent linkability analysis",__FUNCTION__,chainActive.Tip()->GetHeight())); } int tx_height( const uint256 &hash ); @@ -526,7 +526,7 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) if ( ASSETCHAINS_PRIVATE != 0 && AmountFromValue(params[1]) > 0 ) { - if ( komodo_isnotaryvout((char *)params[0].get_str().c_str(),chainActive.LastTip()->nTime) == 0 ) + if ( hush_isnotaryvout((char *)params[0].get_str().c_str(),chainActive.LastTip()->nTime) == 0 ) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); } @@ -563,10 +563,10 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) #include "hush_defs.h" -#define KOMODO_KVPROTECTED 1 -#define KOMODO_KVBINARY 2 -#define KOMODO_KVDURATION 1440 -#define IGUANA_MAXSCRIPTSIZE 10001 +#define HUSH_KVPROTECTED 1 +#define HUSH_KVBINARY 2 +#define HUSH_KVDURATION 1440 +#define DRAGON_MAXSCRIPTSIZE 10001 uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis); int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen); extern int32_t KOMODO_PAX; @@ -575,7 +575,7 @@ int32_t komodo_is_issuer(); int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t komodo_isrealtime(int32_t *kmdheightp); int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); -int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); +int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize); uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen); uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); @@ -587,7 +587,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) { static uint256 zeroes; CWalletTx wtx; UniValue ret(UniValue::VOBJ); - uint8_t keyvalue[IGUANA_MAXSCRIPTSIZE*8],opretbuf[IGUANA_MAXSCRIPTSIZE*8]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct komodo_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig; + uint8_t keyvalue[DRAGON_MAXSCRIPTSIZE*8],opretbuf[DRAGON_MAXSCRIPTSIZE*8]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct komodo_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig; if (fHelp || params.size() < 3 ) throw runtime_error( "kvupdate key \"value\" days passphrase\n" @@ -651,7 +651,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) memcpy(keyvalue,key,keylen); if ( (refvaluesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 ) { - if ( (tmpflags & KOMODO_KVPROTECTED) != 0 ) + if ( (tmpflags & HUSH_KVPROTECTED) != 0 ) { if ( memcmp(&refpubkey,&pubkey,sizeof(refpubkey)) != 0 ) { @@ -678,7 +678,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 ) ret.push_back(Pair("owner",refpubkey.GetHex())); ret.push_back(Pair("height", (int64_t)height)); - duration = komodo_kvduration(flags); //((flags >> 2) + 1) * KOMODO_KVDURATION; + duration = komodo_kvduration(flags); //((flags >> 2) + 1) * HUSH_KVDURATION; ret.push_back(Pair("expiration", (int64_t)(height+duration))); ret.push_back(Pair("flags",(int64_t)flags)); ret.push_back(Pair("key",params[0].get_str())); @@ -4290,7 +4290,7 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp, const CPubKey& my " \"outputPrev\" : n, (numeric) the index of the output within the vShieldedOutput\n" " \"address\" : \"zcashaddress\", (string) The Hush shielded address involved in the transaction\n" " \"value\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n" - " \"valueZat\" : xxxx (numeric) The amount in zatoshis\n" + " \"valueZat\" : xxxx (numeric) The amount in puposhis\n" " }\n" " ,...\n" " ],\n" @@ -4301,7 +4301,7 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp, const CPubKey& my " \"address\" : \"hushaddress\", (string) The Hush address involved in the transaction\n" " \"outgoing\" : true|false (boolean) True if the output is not for an address in the wallet\n" " \"value\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n" - " \"valueZat\" : xxxx (numeric) The amount in zatoshis\n" + " \"valueZat\" : xxxx (numeric) The amount in puposhis\n" " \"memo\" : \"hexmemo\", (string) Hexademical string representation of the memo field\n" " \"memoStr\" : \"memo\", (string) Only returned if memo contains valid UTF-8 text.\n" " }\n" @@ -4535,12 +4535,6 @@ UniValue z_getoperationstatus_IMPL(const UniValue& params, bool fRemoveFinishedO // JSDescription size depends on the transaction version -#define V3_JS_DESCRIPTION_SIZE (GetSerializeSize(JSDescription(), SER_NETWORK, (OVERWINTER_TX_VERSION | (1 << 31)))) -// Here we define the maximum number of zaddr outputs that can be included in a transaction. -// If input notes are small, we might actually require more than one joinsplit per zaddr output. -// For now though, we assume we use one joinsplit per zaddr output (and the second output note is change). -// We reduce the result by 1 to ensure there is room for non-joinsplit CTransaction data. -#define Z_SENDMANY_MAX_ZADDR_OUTPUTS_BEFORE_SAPLING ((MAX_TX_SIZE_BEFORE_SAPLING / V3_JS_DESCRIPTION_SIZE) - 1) // transaction.h comment: spending taddr output requires CTxIn >= 148 bytes and typical taddr txout is 34 bytes #define CTXIN_SPEND_DUST_SIZE 148 @@ -4557,7 +4551,6 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) "\nSend multiple times. Amounts are decimal numbers with at most 8 digits of precision." "\nChange generated from a taddr flows to a new taddr address, while change generated from a zaddr returns to itself." "\nWhen sending coinbase UTXOs to a zaddr, change is not allowed. The entire value of the UTXO(s) must be consumed." - + strprintf("\nBefore Sapling activates, the maximum number of zaddr outputs is %d due to transaction size limits.\n", Z_SENDMANY_MAX_ZADDR_OUTPUTS_BEFORE_SAPLING) + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"fromaddress\" (string, required) The taddr or zaddr to send the funds from.\n" @@ -4579,11 +4572,12 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) LOCK2(cs_main, pwalletMain->cs_wallet); + // Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz THROW_IF_SYNCING(HUSH_INSYNC); // Check that the from address is valid. auto fromaddress = params[0].get_str(); - bool fromTaddr = false; + bool fromTaddr = false; bool fromSapling = false; uint32_t branchId = CurrentEpochBranchId(chainActive.Height(), Params().GetConsensus()); @@ -4642,9 +4636,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) } else { throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address ); } - } - //else if ( ASSETCHAINS_PRIVATE != 0 && komodo_isnotaryvout((char *)address.c_str()) == 0 ) - // throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); + }// else if ( ASSETCHAINS_PRIVATE != 0 && hush_isnotaryvout((char *)address.c_str()) == 0 ) { + // throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Extreme Privacy! You must send to a zaddr"); + //} // Allowing duplicate receivers helps various HushList protocol operations //if (setAddress.count(address)) @@ -4660,8 +4654,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) } else if (!IsHex(memo)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected memo data in hexadecimal format."); } - if (memo.length() > ZC_MEMO_SIZE*2) { - throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", ZC_MEMO_SIZE )); + if (memo.length() > HUSH_MEMO_SIZE*2) { + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", HUSH_MEMO_SIZE )); } } @@ -4733,24 +4727,10 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; - mtx.nVersion = OVERWINTER_TX_VERSION; + mtx.nVersion = OVERWINTER_TX_VERSION; } else { mtx.fOverwintered = false; - mtx.nVersion = 2; - } - - max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING; - - // Check the number of zaddr outputs does not exceed the limit. - if (zaddrRecipients.size() > Z_SENDMANY_MAX_ZADDR_OUTPUTS_BEFORE_SAPLING) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, too many zaddr outputs"); - } - } - - // If Sapling is not active, do not allow sending from or sending to Sapling addresses. - if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { - if (fromSapling || containsSaplingOutput) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated"); + mtx.nVersion = 2; } } @@ -4829,13 +4809,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) boost::optional builder; builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain); - // Contextual transaction we will build on - // (used if no Sapling addresses are involved) - CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); - bool isShielded = !fromTaddr || zaddrRecipients.size() > 0; - if (contextualTx.nVersion == 1 && isShielded) { - contextualTx.nVersion = 2; // Tx format should support vjoinsplits - } + // Contextual transaction + CMutableTransaction contextualTx; // = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); + contextualTx.nVersion = 2; // Create operation and add to global queue std::shared_ptr q = getAsyncRPCQueue(); @@ -4860,7 +4836,6 @@ When estimating the number of coinbase utxos we can shield in a single transacti 105 + 1 + 3*(73+1) = 328 bytes of scriptSig, rounded up to 400 based on testnet experiments. */ #define CTXIN_SPEND_P2SH_SIZE 400 - #define SHIELD_COINBASE_DEFAULT_LIMIT 50 UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& mypk) @@ -4876,8 +4851,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp "\ncan be used to return a list of locked utxos. The number of coinbase utxos selected for shielding can be limited" "\nby the caller. If the limit parameter is set to zero, and Overwinter is not yet active, the -mempooltxinputlimit" "\noption will determine the number of uxtos. Any limit is constrained by the consensus rule defining a maximum" - "\ntransaction size of " - + strprintf("%d bytes before Sapling, and %d bytes once Sapling activates.", MAX_TX_SIZE_BEFORE_SAPLING, MAX_TX_SIZE_AFTER_SAPLING) + "\ntransaction size of " + strprintf("%d bytes.", MAX_TX_SIZE_AFTER_SAPLING) + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"fromaddress\" (string, required) The address is a taddr or \"*\" for all taddrs belonging to the wallet.\n" @@ -4901,6 +4875,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp LOCK2(cs_main, pwalletMain->cs_wallet); + // Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz THROW_IF_SYNCING(HUSH_INSYNC); // Validate the from address @@ -4941,27 +4916,12 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp int nextBlockHeight = chainActive.Height() + 1; bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; - if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { - max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING; - } - - // If Sapling is not active, do not allow sending to a Sapling address. - if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { - auto res = DecodePaymentAddress(destaddress); - if (IsValidPaymentAddress(res)) { - bool toSapling = boost::get(&res) != nullptr; - if (toSapling) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated"); - } - } else { - throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ") + destaddress ); - } - } // Prepare to get coinbase utxos std::vector inputs; CAmount shieldedValue = 0; CAmount remainingValue = 0; + //TODO: update these estimates size_t estimatedTxSize = 2000; // 1802 joinsplit description + tx overhead + wiggle room #ifdef __LP64__ @@ -5087,9 +5047,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp } #define MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT 50 -#define MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT 10 -#define MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT 90 - +#define MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT 90 #define OUTPUTDESCRIPTION_SIZE GetSerializeSize(OutputDescription(), SER_NETWORK, PROTOCOL_VERSION) #define SPENDDESCRIPTION_SIZE GetSerializeSize(SpendDescription(), SER_NETWORK, PROTOCOL_VERSION) @@ -5099,11 +5057,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp return NullUniValue; string enableArg = "zmergetoaddress"; - //auto fEnableMergeToAddress = fExperimentalMode && GetBoolArg("-" + enableArg, true); - //std::string strDisabledMsg = ""; - //if (!fEnableMergeToAddress) { - // strDisabledMsg = experimentalDisabledHelpMsg("z_mergetoaddress", enableArg); - //} if (fHelp || params.size() < 2 || params.size() > 7) throw runtime_error( @@ -5115,8 +5068,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp "\n\nThe number of UTXOs and notes selected for merging can be limited by the caller. If the transparent limit" "\nparameter is set to zero, and Overwinter is not yet active, the -mempooltxinputlimit option will determine the" "\nnumber of UTXOs. Any limit is constrained by the consensus rule defining a maximum transaction size of" - + strprintf("\n%d bytes before Sapling, and %d bytes once Sapling activates.", MAX_TX_SIZE_BEFORE_SAPLING, MAX_TX_SIZE_AFTER_SAPLING) - + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. fromaddresses (string, required) A JSON array with addresses.\n" " The following special strings are accepted inside the array:\n" @@ -5157,9 +5108,10 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp LOCK2(cs_main, pwalletMain->cs_wallet); + // Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz THROW_IF_SYNCING(HUSH_INSYNC); - bool useAnyUTXO = false; + bool useAnyUTXO = false; bool useAnySapling = false; std::set taddrs = {}; std::set zaddrs = {}; @@ -5168,7 +5120,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp if (addresses.size()==0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, fromaddresses array is empty."); - // Keep track of addresses to spot duplicates + // Keep track of addresses std::set setAddress; // Sources @@ -5208,9 +5160,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify specific z-addrs when using \"ANY_SAPLING\""); } - const int nextBlockHeight = chainActive.Height() + 1; + const int nextBlockHeight = chainActive.Height() + 1; const bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); - const bool saplingActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); // Validate the destination address auto destaddress = params[1].get_str(); @@ -5221,10 +5172,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp if (IsValidPaymentAddress(decodeAddr)) { if (boost::get(&decodeAddr) != nullptr) { isToSaplingZaddr = true; - // If Sapling is not active, do not allow sending to a sapling addresses. - if (!saplingActive) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated"); - } } else { throw JSONRPCError(RPC_INVALID_PARAMETER, "Only Sapling zaddrs allowed!"); } @@ -5233,7 +5180,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp } } - // Convert fee from currency format to zatoshis + // Convert fee from currency format to puposhis CAmount nFee = SHIELD_COINBASE_DEFAULT_MINERS_FEE; if (params.size() > 2) { if (params[2].get_real() == 0.0) { @@ -5276,10 +5223,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp if (!isToSaplingZaddr) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo can not be used with a taddr. It can only be used with a zaddr."); } else if (!IsHex(memo)) { + //TODO: this sux, would be nice to accept in utf8 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected memo data in hexadecimal format."); } - if (memo.length() > ZC_MEMO_SIZE*2) { - throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", ZC_MEMO_SIZE )); + if (memo.length() > HUSH_MEMO_SIZE*2) { + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", HUSH_MEMO_SIZE )); } } @@ -5288,17 +5236,16 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp // Prepare to get UTXOs and notes std::vector utxoInputs; std::vector saplingNoteInputs; - CAmount mergedUTXOValue = 0; - CAmount mergedNoteValue = 0; + CAmount mergedUTXOValue = 0; + CAmount mergedNoteValue = 0; CAmount remainingUTXOValue = 0; CAmount remainingNoteValue = 0; - size_t utxoCounter = 0; - size_t noteCounter = 0; - bool maxedOutUTXOsFlag = false; - bool maxedOutNotesFlag = false; - size_t mempoolLimit = (nUTXOLimit != 0) ? nUTXOLimit : (overwinterActive ? 0 : (size_t)GetArg("-mempooltxinputlimit", 0)); - - unsigned int max_tx_size = saplingActive ? MAX_TX_SIZE_AFTER_SAPLING : MAX_TX_SIZE_BEFORE_SAPLING; + size_t utxoCounter = 0; + size_t noteCounter = 0; + bool maxedOutUTXOsFlag = false; + bool maxedOutNotesFlag = false; + size_t mempoolLimit = (nUTXOLimit != 0) ? nUTXOLimit : (overwinterActive ? 0 : (size_t)GetArg("-mempooltxinputlimit", 0)); + unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; size_t estimatedTxSize = 200; // tx overhead + wiggle room if (isToSaplingZaddr) { @@ -5329,8 +5276,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp CAmount nValue = out.tx->vout[out.i].nValue; - if (maximum_utxo_size != 0) - { + if (maximum_utxo_size != 0) { //fprintf(stderr, "utxo txid.%s vout.%i nValue.%li scriptpubkeylength.%i\n",out.tx->GetHash().ToString().c_str(),out.i,nValue,out.tx->vout[out.i].scriptPubKey.size()); if (nValue > maximum_utxo_size) continue; @@ -5426,9 +5372,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp contextInfo.push_back(Pair("fee", ValueFromAmount(nFee))); // Contextual transaction we will build on - CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( - Params().GetConsensus(), - nextBlockHeight); + CMutableTransaction contextualTx; //= CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); // Builder (used if Sapling addresses are involved) boost::optional builder; @@ -5511,7 +5455,7 @@ UniValue z_listoperationids(const UniValue& params, bool fHelp, const CPubKey& m int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); extern std::string NOTARY_PUBKEY; -int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pTr) +int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pTr) { set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 0,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; @@ -5612,8 +5556,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void * #include "../cc/CCPayments.h" #include "../cc/CCPegs.h" -int32_t ensure_CCrequirements(uint8_t evalcode) -{ +int32_t ensure_CCrequirements(uint8_t evalcode) { CCerror = ""; if ( ASSETCHAINS_CCDISABLES[evalcode] != 0 || (evalcode == EVAL_MARMARA && ASSETCHAINS_MARMARA == 0) ) { @@ -5725,54 +5668,46 @@ UniValue setpubkey(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"R-address\" : \"R address\", (string) The pubkey\n" " }\n" "\nExamples:\n" - + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + + HelpExampleCli("setpubkey", "0420597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea1987") + + HelpExampleRpc("setpubkey", "0420597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea1987") ); LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); char Raddress[64]; uint8_t pubkey33[33]; - if ( NOTARY_PUBKEY33[0] == 0 ) - { - if (strlen(params[0].get_str().c_str()) == 66) - { + if ( NOTARY_PUBKEY33[0] == 0 ) { + if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); CBitcoinAddress address(Raddress); bool isValid = address.IsValid(); - if (isValid) - { + if (isValid) { CTxDestination dest = address.Get(); isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - if ( mine == ISMINE_NO ) + if ( mine == ISMINE_NO ) { result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); - else - { + } else { result.push_back(Pair("ismine", "true")); } NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); USE_EXTERNAL_PUBKEY = 1; NOTARY_ADDRESS = address.ToString(); - } - else + } else { result.push_back(Pair("error", "pubkey entered is invalid.")); - } - else + } + } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } - else - { - if ( NOTARY_ADDRESS.empty() ) - { + } + } else { + if ( NOTARY_ADDRESS.empty() ) { pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); } result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } - if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) - { + if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { result.push_back(Pair("address", NOTARY_ADDRESS)); result.push_back(Pair("pubkey", NOTARY_PUBKEY)); } @@ -7443,9 +7378,9 @@ UniValue tokencreate(const UniValue& params, bool fHelp, const CPubKey& mypk) if (params.size() == 4) { nonfungibleData = ParseHex(params[3].get_str()); - if (nonfungibleData.size() > IGUANA_MAXSCRIPTSIZE) // opret limit + if (nonfungibleData.size() > DRAGON_MAXSCRIPTSIZE) // opret limit { - ERR_RESULT("Non-fungible data size must be <= " + std::to_string(IGUANA_MAXSCRIPTSIZE)); + ERR_RESULT("Non-fungible data size must be <= " + std::to_string(DRAGON_MAXSCRIPTSIZE)); return(result); } if( nonfungibleData.empty() ) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d7cb97731..0e03c4d6e 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -347,7 +347,7 @@ struct SaplingNoteEntry SaplingOutPoint op; libzcash::SaplingPaymentAddress address; libzcash::SaplingNote note; - std::array memo; + std::array memo; int confirmations; }; diff --git a/src/zcash/Note.cpp b/src/zcash/Note.cpp index dc8169b81..58279203a 100644 --- a/src/zcash/Note.cpp +++ b/src/zcash/Note.cpp @@ -66,7 +66,7 @@ boost::optional SaplingNote::nullifier(const SaplingFullViewingKey& vk, // Construct and populate SaplingNotePlaintext for a given note and memo. SaplingNotePlaintext::SaplingNotePlaintext( const SaplingNote& note, - std::array memo) : BaseNotePlaintext(note, memo) + std::array memo) : BaseNotePlaintext(note, memo) { d = note.d; rcm = note.r; diff --git a/src/zcash/Note.hpp b/src/zcash/Note.hpp index 5110c7715..617501943 100644 --- a/src/zcash/Note.hpp +++ b/src/zcash/Note.hpp @@ -48,15 +48,15 @@ public: class BaseNotePlaintext { protected: uint64_t value_ = 0; - std::array memo_; + std::array memo_; public: BaseNotePlaintext() {} - BaseNotePlaintext(const BaseNote& note, std::array memo) + BaseNotePlaintext(const BaseNote& note, std::array memo) : value_(note.value()), memo_(memo) {} virtual ~BaseNotePlaintext() {} inline uint64_t value() const { return value_; } - inline const std::array & memo() const { return memo_; } + inline const std::array & memo() const { return memo_; } }; typedef std::pair SaplingNotePlaintextEncryptionResult; @@ -68,7 +68,7 @@ public: SaplingNotePlaintext() {} - SaplingNotePlaintext(const SaplingNote& note, std::array memo); + SaplingNotePlaintext(const SaplingNote& note, std::array memo); static boost::optional decrypt( const SaplingEncCiphertext &ciphertext, diff --git a/src/zcash/Zcash.h b/src/zcash/Zcash.h index a713e45a7..d33de633a 100644 --- a/src/zcash/Zcash.h +++ b/src/zcash/Zcash.h @@ -17,14 +17,14 @@ #define ZC_V_SIZE 8 #define ZC_RHO_SIZE 32 #define ZC_R_SIZE 32 -#define ZC_MEMO_SIZE 512 +#define HUSH_MEMO_SIZE 512 #define ZC_DIVERSIFIER_SIZE 11 #define ZC_JUBJUB_POINT_SIZE 32 #define ZC_JUBJUB_SCALAR_SIZE 32 -#define ZC_NOTEPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE) +#define ZC_NOTEPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + HUSH_MEMO_SIZE) -#define ZC_SAPLING_ENCPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_DIVERSIFIER_SIZE + ZC_V_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE) +#define ZC_SAPLING_ENCPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_DIVERSIFIER_SIZE + ZC_V_SIZE + ZC_R_SIZE + HUSH_MEMO_SIZE) #define ZC_SAPLING_OUTPLAINTEXT_SIZE (ZC_JUBJUB_POINT_SIZE + ZC_JUBJUB_SCALAR_SIZE) #define ZC_SAPLING_ENCCIPHERTEXT_SIZE (ZC_SAPLING_ENCPLAINTEXT_SIZE + NOTEENCRYPTION_AUTH_BYTES) diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index 1a630abf6..582b269b3 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -304,7 +304,7 @@ double benchmark_create_sapling_output() auto sk = libzcash::SaplingSpendingKey::random(); auto address = sk.default_address(); - std::array memo; + std::array memo; SaplingNote note(address, GetRand(MAX_MONEY)); libzcash::SaplingNotePlaintext notePlaintext(note, memo);