From ecd13d3523cd4485c3150d2f39c3fc0c13d09b91 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sat, 3 Feb 2018 01:33:46 +0100 Subject: [PATCH] whitespace fixes to placate flake8 --- code/get-utxo.py | 4 ++-- code/hash_example.py | 10 +++++----- code/pycoin_example.py | 2 ++ code/rpc_block.py | 7 ++----- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/code/get-utxo.py b/code/get-utxo.py index ebce0083..2b3ffef1 100644 --- a/code/get-utxo.py +++ b/code/get-utxo.py @@ -8,7 +8,7 @@ address = '1Dorian4RoXcnBv9hnQ4Y2C1an6NJ4UrjX' # The API URL is https://blockchain.info/unspent?active=
# It returns a JSON object with a list "unspent_outputs", containing UTXO, like this: -#{ "unspent_outputs":[ +# { "unspent_outputs":[ # { # "tx_hash":"ebadfaa92f1fd29e2fe296eda702c48bd11ffd52313e986e99ddad9084062167", # "tx_index":51919767, @@ -19,7 +19,7 @@ address = '1Dorian4RoXcnBv9hnQ4Y2C1an6NJ4UrjX' # "confirmations":28691 # }, # ... -#]} +# ]} resp = requests.get('https://blockchain.info/unspent?active=%s' % address) utxo_set = json.loads(resp.text)["unspent_outputs"] diff --git a/code/hash_example.py b/code/hash_example.py index 14bb5a43..d5e69b2b 100644 --- a/code/hash_example.py +++ b/code/hash_example.py @@ -9,10 +9,10 @@ text = "I am Satoshi Nakamoto" for nonce in range(20): # add the nonce to the end of the text - input_data = text + str(nonce) - + input_data = text + str(nonce) + # calculate the SHA-256 hash of the input (text+nonce) - hash_data = hashlib.sha256(input_data).hexdigest() - + hash_data = hashlib.sha256(input_data).hexdigest() + # show the input and hash result - print(input_data, '=>', hash_data) + print(input_data, '=>', hash_data) diff --git a/code/pycoin_example.py b/code/pycoin_example.py index 0791732c..05761caa 100755 --- a/code/pycoin_example.py +++ b/code/pycoin_example.py @@ -8,6 +8,7 @@ from pycoin.key.validate import is_address_valid, is_wif_valid from pycoin.services import spendables_for_address from pycoin.tx.tx_utils import create_signed_tx + def get_address(which): while 1: print("enter the %s address=> " % which, end='') @@ -17,6 +18,7 @@ def get_address(which): return address print("invalid address, please try again") + src_address = get_address("source") spendables = spendables_for_address(src_address) print(spendables) diff --git a/code/rpc_block.py b/code/rpc_block.py index bd7899ab..52fc28ff 100644 --- a/code/rpc_block.py +++ b/code/rpc_block.py @@ -27,11 +27,8 @@ for txid in transactions: for output in decoded_tx['vout']: # Add up the value of each output tx_value = tx_value + output['value'] - - # Add the value of this transaction to the total + + # Add the value of this transaction to the total block_value = block_value + tx_value print("Total value in block: ", block_value) - - -