Dash Core  0.12.2.1
P2P Digital Currency
util.py
Go to the documentation of this file.
1 # Copyright (c) 2014-2015 The Bitcoin Core developers
2 # Copyright (c) 2014-2017 The Dash Core developers
3 # Distributed under the MIT/X11 software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 
7 #
8 # Helpful routines for regression testing
9 #
10 
11 # Add python-bitcoinrpc to module search path:
12 import os
13 import sys
14 
15 from binascii import hexlify, unhexlify
16 from base64 import b64encode
17 from decimal import Decimal, ROUND_DOWN
18 import json
19 import random
20 import shutil
21 import subprocess
22 import time
23 import re
24 import errno
25 
26 from . import coverage
27 from .authproxy import AuthServiceProxy, JSONRPCException
28 
29 COVERAGE_DIR = None
30 
31 #Set Mocktime default to OFF.
32 #MOCKTIME is only needed for scripts that use the
33 #cached version of the blockchain. If the cached
34 #version of the blockchain is used without MOCKTIME
35 #then the mempools will not sync due to IBD.
36 MOCKTIME = 0
37 
39  #For backwared compatibility of the python scripts
40  #with previous versions of the cache, set MOCKTIME
41  #to regtest genesis time + (201 * 156)
42  global MOCKTIME
43  MOCKTIME = 1417713337 + (201 * 156)
44 
46  global MOCKTIME
47  MOCKTIME = 0
48 
50  return MOCKTIME
51 
52 def enable_coverage(dirname):
53  """Maintain a log of which RPC calls are made during testing."""
54  global COVERAGE_DIR
55  COVERAGE_DIR = dirname
56 
57 
58 def get_rpc_proxy(url, node_number, timeout=None):
59  """
60  Args:
61  url (str): URL of the RPC server to call
62  node_number (int): the node number (or id) that this calls to
63 
64  Kwargs:
65  timeout (int): HTTP timeout in seconds
66 
67  Returns:
68  AuthServiceProxy. convenience object for making RPC calls.
69 
70  """
71  proxy_kwargs = {}
72  if timeout is not None:
73  proxy_kwargs['timeout'] = timeout
74 
75  proxy = AuthServiceProxy(url, **proxy_kwargs)
76  proxy.url = url # store URL on proxy for info
77 
78  coverage_logfile = coverage.get_filename(
79  COVERAGE_DIR, node_number) if COVERAGE_DIR else None
80 
81  return coverage.AuthServiceProxyWrapper(proxy, coverage_logfile)
82 
84  result = node.mnsync("status")
85  return result['IsSynced']
86 
87 def wait_to_sync(node):
88  synced = False
89  while not synced:
90  synced = get_mnsync_status(node)
91  time.sleep(0.5)
92 
93 def p2p_port(n):
94  return 11000 + n + os.getpid()%999
95 def rpc_port(n):
96  return 12000 + n + os.getpid()%999
97 
99  """Make sure json library being used does not lose precision converting BTC values"""
100  n = Decimal("20000000.00000003")
101  satoshis = int(json.loads(json.dumps(float(n)))*1.0e8)
102  if satoshis != 2000000000000003:
103  raise RuntimeError("JSON encode/decode loses precision")
104 
105 def count_bytes(hex_string):
106  return len(bytearray.fromhex(hex_string))
107 
108 def bytes_to_hex_str(byte_str):
109  return hexlify(byte_str).decode('ascii')
110 
111 def hex_str_to_bytes(hex_str):
112  return unhexlify(hex_str.encode('ascii'))
113 
114 def str_to_b64str(string):
115  return b64encode(string.encode('utf-8')).decode('ascii')
116 
117 def sync_blocks(rpc_connections, wait=1):
118  """
119  Wait until everybody has the same block count
120  """
121  while True:
122  counts = [ x.getblockcount() for x in rpc_connections ]
123  if counts == [ counts[0] ]*len(counts):
124  break
125  time.sleep(wait)
126 
127 def sync_mempools(rpc_connections, wait=1):
128  """
129  Wait until everybody has the same transactions in their memory
130  pools
131  """
132  while True:
133  pool = set(rpc_connections[0].getrawmempool())
134  num_match = 1
135  for i in range(1, len(rpc_connections)):
136  if set(rpc_connections[i].getrawmempool()) == pool:
137  num_match = num_match+1
138  if num_match == len(rpc_connections):
139  break
140  time.sleep(wait)
141 
142 def sync_masternodes(rpc_connections):
143  for node in rpc_connections:
144  wait_to_sync(node)
145 
146 bitcoind_processes = {}
147 
148 def initialize_datadir(dirname, n):
149  datadir = os.path.join(dirname, "node"+str(n))
150  if not os.path.isdir(datadir):
151  os.makedirs(datadir)
152  with open(os.path.join(datadir, "dash.conf"), 'w') as f:
153  f.write("regtest=1\n")
154  f.write("rpcuser=rt\n")
155  f.write("rpcpassword=rt\n")
156  f.write("port="+str(p2p_port(n))+"\n")
157  f.write("rpcport="+str(rpc_port(n))+"\n")
158  f.write("listenonion=0\n")
159  return datadir
160 
161 def rpc_url(i, rpchost=None):
162  return "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', rpc_port(i))
163 
164 def wait_for_bitcoind_start(process, url, i):
165  '''
166  Wait for dashd to start. This means that RPC is accessible and fully initialized.
167  Raise an exception if dashd exits during initialization.
168  '''
169  while True:
170  if process.poll() is not None:
171  raise Exception('dashd exited with status %i during initialization' % process.returncode)
172  try:
173  rpc = get_rpc_proxy(url, i)
174  blocks = rpc.getblockcount()
175  break # break out of loop on success
176  except IOError as e:
177  if e.errno != errno.ECONNREFUSED: # Port not yet open?
178  raise # unknown IO error
179  except JSONRPCException as e: # Initialization phase
180  if e.error['code'] != -28: # RPC in warmup?
181  raise # unkown JSON RPC exception
182  time.sleep(0.25)
183 
184 def initialize_chain(test_dir):
185  """
186  Create (or copy from cache) a 200-block-long chain and
187  4 wallets.
188  """
189 
190  if (not os.path.isdir(os.path.join("cache","node0"))
191  or not os.path.isdir(os.path.join("cache","node1"))
192  or not os.path.isdir(os.path.join("cache","node2"))
193  or not os.path.isdir(os.path.join("cache","node3"))):
194 
195  #find and delete old cache directories if any exist
196  for i in range(4):
197  if os.path.isdir(os.path.join("cache","node"+str(i))):
198  shutil.rmtree(os.path.join("cache","node"+str(i)))
199 
200  # Create cache directories, run dashds:
201  for i in range(4):
202  datadir=initialize_datadir("cache", i)
203  args = [ os.getenv("DASHD", "dashd"), "-server", "-keypool=1", "-datadir="+datadir, "-discover=0" ]
204  if i > 0:
205  args.append("-connect=127.0.0.1:"+str(p2p_port(0)))
206  bitcoind_processes[i] = subprocess.Popen(args)
207  if os.getenv("PYTHON_DEBUG", ""):
208  print "initialize_chain: dashd started, waiting for RPC to come up"
209  wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i)
210  if os.getenv("PYTHON_DEBUG", ""):
211  print "initialize_chain: RPC succesfully started"
212 
213  rpcs = []
214  for i in range(4):
215  try:
216  rpcs.append(get_rpc_proxy(rpc_url(i), i))
217  except:
218  sys.stderr.write("Error connecting to "+url+"\n")
219  sys.exit(1)
220 
221  # Create a 200-block-long chain; each of the 4 nodes
222  # gets 25 mature blocks and 25 immature.
223  # blocks are created with timestamps 156 seconds apart
224  # starting from 31356 seconds in the past
226  block_time = get_mocktime() - (201 * 156)
227  for i in range(2):
228  for peer in range(4):
229  for j in range(25):
230  set_node_times(rpcs, block_time)
231  rpcs[peer].generate(1)
232  block_time += 156
233  # Must sync before next peer starts generating blocks
234  sync_blocks(rpcs)
235 
236  # Shut them down, and clean up cache directories:
237  stop_nodes(rpcs)
240  for i in range(4):
241  os.remove(log_filename("cache", i, "debug.log"))
242  os.remove(log_filename("cache", i, "db.log"))
243  os.remove(log_filename("cache", i, "peers.dat"))
244  os.remove(log_filename("cache", i, "fee_estimates.dat"))
245 
246  for i in range(4):
247  from_dir = os.path.join("cache", "node"+str(i))
248  to_dir = os.path.join(test_dir, "node"+str(i))
249  shutil.copytree(from_dir, to_dir)
250  initialize_datadir(test_dir, i) # Overwrite port/rpcport in dash.conf
251 
252 def initialize_chain_clean(test_dir, num_nodes):
253  """
254  Create an empty blockchain and num_nodes wallets.
255  Useful if a test case wants complete control over initialization.
256  """
257  for i in range(num_nodes):
258  datadir=initialize_datadir(test_dir, i)
259 
260 
261 def _rpchost_to_args(rpchost):
262  '''Convert optional IP:port spec to rpcconnect/rpcport args'''
263  if rpchost is None:
264  return []
265 
266  match = re.match('(\[[0-9a-fA-f:]+\]|[^:]+)(?::([0-9]+))?$', rpchost)
267  if not match:
268  raise ValueError('Invalid RPC host spec ' + rpchost)
269 
270  rpcconnect = match.group(1)
271  rpcport = match.group(2)
272 
273  if rpcconnect.startswith('['): # remove IPv6 [...] wrapping
274  rpcconnect = rpcconnect[1:-1]
275 
276  rv = ['-rpcconnect=' + rpcconnect]
277  if rpcport:
278  rv += ['-rpcport=' + rpcport]
279  return rv
280 
281 def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None):
282  """
283  Start a dashd and return RPC connection to it
284  """
285  datadir = os.path.join(dirname, "node"+str(i))
286  if binary is None:
287  binary = os.getenv("DASHD", "dashd")
288  # RPC tests still depend on free transactions
289  args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-blockprioritysize=50000", "-mocktime="+str(get_mocktime()) ]
290  if extra_args is not None: args.extend(extra_args)
291  bitcoind_processes[i] = subprocess.Popen(args)
292  if os.getenv("PYTHON_DEBUG", ""):
293  print "start_node: dashd started, waiting for RPC to come up"
294  url = rpc_url(i, rpchost)
295  wait_for_bitcoind_start(bitcoind_processes[i], url, i)
296  if os.getenv("PYTHON_DEBUG", ""):
297  print "start_node: RPC succesfully started"
298  proxy = get_rpc_proxy(url, i, timeout=timewait)
299 
300  if COVERAGE_DIR:
301  coverage.write_all_rpc_commands(COVERAGE_DIR, proxy)
302 
303  return proxy
304 
305 def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):
306  """
307  Start multiple dashds, return RPC connections to them
308  """
309  if extra_args is None: extra_args = [ None for i in range(num_nodes) ]
310  if binary is None: binary = [ None for i in range(num_nodes) ]
311  rpcs = []
312  try:
313  for i in range(num_nodes):
314  rpcs.append(start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]))
315  except: # If one node failed to start, stop the others
316  stop_nodes(rpcs)
317  raise
318  return rpcs
319 
320 def log_filename(dirname, n_node, logname):
321  return os.path.join(dirname, "node"+str(n_node), "regtest", logname)
322 
323 def stop_node(node, i):
324  node.stop()
325  bitcoind_processes[i].wait()
326  del bitcoind_processes[i]
327 
328 def stop_nodes(nodes):
329  for node in nodes:
330  node.stop()
331  del nodes[:] # Emptying array closes connections as a side effect
332 
333 def set_node_times(nodes, t):
334  for node in nodes:
335  node.setmocktime(t)
336 
338  # Wait for all bitcoinds to cleanly exit
339  for bitcoind in bitcoind_processes.values():
340  bitcoind.wait()
341  bitcoind_processes.clear()
342 
343 def connect_nodes(from_connection, node_num):
344  ip_port = "127.0.0.1:"+str(p2p_port(node_num))
345  from_connection.addnode(ip_port, "onetry")
346  # poll until version handshake complete to avoid race conditions
347  # with transaction relaying
348  while any(peer['version'] == 0 for peer in from_connection.getpeerinfo()):
349  time.sleep(0.1)
350 
351 def connect_nodes_bi(nodes, a, b):
352  connect_nodes(nodes[a], b)
353  connect_nodes(nodes[b], a)
354 
355 def find_output(node, txid, amount):
356  """
357  Return index to output of txid with value amount
358  Raises exception if there is none.
359  """
360  txdata = node.getrawtransaction(txid, 1)
361  for i in range(len(txdata["vout"])):
362  if txdata["vout"][i]["value"] == amount:
363  return i
364  raise RuntimeError("find_output txid %s : %s not found"%(txid,str(amount)))
365 
366 
367 def gather_inputs(from_node, amount_needed, confirmations_required=1):
368  """
369  Return a random set of unspent txouts that are enough to pay amount_needed
370  """
371  assert(confirmations_required >=0)
372  utxo = from_node.listunspent(confirmations_required)
373  random.shuffle(utxo)
374  inputs = []
375  total_in = Decimal("0.00000000")
376  while total_in < amount_needed and len(utxo) > 0:
377  t = utxo.pop()
378  total_in += t["amount"]
379  inputs.append({ "txid" : t["txid"], "vout" : t["vout"], "address" : t["address"] } )
380  if total_in < amount_needed:
381  raise RuntimeError("Insufficient funds: need %d, have %d"%(amount_needed, total_in))
382  return (total_in, inputs)
383 
384 def make_change(from_node, amount_in, amount_out, fee):
385  """
386  Create change output(s), return them
387  """
388  outputs = {}
389  amount = amount_out+fee
390  change = amount_in - amount
391  if change > amount*2:
392  # Create an extra change output to break up big inputs
393  change_address = from_node.getnewaddress()
394  # Split change in two, being careful of rounding:
395  outputs[change_address] = Decimal(change/2).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
396  change = amount_in - amount - outputs[change_address]
397  if change > 0:
398  outputs[from_node.getnewaddress()] = change
399  return outputs
400 
401 def send_zeropri_transaction(from_node, to_node, amount, fee):
402  """
403  Create&broadcast a zero-priority transaction.
404  Returns (txid, hex-encoded-txdata)
405  Ensures transaction is zero-priority by first creating a send-to-self,
406  then using its output
407  """
408 
409  # Create a send-to-self with confirmed inputs:
410  self_address = from_node.getnewaddress()
411  (total_in, inputs) = gather_inputs(from_node, amount+fee*2)
412  outputs = make_change(from_node, total_in, amount+fee, fee)
413  outputs[self_address] = float(amount+fee)
414 
415  self_rawtx = from_node.createrawtransaction(inputs, outputs)
416  self_signresult = from_node.signrawtransaction(self_rawtx)
417  self_txid = from_node.sendrawtransaction(self_signresult["hex"], True)
418 
419  vout = find_output(from_node, self_txid, amount+fee)
420  # Now immediately spend the output to create a 1-input, 1-output
421  # zero-priority transaction:
422  inputs = [ { "txid" : self_txid, "vout" : vout } ]
423  outputs = { to_node.getnewaddress() : float(amount) }
424 
425  rawtx = from_node.createrawtransaction(inputs, outputs)
426  signresult = from_node.signrawtransaction(rawtx)
427  txid = from_node.sendrawtransaction(signresult["hex"], True)
428 
429  return (txid, signresult["hex"])
430 
431 def random_zeropri_transaction(nodes, amount, min_fee, fee_increment, fee_variants):
432  """
433  Create a random zero-priority transaction.
434  Returns (txid, hex-encoded-transaction-data, fee)
435  """
436  from_node = random.choice(nodes)
437  to_node = random.choice(nodes)
438  fee = min_fee + fee_increment*random.randint(0,fee_variants)
439  (txid, txhex) = send_zeropri_transaction(from_node, to_node, amount, fee)
440  return (txid, txhex, fee)
441 
442 def random_transaction(nodes, amount, min_fee, fee_increment, fee_variants):
443  """
444  Create a random transaction.
445  Returns (txid, hex-encoded-transaction-data, fee)
446  """
447  from_node = random.choice(nodes)
448  to_node = random.choice(nodes)
449  fee = min_fee + fee_increment*random.randint(0,fee_variants)
450 
451  (total_in, inputs) = gather_inputs(from_node, amount+fee)
452  outputs = make_change(from_node, total_in, amount, fee)
453  outputs[to_node.getnewaddress()] = float(amount)
454 
455  rawtx = from_node.createrawtransaction(inputs, outputs)
456  signresult = from_node.signrawtransaction(rawtx)
457  txid = from_node.sendrawtransaction(signresult["hex"], True)
458 
459  return (txid, signresult["hex"], fee)
460 
461 def assert_equal(thing1, thing2):
462  if thing1 != thing2:
463  raise AssertionError("%s != %s"%(str(thing1),str(thing2)))
464 
465 def assert_greater_than(thing1, thing2):
466  if thing1 <= thing2:
467  raise AssertionError("%s <= %s"%(str(thing1),str(thing2)))
468 
469 def assert_raises(exc, fun, *args, **kwds):
470  try:
471  fun(*args, **kwds)
472  except exc:
473  pass
474  except Exception as e:
475  raise AssertionError("Unexpected exception raised: "+type(e).__name__)
476  else:
477  raise AssertionError("No exception raised")
478 
480  try:
481  int(string, 16)
482  except Exception as e:
483  raise AssertionError(
484  "Couldn't interpret %r as hexadecimal; raised: %s" % (string, e))
485 
486 def assert_is_hash_string(string, length=64):
487  if not isinstance(string, basestring):
488  raise AssertionError("Expected a string, got type %r" % type(string))
489  elif length and len(string) != length:
490  raise AssertionError(
491  "String of length %d expected; got %d" % (length, len(string)))
492  elif not re.match('[abcdef0-9]+$', string):
493  raise AssertionError(
494  "String %r contains invalid characters for a hash." % string)
495 
496 def assert_array_result(object_array, to_match, expected, should_not_find = False):
497  """
498  Pass in array of JSON objects, a dictionary with key/value pairs
499  to match against, and another dictionary with expected key/value
500  pairs.
501  If the should_not_find flag is true, to_match should not be found
502  in object_array
503  """
504  if should_not_find == True:
505  assert_equal(expected, { })
506  num_matched = 0
507  for item in object_array:
508  all_match = True
509  for key,value in to_match.items():
510  if item[key] != value:
511  all_match = False
512  if not all_match:
513  continue
514  elif should_not_find == True:
515  num_matched = num_matched+1
516  for key,value in expected.items():
517  if item[key] != value:
518  raise AssertionError("%s : expected %s=%s"%(str(item), str(key), str(value)))
519  num_matched = num_matched+1
520  if num_matched == 0 and should_not_find != True:
521  raise AssertionError("No objects matched %s"%(str(to_match)))
522  if num_matched > 0 and should_not_find == True:
523  raise AssertionError("Objects were found %s"%(str(to_match)))
524 
525 def satoshi_round(amount):
526  return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
527 
528 # Helper to create at least "count" utxos
529 # Pass in a fee that is sufficient for relay and mining new transactions.
530 def create_confirmed_utxos(fee, node, count):
531  node.generate(int(0.5*count)+101)
532  utxos = node.listunspent()
533  iterations = count - len(utxos)
534  addr1 = node.getnewaddress()
535  addr2 = node.getnewaddress()
536  if iterations <= 0:
537  return utxos
538  for i in xrange(iterations):
539  t = utxos.pop()
540  inputs = []
541  inputs.append({ "txid" : t["txid"], "vout" : t["vout"]})
542  outputs = {}
543  send_value = t['amount'] - fee
544  outputs[addr1] = satoshi_round(send_value/2)
545  outputs[addr2] = satoshi_round(send_value/2)
546  raw_tx = node.createrawtransaction(inputs, outputs)
547  signed_tx = node.signrawtransaction(raw_tx)["hex"]
548  txid = node.sendrawtransaction(signed_tx)
549 
550  while (node.getmempoolinfo()['size'] > 0):
551  node.generate(1)
552 
553  utxos = node.listunspent()
554  assert(len(utxos) >= count)
555  return utxos
556 
557 # Create large OP_RETURN txouts that can be appended to a transaction
558 # to make it large (helper for constructing large transactions).
560  # Some pre-processing to create a bunch of OP_RETURN txouts to insert into transactions we create
561  # So we have big transactions (and therefore can't fit very many into each block)
562  # create one script_pubkey
563  script_pubkey = "6a4d0200" #OP_RETURN OP_PUSH2 512 bytes
564  for i in xrange (512):
565  script_pubkey = script_pubkey + "01"
566  # concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
567  txouts = "81"
568  for k in xrange(128):
569  # add txout value
570  txouts = txouts + "0000000000000000"
571  # add length of script_pubkey
572  txouts = txouts + "fd0402"
573  # add script_pubkey
574  txouts = txouts + script_pubkey
575  return txouts
576 
577 def create_tx(node, coinbase, to_address, amount):
578  inputs = [{ "txid" : coinbase, "vout" : 0}]
579  outputs = { to_address : amount }
580  rawtx = node.createrawtransaction(inputs, outputs)
581  signresult = node.signrawtransaction(rawtx)
582  assert_equal(signresult["complete"], True)
583  return signresult["hex"]
584 
585 # Create a spend of each passed-in utxo, splicing in "txouts" to each raw
586 # transaction to make it large. See gen_return_txouts() above.
587 def create_lots_of_big_transactions(node, txouts, utxos, fee):
588  addr = node.getnewaddress()
589  txids = []
590  for i in xrange(len(utxos)):
591  t = utxos.pop()
592  inputs = []
593  inputs.append({ "txid" : t["txid"], "vout" : t["vout"]})
594  outputs = {}
595  send_value = t['amount'] - fee
596  outputs[addr] = satoshi_round(send_value)
597  rawtx = node.createrawtransaction(inputs, outputs)
598  newtx = rawtx[0:92]
599  newtx = newtx + txouts
600  newtx = newtx + rawtx[94:]
601  signresult = node.signrawtransaction(newtx, None, None, "NONE")
602  txid = node.sendrawtransaction(signresult["hex"], True)
603  txids.append(txid)
604  return txids
605 
606 def get_bip9_status(node, key):
607  info = node.getblockchaininfo()
608  for row in info['bip9_softforks']:
609  if row['id'] == key:
610  return row
611  raise IndexError ('key:"%s" not found' % key)
def wait_bitcoinds()
Definition: util.py:337
def check_json_precision()
Definition: util.py:98
def get_rpc_proxy(url, node_number, timeout=None)
Definition: util.py:58
def get_mocktime()
Definition: util.py:49
def initialize_chain(test_dir)
Definition: util.py:184
def get_bip9_status(node, key)
Definition: util.py:606
def random_transaction(nodes, amount, min_fee, fee_increment, fee_variants)
Definition: util.py:442
def count_bytes(hex_string)
Definition: util.py:105
def hex_str_to_bytes(hex_str)
Definition: util.py:111
def assert_array_result(object_array, to_match, expected, should_not_find=False)
Definition: util.py:496
def assert_greater_than(thing1, thing2)
Definition: util.py:465
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None)
Definition: util.py:305
def assert_raises(exc, fun, args, kwds)
Definition: util.py:469
def wait_to_sync(node)
Definition: util.py:87
def disable_mocktime()
Definition: util.py:45
def make_change(from_node, amount_in, amount_out, fee)
Definition: util.py:384
def connect_nodes(from_connection, node_num)
Definition: util.py:343
def sync_mempools(rpc_connections, wait=1)
Definition: util.py:127
def sync_masternodes(rpc_connections)
Definition: util.py:142
def send_zeropri_transaction(from_node, to_node, amount, fee)
Definition: util.py:401
def get_mnsync_status(node)
Definition: util.py:83
def rpc_url(i, rpchost=None)
Definition: util.py:161
def enable_mocktime()
Definition: util.py:38
def initialize_chain_clean(test_dir, num_nodes)
Definition: util.py:252
def find_output(node, txid, amount)
Definition: util.py:355
def satoshi_round(amount)
Definition: util.py:525
def gather_inputs(from_node, amount_needed, confirmations_required=1)
Definition: util.py:367
def random_zeropri_transaction(nodes, amount, min_fee, fee_increment, fee_variants)
Definition: util.py:431
def create_tx(node, coinbase, to_address, amount)
Definition: util.py:577
def stop_nodes(nodes)
Definition: util.py:328
def gen_return_txouts()
Definition: util.py:559
def set_node_times(nodes, t)
Definition: util.py:333
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)
Definition: util.py:281
def stop_node(node, i)
Definition: util.py:323
def assert_is_hex_string(string)
Definition: util.py:479
UniValue generate(const UniValue &params, bool fHelp)
Definition: mining.cpp:122
def sync_blocks(rpc_connections, wait=1)
Definition: util.py:117
def enable_coverage(dirname)
Definition: util.py:52
def rpc_port(n)
Definition: util.py:95
def wait_for_bitcoind_start(process, url, i)
Definition: util.py:164
def log_filename(dirname, n_node, logname)
Definition: util.py:320
UniValue getrawmempool(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:234
def initialize_datadir(dirname, n)
Definition: util.py:148
def create_confirmed_utxos(fee, node, count)
Definition: util.py:530
def _rpchost_to_args(rpchost)
Definition: util.py:261
def assert_is_hash_string(string, length=64)
Definition: util.py:486
def str_to_b64str(string)
Definition: util.py:114
def p2p_port(n)
Definition: util.py:93
def assert_equal(thing1, thing2)
Definition: util.py:461
def connect_nodes_bi(nodes, a, b)
Definition: util.py:351
def create_lots_of_big_transactions(node, txouts, utxos, fee)
Definition: util.py:587
def bytes_to_hex_str(byte_str)
Definition: util.py:108