Merge branch 'dev' into lockzins
This commit is contained in:
@@ -4,10 +4,30 @@
|
||||
|
||||
# Run a regression test network
|
||||
#regtest=0
|
||||
# Run a test node (which means you can mine with no peers)
|
||||
#testnode=1
|
||||
|
||||
#set a custom client name/user agent
|
||||
#clientName=GoldenSandtrout
|
||||
|
||||
# Rescan from block height
|
||||
#rescan=123
|
||||
|
||||
# Connect via a SOCKS5 proxy
|
||||
#proxy=127.0.0.1:9050
|
||||
|
||||
# Automatically create Tor hidden service
|
||||
#listenonion=1
|
||||
|
||||
#Use separate SOCKS5 proxy to reach peers via Tor hidden services
|
||||
#onion=1.2.3.4:9050
|
||||
|
||||
# Only connect to nodes in network <net> (ipv4, ipv6, onion or i2p)"));
|
||||
#onlynet=<net>
|
||||
|
||||
#Tor control port to use if onion listening enabled
|
||||
#torcontrol=127.0.0.1:9051
|
||||
|
||||
# Bind to given address and always listen on it. Use [host]:port notation for IPv6
|
||||
#bind=<addr>
|
||||
|
||||
@@ -63,8 +83,9 @@
|
||||
#rpcbind=<addr>
|
||||
|
||||
# You must set rpcuser and rpcpassword to secure the JSON-RPC api
|
||||
#rpcuser=Ulysses
|
||||
#rpcpassword=YourSuperGreatPasswordNumber_DO_NOT_USE_THIS_OR_YOU_WILL_GET_ROBBED_385593
|
||||
# These will automatically be created for you
|
||||
#rpcuser=user
|
||||
#rpcpassword=supersecretpassword
|
||||
|
||||
# How many seconds node will wait for a complete RPC HTTP request.
|
||||
# after the HTTP connection is established.
|
||||
@@ -83,7 +104,7 @@
|
||||
#rpcallowip=2001:db8:85a3:0:0:8a2e:370:7334/96
|
||||
|
||||
# Listen for RPC connections on this TCP port:
|
||||
#rpcport=8232
|
||||
#rpcport=1234
|
||||
|
||||
# You can use hushd to send commands to hushd
|
||||
# running on another host using this option:
|
||||
@@ -100,8 +121,8 @@
|
||||
|
||||
# Miscellaneous options
|
||||
|
||||
# Enable attempt to mine HUSH
|
||||
#gen=0
|
||||
# Enable mining at startup
|
||||
#gen=1
|
||||
|
||||
# Set the number of threads to be used for mining (-1 = all cores).
|
||||
#genproclimit=1
|
||||
@@ -121,7 +142,7 @@
|
||||
#paytxfee=0.00
|
||||
|
||||
#Rewind the chain to specific block height. This is useful for creating snapshots at a given block height.
|
||||
#rewind=777777
|
||||
#rewind=555
|
||||
|
||||
#Stop the chain a specific block height. This is useful for creating snapshots at a given block height.
|
||||
#stopat=1000000
|
||||
@@ -129,9 +150,60 @@
|
||||
#Set an address to use as change address for all transactions. This value must be set to a 33 byte pubkey. All mined coins will also be sent to this address.
|
||||
#pubkey=027dc7b5cfb5efca96674b45e9fda18df069d040b9fd9ff32c35df56005e330392
|
||||
|
||||
#Forfeit all user rewards to miners. Set this to explicitly not claim user rewards.
|
||||
#exchange=1
|
||||
# Disable clearnet (ipv4 and ipv6) connections to this node
|
||||
#clearnet=0
|
||||
|
||||
#Donate all user rewards to a a specific address. This value must be set to a 33 byte pubkey.
|
||||
#donation=027dc7b5cfb5efca96674b45e9fda18df069d040b9fd9ff32c35df56005e330392
|
||||
# Disable ipv4
|
||||
#disableipv4=1
|
||||
# Disable ipv6
|
||||
#disableipv6=1
|
||||
|
||||
# Enable transaction index
|
||||
#txindex=1
|
||||
# Enable address index
|
||||
#addressindex=1
|
||||
# Enable timestamp index
|
||||
#timestampindex=1
|
||||
# Enable spent index
|
||||
#spentindex=1
|
||||
|
||||
# Enable shielded stats index
|
||||
#zindex=1
|
||||
|
||||
# Attempt to salvage a corrupt wallet
|
||||
# salvagewallet=1
|
||||
|
||||
# Mine all blocks to this address (not good for your privacy and not recommended!)
|
||||
# Disallowed if clearnet=0
|
||||
# mineraddress=XXX
|
||||
|
||||
# Disable wallet
|
||||
#disablewallet=1
|
||||
|
||||
# Allow mining to an address that is not in the current wallet
|
||||
#minetolocalwallet=0
|
||||
|
||||
# Delete all wallet transactions
|
||||
#zapwallettxes=1
|
||||
|
||||
# Enable sapling consolidation
|
||||
# consolidation=1
|
||||
|
||||
# Enable stratum server
|
||||
# stratum=1
|
||||
|
||||
# Run a command each time a new block is seen
|
||||
# %s in command is replaced by block hash
|
||||
#blocknotify=/my/awesome/script.sh %s
|
||||
|
||||
# Run a command when wallet gets a new tx
|
||||
# %s in command is replaced with txid
|
||||
#walletnotify=/my/cool/script.sh %s
|
||||
|
||||
# Run a command when tx expires
|
||||
# %s in command is replaced with txid
|
||||
#txexpirynotify=/my/elite/script.sh %s
|
||||
|
||||
# Execute this commend to send a tx
|
||||
# %s is replaced with tx hex
|
||||
#txsend=/send/it.sh %s
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2016-2024 The Hush developers
|
||||
# Copyright (c) 2018 SuperNET developers
|
||||
# Distributed under the GPLv3 software license, see the accompanying
|
||||
@@ -8,7 +8,7 @@ from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, assert_greater_than, \
|
||||
initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \
|
||||
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises
|
||||
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises, assert_true
|
||||
|
||||
import time
|
||||
from decimal import Decimal
|
||||
@@ -21,16 +21,11 @@ def assert_success(result):
|
||||
def assert_error(result):
|
||||
assert_equal(result['result'], 'error')
|
||||
|
||||
def generate_random_string(length):
|
||||
random_string = ''.join(choice(ascii_uppercase) for i in range(length))
|
||||
return random_string
|
||||
|
||||
|
||||
class AssetChainPrivateTest (BitcoinTestFramework):
|
||||
|
||||
class PrivateTest (BitcoinTestFramework):
|
||||
def setup_chain(self):
|
||||
print("Initializing ac_private test directory "+self.options.tmpdir)
|
||||
self.num_nodes = 1
|
||||
self.options.nocleanup = 1 # do not delete datadir after test run
|
||||
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
|
||||
|
||||
def setup_network(self, split = False):
|
||||
@@ -39,21 +34,19 @@ class AssetChainPrivateTest (BitcoinTestFramework):
|
||||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
|
||||
extra_args=[[
|
||||
# always give -ac_name as first extra_arg and port as third
|
||||
'-ac_name=REGTEST',
|
||||
'-conf='+self.options.tmpdir+'/node0/REGTEST.conf',
|
||||
'-ac_name=ZZZ',
|
||||
'-conf='+self.options.tmpdir+'/node0/regtest/ZZZ.conf',
|
||||
'-port=64367',
|
||||
'-rpcport=64368',
|
||||
'-regtest',
|
||||
'-addressindex=1',
|
||||
'-spentindex=1',
|
||||
'-ac_supply=0',
|
||||
'-ac_supply=10',
|
||||
'-ac_reward=25600000000',
|
||||
'-ac_private=1',
|
||||
'-allowlist=127.0.0.1',
|
||||
'-debug',
|
||||
#'-debug',
|
||||
'-regtest',
|
||||
'--daemon',
|
||||
'-rpcuser=rt',
|
||||
'-rpcpassword=rt'
|
||||
'-rpcuser=hush',
|
||||
'-rpcpassword=puppy'
|
||||
]]
|
||||
)
|
||||
self.is_network_split = split
|
||||
@@ -71,23 +64,23 @@ class AssetChainPrivateTest (BitcoinTestFramework):
|
||||
def run_test (self):
|
||||
print("Mining blocks...")
|
||||
rpc = self.nodes[0]
|
||||
# utxos from block 1 become mature in block 101
|
||||
rpc.generate(101)
|
||||
rpc.generate(1)
|
||||
self.sync_all()
|
||||
rpc.getinfo()
|
||||
rpc.getwalletinfo()
|
||||
|
||||
taddr = rpc.getnewaddress()
|
||||
print "Sending to " + taddr
|
||||
# sending to arbitrary non-notary transparent address is not allowed
|
||||
assert_raises(JSONRPCException, rpc.sendtoaddress, taddr,1)
|
||||
|
||||
# this is a current notary address
|
||||
# TODO: keep in sync when notaries change
|
||||
#dev1_jl777 = "RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc"
|
||||
# taddr vout is only allowed if it is a notary address
|
||||
#txid = rpc.sendtoaddress(dev1_jl777, 7)
|
||||
#assert txid, 'got txid'
|
||||
# sending to arbitrary non-notary transparent address is not allowed
|
||||
print("Sending to " + taddr)
|
||||
try:
|
||||
rpc.sendtoaddress(taddr, 1)
|
||||
except:
|
||||
assert_true(1)
|
||||
|
||||
# this should work but don't
|
||||
#assert_raises(JSONRPCException, rpc.sendtoaddress, taddr,1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
AssetChainPrivateTest ().main()
|
||||
PrivateTest ().main()
|
||||
|
||||
104
qa/rpc-tests/lockzins.py
Executable file
104
qa/rpc-tests/lockzins.py
Executable file
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2016-2025 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.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, assert_greater_than, \
|
||||
initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \
|
||||
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises, assert_true, \
|
||||
wait_and_assert_operationid_status
|
||||
|
||||
import time
|
||||
from decimal import Decimal
|
||||
from random import choice
|
||||
from string import ascii_uppercase
|
||||
|
||||
def assert_success(result):
|
||||
assert_equal(result['result'], 'success')
|
||||
|
||||
def assert_error(result):
|
||||
assert_equal(result['result'], 'error')
|
||||
|
||||
class LockZinsTest (BitcoinTestFramework):
|
||||
def setup_chain(self):
|
||||
print("Initializing test directory "+self.options.tmpdir)
|
||||
self.num_nodes = 1
|
||||
self.options.nocleanup = 1 # do not delete datadir after test run
|
||||
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
|
||||
|
||||
def setup_network(self, split = False):
|
||||
print("Setting up network...")
|
||||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
|
||||
extra_args=[[
|
||||
# always give -ac_name as first extra_arg and port as third
|
||||
'-ac_name=ZZZ',
|
||||
#'-ac_algo=randomx',
|
||||
#'-testnode=1', # why does this make the test node hang before run_test() ?
|
||||
'-conf='+self.options.tmpdir+'/node0/regtest/ZZZ.conf',
|
||||
'-port=64367',
|
||||
'-rpcport=64368',
|
||||
'-ac_supply=1',
|
||||
'-ac_reward=100000000',
|
||||
'-ac_private=1',
|
||||
'-allowlist=127.0.0.1',
|
||||
#'-debug',
|
||||
'-regtest',
|
||||
'--daemon',
|
||||
#'-rpcuser=hush',
|
||||
#'-rpcpassword=puppy'
|
||||
]]
|
||||
)
|
||||
self.is_network_split = False
|
||||
self.rpc = self.nodes[0]
|
||||
self.sync_all()
|
||||
print("Done setting up network")
|
||||
|
||||
def run_test (self):
|
||||
print("Mining blocks...")
|
||||
rpc = self.nodes[0]
|
||||
# mine initial ac_supply
|
||||
rpc.generate(1)
|
||||
self.sync_all()
|
||||
|
||||
zaddr1 = rpc.z_getnewaddress()
|
||||
zaddr2 = rpc.z_getnewaddress()
|
||||
|
||||
x = 0
|
||||
while x < 15:
|
||||
rpc.generate(1)
|
||||
self.sync_all()
|
||||
time.sleep(1)
|
||||
rpc.z_shieldcoinbase('*', zaddr1, 0, 1)
|
||||
x = x+1
|
||||
|
||||
rpc.generate(11)
|
||||
self.sync_all()
|
||||
rpc.z_listunspent()
|
||||
rpc.z_getbalances()
|
||||
|
||||
recipients = []
|
||||
recipients.append({"address": zaddr2, "amount": Decimal('3')})
|
||||
|
||||
# queue 4 ztxs, which will try to spend the same funds multiple times
|
||||
# without correct locking of zins
|
||||
opid1 = rpc.z_sendmany(zaddr1,recipients,1,0)
|
||||
opid2 = rpc.z_sendmany(zaddr1,recipients,1,0)
|
||||
opid3 = rpc.z_sendmany(zaddr1,recipients,1,0)
|
||||
opid4 = rpc.z_sendmany(zaddr1,recipients,1,0)
|
||||
|
||||
rpc.generate(1)
|
||||
self.sync_all()
|
||||
wait_and_assert_operationid_status(self.nodes[0], opid1)
|
||||
wait_and_assert_operationid_status(self.nodes[0], opid2)
|
||||
wait_and_assert_operationid_status(self.nodes[0], opid3)
|
||||
wait_and_assert_operationid_status(self.nodes[0], opid4)
|
||||
|
||||
# give time for all z_sendmany's to run
|
||||
#time.sleep(10)
|
||||
|
||||
rpc.z_getoperationstatus()
|
||||
|
||||
if __name__ == '__main__':
|
||||
LockZinsTest ().main()
|
||||
@@ -1,8 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# Copyright (c) 2016-2024 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
|
||||
|
||||
@@ -38,45 +33,37 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
try:
|
||||
import http.client as httplib
|
||||
except ImportError:
|
||||
import httplib
|
||||
import base64
|
||||
import decimal
|
||||
import json
|
||||
import logging
|
||||
try:
|
||||
import urllib.parse as urlparse
|
||||
except ImportError:
|
||||
import urlparse
|
||||
from http.client import HTTPConnection, HTTPSConnection, BadStatusLine
|
||||
from urllib.parse import urlparse
|
||||
|
||||
USER_AGENT = "AuthServiceProxy/0.1"
|
||||
|
||||
USER_AGENT = "FUCKjl777LULZ"
|
||||
HTTP_TIMEOUT = 600
|
||||
|
||||
log = logging.getLogger("BitcoinRPC")
|
||||
|
||||
class JSONRPCException(Exception):
|
||||
def __init__(self, rpc_error):
|
||||
Exception.__init__(self)
|
||||
Exception.__init__(self, rpc_error.get("message"))
|
||||
self.error = rpc_error
|
||||
|
||||
|
||||
def EncodeDecimal(o):
|
||||
if isinstance(o, decimal.Decimal):
|
||||
return round(o, 8)
|
||||
return str(o)
|
||||
raise TypeError(repr(o) + " is not JSON serializable")
|
||||
|
||||
class AuthServiceProxy(object):
|
||||
|
||||
class AuthServiceProxy():
|
||||
__id_count = 0
|
||||
|
||||
def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connection=None):
|
||||
self.__service_url = service_url
|
||||
self.__service_name = service_name
|
||||
self.__url = urlparse.urlparse(service_url)
|
||||
if self.__url.port is None:
|
||||
port = 80
|
||||
else:
|
||||
port = self.__url.port
|
||||
self._service_name = service_name
|
||||
self.__url = urlparse(service_url)
|
||||
(user, passwd) = (self.__url.username, self.__url.password)
|
||||
try:
|
||||
user = user.encode('utf8')
|
||||
@@ -89,23 +76,25 @@ class AuthServiceProxy(object):
|
||||
authpair = user + b':' + passwd
|
||||
self.__auth_header = b'Basic ' + base64.b64encode(authpair)
|
||||
|
||||
if connection:
|
||||
# Callables re-use the connection of the original proxy
|
||||
self.__conn = connection
|
||||
elif self.__url.scheme == 'https':
|
||||
self.__conn = httplib.HTTPSConnection(self.__url.hostname, port,
|
||||
None, None, False,
|
||||
timeout)
|
||||
else:
|
||||
self.__conn = httplib.HTTPConnection(self.__url.hostname, port,
|
||||
False, timeout)
|
||||
self.timeout = timeout
|
||||
self._set_conn(connection)
|
||||
|
||||
def _set_conn(self, connection=None):
|
||||
port = 80 if self.__url.port is None else self.__url.port
|
||||
if connection:
|
||||
self.__conn = connection
|
||||
self.timeout = connection.timeout
|
||||
elif self.__url.scheme == 'https':
|
||||
self.__conn = HTTPSConnection(self.__url.hostname, port, timeout=self.timeout)
|
||||
else:
|
||||
self.__conn = HTTPConnection(self.__url.hostname, port, timeout=self.timeout)
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name.startswith('__') and name.endswith('__'):
|
||||
# Python internal stuff
|
||||
raise AttributeError
|
||||
if self.__service_name is not None:
|
||||
name = "%s.%s" % (self.__service_name, name)
|
||||
if self._service_name is not None:
|
||||
name = "%s.%s" % (self._service_name, name)
|
||||
return AuthServiceProxy(self.__service_url, name, connection=self.__conn)
|
||||
|
||||
def _request(self, method, path, postdata):
|
||||
@@ -124,8 +113,9 @@ class AuthServiceProxy(object):
|
||||
# If connection was closed, try again.
|
||||
# Python 3.5+ raises BrokenPipeError instead of BadStatusLine when the connection was reset.
|
||||
# ConnectionResetError happens on FreeBSD with Python 3.4.
|
||||
# These classes don't exist in Python 2.x, so we can't refer to them directly.
|
||||
if ((isinstance(e, httplib.BadStatusLine) and e.line == "''")
|
||||
# This can be simplified now that we depend on Python 3 (previously, we could not
|
||||
# refer to BrokenPipeError or ConnectionResetError which did not exist on Python 2)
|
||||
if ((isinstance(e, BadStatusLine) and e.line == "''")
|
||||
or e.__class__.__name__ in ('BrokenPipeError', 'ConnectionResetError')):
|
||||
self.__conn.close()
|
||||
self.__conn.request(method, path, postdata, headers)
|
||||
@@ -136,10 +126,10 @@ class AuthServiceProxy(object):
|
||||
def __call__(self, *args):
|
||||
AuthServiceProxy.__id_count += 1
|
||||
|
||||
log.debug("-%s-> %s %s"%(AuthServiceProxy.__id_count, self.__service_name,
|
||||
log.debug("-%s-> %s %s"%(AuthServiceProxy.__id_count, self._service_name,
|
||||
json.dumps(args, default=EncodeDecimal)))
|
||||
postdata = json.dumps({'version': '1.1',
|
||||
'method': self.__service_name,
|
||||
'method': self._service_name,
|
||||
'params': args,
|
||||
'id': AuthServiceProxy.__id_count}, default=EncodeDecimal)
|
||||
response = self._request('POST', self.__url.path, postdata)
|
||||
@@ -161,6 +151,11 @@ class AuthServiceProxy(object):
|
||||
if http_response is None:
|
||||
raise JSONRPCException({
|
||||
'code': -342, 'message': 'missing HTTP response from server'})
|
||||
|
||||
content_type = http_response.getheader('Content-Type')
|
||||
if content_type != 'application/json':
|
||||
raise JSONRPCException({
|
||||
'code': -342, 'message': 'non-JSON HTTP response with \'%i %s\' from server' % (http_response.status, http_response.reason)})
|
||||
|
||||
responsedata = http_response.read().decode('utf8')
|
||||
response = json.loads(responsedata, parse_float=decimal.Decimal)
|
||||
|
||||
@@ -134,10 +134,10 @@ class BitcoinTestFramework(object):
|
||||
stop_nodes(self.nodes)
|
||||
wait_bitcoinds()
|
||||
else:
|
||||
print("Note: hushds were not stopped and may still be running")
|
||||
print("Note: nodes were not stopped and may still be running")
|
||||
|
||||
if not self.options.nocleanup and not self.options.noshutdown:
|
||||
print("Cleaning up")
|
||||
print("Deleting %s" % self.options.tmpdir)
|
||||
shutil.rmtree(self.options.tmpdir)
|
||||
|
||||
if success:
|
||||
@@ -169,7 +169,7 @@ class ComparisonTestFramework(BitcoinTestFramework):
|
||||
help="bitcoind binary to use for reference nodes (if any)")
|
||||
|
||||
def setup_chain(self):
|
||||
print "Initializing test directory "+self.options.tmpdir
|
||||
print("Initializing test directory "+self.options.tmpdir)
|
||||
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
|
||||
|
||||
def setup_network(self):
|
||||
|
||||
@@ -57,7 +57,9 @@ def sync_blocks(rpc_connections, wait=1):
|
||||
break
|
||||
time.sleep(wait)
|
||||
|
||||
# Now that the block counts are in sync, wait for the internal
|
||||
return
|
||||
|
||||
# Now that the block counts are in sync, wait for the internal
|
||||
# notifications to finish
|
||||
while True:
|
||||
notified = [ x.getblockchaininfo()['fullyNotified'] for x in rpc_connections ]
|
||||
@@ -91,15 +93,17 @@ def sync_mempools(rpc_connections, wait=1):
|
||||
bitcoind_processes = {}
|
||||
|
||||
def initialize_datadir(dirname, n):
|
||||
datadir = os.path.join(dirname, "node"+str(n))
|
||||
datadir = os.path.join(datadir,"HUSH3")
|
||||
datadir = os.path.join(dirname, "node"+str(n), "regtest")
|
||||
#datadir = os.path.join(datadir,"ZZZ")
|
||||
if not os.path.isdir(datadir):
|
||||
print("Creating dirs %s" % datadir)
|
||||
os.makedirs(datadir)
|
||||
|
||||
print("Writing to " + os.path.join(datadir,"HUSH3.conf"))
|
||||
with open(os.path.join(datadir, "HUSH3.conf"), 'w') as f:
|
||||
print("Writing to " + os.path.join(datadir,"ZZZ.conf"))
|
||||
with open(os.path.join(datadir, "ZZZ.conf"), 'w') as f:
|
||||
f.write("regtest=1\n");
|
||||
f.write("txindex=1\n");
|
||||
#f.write("testnode=1\n");
|
||||
f.write("server=1\n");
|
||||
f.write("showmetrics=0\n");
|
||||
f.write("rpcuser=hush\n");
|
||||
@@ -107,13 +111,15 @@ def initialize_datadir(dirname, n):
|
||||
f.write("port="+str(p2p_port(n))+"\n");
|
||||
rpcport = str(rpc_port(n))
|
||||
f.write("rpcport="+rpcport+"\n");
|
||||
print "RPC port=" + rpcport
|
||||
print("RPC port=" + rpcport)
|
||||
f.write("listenonion=0\n");
|
||||
# TODO: maybe make these optional, via arg to initialize_datadir, defaulted to on for now
|
||||
f.write("addressindex=1\n");
|
||||
f.write("spentindex=1\n");
|
||||
f.write("timestampindex=1\n");
|
||||
f.write("zindex=1\n");
|
||||
#f.write("zindex=1\n");
|
||||
print("Done writing to %s" % os.path.join(datadir,"ZZZ.conf") )
|
||||
|
||||
return datadir
|
||||
|
||||
def initialize_chain(test_dir):
|
||||
@@ -136,14 +142,14 @@ def initialize_chain(test_dir):
|
||||
cmd = os.getenv("BITCOINCLI", "hush-cli")
|
||||
cmd_args = cmd + " -datadir="+datadir + " -rpcwait getblockcount"
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print "initialize_chain: hushd started, calling: " + cmd_args
|
||||
print("initialize_chain: hushd started, calling: " + cmd_args)
|
||||
strcmd = cmd + " " + "-datadir="+datadir + " -rpcwait getblockcount"
|
||||
|
||||
print("Running " + strcmd)
|
||||
subprocess.check_call(strcmd, shell=True);
|
||||
#subprocess.check_call([ cmd, "-rpcwait", "getblockcount"], stdout=devnull)
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print "initialize_chain: hush-cli -rpcwait getblockcount completed"
|
||||
print("initialize_chain: hush-cli -rpcwait getblockcount completed")
|
||||
devnull.close()
|
||||
rpcs = []
|
||||
for i in range(4):
|
||||
@@ -175,7 +181,7 @@ def initialize_chain(test_dir):
|
||||
stop_nodes(rpcs)
|
||||
wait_bitcoinds()
|
||||
for i in range(4):
|
||||
print "Cleaning up cache dir files"
|
||||
print("Cleaning up cache dir files")
|
||||
os.remove(log_filename("cache", i, "debug.log"))
|
||||
os.remove(log_filename("cache", i, "db.log"))
|
||||
os.remove(log_filename("cache", i, "peers.dat"))
|
||||
@@ -221,36 +227,41 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
||||
"""
|
||||
Start a hushd and return RPC connection to it
|
||||
"""
|
||||
print("Starting node " + str(i))
|
||||
datadir = os.path.join(dirname, "node"+str(i))
|
||||
# creating special config in case of cryptocondition asset chain test
|
||||
if len(extra_args) > 0 and extra_args[0] == '-ac_name=REGTEST':
|
||||
configpath = datadir + "/REGTEST.conf"
|
||||
print("Starting node " + str(i) + " in dir " + dirname)
|
||||
datadir = os.path.join(dirname, "node"+str(i), "regtest")
|
||||
# creating special config
|
||||
if len(extra_args) > 0 and extra_args[0] == '-ac_name=ZZZ':
|
||||
configpath = datadir + "/ZZZ.conf"
|
||||
with open(configpath, "w+") as config:
|
||||
config.write("regtest=1\n")
|
||||
config.write("rpcuser=rt\n")
|
||||
config.write("rpcpassword=rt\n")
|
||||
config.write("rpcuser=hush\n")
|
||||
config.write("rpcpassword=puppy\n")
|
||||
port = extra_args[3]
|
||||
config.write("rpcport=" + (port[9:]) + "\n")
|
||||
config.write("server=1\n")
|
||||
#config.write("testnode=1\n")
|
||||
config.write("txindex=1\n")
|
||||
config.write("rpcworkqueue=256\n")
|
||||
config.write("rpcallowip=127.0.0.1\n")
|
||||
config.write("bind=127.0.0.1\n")
|
||||
config.write("rpcbind=127.0.0.1")
|
||||
#config.write("listenonion=0\n")
|
||||
#config.write("torcontrol=127.0.0.1:9999\n")
|
||||
config.write("rpcbind=127.0.0.1\n")
|
||||
print("Done writing to %s" % configpath)
|
||||
|
||||
if binary is None:
|
||||
binary = os.getenv("BITCOIND", "hushd")
|
||||
binary = os.getenv("BITCOIND", "src/hushd")
|
||||
args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ]
|
||||
if extra_args is not None: args.extend(extra_args)
|
||||
#print("args=" + ' '.join(args))
|
||||
print("args=" + ' '.join(args))
|
||||
bitcoind_processes[i] = subprocess.Popen(args)
|
||||
devnull = open("/dev/null", "w+")
|
||||
|
||||
cmd = os.getenv("BITCOINCLI", "hush-cli")
|
||||
cmd = os.getenv("BITCOINCLI", "src/hush-cli")
|
||||
print("cmd=" + cmd)
|
||||
cmd_args = ' '.join(extra_args) + " -rpcwait getblockcount "
|
||||
args = [ extra_args[0], "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ]
|
||||
cmd_args = ' '.join(args) + " -rpcwait getblockcount "
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print "start_node: hushd started, calling : " + cmd + " " + cmd_args
|
||||
print("start_node: hushd started, calling : " + cmd + " " + cmd_args)
|
||||
strcmd = cmd + " " + cmd_args
|
||||
|
||||
print("Running " + strcmd)
|
||||
@@ -261,13 +272,14 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
||||
# _rpchost_to_args(rpchost) +
|
||||
# ["-rpcwait", "-rpcport=6438", "getblockcount"], stdout=devnull)
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print "start_node: calling hush-cli -rpcwait getblockcount returned"
|
||||
print("start_node: calling hush-cli -rpcwait getblockcount returned")
|
||||
devnull.close()
|
||||
#port = extra_args[3]
|
||||
port = rpc_port(i)
|
||||
port = extra_args[3]
|
||||
#port = rpc_port(i)
|
||||
print("port=%s" % port)
|
||||
username = rpc_username()
|
||||
password = rpc_password()
|
||||
url = "http://%s:%s@%s:%d" % (username, password, rpchost or '127.0.0.1', int(port[9:]))
|
||||
url = "http://%s:%s@%s:%s" % (username, password, rpchost or '127.0.0.1', port[9:])
|
||||
print("connecting to " + url)
|
||||
if timewait is not None:
|
||||
proxy = AuthServiceProxy(url, timeout=timewait)
|
||||
@@ -470,7 +482,7 @@ def assert_raises(exc, fun, *args, **kwds):
|
||||
def wait_and_assert_operationid_status(node, myopid, in_status='success', in_errormsg=None, timeout=300):
|
||||
print('waiting for async operation {}'.format(myopid))
|
||||
result = None
|
||||
for _ in xrange(1, timeout):
|
||||
for _ in range(1, timeout):
|
||||
results = node.z_getoperationresult([myopid])
|
||||
if len(results) > 0:
|
||||
result = results[0]
|
||||
|
||||
@@ -577,13 +577,12 @@ extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTP
|
||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA;
|
||||
extern std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
|
||||
extern uint256 HUSH_EARLYTXID;
|
||||
extern int32_t HUSH_CONNECTING,HUSH_CCACTIVATE,HUSH_DEALERNODE;
|
||||
extern int32_t HUSH_CONNECTING,HUSH_CCACTIVATE;
|
||||
extern uint32_t ASSETCHAINS_CC;
|
||||
extern std::string CCerror,ASSETCHAINS_CCLIB;
|
||||
extern uint8_t ASSETCHAINS_CCDISABLES[256];
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS;
|
||||
extern std::string DONATION_PUBKEY;
|
||||
extern uint8_t ASSETCHAINS_PRIVATE;
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
extern char NOTARYADDRS[64][64];
|
||||
|
||||
@@ -45,9 +45,9 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||
unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10;
|
||||
uint256 HUSH_EARLYTXID;
|
||||
|
||||
int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,ASSETCHAINS_SEED,HUSH_ON_DEMAND,HUSH_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,HUSH_PAX,HUSH_EXCHANGEWALLET,HUSH_REWIND,HUSH_CONNECTING = -1,HUSH_DEALERNODE,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,HUSH_NSPV;
|
||||
int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,ASSETCHAINS_SEED,HUSH_ON_DEMAND,HUSH_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,HUSH_PAX,HUSH_EXCHANGEWALLET,HUSH_REWIND,HUSH_CONNECTING = -1,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,HUSH_NSPV;
|
||||
int32_t HUSH_INSYNC,HUSH_LASTMINED,prevHUSH_LASTMINED,HUSH_CCACTIVATE;
|
||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB;
|
||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB;
|
||||
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA;
|
||||
int8_t ASSETCHAINS_ADAPTIVEPOW;
|
||||
uint8_t ASSETCHAINS_CLEARNET = 1;
|
||||
|
||||
@@ -1763,9 +1763,7 @@ void hush_args(char *argv0)
|
||||
{
|
||||
HUSH_MININGTHREADS = GetArg("-genproclimit",-1);
|
||||
}
|
||||
DONATION_PUBKEY = GetArg("-donation", "");
|
||||
NOTARY_PUBKEY = GetArg("-pubkey", "");
|
||||
HUSH_DEALERNODE = GetArg("-dealer",0);
|
||||
HUSH_TESTNODE = GetArg("-testnode",0);
|
||||
|
||||
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
|
||||
|
||||
@@ -82,9 +82,7 @@ char *uint256_str(char *dest,uint256 txid);
|
||||
// Private method:
|
||||
UniValue z_getoperationstatus_IMPL(const UniValue&, bool);
|
||||
|
||||
#define PLAN_NAME_MAX 8
|
||||
#define VALID_PLAN_NAME(x) (strlen(x) <= PLAN_NAME_MAX)
|
||||
#define THROW_IF_SYNCING(INSYNC) if (HUSH_TESTNODE == 0 && INSYNC == 0) { throw runtime_error(strprintf("%s: Extreme Privacy! Chain still syncing at height %d, aborting to prevent linkability analysis. Please wait until FULLY SYNCED and try again.",__FUNCTION__,chainActive.Tip()->GetHeight())); }
|
||||
#define THROW_IF_SYNCING(INSYNC) if (Params().NetworkIDString() != "regtest" && HUSH_TESTNODE == 0 && INSYNC == 0) { throw runtime_error(strprintf("%s: Extreme Privacy! Chain still syncing at height %d, aborting to prevent linkability analysis. Please wait until FULLY SYNCED and try again.",__FUNCTION__,chainActive.Tip()->GetHeight())); }
|
||||
|
||||
int tx_height( const uint256 &hash );
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ bool fPayAtLeastCustomFee = true;
|
||||
#include "hush_defs.h"
|
||||
|
||||
CBlockIndex *hush_chainactive(int32_t height);
|
||||
extern std::string DONATION_PUBKEY;
|
||||
extern int32_t HUSH_LOADINGBLOCKS;
|
||||
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
|
||||
int tx_height( const uint256 &hash );
|
||||
|
||||
Reference in New Issue
Block a user