mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Port of wallet.sh to python (wallet.py).
Also included are minor edits to util.py to create a clean blockchain and add a parameter to gather_inputs to specify number of confirmations.
This commit is contained in:
@@ -57,7 +57,6 @@ def sync_mempools(rpc_connections):
|
||||
if num_match == len(rpc_connections):
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
bitcoind_processes = {}
|
||||
|
||||
@@ -130,6 +129,15 @@ def initialize_chain(test_dir):
|
||||
shutil.copytree(from_dir, to_dir)
|
||||
initialize_datadir(test_dir, i) # Overwrite port/rpcport in bitcoin.conf
|
||||
|
||||
def initialize_chain_clean(test_dir, num_nodes):
|
||||
"""
|
||||
Create an empty blockchain and num_nodes wallets.
|
||||
Useful if a test case wants complete control over initialization.
|
||||
"""
|
||||
for i in range(num_nodes):
|
||||
datadir=initialize_datadir(test_dir, i)
|
||||
|
||||
|
||||
def _rpchost_to_args(rpchost):
|
||||
'''Convert optional IP:port spec to rpcconnect/rpcport args'''
|
||||
if rpchost is None:
|
||||
@@ -221,11 +229,13 @@ def find_output(node, txid, amount):
|
||||
return i
|
||||
raise RuntimeError("find_output txid %s : %s not found"%(txid,str(amount)))
|
||||
|
||||
def gather_inputs(from_node, amount_needed):
|
||||
|
||||
def gather_inputs(from_node, amount_needed, confirmations_required=1):
|
||||
"""
|
||||
Return a random set of unspent txouts that are enough to pay amount_needed
|
||||
"""
|
||||
utxo = from_node.listunspent(1)
|
||||
assert(confirmations_required >=0)
|
||||
utxo = from_node.listunspent(confirmations_required)
|
||||
random.shuffle(utxo)
|
||||
inputs = []
|
||||
total_in = Decimal("0.00000000")
|
||||
|
||||
Reference in New Issue
Block a user