Browse Source

Stuck in the grind

pull/5/head
Duke Leto 3 years ago
parent
commit
980350b9b4
  1. 25
      qa/hush/create_benchmark_archive.py
  2. 4
      qa/hush/create_wallet_200k_utxos.py
  3. 3
      qa/hush/full-test-suite.sh
  4. 5
      qa/hush/full_test_suite.py
  5. 10
      qa/rpc-tests/README.md
  6. 4
      qa/rpc-tests/ac_private.py
  7. 6
      qa/rpc-tests/addressindex.py
  8. 5
      qa/rpc-tests/bip65-cltv-p2p.py
  9. 2
      qa/rpc-tests/bipdersig-p2p.py
  10. 1
      qa/rpc-tests/blockchain.py
  11. 1
      qa/rpc-tests/cryptoconditions.py
  12. 1
      qa/rpc-tests/cryptoconditions_channels.py
  13. 1
      qa/rpc-tests/cryptoconditions_dice.py
  14. 1
      qa/rpc-tests/cryptoconditions_faucet.py
  15. 1
      qa/rpc-tests/cryptoconditions_gateways.py
  16. 1
      qa/rpc-tests/cryptoconditions_heir.py
  17. 1
      qa/rpc-tests/cryptoconditions_oracles.py
  18. 1
      qa/rpc-tests/cryptoconditions_rewards.py
  19. 1
      qa/rpc-tests/cryptoconditions_token.py
  20. 1
      qa/rpc-tests/decodescript.py
  21. 1
      qa/rpc-tests/disablewallet.py
  22. 1
      qa/rpc-tests/finalsaplingroot.py
  23. 1
      qa/rpc-tests/forknotify.py
  24. 1
      qa/rpc-tests/fundrawtransaction.py
  25. 1
      qa/rpc-tests/getblocktemplate.py
  26. 1
      qa/rpc-tests/getblocktemplate_longpoll.py
  27. 1
      qa/rpc-tests/getblocktemplate_proposals.py
  28. 1
      qa/rpc-tests/getchaintips.py
  29. 1
      qa/rpc-tests/hardforkdetection.py
  30. 1
      qa/rpc-tests/httpbasics.py
  31. 1
      qa/rpc-tests/invalidateblock.py
  32. 1
      qa/rpc-tests/invalidblockrequest.py
  33. 1
      qa/rpc-tests/ivk_import_export.py
  34. 1
      qa/rpc-tests/key_import_export.py
  35. 1
      qa/rpc-tests/keypool.py
  36. 1
      qa/rpc-tests/listtransactions.py
  37. 1
      qa/rpc-tests/maxblocksinflight.py
  38. 1
      qa/rpc-tests/mempool_nu_activation.py
  39. 1
      qa/rpc-tests/mempool_reorg.py
  40. 1
      qa/rpc-tests/mempool_resurrect_test.py
  41. 1
      qa/rpc-tests/mempool_spendcoinbase.py
  42. 1
      qa/rpc-tests/mempool_tx_expiry.py
  43. 1
      qa/rpc-tests/mempool_tx_input_limit.py
  44. 1
      qa/rpc-tests/merkle_blocks.py
  45. 1
      qa/rpc-tests/nodehandling.py
  46. 37
      qa/rpc-tests/nspv_client_test.py
  47. 1
      qa/rpc-tests/p2p-acceptblock.py
  48. 1
      qa/rpc-tests/p2p_node_bloom.py
  49. 1
      qa/rpc-tests/p2p_txexpiry_dos.py
  50. 1
      qa/rpc-tests/prioritisetransaction.py
  51. 1
      qa/rpc-tests/proxy_test.py
  52. 1
      qa/rpc-tests/pruning.py
  53. 1
      qa/rpc-tests/rawtransactions.py
  54. 1
      qa/rpc-tests/receivedby.py
  55. 1
      qa/rpc-tests/rest.py
  56. 1
      qa/rpc-tests/rewind_index.py
  57. 1
      qa/rpc-tests/rpcbind_test.py
  58. 1
      qa/rpc-tests/script_test.py
  59. 5
      qa/rpc-tests/signrawtransaction_offline.py
  60. 1
      qa/rpc-tests/signrawtransactions.py
  61. 1
      qa/rpc-tests/smartfees.py
  62. 3
      qa/rpc-tests/spentindex.py
  63. 7
      qa/rpc-tests/test_framework/authproxy.py
  64. 9
      qa/rpc-tests/test_framework/bignum.py
  65. 3
      qa/rpc-tests/test_framework/blockstore.py
  66. 6
      qa/rpc-tests/test_framework/blocktools.py
  67. 3
      qa/rpc-tests/test_framework/comptool.py
  68. 3
      qa/rpc-tests/test_framework/equihash.py
  69. 27
      qa/rpc-tests/test_framework/mininode.py
  70. 1
      qa/rpc-tests/test_framework/netutil.py
  71. 20
      qa/rpc-tests/test_framework/script.py
  72. 1
      qa/rpc-tests/test_framework/socks5.py
  73. 7
      qa/rpc-tests/test_framework/test_framework.py
  74. 5
      qa/rpc-tests/test_framework/util.py
  75. 9
      qa/rpc-tests/timestampindex.py
  76. 3
      qa/rpc-tests/txindex.py
  77. 1
      qa/rpc-tests/txn_doublespend.py
  78. 1
      qa/rpc-tests/wallet.py
  79. 1
      qa/rpc-tests/wallet_1941.py
  80. 1
      qa/rpc-tests/wallet_addresses.py
  81. 1
      qa/rpc-tests/wallet_anchorfork.py
  82. 1
      qa/rpc-tests/wallet_changeindicator.py
  83. 3
      qa/rpc-tests/wallet_import_export.py
  84. 1
      qa/rpc-tests/wallet_listreceived.py
  85. 1
      qa/rpc-tests/wallet_mergetoaddress.py
  86. 1
      qa/rpc-tests/wallet_nullifiers.py
  87. 1
      qa/rpc-tests/wallet_overwintertx.py
  88. 1
      qa/rpc-tests/wallet_persistence.py
  89. 4
      qa/rpc-tests/wallet_protectcoinbase.py
  90. 5
      qa/rpc-tests/wallet_sapling.py
  91. 1
      qa/rpc-tests/wallet_shieldcoinbase.py
  92. 3
      qa/rpc-tests/wallet_shieldcoinbase_sapling.py
  93. 1
      qa/rpc-tests/wallet_treestate.py
  94. 1
      qa/rpc-tests/walletbackup.py
  95. 1
      qa/rpc-tests/zapwallettxes.py
  96. 1
      qa/rpc-tests/zkey_import_export.py
  97. 4
      qa/rpc-tests/zmq_test.py
  98. 130
      src/alert.cpp
  99. 2
      src/cc/CCPrices.h
  100. 27
      src/cc/CCinclude.h
  101. 6
      src/cc/import.cpp
  102. 30
      src/cc/importgateway.cpp
  103. 6
      src/cc/oracles.cpp
  104. 18
      src/cc/prices.cpp
  105. 88
      src/crosschain.cpp
  106. 4
      src/gtest/test_noteencryption.cpp
  107. 2
      src/hush.h
  108. 15
      src/hush_defs.h
  109. 8
      src/hush_globals.h
  110. 6
      src/hush_structs.h
  111. 2
      src/hush_utils.h
  112. 8
      src/komodo_cJSON.h
  113. 28
      src/komodo_kv.h
  114. 208
      src/main.cpp
  115. 60
      src/miner.cpp
  116. 43
      src/notarizationdb.cpp
  117. 55
      src/pow.cpp
  118. 4
      src/rpc/blockchain.cpp
  119. 8
      src/test/alert_tests.cpp
  120. 20
      src/test/rpc_wallet_tests.cpp
  121. 2
      src/transaction_builder.cpp
  122. 6
      src/transaction_builder.h
  123. 12
      src/wallet/asyncrpcoperation_mergetoaddress.cpp
  124. 4
      src/wallet/asyncrpcoperation_mergetoaddress.h
  125. 63
      src/wallet/asyncrpcoperation_sendmany.cpp
  126. 4
      src/wallet/asyncrpcoperation_sendmany.h
  127. 195
      src/wallet/rpcwallet.cpp
  128. 2
      src/wallet/wallet.h
  129. 2
      src/zcash/Note.cpp
  130. 8
      src/zcash/Note.hpp
  131. 6
      src/zcash/Zcash.h
  132. 2
      src/zcbenchmarks.cpp

25
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 binascii
import calendar import calendar
import json import json
@ -10,13 +13,13 @@ import sys
import tarfile import tarfile
import time import time
ZCASH_CLI = './src/zcash-cli' HUSH_CLI = './src/hush-cli'
USAGE = """ USAGE = """
Requirements: Requirements:
- find - find
- xz - xz
- %s (edit ZCASH_CLI in this script to alter the path) - %s (edit HUSH_CLI in this script to alter the path)
- A running mainnet zcashd using the default datadir with -txindex=1 - A running mainnet hushd using the default datadir with -txindex=1
Example usage: Example usage:
@ -25,11 +28,11 @@ virtualenv venv
. venv/bin/activate . 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 --global-option=build_ext --global-option="-L$(pwd)/src/leveldb/" --global-option="-I$(pwd)/src/leveldb/include/" plyvel
pip install progressbar2 pip install progressbar2
LD_LIBRARY_PATH=src/leveldb python qa/zcash/create_benchmark_archive.py LD_LIBRARY_PATH=src/leveldb python qa/hush/create_benchmark_archive.py
""" % ZCASH_CLI """ % HUSH_CLI
def check_deps(): 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 print USAGE
sys.exit() sys.exit()
@ -154,15 +157,15 @@ def deterministic_filter(tarinfo):
return tarinfo return tarinfo
def create_benchmark_archive(blk_hash): 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 'Height: %d' % blk['height']
print 'Transactions: %d' % len(blk['tx']) print 'Transactions: %d' % len(blk['tx'])
os.mkdir('benchmark') os.mkdir('benchmark')
with open('benchmark/block-%d.dat' % blk['height'], 'wb') as f: 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']] ) for tx in blk['tx']]
js_txs = len([tx for tx in txs if len(tx['vjoinsplit']) > 0]) 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) bar = progressbar.ProgressBar(redirect_stdout=True)
print 'Collecting input coins for block' print 'Collecting input coins for block'
for tx in bar(unique_inputs.keys()): 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_size = 0
mask_code = 0 mask_code = 0
@ -235,7 +238,7 @@ def create_benchmark_archive(blk_hash):
binascii.unhexlify(rawtx['vout'][i]['scriptPubKey']['hex']))) binascii.unhexlify(rawtx['vout'][i]['scriptPubKey']['hex'])))
# - VARINT(nHeight) # - VARINT(nHeight)
coins.extend(encode_varint(json.loads( coins.extend(encode_varint(json.loads(
subprocess.check_output([ZCASH_CLI, 'getblockheader', rawtx['blockhash']]) subprocess.check_output([HUSH_CLI, 'getblockheader', rawtx['blockhash']])
)['height'])) )['height']))
db_key = b'c' + bytes(binascii.unhexlify(tx)[::-1]) db_key = b'c' + bytes(binascii.unhexlify(tx)[::-1])

4
qa/hush/create_wallet_200k_utxos.py

@ -1,9 +1,8 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Create a large wallet # Create a large wallet
# #
# To use: # To use:
@ -11,7 +10,6 @@
# - Add wallet_large.py to RPC tests list # - Add wallet_large.py to RPC tests list
# - ./qa/pull-tester/rpc-tests.sh wallet_large --nocleanup # - ./qa/pull-tester/rpc-tests.sh wallet_large --nocleanup
# - Archive the resulting /tmp/test###### directory # - Archive the resulting /tmp/test###### directory
#
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (

3
qa/hush/full-test-suite.sh

@ -1,7 +1,8 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers # Copyright (c) 2016-2020 The Hush developers
# Released under the GPLv3
# Execute all of the automated tests related to Hush # 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 argparse
import os import os

5
qa/hush/full_test_suite.py

@ -1,9 +1,8 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush 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
# Execute all of the automated tests related to Hush # Execute all of the automated tests related to Hush
#
import argparse import argparse
from glob import glob from glob import glob

10
qa/rpc-tests/README.md

@ -20,10 +20,9 @@ Possible options:
``` ```
-h, --help show this help message and exit -h, --help show this help message and exit
--nocleanup Leave komodods and test.* datadir on exit or error --nocleanup Leave binaries and test.* datadir on exit or error
--noshutdown Don't stop komodods after the test execution --noshutdown Don't stop full node after the test execution
--srcdir=SRCDIR Source directory containing hushd/hush-cli (default: --srcdir=SRCDIR Source directory containing hushd/hush-cli (default: ../../src)
../../src)
--tmpdir=TMPDIR Root directory for datadirs --tmpdir=TMPDIR Root directory for datadirs
--tracerpc Print out all RPC calls as they are made --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 copied into a temporary directory and used as the initial
test state. test state.
If you get into a bad state, you should be able If you get into a bad state, you should be able to recover with:
to recover with:
```bash ```bash
rm -rf cache rm -rf cache

4
qa/rpc-tests/ac_private.py

@ -1,8 +1,6 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2018-2020 The Hush developers # Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Released under the GPLv3
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

6
qa/rpc-tests/addressindex.py

@ -1,11 +1,9 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers # Copyright (c) 2014-2015 The Bitcoin Core developers
# Copyright (c) 2016-2020 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Test addressindex generation and fetching # Test addressindex generation and fetching
#
import time import time
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
@ -346,4 +344,4 @@ class AddressIndexTest(BitcoinTestFramework):
if __name__ == '__main__': if __name__ == '__main__':
AddressIndexTest().main() AddressIndexTest().main()

5
qa/rpc-tests/bip65-cltv-p2p.py

@ -1,8 +1,7 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# # Copyright (c) 2016-2020 The Hush developers
# Distributed under the GPLv3/X11 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#
from test_framework.test_framework import ComparisonTestFramework from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import start_nodes from test_framework.util import start_nodes

2
qa/rpc-tests/bipdersig-p2p.py

@ -1,5 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# # Copyright (c) 2016-2020 The Hush developers
# Distributed under the GPLv3/X11 software license, see the accompanying # Distributed under the GPLv3/X11 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
# #

1
qa/rpc-tests/blockchain.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions_channels.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions_dice.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions_faucet.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions_gateways.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions_heir.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions_oracles.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions_rewards.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/cryptoconditions_token.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 SuperNET developers # Copyright (c) 2018 SuperNET developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/decodescript.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2015 The Bitcoin Core developers # Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/disablewallet.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/finalsaplingroot.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/forknotify.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/fundrawtransaction.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/getblocktemplate.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/getblocktemplate_longpoll.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/getblocktemplate_proposals.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/getchaintips.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/hardforkdetection.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# #
# Test hard fork detection # Test hard fork detection

1
qa/rpc-tests/httpbasics.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/invalidateblock.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/invalidblockrequest.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# #
# Distributed under the GPLv3/X11 software license, see the accompanying # Distributed under the GPLv3/X11 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/ivk_import_export.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2019 Bartlomiej Lisiecki # Copyright (c) 2019 Bartlomiej Lisiecki
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/key_import_export.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/keypool.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/listtransactions.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/maxblocksinflight.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# #
# Distributed under the GPLv3/X11 software license, see the accompanying # Distributed under the GPLv3/X11 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/mempool_nu_activation.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/mempool_reorg.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/mempool_resurrect_test.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/mempool_spendcoinbase.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/mempool_tx_expiry.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/mempool_tx_input_limit.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/merkle_blocks.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/nodehandling.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

37
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 import sys
sys.path.append('../../src/tui') # tuilib was removed, tests left here as inspiration
#sys.path.append('../../src/tui')
from lib import tuilib #from lib import tuilib
import unittest import unittest
import time 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) added 1 second sleep after each case to surely not face the nSPV server limitation (1 call/second)
''' '''
wif = '' wif = ''
dest_address = '' dest_address = ''
amount = '0.01' amount = '0.01'
chain = 'ILN' chain = 'HUSH3'
if not wif or not dest_address: if not wif or not dest_address:
raise Exception("Please set test wif and address to send transactions to") raise Exception("Please set test wif and address to send transactions to")
rpc_proxy = tuilib.def_credentials(chain) rpc_proxy = tuilib.def_credentials(chain)
chain_params = {"KMD": { chain_params = {"HUSH3": {
'tx_list_address': 'RGShWG446Pv24CKzzxjA23obrzYwNbs1kA', 'tx_list_address': 'RGShWG446Pv24CKzzxjA23obrzYwNbs1kA',
'min_chain_height': 1468080, 'min_chain_height': 1468080,
'notarization_height': '1468000', 'notarization_height': '1468000',
@ -33,19 +37,6 @@ chain_params = {"KMD": {
'tx_proof_id': 'f7beb36a65bc5bcbc9c8f398345aab7948160493955eb4a1f05da08c4ac3784f', 'tx_proof_id': 'f7beb36a65bc5bcbc9c8f398345aab7948160493955eb4a1f05da08c4ac3784f',
'tx_spent_height': 1456212, 'tx_spent_height': 1456212,
'tx_proof_height': '1468520', '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") print("testing nspv_login")
result = rpc_proxy.nspv_login(wif) result = rpc_proxy.nspv_login(wif)
self.assertEqual(result["result"], "success") 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) time.sleep(1)
def test_nspv_listunspent(self): def test_nspv_listunspent(self):
@ -156,9 +147,9 @@ class TestNspvClient(unittest.TestCase):
time.sleep(1) time.sleep(1)
def test_nspv_login_timout(self): 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) rpc_proxy.nspv_login(wif)
time.sleep(778) time.sleep(556)
result = rpc_proxy.nspv_spend(dest_address, amount) result = rpc_proxy.nspv_spend(dest_address, amount)
self.assertEqual(result["result"], "error") self.assertEqual(result["result"], "error")
self.assertEqual(result["error"], "wif expired") self.assertEqual(result["error"], "wif expired")

1
qa/rpc-tests/p2p-acceptblock.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# #
# Distributed under the GPLv3/X11 software license, see the accompanying # Distributed under the GPLv3/X11 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/p2p_node_bloom.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/p2p_txexpiry_dos.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/prioritisetransaction.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/proxy_test.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2015 The Bitcoin Core developers # Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/pruning.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/rawtransactions.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/receivedby.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/rest.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/rewind_index.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/rpcbind_test.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/script_test.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# #
# Distributed under the GPLv3/X11 software license, see the accompanying # Distributed under the GPLv3/X11 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

5
qa/rpc-tests/signrawtransaction_offline.py

@ -1,4 +1,7 @@
#!/usr/bin/env python2 #!/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.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_true, initialize_chain_clean, start_node 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) assert_true(len(online_tx_hash) > 0)
if __name__ == '__main__': if __name__ == '__main__':
SignOfflineTest().main() SignOfflineTest().main()

1
qa/rpc-tests/signrawtransactions.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2015 The Bitcoin Core developers # Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/smartfees.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014-2015 The Bitcoin Core developers # Copyright (c) 2014-2015 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

3
qa/rpc-tests/spentindex.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014-2015 The Bitcoin Core developers # Copyright (c) 2014-2015 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
@ -136,4 +137,4 @@ class SpentIndexTest(BitcoinTestFramework):
if __name__ == '__main__': if __name__ == '__main__':
SpentIndexTest().main() SpentIndexTest().main()

7
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 Copyright 2011 Jeff Garzik
@ -47,10 +50,8 @@ try:
except ImportError: except ImportError:
import urlparse import urlparse
USER_AGENT = "AuthServiceProxy/0.1" USER_AGENT = "FUCKjl777LULZ"
HTTP_TIMEOUT = 600 HTTP_TIMEOUT = 600
log = logging.getLogger("BitcoinRPC") log = logging.getLogger("BitcoinRPC")
class JSONRPCException(Exception): class JSONRPCException(Exception):

9
qa/rpc-tests/test_framework/bignum.py

@ -1,12 +1,7 @@
# # Copyright (c) 2016-2020 The Hush developers
#
# bignum.py
#
# This file is copied from python-bitcoinlib.
#
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
# # This file is from python-bitcoinlib.
"""Bignum routines""" """Bignum routines"""

3
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 # BlockStore: a helper class that keeps a map of blocks and implements
# helper functions for responding to getheaders and getdata, # helper functions for responding to getheaders and getdata,
# and for constructing a getheaders message # and for constructing a getheaders message

6
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 # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # 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 mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint
from script import CScript, OP_0, OP_EQUAL, OP_HASH160 from script import CScript, OP_0, OP_EQUAL, OP_HASH160

3
qa/rpc-tests/test_framework/comptool.py

@ -1,8 +1,7 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# # Copyright (c) 2016-2020 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#
from mininode import CBlock, CTransaction, CInv, NodeConn, NodeConnCB, \ from mininode import CBlock, CTransaction, CInv, NodeConn, NodeConnCB, \
msg_inv, msg_getheaders, msg_ping, msg_mempool, mininode_lock, MAX_INV_SZ msg_inv, msg_getheaders, msg_ping, msg_mempool, mininode_lock, MAX_INV_SZ

3
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 from operator import itemgetter
import struct import struct

27
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 # 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 # 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. # found in the mini-node branch of http://github.com/jgarzik/pynode.
@ -40,18 +41,14 @@ from .equihash import (
zcash_person, zcash_person,
) )
OVERWINTER_PROTO_VERSION = 170003 OVERWINTER_PROTO_VERSION = 170003
BIP0031_VERSION = 60000 BIP0031_VERSION = 60000
SPROUT_PROTO_VERSION = 170002 # past bip-31 for ping/pong SPROUT_PROTO_VERSION = 170002 # past bip-31 for ping/pong
SAPLING_PROTO_VERSION = 170006 SAPLING_PROTO_VERSION = 1987420
MY_SUBVERSION = "/python-mininode-hush-tester:3.3.0/" MY_SUBVERSION = "/SpicySand/"
OVERWINTER_VERSION_GROUP_ID = 0x03C48270 OVERWINTER_VERSION_GROUP_ID = 0x03C48270
MAX_INV_SZ = 50000
MAX_INV_SZ = 50000 COIN = 100000000 # 1 HUSH in puposhis
COIN = 100000000 # 1 HUSH in puposhis
# Keep our own socket map for asyncore, so that we can track disconnects # Keep our own socket map for asyncore, so that we can track disconnects
# ourselves (to workaround an issue with closing an asyncore socket when # ourselves (to workaround an issue with closing an asyncore socket when
@ -417,14 +414,14 @@ ZC_NOTEPLAINTEXT_LEADING = 1
ZC_V_SIZE = 8 ZC_V_SIZE = 8
ZC_RHO_SIZE = 32 ZC_RHO_SIZE = 32
ZC_R_SIZE = 32 ZC_R_SIZE = 32
ZC_MEMO_SIZE = 512 HUSH_MEMO_SIZE = 512
ZC_NOTEPLAINTEXT_SIZE = ( ZC_NOTEPLAINTEXT_SIZE = (
ZC_NOTEPLAINTEXT_LEADING + ZC_NOTEPLAINTEXT_LEADING +
ZC_V_SIZE + ZC_V_SIZE +
ZC_RHO_SIZE + ZC_RHO_SIZE +
ZC_R_SIZE + ZC_R_SIZE +
ZC_MEMO_SIZE HUSH_MEMO_SIZE
) )
NOTEENCRYPTION_AUTH_BYTES = 16 NOTEENCRYPTION_AUTH_BYTES = 16

1
qa/rpc-tests/test_framework/netutil.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

20
qa/rpc-tests/test_framework/script.py

@ -1,15 +1,11 @@
# # Copyright (c) 2016-2020 The Hush developers
# script.py
#
# This file is modified from python-bitcoinlib.
#
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
# # This file is modified from python-bitcoinlib.
"""Scripts """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 from __future__ import absolute_import, division, print_function, unicode_literals
@ -29,13 +25,11 @@ import binascii
from test_framework import bignum from test_framework import bignum
MAX_SCRIPT_SIZE = 10000 MAX_SCRIPT_SIZE = 10000
MAX_SCRIPT_ELEMENT_SIZE = 520 MAX_SCRIPT_ELEMENT_SIZE = 520
MAX_SCRIPT_OPCODES = 201 MAX_SCRIPT_OPCODES = 201
OPCODE_NAMES = {}
OPCODE_NAMES = {} _opcode_instances = []
_opcode_instances = []
class CScriptOp(int): class CScriptOp(int):
"""A single script opcode""" """A single script opcode"""
__slots__ = [] __slots__ = []

1
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 # Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

7
qa/rpc-tests/test_framework/test_framework.py

@ -1,14 +1,12 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Copyright (c) 2016-2020 The Hush 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 # Base class for RPC testing
# Add python-bitcoinrpc to module search path: # Add python-bitcoinrpc to module search path:
import os import os
import sys import sys
import shutil import shutil
import tempfile import tempfile
import traceback import traceback
@ -19,7 +17,6 @@ from util import assert_equal, check_json_precision, \
start_nodes, connect_nodes_bi, stop_nodes, \ start_nodes, connect_nodes_bi, stop_nodes, \
sync_blocks, sync_mempools, wait_bitcoinds sync_blocks, sync_mempools, wait_bitcoinds
class BitcoinTestFramework(object): class BitcoinTestFramework(object):
# These may be over-ridden by subclasses: # These may be over-ridden by subclasses:

5
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) 2014 The Bitcoin Core developers
# Copyright (c) 2018-2019 The SuperNET developers # Copyright (c) 2018-2019 The SuperNET developers
# Copyright (c) 2018-2020 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Helpful routines for regression testing # Helpful routines for regression testing
#
# Add python-bitcoinrpc to module search path: # Add python-bitcoinrpc to module search path:
import os import os
import sys import sys

9
qa/rpc-tests/timestampindex.py

@ -1,17 +1,14 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
# Copyright (c) 2016-2020 The Hush 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 # Test timestampindex generation and fetching
#
import time import time
from test_framework.test_framework import HushTestFramework from test_framework.test_framework import HushTestFramework
from test_framework.util import * from test_framework.util import *
class TimestampIndexTest(HushTestFramework): class TimestampIndexTest(HushTestFramework):
def setup_chain(self): def setup_chain(self):

3
qa/rpc-tests/txindex.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014-2015 The Bitcoin Core developers # Copyright (c) 2014-2015 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
@ -70,4 +71,4 @@ class TxIndexTest(BitcoinTestFramework):
if __name__ == '__main__': if __name__ == '__main__':
TxIndexTest().main() TxIndexTest().main()

1
qa/rpc-tests/txn_doublespend.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet_1941.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet_addresses.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet_anchorfork.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet_changeindicator.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

3
qa/rpc-tests/wallet_import_export.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # 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) return ("".join(keys), i)
if __name__ == '__main__': if __name__ == '__main__':
WalletImportExportTest().main() WalletImportExportTest().main()

1
qa/rpc-tests/wallet_listreceived.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet_mergetoaddress.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet_nullifiers.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet_overwintertx.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/wallet_persistence.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

4
qa/rpc-tests/wallet_protectcoinbase.py

@ -1,9 +1,9 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.mininode import COIN 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. # 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. # At this point in time, unspent notes all have a value of 10.0 and standard z_sendmany fee is 0.0001.
recipients = [] 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 }) recipients.append({"address":self.nodes[0].getnewaddress(), "amount":amount })
myopid = self.nodes[0].z_sendmany(mytaddr, recipients) 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)") 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)")

5
qa/rpc-tests/wallet_sapling.py

@ -1,7 +1,8 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2018 The Zcash developers
# Copyright (c) 2016-2020 The Hush 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.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException

1
qa/rpc-tests/wallet_shieldcoinbase.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

3
qa/rpc-tests/wallet_shieldcoinbase_sapling.py

@ -1,6 +1,7 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush 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
import inspect import inspect
import os import os

1
qa/rpc-tests/wallet_treestate.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/walletbackup.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/zapwallettxes.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

1
qa/rpc-tests/zkey_import_export.py

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html

4
qa/rpc-tests/zmq_test.py

@ -1,11 +1,9 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2016-2020 The Hush developers
# Copyright (c) 2015 The Bitcoin Core developers # Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the GPLv3 software license, see the accompanying # Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Test ZMQ interface # Test ZMQ interface
#
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, bytes_to_hex_str, start_nodes from test_framework.util import assert_equal, bytes_to_hex_str, start_nodes

130
src/alert.cpp

@ -3,7 +3,6 @@
// Copyright (c) 2016-2020 The Hush developers // Copyright (c) 2016-2020 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying // Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/****************************************************************************** /******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. * * Copyright © 2014-2019 The SuperNET Developers. *
* * * *
@ -18,20 +17,16 @@
* Removal or modification of this copyright notice is prohibited. * * Removal or modification of this copyright notice is prohibited. *
* * * *
******************************************************************************/ ******************************************************************************/
#include "alert.h" #include "alert.h"
#include "clientversion.h" #include "clientversion.h"
#include "net.h" #include "net.h"
#include "pubkey.h" #include "pubkey.h"
#include "timedata.h" #include "timedata.h"
#include "ui_interface.h" #include "ui_interface.h"
#include "util.h" #include "util.h"
#include <stdint.h> #include <stdint.h>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -118,7 +113,7 @@ uint256 CAlert::GetHash() const
bool CAlert::IsInEffect() const bool CAlert::IsInEffect() const
{ {
return (GetTime() < nExpiration); return false;
} }
bool CAlert::Cancels(const CAlert& alert) const 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 bool CAlert::AppliesToMe() const
{ {
return AppliesTo(PROTOCOL_VERSION, FormatSubVersion(GetArg("-clientname","MagicBean"), CLIENT_VERSION, std::vector<std::string>())); return false;
} }
bool CAlert::RelayTo(CNode* pnode) const 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; return false;
} }
bool CAlert::CheckSignature(const std::vector<unsigned char>& alertKey) const bool CAlert::CheckSignature(const std::vector<unsigned char>& alertKey) const
{ {
CPubKey key(alertKey); return false;
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;
} }
CAlert CAlert::getAlertByHash(const uint256 &hash) CAlert CAlert::getAlertByHash(const uint256 &hash)
{ {
CAlert retval; CAlert retval;
{
LOCK(cs_mapAlerts);
map<uint256, CAlert>::iterator mi = mapAlerts.find(hash);
if(mi != mapAlerts.end())
retval = mi->second;
}
return retval; return retval;
} }
bool CAlert::ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThread) bool CAlert::ProcessAlert(const std::vector<unsigned char>& 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<int>::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<uint256, CAlert>::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; return true;
} }
void void CAlert::Notify(const std::string& strMessage, bool fThread)
CAlert::Notify(const std::string& strMessage, bool fThread)
{ {
std::string strCmd = GetArg("-alertnotify", ""); return;
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);
} }

2
src/cc/CCPrices.h

@ -25,7 +25,7 @@
int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
extern void GetKomodoEarlytxidScriptPub(); 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_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) // defined in hush_defs.h
#define PRICES_TXFEE 10000 #define PRICES_TXFEE 10000

27
src/cc/CCinclude.h

@ -15,7 +15,6 @@
* Removal or modification of this copyright notice is prohibited. * * Removal or modification of this copyright notice is prohibited. *
* * * *
******************************************************************************/ ******************************************************************************/
#ifndef CC_INCLUDE_H #ifndef CC_INCLUDE_H
#define CC_INCLUDE_H #define CC_INCLUDE_H
@ -32,7 +31,7 @@ Details.
/// this script's hash is what the p2sh address was. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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 { enum opretid : uint8_t {
// cc contracts data: // cc contracts data:
OPRETID_NONFUNGIBLEDATA = 0x11, //!< NFT data id OPRETID_NONFUNGIBLEDATA = 0x11, //!< NFT data id
OPRETID_ASSETSDATA = 0x12, //!< assets contract data id OPRETID_ASSETSDATA = 0x12, //!< assets contract data id
OPRETID_GATEWAYSDATA = 0x13, //!< gateways contract data id OPRETID_GATEWAYSDATA = 0x13, //!< gateways contract data id
OPRETID_CHANNELSDATA = 0x14, //!< channels contract data id OPRETID_CHANNELSDATA = 0x14, //!< channels contract data id
OPRETID_HEIRDATA = 0x15, //!< heir contract data id OPRETID_HEIRDATA = 0x15, //!< heir contract data id
OPRETID_ROGUEGAMEDATA = 0x16, //!< rogue contract data id OPRETID_ROGUEGAMEDATA = 0x16, //!< rogue contract data id
OPRETID_PEGSDATA = 0x17, //!< pegs contract data id OPRETID_PEGSDATA = 0x17, //!< pegs contract data id
/*! \cond INTERNAL */ /*! \cond INTERNAL */
// non cc contract data: // non cc contract data:
@ -138,8 +137,6 @@ struct CC_utxo
/// \endcond /// \endcond
/// \cond INTERNAL /// \cond INTERNAL
// these are the parameters stored after Verus crypto-condition vouts. new versions may change
// the format
struct CC_meta struct CC_meta
{ {
std::vector<unsigned char> version; std::vector<unsigned char> version;
@ -774,7 +771,7 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
/// @returns true if success /// @returns true if success
bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t taddr,uint8_t prefix,uint8_t prefix2); 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 /// @returns public key as byte array
std::vector<uint8_t> Mypubkey(); std::vector<uint8_t> 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. /// 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. /// 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 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. /// 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); 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. /// 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 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 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 /// @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. /// Macro for logging messages using bitcoin LogAcceptCategory and LogPrintStr functions.
/// Supports error, info and three levels of debug messages. /// 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 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. /// 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 /// Error-level messages will always be printed, even if -debug parameter is not set

6
src/cc/import.cpp

@ -39,7 +39,7 @@
extern std::string ASSETCHAINS_SELFIMPORT; extern std::string ASSETCHAINS_SELFIMPORT;
extern uint16_t ASSETCHAINS_CODAPORT,ASSETCHAINS_BEAMPORT; extern uint16_t ASSETCHAINS_CODAPORT,ASSETCHAINS_BEAMPORT;
extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33]; extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33];
extern uint256 KOMODO_EARLYTXID; extern uint256 HUSH_EARLYTXID;
// utilities from gateways.cpp // utilities from gateways.cpp
uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::vector<uint256> &txids); uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::vector<uint256> &txids);
@ -364,9 +364,9 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
// ASSETCHAINS_SELFIMPORT is coin // 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); return(-1);
} }
// check for valid burn from external coin blockchain and if valid return(0); // check for valid burn from external coin blockchain and if valid return(0);

30
src/cc/importgateway.cpp

@ -28,7 +28,7 @@
#define KMD_TADDR 0 #define KMD_TADDR 0
#define CC_MARKER_VALUE 10000 #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<CPubKey> importgatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2,uint8_t wiftype) CScript EncodeImportGatewayBindOpRet(uint8_t funcid,std::string coin,uint256 oracletxid,uint8_t M,uint8_t N,std::vector<CPubKey> 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; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::string coin; struct CCcontract_info *cp,C;
std::vector<CPubKey> pubkeys,publishers; std::vector<uint256> txids; char str[128],burnaddr[64]; std::vector<CPubKey> pubkeys,publishers; std::vector<uint256> 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); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
@ -649,9 +649,9 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re
std::vector<CPubKey> msigpubkeys; char burnaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C; std::vector<CPubKey> msigpubkeys; char burnaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C;
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > 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); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
@ -748,9 +748,9 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); 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); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
@ -795,9 +795,9 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); 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); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
@ -866,9 +866,9 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); 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); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
@ -912,9 +912,9 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); 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); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
@ -990,9 +990,9 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); 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); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }

6
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 ( str != 0 )
{ {
if ( slen < IGUANA_MAXSCRIPTSIZE && offset+slen <= datalen ) if ( slen < DRAGON_MAXSCRIPTSIZE && offset+slen <= datalen )
{ {
for (i=0; i<slen; i++) for (i=0; i<slen; i++)
str[i] = data[offset++]; str[i] = data[offset++];
@ -375,7 +375,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t
{ {
if ( str != 0 ) if ( str != 0 )
{ {
if ( dlen < IGUANA_MAXSCRIPTSIZE && offset+dlen <= datalen ) if ( dlen < DRAGON_MAXSCRIPTSIZE && offset+dlen <= datalen )
{ {
for (i=0; i<dlen; i++) for (i=0; i<dlen; i++)
sprintf(&str[i<<1],"%02x",data[offset++]); sprintf(&str[i<<1],"%02x",data[offset++]);
@ -1024,7 +1024,7 @@ UniValue OracleData(const CPubKey& pk, int64_t txfee,uint256 oracletxid,std::vec
UniValue OracleFormat(uint8_t *data,int32_t datalen,char *format,int32_t formatlen) UniValue OracleFormat(uint8_t *data,int32_t datalen,char *format,int32_t formatlen)
{ {
UniValue obj(UniValue::VARR); uint256 hash; int32_t i,j=0; int64_t val; char str[IGUANA_MAXSCRIPTSIZE*2+1]; UniValue obj(UniValue::VARR); uint256 hash; int32_t i,j=0; int64_t val; char str[DRAGON_MAXSCRIPTSIZE*2+1];
for (i=0; i<formatlen && j<datalen; i++) for (i=0; i<formatlen && j<datalen; i++)
{ {
str[0] = 0; str[0] = 0;

18
src/cc/prices.cpp

@ -64,7 +64,7 @@ Restart the daemon with -earlytxid=<txid of opreturn_burn transaction> eg:
mine the chain past block 100, preventing anyone else, creating another payments plan on chain before block 100. 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. 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(); GetKomodoEarlytxidScriptPub();
This will fetch the op_return, calculate the scriptPubKey and save it to the global. 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<uint16_t> vec; std::vector<uint16_t> vec;
// check payment cc config: // 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(); GetKomodoEarlytxidScriptPub();
if (bettx.vout.size() < 6 || bettx.vout.size() > 7) 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] ) 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"); 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? // 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."); return eval->Invalid("the fee was paid to wrong address.");
int64_t betamount = bettx.vout[2].nValue; 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; vscript_t vintxOpret;
// check payment cc config: // 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(); GetKomodoEarlytxidScriptPub();
if (addfundingtx.vout.size() < 4 || addfundingtx.vout.size() > 5) 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"); 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? // 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."); return eval->Invalid("the fee was paid to wrong address.");
int64_t betamount = addfundingtx.vout[1].nValue; 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, txfee, pricespk)); // vout1 cc marker (NVOUT_CCMARKER)
mtx.vout.push_back(MakeCC1vout(cp->evalcode, betamount, pricespk)); // vout2 betamount 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 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. // 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. // 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); LOCK(cs_main);
GetKomodoEarlytxidScriptPub(); 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 //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)); 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, txfee, mypk)); // vout0 baton for total funding
mtx.vout.push_back(MakeCC1vout(cp->evalcode, betamount, pricespk)); // vout1 added amount 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. // 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. // 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); LOCK(cs_main);
GetKomodoEarlytxidScriptPub(); 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 // 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)); rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, prices_addopret(bettxid, mypk, amount));

88
src/crosschain.cpp

@ -15,7 +15,6 @@
* Removal or modification of this copyright notice is prohibited. * * Removal or modification of this copyright notice is prohibited. *
* * * *
******************************************************************************/ ******************************************************************************/
#include "cc/eval.h" #include "cc/eval.h"
#include "crosschain.h" #include "crosschain.h"
#include "importcoin.h" #include "importcoin.h"
@ -23,15 +22,14 @@
#include "notarizationdb.h" #include "notarizationdb.h"
#include "merkleblock.h" #include "merkleblock.h"
#include "cc/CCinclude.h" #include "cc/CCinclude.h"
/* /*
* The crosschain workflow. * The crosschain workflow.
* *
* 3 chains, A, B, and HUSH. We would like to prove TX on B. * 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. * There is a notarization, nA0, which will include TX via an MoM.
* The notarisation nA0 must fall between 2 notarisations of B, * The notarization nA0 must fall between 2 notarizations of B,
* ie, nB0 and nB1. An MoMoM including this range is propagated to * 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 * A: TX bnA0
* \ / * \ /
@ -42,10 +40,8 @@
// XXX: There are potential crashes wherever we access chainActive without a lock, // XXX: There are potential crashes wherever we access chainActive without a lock,
// because it might be disconnecting blocks at the same time. // because it might be disconnecting blocks at the same time.
// 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;
// TODO: this assumes a blocktime of 60 seconds and limiting of 1 day of blocks
int NOTARISATION_SCAN_LIMIT_BLOCKS = 1440;
CBlockIndex *komodo_getblockindex(uint256 hash); CBlockIndex *komodo_getblockindex(uint256 hash);
/* On HUSH */ /* On HUSH */
@ -53,12 +49,12 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig
std::vector<uint256> &moms, uint256 &destNotarizationTxid) std::vector<uint256> &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 * 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 * including the block height of the last notarization until the height before the
* previous notarisation. * previous notarization.
* *
* hushHeight notarisations-0 notarisations-1 * hushHeight notarizations-0 notarizations-1
* *********************| * *********************|
* > scan backwards > * > scan backwards >
*/ */
@ -76,13 +72,13 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig
for (i=0; i<NOTARISATION_SCAN_LIMIT_BLOCKS; i++) { for (i=0; i<NOTARISATION_SCAN_LIMIT_BLOCKS; i++) {
if (i > hushHeight) break; if (i > hushHeight) break;
NotarizationsInBlock notarisations; NotarizationsInBlock notarizations;
uint256 blockHash = *chainActive[hushHeight-i]->phashBlock; uint256 blockHash = *chainActive[hushHeight-i]->phashBlock;
if (!GetBlockNotarizations(blockHash, notarisations)) if (!GetBlockNotarizations(blockHash, notarizations))
continue; continue;
// See if we have an own notarisation in this block // See if we have an own notarization in this block
BOOST_FOREACH(Notarization& nota, notarisations) { BOOST_FOREACH(Notarization& nota, notarizations) {
if (strcmp(nota.second.symbol, symbol) == 0) if (strcmp(nota.second.symbol, symbol) == 0)
{ {
seenOwnNotarizations++; seenOwnNotarizations++;
@ -95,7 +91,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig
} }
if (seenOwnNotarizations >= 1) { if (seenOwnNotarizations >= 1) {
BOOST_FOREACH(Notarization& nota, notarisations) { BOOST_FOREACH(Notarization& nota, notarizations) {
if (GetSymbolAuthority(nota.second.symbol) == authority) if (GetSymbolAuthority(nota.second.symbol) == authority)
if (nota.second.ccId == targetCCid) { if (nota.second.ccId == targetCCid) {
tmp_moms.insert(nota.second.MoM); 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(); destNotarizationTxid = uint256();
moms.clear(); moms.clear();
return uint256(); 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 <typename IsTarget> template <typename IsTarget>
int ScanNotarizationsFromHeight(int nHeight, const IsTarget f, Notarization &found) 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); int start = std::max(nHeight, 1);
for (int h=start; h<limit; h++) { for (int h=start; h<limit; h++) {
NotarizationsInBlock notarisations; NotarizationsInBlock notarizations;
if (!GetBlockNotarizations(*chainActive[h]->phashBlock, notarisations)) if (!GetBlockNotarizations(*chainActive[h]->phashBlock, notarizations))
continue; continue;
BOOST_FOREACH(found, notarisations) { BOOST_FOREACH(found, notarizations) {
if (f(found)) { if (f(found)) {
return h; 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 * 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 * an assetchain MoM. We need to go from the notarizationTxid for A to the MoMoM range of the
* backnotarisation for B (given by hushHeight of notarisation), find the MoM within the MoMs for * 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). * that range, and finally extend the proof to lead to the MoMoM (proof root).
*/ */
EvalRef eval; EvalRef eval;
uint256 MoM = assetChainProof.second.Exec(txid); uint256 MoM = assetChainProof.second.Exec(txid);
// Get a Hush height for given notarisation Txid // Get a Hush height for given notarization Txid
int hushHeight; int hushHeight;
{ {
CTransaction sourceNotarization; CTransaction sourceNotarization;
@ -170,11 +166,11 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
hushHeight = blockIdx.GetHeight(); 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. // at that height.
// If we call CalculateProofRoot with that height, it'll scan backwards, until it finds // 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 // 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 notarisation for B, // at all. So, the thing we need to do is scan forwards to find the notarization for B,
// that is inclusive of A. // that is inclusive of A.
Notarization nota; Notarization nota;
auto isTarget = [&](Notarization &nota) { auto isTarget = [&](Notarization &nota) {
@ -182,7 +178,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
}; };
hushHeight = ScanNotarizationsFromHeight(hushHeight, isTarget, nota); hushHeight = ScanNotarizationsFromHeight(hushHeight, isTarget, nota);
if (!hushHeight) 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 ) if ( offset != 0 )
hushHeight += offset; hushHeight += offset;
@ -257,38 +253,36 @@ bool IsSameAssetChain(const Notarization &nota) {
return strcmp(nota.second.symbol, SMART_CHAIN_SYMBOL) == 0; return strcmp(nota.second.symbol, SMART_CHAIN_SYMBOL) == 0;
}; };
/* On assetchain */ /* On assetchain */
bool GetNextBacknotarisation(uint256 hushNotarizationTxid, Notarization &out) bool GetNextBacknotarization(uint256 hushNotarizationTxid, Notarization &out)
{ {
/* /*
* Here we are given a txid, and a proof. * Here we are given a txid, and a proof.
* We go from the HUSH notarisation txid to the backnotarisation, * We go from the HUSH notarization txid to the backnotarization,
* then jump to the next backnotarisation, which contains the corresponding MoMoM. * then jump to the next backnotarization, which contains the corresponding MoMoM.
*/ */
Notarization bn; Notarization bn;
if (!GetBackNotarization(hushNotarizationTxid, bn)) if (!GetBackNotarization(hushNotarizationTxid, bn))
return false; return false;
// Need to get block height of that backnotarisation // Need to get block height of that backnotarization
EvalRef eval; EvalRef eval;
CBlockIndex block; CBlockIndex block;
CTransaction tx; CTransaction tx;
if (!eval->GetTxConfirmed(bn.first, tx, block)){ 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 false;
} }
return (bool) ScanNotarizationsFromHeight(block.GetHeight()+1, &IsSameAssetChain, out); return (bool) ScanNotarizationsFromHeight(block.GetHeight()+1, &IsSameAssetChain, out);
} }
bool CheckMoMoM(uint256 hushNotarizationHash, uint256 momom) bool CheckMoMoM(uint256 hushNotarizationHash, uint256 momom)
{ {
/* /*
* Given a notarisation hash and an MoMoM. Backnotarisations may arrive out of order * Given a notarization hash and an MoMoM. Backnotarizations may arrive out of order
* or multiple in the same block. So dereference the notarisation hash to the corresponding * or multiple in the same block. So dereference the notarization hash to the corresponding
* backnotarisation and scan around the hushheight to see if the MoMoM is a match. * backnotarization and scan around the hushheight to see if the MoMoM is a match.
* This is a sledgehammer approach... * This is a sledgehammer approach...
*/ */
@ -296,12 +290,12 @@ bool CheckMoMoM(uint256 hushNotarizationHash, uint256 momom)
if (!GetBackNotarization(hushNotarizationHash, bn)) if (!GetBackNotarization(hushNotarizationHash, bn))
return false; return false;
// Need to get block height of that backnotarisation // Need to get block height of that backnotarization
EvalRef eval; EvalRef eval;
CBlockIndex block; CBlockIndex block;
CTransaction tx; CTransaction tx;
if (!eval->GetTxConfirmed(bn.first, tx, block)){ 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 false;
} }
@ -423,7 +417,7 @@ bool CheckNotariesApproval(uint256 burntxid, const std::vector<uint256> & notary
/* /*
* On assetchain * On assetchain
* in: txid * in: txid
* out: pair<notarisationTxHash,merkleBranch> * out: pair<notarizationTxHash,merkleBranch>
*/ */
TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx) TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx)
@ -443,15 +437,15 @@ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx)
blockIndex = komodo_getblockindex(blockHash); blockIndex = komodo_getblockindex(blockHash);
int h = blockIndex->GetHeight(); 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 // 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 &nota) { auto isTarget = [&](Notarization &nota) {
if (!IsSameAssetChain(nota)) return false; if (!IsSameAssetChain(nota)) return false;
return nota.second.height >= blockIndex->GetHeight(); return nota.second.height >= blockIndex->GetHeight();
}; };
if (!ScanNotarizationsFromHeight(blockIndex->GetHeight(), isTarget, nota)) 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 // index of block in MoM leaves
nIndex = nota.second.height - blockIndex->GetHeight(); nIndex = nota.second.height - blockIndex->GetHeight();

4
src/gtest/test_noteencryption.cpp

@ -31,8 +31,8 @@ TEST(noteencryption, NotePlaintext)
auto ivk = fvk.in_viewing_key(); auto ivk = fvk.in_viewing_key();
SaplingPaymentAddress addr = *ivk.address({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); SaplingPaymentAddress addr = *ivk.address({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
std::array<unsigned char, ZC_MEMO_SIZE> memo; std::array<unsigned char, HUSH_MEMO_SIZE> memo;
for (size_t i = 0; i < ZC_MEMO_SIZE; i++) { for (size_t i = 0; i < HUSH_MEMO_SIZE; i++) {
// Fill the message with dummy data // Fill the message with dummy data
memo[i] = (unsigned char) i; memo[i] = (unsigned char) i;
} }

2
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]; 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 ) if ( didinit == 0 )
{ {
portable_mutex_init(&KOMODO_KV_mutex); portable_mutex_init(&HUSH_KV_mutex);
portable_mutex_init(&KOMODO_CC_mutex); portable_mutex_init(&KOMODO_CC_mutex);
didinit = 1; didinit = 1;
} }

15
src/hush_defs.h

@ -20,14 +20,14 @@
#include "arith_uint256.h" #include "arith_uint256.h"
#include "chain.h" #include "chain.h"
#include "hush_nk.h" #include "hush_nk.h"
#define KOMODO_EARLYTXID_HEIGHT 100 #define HUSH_EARLYTXID_HEIGHT 100
#define ASSETCHAINS_MINHEIGHT 128 #define ASSETCHAINS_MINHEIGHT 128
#define ASSETCHAINS_MAX_ERAS 7 #define ASSETCHAINS_MAX_ERAS 7
#define KOMODO_ELECTION_GAP 2000 #define KOMODO_ELECTION_GAP 2000
#define ROUNDROBIN_DELAY 61 #define ROUNDROBIN_DELAY 61
#define HUSH_SMART_CHAIN_MAXLEN 65 #define HUSH_SMART_CHAIN_MAXLEN 65
#define KOMODO_LIMITED_NETWORKSIZE 4 #define KOMODO_LIMITED_NETWORKSIZE 4
#define IGUANA_MAXSCRIPTSIZE 10001 #define DRAGON_MAXSCRIPTSIZE 10001
#define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus #define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus
#define CRYPTO555_PUBSECPSTR "038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac" #define CRYPTO555_PUBSECPSTR "038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac"
#define CRYPTO555_HUSHADDR "RFetqf8WUfWnwNeXdknkm8ojk7EXnYFzrv" #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 uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA;
extern std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; extern std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
extern uint256 KOMODO_EARLYTXID; extern uint256 HUSH_EARLYTXID;
extern int32_t HUSH_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern int32_t HUSH_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE;
extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_CC;
@ -529,7 +529,6 @@ extern char NOTARYADDRS[64][64];
extern char NOTARY_ADDRESSES[NUM_HUSH_SEASONS][64][64]; extern char NOTARY_ADDRESSES[NUM_HUSH_SEASONS][64][64];
extern int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL; extern int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL;
extern int32_t ASSETCHAINS_EARLYTXIDCONTRACT; extern int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
extern int32_t ASSETCHAINS_STAKED_SPLIT_PERCENTAGE;
int tx_height( const uint256 &hash ); int tx_height( const uint256 &hash );
extern std::vector<std::string> vWhiteListAddress; extern std::vector<std::string> vWhiteListAddress;
extern std::map <std::int8_t, int32_t> mapHeightEvalActivate; extern std::map <std::int8_t, int32_t> mapHeightEvalActivate;
@ -537,9 +536,9 @@ void komodo_netevent(std::vector<uint8_t> payload);
int32_t getacseason(uint32_t timestamp); int32_t getacseason(uint32_t timestamp);
int32_t gethushseason(int32_t height); int32_t gethushseason(int32_t height);
#define IGUANA_MAXSCRIPTSIZE 10001 #define DRAGON_MAXSCRIPTSIZE 10001
#define KOMODO_KVDURATION 1440 #define HUSH_KVDURATION 1440
#define KOMODO_KVBINARY 2 #define HUSH_KVBINARY 2
#define PRICES_SMOOTHWIDTH 1 #define PRICES_SMOOTHWIDTH 1
#define PRICES_MAXDATAPOINTS 8 #define PRICES_MAXDATAPOINTS 8
uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); 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); 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); 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_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); uint32_t komodo_blocktime(uint256 hash);
int32_t hush_longestchain(); int32_t hush_longestchain();

8
src/hush_globals.h

@ -45,7 +45,7 @@ struct hush_state KOMODO_STATES[34];
#define _COINBASE_MATURITY 100 #define _COINBASE_MATURITY 100
int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; 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_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; 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; extern int32_t HUSH_LOADINGBLOCKS;
unsigned int MAX_BLOCK_SIGOPS = 20000; unsigned int MAX_BLOCK_SIGOPS = 20000;
int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL; int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL;
CScript KOMODO_EARLYTXID_SCRIPTPUB; CScript HUSH_EARLYTXID_SCRIPTPUB;
int32_t ASSETCHAINS_EARLYTXIDCONTRACT; int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
std::map <std::int8_t, int32_t> mapHeightEvalActivate; std::map <std::int8_t, int32_t> mapHeightEvalActivate;
struct komodo_kv *KOMODO_KV; struct komodo_kv *HUSH_KV;
pthread_mutex_t KOMODO_KV_mutex,KOMODO_CC_mutex; pthread_mutex_t HUSH_KV_mutex,KOMODO_CC_mutex;
#define MAX_CURRENCIES 32 #define MAX_CURRENCIES 32
char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies

6
src/hush_structs.h

@ -45,9 +45,9 @@
#define KOMODO_OPRETURN_WITHDRAW 'W' // assetchain #define KOMODO_OPRETURN_WITHDRAW 'W' // assetchain
#define KOMODO_OPRETURN_REDEEMED 'X' #define KOMODO_OPRETURN_REDEEMED 'X'
#define KOMODO_KVPROTECTED 1 #define HUSH_KVPROTECTED 1
#define KOMODO_KVBINARY 2 #define HUSH_KVBINARY 2
#define KOMODO_KVDURATION 1440 #define HUSH_KVDURATION 1440
#define HUSH_SMART_CHAIN_MAXLEN 65 #define HUSH_SMART_CHAIN_MAXLEN 65
#ifndef _BITS256 #ifndef _BITS256

2
src/hush_utils.h

@ -1860,7 +1860,7 @@ void hush_args(char *argv0)
{ {
printf("HUSH_REWIND %d\n",HUSH_REWIND); 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); ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
if ( name.c_str()[0] != 0 ) if ( name.c_str()[0] != 0 )
{ {

8
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 Copyright (c) 2009 Dave Gamble
@ -19,7 +22,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/****************************************************************************** /******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. * * Copyright © 2014-2019 The SuperNET Developers. *
* * * *
@ -34,10 +36,8 @@
* Removal or modification of this copyright notice is prohibited. * * Removal or modification of this copyright notice is prohibited. *
* * * *
******************************************************************************/ ******************************************************************************/
#ifndef komodo_cJSON__h #ifndef komodo_cJSON__h
#define komodo_cJSON__h #define komodo_cJSON__h
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@ -45,9 +45,7 @@
#include <ctype.h> #include <ctype.h>
#include <float.h> #include <float.h>
#include <memory.h> #include <memory.h>
#include "cJSON.h" #include "cJSON.h"
//#include "../crypto555/OS_portable.h" //#include "../crypto555/OS_portable.h"
#define MAX_JSON_FIELD 4096 // on the big side #define MAX_JSON_FIELD 4096 // on the big side

28
src/komodo_kv.h

@ -42,7 +42,7 @@ int32_t komodo_kvnumdays(uint32_t flags)
int32_t komodo_kvduration(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) 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); 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; struct komodo_kv *ptr; int32_t duration,retval = -1;
*heightp = -1; *heightp = -1;
*flagsp = 0; *flagsp = 0;
memset(pubkeyp,0,sizeof(*pubkeyp)); memset(pubkeyp,0,sizeof(*pubkeyp));
portable_mutex_lock(&KOMODO_KV_mutex); portable_mutex_lock(&HUSH_KV_mutex);
HASH_FIND(hh,KOMODO_KV,key,keylen,ptr); HASH_FIND(hh,HUSH_KV,key,keylen,ptr);
if ( ptr != 0 ) if ( ptr != 0 )
{ {
duration = komodo_kvduration(ptr->flags); 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); //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) ) if ( current_height > (ptr->height + duration) )
{ {
HASH_DELETE(hh,KOMODO_KV,ptr); HASH_DELETE(hh,HUSH_KV,ptr);
if ( ptr->value != 0 ) if ( ptr->value != 0 )
free(ptr->value); free(ptr->value);
if ( ptr->key != 0 ) 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); memcpy(value,ptr->value,retval);
} }
} //else fprintf(stderr,"couldnt find (%s)\n",(char *)key); } //else fprintf(stderr,"couldnt find (%s)\n",(char *)key);
portable_mutex_unlock(&KOMODO_KV_mutex); portable_mutex_unlock(&HUSH_KV_mutex);
if ( retval < 0 ) if ( retval < 0 )
{ {
// search rawmempool // 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) void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
{ {
static uint256 zeroes; 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 if ( SMART_CHAIN_SYMBOL[0] == 0 ) // disable KV for KMD
return; return;
dragon_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen); 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); portable_mutex_lock(&HUSH_KV_mutex);
HASH_FIND(hh,KOMODO_KV,key,keylen,ptr); HASH_FIND(hh,HUSH_KV,key,keylen,ptr);
if ( ptr != 0 ) if ( ptr != 0 )
{ {
//fprintf(stderr,"(%s) already there\n",(char *)key); //fprintf(stderr,"(%s) already there\n",(char *)key);
//if ( (ptr->flags & KOMODO_KVPROTECTED) != 0 ) //if ( (ptr->flags & HUSH_KVPROTECTED) != 0 )
{ {
tstr = (char *)"transfer:"; tstr = (char *)"transfer:";
transferpubstr = (char *)&valueptr[strlen(tstr)]; transferpubstr = (char *)&valueptr[strlen(tstr)];
@ -174,10 +174,10 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
ptr->keylen = keylen; ptr->keylen = keylen;
memcpy(ptr->key,key,keylen); memcpy(ptr->key,key,keylen);
newflag = 1; 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); //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 ) if ( ptr->value != 0 )
free(ptr->value), 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); ptr->value = (uint8_t *)calloc(1,valuesize);
memcpy(ptr->value,valueptr,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++) /*for (i=0; i<32; i++)
printf("%02x",((uint8_t *)&ptr->pubkey)[i]); printf("%02x",((uint8_t *)&ptr->pubkey)[i]);
printf(" <- "); printf(" <- ");
@ -196,7 +196,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
memcpy(&ptr->pubkey,&pubkey,sizeof(ptr->pubkey)); memcpy(&ptr->pubkey,&pubkey,sizeof(ptr->pubkey));
ptr->height = height; ptr->height = height;
ptr->flags = flags; // jl777 used to or in KVPROTECTED 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,"KV update size mismatch %d vs %d\n",opretlen,coresize);
} else fprintf(stderr,"not enough fee\n"); } else fprintf(stderr,"not enough fee\n");
} }

208
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 IsStandardTx(const CTransaction& tx, string& reason, const int nHeight)
{ {
bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); 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) { if (saplingActive) {
// Sapling standard rules apply // Sapling standard rules apply
@ -891,7 +891,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight)
if (whichType == TX_NULL_DATA) if (whichType == TX_NULL_DATA)
{ {
if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE ) if ( txout.scriptPubKey.size() > DRAGON_MAXSCRIPTSIZE )
{ {
reason = "opreturn too big"; reason = "opreturn too big";
return(false); return(false);
@ -1098,17 +1098,10 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
return nSigOps; 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) 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 ) if ( slowflag != 0 && ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 )
{
}
else if ( slowflag != 0 && ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 )
{ {
if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 )
return(false); return(false);
@ -1133,8 +1126,8 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde
bool (*isInitBlockDownload)(),int32_t validateprices) bool (*isInitBlockDownload)(),int32_t validateprices)
{ {
bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); 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);
bool isSprout = !overwinterActive; bool isSprout = !overwinterActive;
// If Sprout rules apply, reject transactions which are intended for Overwinter and beyond // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond
if (isSprout && tx.fOverwintered) { if (isSprout && tx.fOverwintered) {
@ -1361,21 +1354,19 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState
return true; 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); 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]; uint8_t pubkeys[64][33];
hush_notaries(pubkeys,0,tiptime); hush_notaries(pubkeys,0,tiptime);
} }
if ( strcmp(coinaddr,CRYPTO555_HUSHADDR) == 0 ) if ( strcmp(coinaddr,CRYPTO555_HUSHADDR) == 0 )
return(1); return(1);
for (int32_t i = 0; i < NUM_HUSH_NOTARIES; i++) for (int32_t i = 0; i < NUM_HUSH_NOTARIES; i++) {
{ if ( strcmp(coinaddr,NOTARY_ADDRESSES[season-1][i]) == 0 ) {
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]);
//fprintf(stderr, "coinaddr.%s notaryaddress[%i].%s\n",coinaddr,i,NOTARY_ADDRESSES[season-1][i]); }
return(1); return(1);
} }
} }
@ -1471,14 +1462,14 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
// //
char destaddr[65]; char destaddr[65];
Getscriptaddress(destaddr,txout.scriptPubKey); Getscriptaddress(destaddr,txout.scriptPubKey);
if ( komodo_isnotaryvout(destaddr,tiptime) == 0 ) if ( hush_isnotaryvout(destaddr,tiptime) == 0 )
{ {
invalid_private_taddr = 1; invalid_private_taddr = 1;
//return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain"); //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"); return state.DoS(100, error("CheckTransaction(): txout.scriptPubKey.size() too big"),REJECT_INVALID, "bad-txns-opret-too-big");
nValueOut += txout.nValue; nValueOut += txout.nValue;
if (!MoneyRange(nValueOut)) if (!MoneyRange(nValueOut))
@ -2886,14 +2877,13 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const CO
void ConnectNotarizations(const CBlock &block, int height) void ConnectNotarizations(const CBlock &block, int height)
{ {
NotarizationsInBlock notarisations = ScanBlockNotarizations(block, height); NotarizationsInBlock notarizations = ScanBlockNotarizations(block, height);
if (notarisations.size() > 0) { if (notarizations.size() > 0) {
CDBBatch batch = CDBBatch(*pnotarizations); CDBBatch batch = CDBBatch(*pnotarizations);
batch.Write(block.GetHash(), notarisations); batch.Write(block.GetHash(), notarizations);
WriteBackNotarizations(notarisations, batch); WriteBackNotarizations(notarizations, batch);
pnotarizations->WriteBatch(batch, true); pnotarizations->WriteBatch(batch, true);
LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n", LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n", notarizations.size(), block.GetHash().GetHex().data());
notarisations.size(), block.GetHash().GetHex().data());
} }
} }
@ -2905,8 +2895,7 @@ void DisconnectNotarizations(const CBlock &block)
batch.Erase(block.GetHash()); batch.Erase(block.GetHash());
EraseBackNotarizations(nibs, batch); EraseBackNotarizations(nibs, batch);
pnotarizations->WriteBatch(batch, true); pnotarizations->WriteBatch(batch, true);
LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n", LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n", nibs.size(), block.GetHash().GetHex().data());
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. // Do this here before the block is moved to the main block files.
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) 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. // do a full block scan to get ntz 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. // if ntz in the block, must be position 1 and the coinbase must pay notaries.
int32_t notarisationTx = hush_connectblock(true,pindex,*(CBlock *)&block); 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. // -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!"), 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"); 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! // 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 notaries create a notarization even if its not in this chain it will need to be mined inside its own block!
if ( notarisationTx == 1 ) if ( notarizationTx == 1 )
{ {
// Check if the notaries have been paid. // Check if the notaries have been paid.
if ( block.vtx[0].vout.size() == 1 ) if ( block.vtx[0].vout.size() == 1 )
return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"), return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"), REJECT_INVALID, "bad-cb-amount");
REJECT_INVALID, "bad-cb-amount");
// calculate the notaries compensation and validate the amounts and pubkeys are correct. // calculate the notaries compensation and validate the amounts and pubkeys are correct.
notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight());
//fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); //fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque);
@ -3294,6 +3282,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
REJECT_INVALID, "bad-cb-amount"); REJECT_INVALID, "bad-cb-amount");
} }
} }
// Move the block to the main block file, we need this to create the TxIndex in the following loop. // 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 ) if ( (pindex->nStatus & BLOCK_IN_TMPFILE) != 0 )
{ {
@ -3626,7 +3615,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
setDirtyBlockIndex.insert(pindex); setDirtyBlockIndex.insert(pindex);
} }
ConnectNotarizations(block, pindex->GetHeight()); // MoMoM notarisation DB. ConnectNotarizations(block, pindex->GetHeight()); // MoMoM notarization DB.
if (fTxIndex) if (fTxIndex)
if (!pblocktree->WriteTxIndex(vPos)) 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); LOCK(cs_mapAlerts);
BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
item.second.RelayTo(pfrom); item.second.RelayTo(pfrom);
} }
*/
pfrom->fSuccessfullyConnected = true; pfrom->fSuccessfullyConnected = true;
@ -7183,17 +7174,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
//pfrom->nTimeOffset = nTimeOffset; //pfrom->nTimeOffset = nTimeOffset;
//AddTimeData(pfrom->addr, nTimeOffset); //AddTimeData(pfrom->addr, nTimeOffset);
pfrom->nTimeOffset = timeWarning.AddTimeData(pfrom->addr, nTime, GetTime()); 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 // Must have a version message before anything else
Misbehaving(pfrom->GetId(), 1); Misbehaving(pfrom->GetId(), 1);
return false; return false;
} } else if ( strCommand == "events" ) {
else if ( strCommand == "events" )
{
if ( ASSETCHAINS_CCLIB != "gamescc" ) if ( ASSETCHAINS_CCLIB != "gamescc" )
{ {
Misbehaving(pfrom->GetId(), 1); Misbehaving(pfrom->GetId(), 1);
@ -7203,9 +7188,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vRecv >> payload; vRecv >> payload;
komodo_netevent(payload); komodo_netevent(payload);
return(true); return(true);
} } else if (strCommand == "verack") {
else if (strCommand == "verack")
{
pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
if ( HUSH_NSPV_SUPERLITE ) if ( HUSH_NSPV_SUPERLITE )
@ -7224,26 +7207,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
} }
// Disconnect existing peer connection when: // Disconnect existing peer connection when:
// 1. The version message has been received // 1. The version message has been received
// 2. Peer version is below the minimum version for the current epoch // 2. Peer version is below the minimum version for the current epoch
else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[ else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion) {
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);
{
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, pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", strprintf("Version must be %d or greater",
chainparams.GetConsensus().vUpgrades[ chainparams.GetConsensus().vUpgrades[
CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion)); CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion));
pfrom->fDisconnect = true; pfrom->fDisconnect = true;
return false; return false;
} } else if (strCommand == "addr") {
else if (strCommand == "addr")
{
vector<CAddress> vAddr; vector<CAddress> vAddr;
vRecv >> vAddr; vRecv >> vAddr;
@ -7490,11 +7465,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (!vToFetch.empty()) if (!vToFetch.empty())
pfrom->PushMessage("getdata", vToFetch); pfrom->PushMessage("getdata", vToFetch);
} } else if (strCommand == "getdata") {
else if (strCommand == "getdata")
{
vector<CInv> vInv; vector<CInv> vInv;
vRecv >> vInv; vRecv >> vInv;
if (vInv.size() > MAX_INV_SZ) 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()); pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
ProcessGetData(pfrom); ProcessGetData(pfrom);
} } else if (strCommand == "getblocks") {
else if (strCommand == "getblocks")
{
CBlockLocator locator; CBlockLocator locator;
uint256 hashStop; uint256 hashStop;
vRecv >> locator >> hashStop; vRecv >> locator >> hashStop;
@ -7547,11 +7514,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
break; break;
} }
} }
} } else if (strCommand == "getheaders") {
else if (strCommand == "getheaders")
{
CBlockLocator locator; CBlockLocator locator;
uint256 hashStop; uint256 hashStop;
vRecv >> locator >> hashStop; vRecv >> locator >> hashStop;
@ -7574,9 +7537,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
return true; return true;
} }
pindex = (*mi).second; pindex = (*mi).second;
} } else {
else
{
// Find the last block the caller has in the main chain // Find the last block the caller has in the main chain
pindex = FindForkInGlobalIndex(chainActive, locator); pindex = FindForkInGlobalIndex(chainActive, locator);
if (pindex) if (pindex)
@ -7607,11 +7568,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if ( counter++ < 3 ) 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); 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()) if (IsInitialBlockDownload())
return true; return true;
@ -7696,7 +7653,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
BOOST_FOREACH(uint256 hash, vEraseQueue) BOOST_FOREACH(uint256 hash, vEraseQueue)
EraseOrphanTx(hash); 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 && else if (fMissingInputs &&
tx.vjoinsplit.empty() && tx.vjoinsplit.empty() &&
tx.vShieldedSpend.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 // 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 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) if (nEvicted > 0)
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted); LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
} else { } else {
@ -7744,9 +7701,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (nDoS > 0) if (nDoS > 0)
Misbehaving(pfrom->GetId(), nDoS); 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<CBlockHeader> headers; std::vector<CBlockHeader> headers;
@ -7809,9 +7764,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
CheckBlockIndex(); 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; CBlock block;
vRecv >> 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); LOCK2(cs_main, pfrom->cs_filter);
std::vector<uint256> vtxid; std::vector<uint256> vtxid;
@ -7864,17 +7813,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
if (vInv.size() > 0) if (vInv.size() > 0)
pfrom->PushMessage("inv", vInv); pfrom->PushMessage("inv", vInv);
} } else if (fAlerts && strCommand == "alert") {
else if (fAlerts && strCommand == "alert") //TODO: probably completely ignore this
{
CAlert alert; CAlert alert;
vRecv >> alert; vRecv >> alert;
uint256 alertHash = alert.GetHash(); uint256 alertHash = alert.GetHash();
if (pfrom->setKnown.count(alertHash) == 0) if (pfrom->setKnown.count(alertHash) == 0) {
{ if (alert.ProcessAlert(Params().AlertKey())) {
if (alert.ProcessAlert(Params().AlertKey()))
{
// Relay // Relay
pfrom->setKnown.insert(alertHash); pfrom->setKnown.insert(alertHash);
{ {
@ -7882,8 +7828,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
BOOST_FOREACH(CNode* pnode, vNodes) BOOST_FOREACH(CNode* pnode, vNodes)
alert.RelayTo(pnode); alert.RelayTo(pnode);
} }
} } else {
else {
// Small DoS penalty so peers that send us lots of // Small DoS penalty so peers that send us lots of
// duplicate/expired/invalid-signature/whatever alerts // duplicate/expired/invalid-signature/whatever alerts
// eventually get banned. // eventually get banned.
@ -7893,12 +7838,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
Misbehaving(pfrom->GetId(), 10); Misbehaving(pfrom->GetId(), 10);
} }
} }
} } else if (!(nLocalServices & NODE_BLOOM) &&
else if (!(nLocalServices & NODE_BLOOM) &&
(strCommand == "filterload" || (strCommand == "filterload" ||
strCommand == "filteradd")) strCommand == "filteradd")) {
{
if (pfrom->nVersion >= NO_BLOOM_VERSION) { if (pfrom->nVersion >= NO_BLOOM_VERSION) {
Misbehaving(pfrom->GetId(), 100); Misbehaving(pfrom->GetId(), 100);
return false; return false;
@ -7906,11 +7848,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
pfrom->fDisconnect = true; pfrom->fDisconnect = true;
return false; return false;
} }
} } else if (strCommand == "filterload") {
else if (strCommand == "filterload")
{
CBloomFilter filter; CBloomFilter filter;
vRecv >> filter; vRecv >> filter;
@ -7925,11 +7863,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
pfrom->pfilter->UpdateEmptyFull(); pfrom->pfilter->UpdateEmptyFull();
} }
pfrom->fRelayTxes = true; pfrom->fRelayTxes = true;
} } else if (strCommand == "filteradd") {
else if (strCommand == "filteradd")
{
vector<unsigned char> vData; vector<unsigned char> vData;
vRecv >> vData; vRecv >> vData;
@ -7945,22 +7879,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
else else
Misbehaving(pfrom->GetId(), 100); Misbehaving(pfrom->GetId(), 100);
} }
} } else if (strCommand == "filterclear") {
else if (strCommand == "filterclear")
{
LOCK(pfrom->cs_filter); LOCK(pfrom->cs_filter);
if (nLocalServices & NODE_BLOOM) { if (nLocalServices & NODE_BLOOM) {
delete pfrom->pfilter; delete pfrom->pfilter;
pfrom->pfilter = new CBloomFilter(); pfrom->pfilter = new CBloomFilter();
} }
pfrom->fRelayTxes = true; pfrom->fRelayTxes = true;
} } else if (strCommand == "reject") {
else if (strCommand == "reject")
{
if (fDebug) { if (fDebug) {
try { try {
string strMsg; unsigned char ccode; string strReason; 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"); 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 // We do not care about the NOTFOUND message, but logging an Unknown Command
// message would be undesirable as we transmit it ourselves. // message would be undesirable as we transmit it ourselves.
} } else {
else {
// Ignore unknown commands for extensibility // Ignore unknown commands for extensibility
LogPrint("net", "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id); LogPrint("net", "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id);
} }
return true; return true;
} }
@ -8117,7 +8038,6 @@ bool ProcessMessages(CNode* pfrom)
return fOk; return fOk;
} }
bool SendMessages(CNode* pto, bool fSendTrickle) bool SendMessages(CNode* pto, bool fSendTrickle)
{ {
const Consensus::Params& consensusParams = Params().GetConsensus(); 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)); 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 static class CMainCleanup
{ {
public: public:

60
src/miner.cpp

@ -47,12 +47,9 @@
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
#include "wallet/wallet.h" #include "wallet/wallet.h"
#endif #endif
#include "zcash/Address.hpp" #include "zcash/Address.hpp"
#include "transaction_builder.h" #include "transaction_builder.h"
#include "sodium.h" #include "sodium.h"
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#ifdef ENABLE_MINING #ifdef ENABLE_MINING
@ -145,7 +142,7 @@ int32_t komodo_baseid(char *origbase);
int32_t hush_longestchain(); int32_t hush_longestchain();
int64_t komodo_block_unlocktime(uint32_t nHeight); int64_t komodo_block_unlocktime(uint32_t nHeight);
uint64_t the_commission(const CBlock *block,int32_t height); 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 decode_hex(uint8_t *bytes,int32_t n,char *hex);
int32_t komodo_is_notarytx(const CTransaction& tx); int32_t komodo_is_notarytx(const CTransaction& tx);
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &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(); 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 ) 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); 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 ) 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<int> checkdupes( TMP_NotarizationNotaries.begin(), TMP_NotarizationNotaries.end() ); std::set<int> checkdupes( TMP_NotarizationNotaries.begin(), TMP_NotarizationNotaries.end() );
if ( checkdupes.size() != TMP_NotarizationNotaries.size() ) 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; } else fNotarization = true;
} }
nTotalIn += tx.GetShieldedValueIn(); nTotalIn += tx.GetShieldedValueIn();
@ -394,12 +391,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); 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. // 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 ) 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]; uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0];
int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size();
if ( script[0] == OP_RETURN ) 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; 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->dPriority = dPriority;
porphan->feeRate = feeRate; porphan->feeRate = feeRate;
} } else {
else
vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx())));
}
} }
// Collect transactions into block // Collect transactions into block
uint64_t nBlockSize = 1000;
uint64_t nBlockTx = 0;
int64_t interest; int64_t interest;
int nBlockSigOps = 100; uint64_t nBlockSize = 1000;
bool fSortedByFee = (nBlockPrioritySize <= 0); uint64_t nBlockTx = 0;
int nBlockSigOps = 100;
bool fSortedByFee = (nBlockPrioritySize <= 0);
TxPriorityCompare comparer(fSortedByFee); TxPriorityCompare comparer(fSortedByFee);
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
while (!vecPriority.empty()) while (!vecPriority.empty()) {
{
// Take highest priority transaction off the priority queue: // Take highest priority transaction off the priority queue:
double dPriority = vecPriority.front().get<0>(); double dPriority = vecPriority.front().get<0>();
CFeeRate feeRate = vecPriority.front().get<1>(); CFeeRate feeRate = vecPriority.front().get<1>();
@ -625,7 +617,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{ {
static bool didinit = false; 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()); fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
didinit = true; didinit = true;
@ -637,9 +629,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
txNew.vout[1].scriptPubKey.resize(len); txNew.vout[1].scriptPubKey.resize(len);
ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0];
decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
} } else {
else
{
txNew.vout[1].scriptPubKey.resize(35); txNew.vout[1].scriptPubKey.resize(35);
ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0]; ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0];
ptr[0] = 33; 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"); //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n");
} }
//printf("autocreate commision vout\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"); fprintf(stderr,"timelocked chains not supported in this code!\n");
LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(cs_main);
LEAVE_CRITICAL_SECTION(mempool.cs); LEAVE_CRITICAL_SECTION(mempool.cs);
return(0); return(0);
} } else if ( fNotarizationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 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 notarization
{
// Get the OP_RETURN for the notarisation
uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0]; uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0];
int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size();
if ( script[0] == OP_RETURN ) if ( script[0] == OP_RETURN )
@ -679,7 +665,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
return(0); return(0);
} }
//fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); //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 ) if ( ASSETCHAINS_CBOPRET != 0 )
{ {
@ -733,7 +719,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
memcpy(&r,&randvals,sizeof(r)); memcpy(&r,&randvals,sizeof(r));
pblock->nTime += (r % (33 - gpucount)*(33 - gpucount)); 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; CAmount txfees = 5000;
pblock->vtx.push_back(txNotary); pblock->vtx.push_back(txNotary);

43
src/notarizationdb.cpp

@ -12,16 +12,15 @@
NotarizationDB *pnotarizations; NotarizationDB *pnotarizations;
NotarizationDB::NotarizationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "notarizations", nCacheSize, fMemory, fWipe, false, 64) { } 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; EvalRef eval;
NotarizationsInBlock vNotarizations; NotarizationsInBlock vNotarizations;
int timestamp = block.nTime; int timestamp = block.nTime;
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
// No valid ntz's before this height // No valid ntz's before this height
int minheight = ishush3 ? 360000 : 1; int minheight = ishush3 ? 365420 : 1;
if(ishush3 && (nHeight <= GetArg("-dpow_height",minheight))) { if(ishush3 && (nHeight <= GetArg("-dpow-start-height",minheight))) {
return vNotarizations; 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); 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()); 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); LogPrintf("WARNING: Couldn't parse notarization for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight);
}
} }
return vNotarizations; return vNotarizations;
} }
bool GetBlockNotarizations(uint256 blockHash, NotarizationsInBlock &nibs) bool GetBlockNotarizations(uint256 blockHash, NotarizationsInBlock &nibs) {
{
return pnotarizations->Read(blockHash, nibs); return pnotarizations->Read(blockHash, nibs);
} }
bool GetBackNotarization(uint256 notarisationHash, Notarization &n) bool GetBackNotarization(uint256 notarizationHash, Notarization &n) {
{ return pnotarizations->Read(notarizationHash, n);
return pnotarizations->Read(notarisationHash, n);
} }
// Write an index of HUSH notarisation id -> backnotarisation // Write an index of HUSH notarization id -> backnotarization
void WriteBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch) void WriteBackNotarizations(const NotarizationsInBlock notarizations, CDBBatch &batch) {
{
int wrote = 0; int wrote = 0;
BOOST_FOREACH(const Notarization &n, notarisations) BOOST_FOREACH(const Notarization &n, notarizations)
{ {
if (!n.second.txHash.IsNull()) { if (!n.second.txHash.IsNull()) {
batch.Write(n.second.txHash, n); batch.Write(n.second.txHash, n);
@ -78,30 +75,28 @@ void WriteBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &
} }
} }
void EraseBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch) void EraseBackNotarizations(const NotarizationsInBlock notarizations, CDBBatch &batch) {
{ BOOST_FOREACH(const Notarization &n, notarizations)
BOOST_FOREACH(const Notarization &n, notarisations)
{ {
if (!n.second.txHash.IsNull()) if (!n.second.txHash.IsNull())
batch.Erase(n.second.txHash); batch.Erase(n.second.txHash);
} }
} }
// Scan notarisationsdb backwards for blocks containing a notarisation // Scan notarizationsdb backwards for blocks containing a notarization
// for given symbol. Return height of matched notarisation or 0. // for given symbol. Return height of matched notarization or 0.
int ScanNotarizationsDB(int height, std::string symbol, int scanLimitBlocks, Notarization& out) int ScanNotarizationsDB(int height, std::string symbol, int scanLimitBlocks, Notarization& out) {
{
if (height < 0 || height > chainActive.Height()) if (height < 0 || height > chainActive.Height())
return false; return false;
for (int i=0; i<scanLimitBlocks; i++) { for (int i=0; i<scanLimitBlocks; i++) {
if (i > height) break; if (i > height) break;
NotarizationsInBlock notarisations; NotarizationsInBlock notarizations;
uint256 blockHash = *chainActive[height-i]->phashBlock; uint256 blockHash = *chainActive[height-i]->phashBlock;
if (!GetBlockNotarizations(blockHash, notarisations)) if (!GetBlockNotarizations(blockHash, notarizations))
continue; continue;
BOOST_FOREACH(Notarization& nota, notarisations) { BOOST_FOREACH(Notarization& nota, notarizations) {
if (strcmp(nota.second.symbol, symbol.data()) == 0) { if (strcmp(nota.second.symbol, symbol.data()) == 0) {
out = nota; out = nota;
return height-i; return height-i;

55
src/pow.cpp

@ -509,14 +509,12 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
// changes consensus. Have fun -- Duke // changes consensus. Have fun -- Duke
int64_t AveragingWindowTimespan(int32_t height) { int64_t AveragingWindowTimespan(int32_t height) {
int64_t AWT = 2550; int64_t AWT = 2550;
if (height >= 340000) { /*
//trying to emulate 3.5.0 behavior int32_t forkHeight = 0;
//AWT = 1275; if (height >= forkHeight) {
AWT = 1275;
} }
// TODO: */
//if (height >= XXX){
// AWT = 1275;
//}
return AWT; return AWT;
} }
@ -703,48 +701,10 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
memset(blocktimes,0,sizeof(blocktimes)); memset(blocktimes,0,sizeof(blocktimes));
tiptime = komodo_chainactive_timestamp(); tiptime = komodo_chainactive_timestamp();
bnTarget.SetCompact(blkHeader.nBits, &fNegative, &fOverflow); bnTarget.SetCompact(blkHeader.nBits, &fNegative, &fOverflow);
if ( height == 0 ) if ( height == 0 ) {
{
height = komodo_currentheight() + 1; height = komodo_currentheight() + 1;
//fprintf(stderr,"set height to %d\n",height); //fprintf(stderr,"set height to %d\n",height);
} }
if ( height > 34000 && SMART_CHAIN_SYMBOL[0] == 0 ) // 0 -> non-special notary
{
special = hush_chosennotary(&notaryid,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); arith_uint256 bnLimit = (height <= 1 || ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) ? UintToArith256(params.powLimit) : UintToArith256(params.powAlternate);
if (fNegative || bnTarget == 0 || fOverflow || bnTarget > bnLimit) if (fNegative || bnTarget == 0 || fOverflow || bnTarget > bnLimit)
return error("CheckProofOfWork(): nBits below minimum work"); 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 ) if ( HUSH_LOADINGBLOCKS != 0 )
return true; return true;
/*
if ( SMART_CHAIN_SYMBOL[0] != 0 || height > 792000 ) if ( SMART_CHAIN_SYMBOL[0] != 0 || height > 792000 )
{ {
//if ( 0 && height > 792000 )
if ( Params().NetworkIDString() != "regtest" ) if ( Params().NetworkIDString() != "regtest" )
{ {
for (i=31; i>=0; i--) for (i=31; i>=0; i--)
@ -780,6 +740,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
} }
return false; return false;
} }
*/
} }
/*for (i=31; i>=0; i--) /*for (i=31; i>=0; i--)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);

4
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 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 ) if (fHelp || params.size() != 1 )
throw runtime_error( throw runtime_error(
"kvsearch key\n" "kvsearch key\n"
@ -902,7 +902,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 ) if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
ret.push_back(Pair("owner",refpubkey.GetHex())); ret.push_back(Pair("owner",refpubkey.GetHex()));
ret.push_back(Pair("height",height)); 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("expiration", (int64_t)(height+duration)));
ret.push_back(Pair("flags",(int64_t)flags)); ret.push_back(Pair("flags",(int64_t)flags));
ret.push_back(Pair("value",val)); ret.push_back(Pair("value",val));

8
src/test/alert_tests.cpp

@ -2,17 +2,13 @@
// Copyright (c) 2016-2020 The Hush developers // Copyright (c) 2016-2020 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying // Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
//
// Unit tests for alert system // Unit tests for alert system
//
#include "alert.h" #include "alert.h"
#include "chain.h" #include "chain.h"
#include "chainparams.h" #include "chainparams.h"
#include "clientversion.h" #include "clientversion.h"
#include "data/alertTests.raw.h" #include "data/alertTests.raw.h"
#include "main.h" #include "main.h"
#include "rpc/protocol.h" #include "rpc/protocol.h"
#include "rpc/server.h" #include "rpc/server.h"
@ -20,15 +16,11 @@
#include "streams.h" #include "streams.h"
#include "util.h" #include "util.h"
#include "utilstrencodings.h" #include "utilstrencodings.h"
#include "test/test_bitcoin.h" #include "test/test_bitcoin.h"
#include <fstream> #include <fstream>
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "key.h" #include "key.h"
#include "alertkeys.h" #include "alertkeys.h"
#include <iostream> #include <iostream>

20
src/test/rpc_wallet_tests.cpp

@ -910,8 +910,8 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters)
"1 50.00000001" "1 50.00000001"
), runtime_error); ), runtime_error);
// memo bigger than allowed length of ZC_MEMO_SIZE // memo bigger than allowed length of HUSH_MEMO_SIZE
std::vector<char> v (2 * (ZC_MEMO_SIZE+1)); // x2 for hexadecimal string format std::vector<char> v (2 * (HUSH_MEMO_SIZE+1)); // x2 for hexadecimal string format
std::fill(v.begin(),v.end(), 'A'); std::fill(v.begin(),v.end(), 'A');
std::string badmemo(v.begin(), v.end()); std::string badmemo(v.begin(), v.end());
auto pa = pwalletMain->GenerateNewSproutZKey(); auto pa = pwalletMain->GenerateNewSproutZKey();
@ -1035,17 +1035,17 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr); TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr);
std::string memo = "DEADBEEF"; std::string memo = "DEADBEEF";
std::array<unsigned char, ZC_MEMO_SIZE> array = proxy.get_memo_from_hex_string(memo); std::array<unsigned char, HUSH_MEMO_SIZE> array = proxy.get_memo_from_hex_string(memo);
BOOST_CHECK_EQUAL(array[0], 0xDE); BOOST_CHECK_EQUAL(array[0], 0xDE);
BOOST_CHECK_EQUAL(array[1], 0xAD); BOOST_CHECK_EQUAL(array[1], 0xAD);
BOOST_CHECK_EQUAL(array[2], 0xBE); BOOST_CHECK_EQUAL(array[2], 0xBE);
BOOST_CHECK_EQUAL(array[3], 0xEF); BOOST_CHECK_EQUAL(array[3], 0xEF);
for (int i=4; i<ZC_MEMO_SIZE; i++) { for (int i=4; i<HUSH_MEMO_SIZE; i++) {
BOOST_CHECK_EQUAL(array[i], 0x00); // zero padding BOOST_CHECK_EQUAL(array[i], 0x00); // zero padding
} }
// memo is longer than allowed // memo is longer than allowed
std::vector<char> v (2 * (ZC_MEMO_SIZE+1)); std::vector<char> v (2 * (HUSH_MEMO_SIZE+1));
std::fill(v.begin(),v.end(), 'A'); std::fill(v.begin(),v.end(), 'A');
std::string bigmemo(v.begin(), v.end()); std::string bigmemo(v.begin(), v.end());
@ -1697,8 +1697,8 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
"0.0001 100 -1" "0.0001 100 -1"
), runtime_error); ), runtime_error);
// memo bigger than allowed length of ZC_MEMO_SIZE // memo bigger than allowed length of HUSH_MEMO_SIZE
std::vector<char> v (2 * (ZC_MEMO_SIZE+1)); // x2 for hexadecimal string format std::vector<char> v (2 * (HUSH_MEMO_SIZE+1)); // x2 for hexadecimal string format
std::fill(v.begin(),v.end(), 'A'); std::fill(v.begin(),v.end(), 'A');
std::string badmemo(v.begin(), v.end()); std::string badmemo(v.begin(), v.end());
auto pa = pwalletMain->GenerateNewSproutZKey(); auto pa = pwalletMain->GenerateNewSproutZKey();
@ -1806,17 +1806,17 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals)
TEST_FRIEND_AsyncRPCOperation_mergetoaddress proxy(ptr); TEST_FRIEND_AsyncRPCOperation_mergetoaddress proxy(ptr);
std::string memo = "DEADBEEF"; std::string memo = "DEADBEEF";
std::array<unsigned char, ZC_MEMO_SIZE> array = proxy.get_memo_from_hex_string(memo); std::array<unsigned char, HUSH_MEMO_SIZE> array = proxy.get_memo_from_hex_string(memo);
BOOST_CHECK_EQUAL(array[0], 0xDE); BOOST_CHECK_EQUAL(array[0], 0xDE);
BOOST_CHECK_EQUAL(array[1], 0xAD); BOOST_CHECK_EQUAL(array[1], 0xAD);
BOOST_CHECK_EQUAL(array[2], 0xBE); BOOST_CHECK_EQUAL(array[2], 0xBE);
BOOST_CHECK_EQUAL(array[3], 0xEF); BOOST_CHECK_EQUAL(array[3], 0xEF);
for (int i=4; i<ZC_MEMO_SIZE; i++) { for (int i=4; i<HUSH_MEMO_SIZE; i++) {
BOOST_CHECK_EQUAL(array[i], 0x00); // zero padding BOOST_CHECK_EQUAL(array[i], 0x00); // zero padding
} }
// memo is longer than allowed // memo is longer than allowed
std::vector<char> v (2 * (ZC_MEMO_SIZE+1)); std::vector<char> v (2 * (HUSH_MEMO_SIZE+1));
std::fill(v.begin(),v.end(), 'A'); std::fill(v.begin(),v.end(), 'A');
std::string bigmemo(v.begin(), v.end()); std::string bigmemo(v.begin(), v.end());

2
src/transaction_builder.cpp

@ -53,7 +53,7 @@ void TransactionBuilder::AddSaplingOutput(
uint256 ovk, uint256 ovk,
libzcash::SaplingPaymentAddress to, libzcash::SaplingPaymentAddress to,
CAmount value, CAmount value,
std::array<unsigned char, ZC_MEMO_SIZE> memo) std::array<unsigned char, HUSH_MEMO_SIZE> memo)
{ {
auto note = libzcash::SaplingNote(to, value); auto note = libzcash::SaplingNote(to, value);
outputs.emplace_back(ovk, note, memo); outputs.emplace_back(ovk, note, memo);

6
src/transaction_builder.h

@ -36,12 +36,12 @@ struct SpendDescriptionInfo {
struct OutputDescriptionInfo { struct OutputDescriptionInfo {
uint256 ovk; uint256 ovk;
libzcash::SaplingNote note; libzcash::SaplingNote note;
std::array<unsigned char, ZC_MEMO_SIZE> memo; std::array<unsigned char, HUSH_MEMO_SIZE> memo;
OutputDescriptionInfo( OutputDescriptionInfo(
uint256 ovk, uint256 ovk,
libzcash::SaplingNote note, libzcash::SaplingNote note,
std::array<unsigned char, ZC_MEMO_SIZE> memo) : ovk(ovk), note(note), memo(memo) {} std::array<unsigned char, HUSH_MEMO_SIZE> memo) : ovk(ovk), note(note), memo(memo) {}
}; };
struct TransparentInputInfo { struct TransparentInputInfo {
@ -90,7 +90,7 @@ public:
uint256 ovk, uint256 ovk,
libzcash::SaplingPaymentAddress to, libzcash::SaplingPaymentAddress to,
CAmount value, CAmount value,
std::array<unsigned char, ZC_MEMO_SIZE> memo = {{0}}); std::array<unsigned char, HUSH_MEMO_SIZE> memo = {{0}});
// Assumes that the value correctly corresponds to the provided UTXO. // Assumes that the value correctly corresponds to the provided UTXO.
void AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t nSequence = 0xffffffff); void AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t nSequence = 0xffffffff);

12
src/wallet/asyncrpcoperation_mergetoaddress.cpp

@ -333,7 +333,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
} else { } else {
std::string zaddr = std::get<0>(recipient_); std::string zaddr = std::get<0>(recipient_);
std::string memo = std::get<1>(recipient_); std::string memo = std::get<1>(recipient_);
std::array<unsigned char, ZC_MEMO_SIZE> hexMemo = get_memo_from_hex_string(memo); std::array<unsigned char, HUSH_MEMO_SIZE> hexMemo = get_memo_from_hex_string(memo);
auto saplingPaymentAddress = boost::get<libzcash::SaplingPaymentAddress>(&toPaymentAddress_); auto saplingPaymentAddress = boost::get<libzcash::SaplingPaymentAddress>(&toPaymentAddress_);
if (saplingPaymentAddress == nullptr) { if (saplingPaymentAddress == nullptr) {
// This should never happen as we have already determined that the payment is to sapling // 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; tx_ = tx;
} }
std::array<unsigned char, ZC_MEMO_SIZE> AsyncRPCOperation_mergetoaddress::get_memo_from_hex_string(std::string s) std::array<unsigned char, HUSH_MEMO_SIZE> AsyncRPCOperation_mergetoaddress::get_memo_from_hex_string(std::string s)
{ {
std::array<unsigned char, ZC_MEMO_SIZE> memo = {{0x00}}; std::array<unsigned char, HUSH_MEMO_SIZE> memo = {{0x00}};
std::vector<unsigned char> rawMemo = ParseHex(s.c_str()); std::vector<unsigned char> rawMemo = ParseHex(s.c_str());
@ -498,13 +498,13 @@ std::array<unsigned char, ZC_MEMO_SIZE> AsyncRPCOperation_mergetoaddress::get_me
throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo must be in hexadecimal format"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo must be in hexadecimal format");
} }
if (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(), ZC_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 // copy vector into boost array
int lenMemo = rawMemo.size(); 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]; memo[i] = rawMemo[i];
} }
return memo; return memo;

4
src/wallet/asyncrpcoperation_mergetoaddress.h

@ -99,7 +99,7 @@ private:
TransactionBuilder builder_; TransactionBuilder builder_;
CTransaction tx_; CTransaction tx_;
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s); std::array<unsigned char, HUSH_MEMO_SIZE> get_memo_from_hex_string(std::string s);
bool main_impl(); bool main_impl();
void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error
@ -135,7 +135,7 @@ public:
// Delegated methods // Delegated methods
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s) std::array<unsigned char, HUSH_MEMO_SIZE> get_memo_from_hex_string(std::string s)
{ {
return delegate->get_memo_from_hex_string(s); return delegate->get_memo_from_hex_string(s);
} }

63
src/wallet/asyncrpcoperation_sendmany.cpp

@ -2,7 +2,6 @@
// Copyright (c) 2016-2020 The Hush developers // Copyright (c) 2016-2020 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying // Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/****************************************************************************** /******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. * * Copyright © 2014-2019 The SuperNET Developers. *
* * * *
@ -17,7 +16,6 @@
* Removal or modification of this copyright notice is prohibited. * * Removal or modification of this copyright notice is prohibited. *
* * * *
******************************************************************************/ ******************************************************************************/
#include "asyncrpcoperation_sendmany.h" #include "asyncrpcoperation_sendmany.h"
#include "asyncrpcqueue.h" #include "asyncrpcqueue.h"
#include "amount.h" #include "amount.h"
@ -40,15 +38,12 @@
#include "zcash/IncrementalMerkleTree.hpp" #include "zcash/IncrementalMerkleTree.hpp"
#include "sodium.h" #include "sodium.h"
#include "miner.h" #include "miner.h"
#include <stdint.h> #include <stdint.h>
#include <array> #include <array>
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <string> #include <string>
#include <boost/optional/optional_io.hpp> #include <boost/optional/optional_io.hpp>
using namespace libzcash; using namespace libzcash;
@ -199,11 +194,16 @@ bool AsyncRPCOperation_sendmany::main_impl() {
assert(isfromtaddr_ != isfromzaddr_); 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 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_; 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 // 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. // and if there are multiple zaddrs, we don't know where to send it.
if (isfromtaddr_) { if (isfromtaddr_) {
@ -243,12 +243,13 @@ bool AsyncRPCOperation_sendmany::main_impl() {
t_outputs_total += std::get<1>(t); t_outputs_total += std::get<1>(t);
} }
CAmount z_outputs_total = 0; CAmount z_outputs_total = 0;
for (SendManyRecipient & t : z_outputs_) { for (SendManyRecipient & t : z_outputs_) {
z_outputs_total += std::get<1>(t); 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; CAmount targetAmount = sendAmount + minersFee;
assert(!isfromtaddr_ || z_inputs_total == 0); 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))); FormatMoney(t_inputs_total), FormatMoney(dustThreshold - dustChange), FormatMoney(dustChange), FormatMoney(dustThreshold)));
} }
t_inputs_ = selectedTInputs; t_inputs_ = selectedTInputs;
t_inputs_total = selectedUTXOAmount; t_inputs_total = selectedUTXOAmount;
// Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects // 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); CAmount amount = std::get<2>(t);
builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount); builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount);
} }
// for Komodo, set lock time to accure interest, for other chains, set // for other chains, set locktime to spend time locked coinbases
// locktime to spend time locked coinbases //builder_.SetLockTime((uint32_t)chainActive.Tip()->GetMedianTimePast());
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());
}
} else { } else {
CMutableTransaction rawTx(tx_); CMutableTransaction rawTx(tx_);
for (SendManyInputUTXO & t : t_inputs_) { for (SendManyInputUTXO & t : t_inputs_) {
@ -349,13 +343,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
CTxIn in(COutPoint(txid, vout)); CTxIn in(COutPoint(txid, vout));
rawTx.vin.push_back(in); rawTx.vin.push_back(in);
} }
if (SMART_CHAIN_SYMBOL[0] == 0) //rawTx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast();
{
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();
}
tx_ = CTransaction(rawTx); 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. * Sprout not involved, so we just use the TransactionBuilder and we're done.
* We added the transparent inputs to the builder earlier. * We added the transparent inputs to the builder earlier.
*/ */
@ -516,14 +503,11 @@ bool AsyncRPCOperation_sendmany::main_impl() {
return true; return true;
} }
/** // END SCENARIO #0
* END SCENARIO #0 // No other scenarios, because Hush developers are elite.
*/
return false; return false;
} }
/** /**
* Sign and send a raw transaction. * Sign and send a raw transaction.
* Raw transaction as hex string should be in object field "rawtxn" * 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); set_result(o);
} else { } else {
// Test mode does not send the transaction to the network. // Test mode does not send the transaction to the network.
CDataStream stream(ParseHex(signedtxn), SER_NETWORK, PROTOCOL_VERSION); CDataStream stream(ParseHex(signedtxn), SER_NETWORK, PROTOCOL_VERSION);
CTransaction tx; CTransaction tx;
stream >> tx; stream >> tx;
@ -751,9 +734,9 @@ void AsyncRPCOperation_sendmany::add_taddr_change_output_to_tx(CBitcoinAddress *
tx_ = CTransaction(rawTx); tx_ = CTransaction(rawTx);
} }
std::array<unsigned char, ZC_MEMO_SIZE> AsyncRPCOperation_sendmany::get_memo_from_hex_string(std::string s) { std::array<unsigned char, HUSH_MEMO_SIZE> AsyncRPCOperation_sendmany::get_memo_from_hex_string(std::string s) {
// initialize to default memo (no_memo), see section 5.5 of the protocol spec // initialize to default memo (no_memo), see section 5.5 of the protocol spec
std::array<unsigned char, ZC_MEMO_SIZE> memo = {{0xF6}}; std::array<unsigned char, HUSH_MEMO_SIZE> memo = {{0xF6}};
std::vector<unsigned char> rawMemo = ParseHex(s.c_str()); std::vector<unsigned char> rawMemo = ParseHex(s.c_str());
@ -763,21 +746,19 @@ std::array<unsigned char, ZC_MEMO_SIZE> AsyncRPCOperation_sendmany::get_memo_fro
throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo must be in hexadecimal format"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo must be in hexadecimal format");
} }
if (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(), ZC_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 // copy vector into boost array
int lenMemo = rawMemo.size(); 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]; memo[i] = rawMemo[i];
} }
return memo; 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 AsyncRPCOperation_sendmany::getStatus() const {
UniValue v = AsyncRPCOperation::getStatus(); UniValue v = AsyncRPCOperation::getStatus();
if (contextinfo_.isNull()) { if (contextinfo_.isNull()) {

4
src/wallet/asyncrpcoperation_sendmany.h

@ -112,7 +112,7 @@ private:
void add_taddr_outputs_to_tx(); void add_taddr_outputs_to_tx();
bool find_unspent_notes(); bool find_unspent_notes();
bool find_utxos(bool fAcceptCoinbase); bool find_utxos(bool fAcceptCoinbase);
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s); std::array<unsigned char, HUSH_MEMO_SIZE> get_memo_from_hex_string(std::string s);
bool main_impl(); bool main_impl();
void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error
@ -152,7 +152,7 @@ public:
return delegate->find_utxos(fAcceptCoinbase); return delegate->find_utxos(fAcceptCoinbase);
} }
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s) { std::array<unsigned char, HUSH_MEMO_SIZE> get_memo_from_hex_string(std::string s) {
return delegate->get_memo_from_hex_string(s); return delegate->get_memo_from_hex_string(s);
} }

195
src/wallet/rpcwallet.cpp

@ -64,7 +64,7 @@ const std::string ADDR_TYPE_AMNESIA = "amnesia";
extern int32_t HUSH_INSYNC; extern int32_t HUSH_INSYNC;
uint32_t komodo_segid32(char *coinaddr); uint32_t komodo_segid32(char *coinaddr);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs); 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); CBlockIndex *komodo_getblockindex(uint256 hash);
extern string randomSietchZaddr(); extern string randomSietchZaddr();
extern CAmount fConsolidationTxFee; extern CAmount fConsolidationTxFee;
@ -83,7 +83,7 @@ UniValue z_getoperationstatus_IMPL(const UniValue&, bool);
#define PLAN_NAME_MAX 8 #define PLAN_NAME_MAX 8
#define VALID_PLAN_NAME(x) (strlen(x) <= PLAN_NAME_MAX) #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 ); 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 ( 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"); 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" #include "hush_defs.h"
#define KOMODO_KVPROTECTED 1 #define HUSH_KVPROTECTED 1
#define KOMODO_KVBINARY 2 #define HUSH_KVBINARY 2
#define KOMODO_KVDURATION 1440 #define HUSH_KVDURATION 1440
#define IGUANA_MAXSCRIPTSIZE 10001 #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); uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen); int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
extern int32_t KOMODO_PAX; 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 dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t komodo_isrealtime(int32_t *kmdheightp); 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 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); 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); uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen);
uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); 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; static uint256 zeroes;
CWalletTx wtx; UniValue ret(UniValue::VOBJ); 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 ) if (fHelp || params.size() < 3 )
throw runtime_error( throw runtime_error(
"kvupdate key \"value\" days passphrase\n" "kvupdate key \"value\" days passphrase\n"
@ -651,7 +651,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
memcpy(keyvalue,key,keylen); memcpy(keyvalue,key,keylen);
if ( (refvaluesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 ) 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 ) 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 ) if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
ret.push_back(Pair("owner",refpubkey.GetHex())); ret.push_back(Pair("owner",refpubkey.GetHex()));
ret.push_back(Pair("height", (int64_t)height)); 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("expiration", (int64_t)(height+duration)));
ret.push_back(Pair("flags",(int64_t)flags)); ret.push_back(Pair("flags",(int64_t)flags));
ret.push_back(Pair("key",params[0].get_str())); 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" " \"outputPrev\" : n, (numeric) the index of the output within the vShieldedOutput\n"
" \"address\" : \"zcashaddress\", (string) The Hush shielded address involved in the transaction\n" " \"address\" : \"zcashaddress\", (string) The Hush shielded address involved in the transaction\n"
" \"value\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\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" " ,...\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" " \"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" " \"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" " \"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" " \"memo\" : \"hexmemo\", (string) Hexademical string representation of the memo field\n"
" \"memoStr\" : \"memo\", (string) Only returned if memo contains valid UTF-8 text.\n" " \"memoStr\" : \"memo\", (string) Only returned if memo contains valid UTF-8 text.\n"
" }\n" " }\n"
@ -4535,12 +4535,6 @@ UniValue z_getoperationstatus_IMPL(const UniValue& params, bool fRemoveFinishedO
// JSDescription size depends on the transaction version // 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 // transaction.h comment: spending taddr output requires CTxIn >= 148 bytes and typical taddr txout is 34 bytes
#define CTXIN_SPEND_DUST_SIZE 148 #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." "\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." "\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." "\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" + HelpRequiringPassphrase() + "\n"
"\nArguments:\n" "\nArguments:\n"
"1. \"fromaddress\" (string, required) The taddr or zaddr to send the funds from.\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); LOCK2(cs_main, pwalletMain->cs_wallet);
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
THROW_IF_SYNCING(HUSH_INSYNC); THROW_IF_SYNCING(HUSH_INSYNC);
// Check that the from address is valid. // Check that the from address is valid.
auto fromaddress = params[0].get_str(); auto fromaddress = params[0].get_str();
bool fromTaddr = false; bool fromTaddr = false;
bool fromSapling = false; bool fromSapling = false;
uint32_t branchId = CurrentEpochBranchId(chainActive.Height(), Params().GetConsensus()); uint32_t branchId = CurrentEpochBranchId(chainActive.Height(), Params().GetConsensus());
@ -4642,9 +4636,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
} else { } else {
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address ); throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address );
} }
} }// else if ( ASSETCHAINS_PRIVATE != 0 && hush_isnotaryvout((char *)address.c_str()) == 0 ) {
//else if ( ASSETCHAINS_PRIVATE != 0 && komodo_isnotaryvout((char *)address.c_str()) == 0 ) // throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Extreme Privacy! You must send to a zaddr");
// throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); //}
// Allowing duplicate receivers helps various HushList protocol operations // Allowing duplicate receivers helps various HushList protocol operations
//if (setAddress.count(address)) //if (setAddress.count(address))
@ -4660,8 +4654,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
} else if (!IsHex(memo)) { } else if (!IsHex(memo)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected memo data in hexadecimal format."); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected memo data in hexadecimal format.");
} }
if (memo.length() > ZC_MEMO_SIZE*2) { if (memo.length() > HUSH_MEMO_SIZE*2) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", ZC_MEMO_SIZE )); 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_SAPLING)) {
if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nVersion = OVERWINTER_TX_VERSION; mtx.nVersion = OVERWINTER_TX_VERSION;
} else { } else {
mtx.fOverwintered = false; mtx.fOverwintered = false;
mtx.nVersion = 2; 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");
} }
} }
@ -4829,13 +4809,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
boost::optional<TransactionBuilder> builder; boost::optional<TransactionBuilder> builder;
builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain); builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain);
// Contextual transaction we will build on // Contextual transaction
// (used if no Sapling addresses are involved) CMutableTransaction contextualTx; // = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight);
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); contextualTx.nVersion = 2;
bool isShielded = !fromTaddr || zaddrRecipients.size() > 0;
if (contextualTx.nVersion == 1 && isShielded) {
contextualTx.nVersion = 2; // Tx format should support vjoinsplits
}
// Create operation and add to global queue // Create operation and add to global queue
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue(); std::shared_ptr<AsyncRPCQueue> 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. 105 + 1 + 3*(73+1) = 328 bytes of scriptSig, rounded up to 400 based on testnet experiments.
*/ */
#define CTXIN_SPEND_P2SH_SIZE 400 #define CTXIN_SPEND_P2SH_SIZE 400
#define SHIELD_COINBASE_DEFAULT_LIMIT 50 #define SHIELD_COINBASE_DEFAULT_LIMIT 50
UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& mypk) 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" "\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" "\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" "\noption will determine the number of uxtos. Any limit is constrained by the consensus rule defining a maximum"
"\ntransaction size of " "\ntransaction size of " + strprintf("%d bytes.", MAX_TX_SIZE_AFTER_SAPLING)
+ strprintf("%d bytes before Sapling, and %d bytes once Sapling activates.", MAX_TX_SIZE_BEFORE_SAPLING, MAX_TX_SIZE_AFTER_SAPLING)
+ HelpRequiringPassphrase() + "\n" + HelpRequiringPassphrase() + "\n"
"\nArguments:\n" "\nArguments:\n"
"1. \"fromaddress\" (string, required) The address is a taddr or \"*\" for all taddrs belonging to the wallet.\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); LOCK2(cs_main, pwalletMain->cs_wallet);
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
THROW_IF_SYNCING(HUSH_INSYNC); THROW_IF_SYNCING(HUSH_INSYNC);
// Validate the from address // Validate the from address
@ -4941,27 +4916,12 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
int nextBlockHeight = chainActive.Height() + 1; int nextBlockHeight = chainActive.Height() + 1;
bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; 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<libzcash::SaplingPaymentAddress>(&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 // Prepare to get coinbase utxos
std::vector<ShieldCoinbaseUTXO> inputs; std::vector<ShieldCoinbaseUTXO> inputs;
CAmount shieldedValue = 0; CAmount shieldedValue = 0;
CAmount remainingValue = 0; CAmount remainingValue = 0;
//TODO: update these estimates
size_t estimatedTxSize = 2000; // 1802 joinsplit description + tx overhead + wiggle room size_t estimatedTxSize = 2000; // 1802 joinsplit description + tx overhead + wiggle room
#ifdef __LP64__ #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_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 OUTPUTDESCRIPTION_SIZE GetSerializeSize(OutputDescription(), SER_NETWORK, PROTOCOL_VERSION)
#define SPENDDESCRIPTION_SIZE GetSerializeSize(SpendDescription(), 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; return NullUniValue;
string enableArg = "zmergetoaddress"; 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) if (fHelp || params.size() < 2 || params.size() > 7)
throw runtime_error( 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" "\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" "\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" "\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" "\nArguments:\n"
"1. fromaddresses (string, required) A JSON array with addresses.\n" "1. fromaddresses (string, required) A JSON array with addresses.\n"
" The following special strings are accepted inside the array:\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); LOCK2(cs_main, pwalletMain->cs_wallet);
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
THROW_IF_SYNCING(HUSH_INSYNC); THROW_IF_SYNCING(HUSH_INSYNC);
bool useAnyUTXO = false; bool useAnyUTXO = false;
bool useAnySapling = false; bool useAnySapling = false;
std::set<CTxDestination> taddrs = {}; std::set<CTxDestination> taddrs = {};
std::set<libzcash::PaymentAddress> zaddrs = {}; std::set<libzcash::PaymentAddress> zaddrs = {};
@ -5168,7 +5120,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
if (addresses.size()==0) if (addresses.size()==0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, fromaddresses array is empty."); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, fromaddresses array is empty.");
// Keep track of addresses to spot duplicates // Keep track of addresses
std::set<std::string> setAddress; std::set<std::string> setAddress;
// Sources // 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\""); 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 overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
const bool saplingActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
// Validate the destination address // Validate the destination address
auto destaddress = params[1].get_str(); 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 (IsValidPaymentAddress(decodeAddr)) {
if (boost::get<libzcash::SaplingPaymentAddress>(&decodeAddr) != nullptr) { if (boost::get<libzcash::SaplingPaymentAddress>(&decodeAddr) != nullptr) {
isToSaplingZaddr = true; 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 { } else {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Only Sapling zaddrs allowed!"); 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; CAmount nFee = SHIELD_COINBASE_DEFAULT_MINERS_FEE;
if (params.size() > 2) { if (params.size() > 2) {
if (params[2].get_real() == 0.0) { if (params[2].get_real() == 0.0) {
@ -5276,10 +5223,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
if (!isToSaplingZaddr) { if (!isToSaplingZaddr) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo can not be used with a taddr. It can only be used with a zaddr."); 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)) { } 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."); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected memo data in hexadecimal format.");
} }
if (memo.length() > ZC_MEMO_SIZE*2) { if (memo.length() > HUSH_MEMO_SIZE*2) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", ZC_MEMO_SIZE )); 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 // Prepare to get UTXOs and notes
std::vector<MergeToAddressInputUTXO> utxoInputs; std::vector<MergeToAddressInputUTXO> utxoInputs;
std::vector<MergeToAddressInputSaplingNote> saplingNoteInputs; std::vector<MergeToAddressInputSaplingNote> saplingNoteInputs;
CAmount mergedUTXOValue = 0; CAmount mergedUTXOValue = 0;
CAmount mergedNoteValue = 0; CAmount mergedNoteValue = 0;
CAmount remainingUTXOValue = 0; CAmount remainingUTXOValue = 0;
CAmount remainingNoteValue = 0; CAmount remainingNoteValue = 0;
size_t utxoCounter = 0; size_t utxoCounter = 0;
size_t noteCounter = 0; size_t noteCounter = 0;
bool maxedOutUTXOsFlag = false; bool maxedOutUTXOsFlag = false;
bool maxedOutNotesFlag = false; bool maxedOutNotesFlag = false;
size_t mempoolLimit = (nUTXOLimit != 0) ? nUTXOLimit : (overwinterActive ? 0 : (size_t)GetArg("-mempooltxinputlimit", 0)); size_t mempoolLimit = (nUTXOLimit != 0) ? nUTXOLimit : (overwinterActive ? 0 : (size_t)GetArg("-mempooltxinputlimit", 0));
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
unsigned int max_tx_size = saplingActive ? MAX_TX_SIZE_AFTER_SAPLING : MAX_TX_SIZE_BEFORE_SAPLING;
size_t estimatedTxSize = 200; // tx overhead + wiggle room size_t estimatedTxSize = 200; // tx overhead + wiggle room
if (isToSaplingZaddr) { 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; 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()); //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) if (nValue > maximum_utxo_size)
continue; continue;
@ -5426,9 +5372,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
contextInfo.push_back(Pair("fee", ValueFromAmount(nFee))); contextInfo.push_back(Pair("fee", ValueFromAmount(nFee)));
// Contextual transaction we will build on // Contextual transaction we will build on
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( CMutableTransaction contextualTx; //= CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight);
Params().GetConsensus(),
nextBlockHeight);
// Builder (used if Sapling addresses are involved) // Builder (used if Sapling addresses are involved)
boost::optional<TransactionBuilder> builder; boost::optional<TransactionBuilder> 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); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
extern std::string NOTARY_PUBKEY; 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<CBitcoinAddress> setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 0,nMaxDepth = 9999999; vector<COutput> vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; set<CBitcoinAddress> setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 0,nMaxDepth = 9999999; vector<COutput> vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow;
bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; 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/CCPayments.h"
#include "../cc/CCPegs.h" #include "../cc/CCPegs.h"
int32_t ensure_CCrequirements(uint8_t evalcode) int32_t ensure_CCrequirements(uint8_t evalcode) {
{
CCerror = ""; CCerror = "";
if ( ASSETCHAINS_CCDISABLES[evalcode] != 0 || (evalcode == EVAL_MARMARA && ASSETCHAINS_MARMARA == 0) ) 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" " \"R-address\" : \"R address\", (string) The pubkey\n"
" }\n" " }\n"
"\nExamples:\n" "\nExamples:\n"
+ HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + HelpExampleCli("setpubkey", "0420597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea1987")
+ HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + HelpExampleRpc("setpubkey", "0420597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea1987")
); );
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
char Raddress[64]; char Raddress[64];
uint8_t pubkey33[33]; uint8_t pubkey33[33];
if ( NOTARY_PUBKEY33[0] == 0 ) if ( NOTARY_PUBKEY33[0] == 0 ) {
{ if (strlen(params[0].get_str().c_str()) == 66) {
if (strlen(params[0].get_str().c_str()) == 66)
{
decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); decode_hex(pubkey33,33,(char *)params[0].get_str().c_str());
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
CBitcoinAddress address(Raddress); CBitcoinAddress address(Raddress);
bool isValid = address.IsValid(); bool isValid = address.IsValid();
if (isValid) if (isValid) {
{
CTxDestination dest = address.Get(); CTxDestination dest = address.Get();
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; 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!")); result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!"));
else } else {
{
result.push_back(Pair("ismine", "true")); result.push_back(Pair("ismine", "true"));
} }
NOTARY_PUBKEY = params[0].get_str(); NOTARY_PUBKEY = params[0].get_str();
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
USE_EXTERNAL_PUBKEY = 1; USE_EXTERNAL_PUBKEY = 1;
NOTARY_ADDRESS = address.ToString(); NOTARY_ADDRESS = address.ToString();
} } else {
else
result.push_back(Pair("error", "pubkey entered is invalid.")); 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.")); result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
} }
else } else {
{ if ( NOTARY_ADDRESS.empty() ) {
if ( NOTARY_ADDRESS.empty() )
{
pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33);
NOTARY_ADDRESS.assign(Raddress); NOTARY_ADDRESS.assign(Raddress);
} }
result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); 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("address", NOTARY_ADDRESS));
result.push_back(Pair("pubkey", NOTARY_PUBKEY)); 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) { if (params.size() == 4) {
nonfungibleData = ParseHex(params[3].get_str()); 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); return(result);
} }
if( nonfungibleData.empty() ) { if( nonfungibleData.empty() ) {

2
src/wallet/wallet.h

@ -347,7 +347,7 @@ struct SaplingNoteEntry
SaplingOutPoint op; SaplingOutPoint op;
libzcash::SaplingPaymentAddress address; libzcash::SaplingPaymentAddress address;
libzcash::SaplingNote note; libzcash::SaplingNote note;
std::array<unsigned char, ZC_MEMO_SIZE> memo; std::array<unsigned char, HUSH_MEMO_SIZE> memo;
int confirmations; int confirmations;
}; };

2
src/zcash/Note.cpp

@ -66,7 +66,7 @@ boost::optional<uint256> SaplingNote::nullifier(const SaplingFullViewingKey& vk,
// Construct and populate SaplingNotePlaintext for a given note and memo. // Construct and populate SaplingNotePlaintext for a given note and memo.
SaplingNotePlaintext::SaplingNotePlaintext( SaplingNotePlaintext::SaplingNotePlaintext(
const SaplingNote& note, const SaplingNote& note,
std::array<unsigned char, ZC_MEMO_SIZE> memo) : BaseNotePlaintext(note, memo) std::array<unsigned char, HUSH_MEMO_SIZE> memo) : BaseNotePlaintext(note, memo)
{ {
d = note.d; d = note.d;
rcm = note.r; rcm = note.r;

8
src/zcash/Note.hpp

@ -48,15 +48,15 @@ public:
class BaseNotePlaintext { class BaseNotePlaintext {
protected: protected:
uint64_t value_ = 0; uint64_t value_ = 0;
std::array<unsigned char, ZC_MEMO_SIZE> memo_; std::array<unsigned char, HUSH_MEMO_SIZE> memo_;
public: public:
BaseNotePlaintext() {} BaseNotePlaintext() {}
BaseNotePlaintext(const BaseNote& note, std::array<unsigned char, ZC_MEMO_SIZE> memo) BaseNotePlaintext(const BaseNote& note, std::array<unsigned char, HUSH_MEMO_SIZE> memo)
: value_(note.value()), memo_(memo) {} : value_(note.value()), memo_(memo) {}
virtual ~BaseNotePlaintext() {} virtual ~BaseNotePlaintext() {}
inline uint64_t value() const { return value_; } inline uint64_t value() const { return value_; }
inline const std::array<unsigned char, ZC_MEMO_SIZE> & memo() const { return memo_; } inline const std::array<unsigned char, HUSH_MEMO_SIZE> & memo() const { return memo_; }
}; };
typedef std::pair<SaplingEncCiphertext, SaplingNoteEncryption> SaplingNotePlaintextEncryptionResult; typedef std::pair<SaplingEncCiphertext, SaplingNoteEncryption> SaplingNotePlaintextEncryptionResult;
@ -68,7 +68,7 @@ public:
SaplingNotePlaintext() {} SaplingNotePlaintext() {}
SaplingNotePlaintext(const SaplingNote& note, std::array<unsigned char, ZC_MEMO_SIZE> memo); SaplingNotePlaintext(const SaplingNote& note, std::array<unsigned char, HUSH_MEMO_SIZE> memo);
static boost::optional<SaplingNotePlaintext> decrypt( static boost::optional<SaplingNotePlaintext> decrypt(
const SaplingEncCiphertext &ciphertext, const SaplingEncCiphertext &ciphertext,

6
src/zcash/Zcash.h

@ -17,14 +17,14 @@
#define ZC_V_SIZE 8 #define ZC_V_SIZE 8
#define ZC_RHO_SIZE 32 #define ZC_RHO_SIZE 32
#define ZC_R_SIZE 32 #define ZC_R_SIZE 32
#define ZC_MEMO_SIZE 512 #define HUSH_MEMO_SIZE 512
#define ZC_DIVERSIFIER_SIZE 11 #define ZC_DIVERSIFIER_SIZE 11
#define ZC_JUBJUB_POINT_SIZE 32 #define ZC_JUBJUB_POINT_SIZE 32
#define ZC_JUBJUB_SCALAR_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_OUTPLAINTEXT_SIZE (ZC_JUBJUB_POINT_SIZE + ZC_JUBJUB_SCALAR_SIZE)
#define ZC_SAPLING_ENCCIPHERTEXT_SIZE (ZC_SAPLING_ENCPLAINTEXT_SIZE + NOTEENCRYPTION_AUTH_BYTES) #define ZC_SAPLING_ENCCIPHERTEXT_SIZE (ZC_SAPLING_ENCPLAINTEXT_SIZE + NOTEENCRYPTION_AUTH_BYTES)

2
src/zcbenchmarks.cpp

@ -304,7 +304,7 @@ double benchmark_create_sapling_output()
auto sk = libzcash::SaplingSpendingKey::random(); auto sk = libzcash::SaplingSpendingKey::random();
auto address = sk.default_address(); auto address = sk.default_address();
std::array<unsigned char, ZC_MEMO_SIZE> memo; std::array<unsigned char, HUSH_MEMO_SIZE> memo;
SaplingNote note(address, GetRand(MAX_MONEY)); SaplingNote note(address, GetRand(MAX_MONEY));
libzcash::SaplingNotePlaintext notePlaintext(note, memo); libzcash::SaplingNotePlaintext notePlaintext(note, memo);

Loading…
Cancel
Save