diff --git a/.arclint b/.arclint --- a/.arclint +++ b/.arclint @@ -15,7 +15,10 @@ "autopep8": { "type": "autopep8", "version": ">=1.3.4", - "include": "(\\.py$)" + "include": "(\\.py$)", + "flags": [ + "--global-config=.autopep8" + ] }, "flake8": { "type": "flake8", diff --git a/.autopep8 b/.autopep8 new file mode 100644 --- /dev/null +++ b/.autopep8 @@ -0,0 +1,2 @@ +[pycodestyle] +select = E,W diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py --- a/contrib/devtools/security-check.py +++ b/contrib/devtools/security-check.py @@ -132,7 +132,7 @@ Returns a tuple (arch,bits) where arch is 'i386:x86-64' or 'i386' and bits is the DllCharacteristics value. ''' - p = subprocess.Popen([OBJDUMP_CMD, '-x', executable], stdout=subprocess.PIPE, + p = subprocess.Popen([OBJDUMP_CMD, '-x', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() if p.returncode: diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -36,10 +36,10 @@ # (glibc) GLIBC_2_19 # MAX_VERSIONS = { - 'GCC': (4, 8, 0), - 'CXXABI': (1, 3, 7), - 'GLIBCXX': (3, 4, 18), - 'GLIBC': (2, 19), + 'GCC': (4, 8, 0), + 'CXXABI': (1, 3, 7), + 'GLIBCXX': (3, 4, 18), + 'GLIBC': (2, 19), 'LIBATOMIC': (1, 0) } # See here for a description of _IO_stdin_used: @@ -77,9 +77,9 @@ 'libdl.so.2' # programming interface to dynamic linker } ARCH_MIN_GLIBC_VER = { - '80386': (2, 1), + '80386': (2, 1), 'X86-64': (2, 2, 5), - 'ARM': (2, 4), + 'ARM': (2, 4), 'AArch64': (2, 17) } diff --git a/contrib/gitian-build.py b/contrib/gitian-build.py --- a/contrib/gitian-build.py +++ b/contrib/gitian-build.py @@ -62,8 +62,8 @@ output_dir_src = '../' + base_output_dir + '/src' if args.linux: print('\nCompiling ' + args.version + ' Linux') - subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'bitcoin='+args.commit, - '--url', 'bitcoin='+args.url, '../bitcoin-abc/contrib/gitian-descriptors/gitian-linux.yml']) + subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'bitcoin=' + args.commit, + '--url', 'bitcoin=' + args.url, '../bitcoin-abc/contrib/gitian-descriptors/gitian-linux.yml']) subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version + '-linux', '--destination', '../gitian.sigs/', '../bitcoin-abc/contrib/gitian-descriptors/gitian-linux.yml']) output_dir_linux = '../' + base_output_dir + '/linux' @@ -77,8 +77,8 @@ if args.windows: print('\nCompiling ' + args.version + ' Windows') - subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'bitcoin='+args.commit, - '--url', 'bitcoin='+args.url, '../bitcoin-abc/contrib/gitian-descriptors/gitian-win.yml']) + subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'bitcoin=' + args.commit, + '--url', 'bitcoin=' + args.url, '../bitcoin-abc/contrib/gitian-descriptors/gitian-win.yml']) subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version + '-win-unsigned', '--destination', '../gitian.sigs/', '../bitcoin-abc/contrib/gitian-descriptors/gitian-win.yml']) output_dir_win = '../' + base_output_dir + '/win' @@ -94,8 +94,8 @@ if args.macos: print('\nCompiling ' + args.version + ' MacOS') - subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'bitcoin='+args.commit, - '--url', 'bitcoin='+args.url, '../bitcoin-abc/contrib/gitian-descriptors/gitian-osx.yml']) + subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'bitcoin=' + args.commit, + '--url', 'bitcoin=' + args.url, '../bitcoin-abc/contrib/gitian-descriptors/gitian-osx.yml']) subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version + '-osx-unsigned', '--destination', '../gitian.sigs/', '../bitcoin-abc/contrib/gitian-descriptors/gitian-osx.yml']) output_dir_osx = '../' + base_output_dir + '/osx' @@ -112,16 +112,16 @@ os.chdir(workdir) if args.commit_files: - print('\nCommitting '+args.version+' Unsigned Sigs\n') + print('\nCommitting ' + args.version + ' Unsigned Sigs\n') os.chdir('gitian.sigs') subprocess.check_call( - ['git', 'add', args.version+'-linux/'+args.signer]) + ['git', 'add', args.version + '-linux/' + args.signer]) subprocess.check_call( - ['git', 'add', args.version+'-win-unsigned/'+args.signer]) + ['git', 'add', args.version + '-win-unsigned/' + args.signer]) subprocess.check_call( - ['git', 'add', args.version+'-osx-unsigned/'+args.signer]) + ['git', 'add', args.version + '-osx-unsigned/' + args.signer]) subprocess.check_call( - ['git', 'commit', '-m', 'Add '+args.version+' unsigned sigs for '+args.signer]) + ['git', 'commit', '-m', 'Add ' + args.version + ' unsigned sigs for ' + args.signer]) os.chdir(workdir) @@ -133,37 +133,37 @@ print('\nSigning ' + args.version + ' Windows') subprocess.check_call('cp inputs/bitcoin-' + args.version + '-win-unsigned.tar.gz inputs/bitcoin-win-unsigned.tar.gz', shell=True) - subprocess.check_call(['bin/gbuild', '-i', '--commit', 'signature='+args.commit, + subprocess.check_call(['bin/gbuild', '-i', '--commit', 'signature=' + args.commit, '../bitcoin-abc/contrib/gitian-descriptors/gitian-win-signer.yml']) - subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-win-signed', + subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version + '-win-signed', '--destination', '../gitian.sigs/', '../bitcoin-abc/contrib/gitian-descriptors/gitian-win-signer.yml']) subprocess.check_call( - 'mv build/out/bitcoin-*win64-setup.exe ../bitcoin-binaries/'+args.version, shell=True) + 'mv build/out/bitcoin-*win64-setup.exe ../bitcoin-binaries/' + args.version, shell=True) subprocess.check_call( - 'mv build/out/bitcoin-*win32-setup.exe ../bitcoin-binaries/'+args.version, shell=True) + 'mv build/out/bitcoin-*win32-setup.exe ../bitcoin-binaries/' + args.version, shell=True) if args.macos: print('\nSigning ' + args.version + ' MacOS') subprocess.check_call('cp inputs/bitcoin-' + args.version + '-osx-unsigned.tar.gz inputs/bitcoin-osx-unsigned.tar.gz', shell=True) - subprocess.check_call(['bin/gbuild', '-i', '--commit', 'signature='+args.commit, + subprocess.check_call(['bin/gbuild', '-i', '--commit', 'signature=' + args.commit, '../bitcoin-abc/contrib/gitian-descriptors/gitian-osx-signer.yml']) - subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-osx-signed', + subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version + '-osx-signed', '--destination', '../gitian.sigs/', '../bitcoin-abc/contrib/gitian-descriptors/gitian-osx-signer.yml']) subprocess.check_call('mv build/out/bitcoin-osx-signed.dmg ../bitcoin-binaries/' + - args.version+'/bitcoin-'+args.version+'-osx.dmg', shell=True) + args.version + '/bitcoin-' + args.version + '-osx.dmg', shell=True) os.chdir(workdir) if args.commit_files: - print('\nCommitting '+args.version+' Signed Sigs\n') + print('\nCommitting ' + args.version + ' Signed Sigs\n') os.chdir('gitian.sigs') subprocess.check_call( - ['git', 'add', args.version+'-win-signed/'+args.signer]) + ['git', 'add', args.version + '-win-signed/' + args.signer]) subprocess.check_call( - ['git', 'add', args.version+'-osx-signed/'+args.signer]) + ['git', 'add', args.version + '-osx-signed/' + args.signer]) subprocess.check_call(['git', 'commit', '-a', '-m', 'Add ' + - args.version+' signed binary sigs for '+args.signer]) + args.version + ' signed binary sigs for ' + args.signer]) os.chdir(workdir) @@ -171,19 +171,19 @@ global args, workdir os.chdir('gitian-builder') - print('\nVerifying v'+args.version+' Linux\n') + print('\nVerifying v' + args.version + ' Linux\n') subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version + '-linux', '../bitcoin-abc/contrib/gitian-descriptors/gitian-linux.yml']) - print('\nVerifying v'+args.version+' Windows\n') + print('\nVerifying v' + args.version + ' Windows\n') subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version + '-win-unsigned', '../bitcoin-abc/contrib/gitian-descriptors/gitian-win.yml']) - print('\nVerifying v'+args.version+' MacOS\n') + print('\nVerifying v' + args.version + ' MacOS\n') subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version + '-osx-unsigned', '../bitcoin-abc/contrib/gitian-descriptors/gitian-osx.yml']) - print('\nVerifying v'+args.version+' Signed Windows\n') + print('\nVerifying v' + args.version + ' Signed Windows\n') subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version + '-win-signed', '../bitcoin-abc/contrib/gitian-descriptors/gitian-win-signer.yml']) - print('\nVerifying v'+args.version+' Signed MacOS\n') + print('\nVerifying v' + args.version + ' Signed MacOS\n') subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version + '-osx-signed', '../bitcoin-abc/contrib/gitian-descriptors/gitian-osx-signer.yml']) @@ -267,12 +267,12 @@ script_name = os.path.basename(sys.argv[0]) # Signer and version shouldn't be empty if args.signer == '': - print(script_name+': Missing signer.') - print('Try '+script_name+' --help for more information') + print(script_name + ': Missing signer.') + print('Try ' + script_name + ' --help for more information') exit(1) if args.version == '': - print(script_name+': Missing version.') - print('Try '+script_name+' --help for more information') + print(script_name + ': Missing version.') + print('Try ' + script_name + ' --help for more information') exit(1) # Add leading 'v' for tags @@ -286,10 +286,10 @@ os.chdir('bitcoin-abc') if args.pull: subprocess.check_call( - ['git', 'fetch', args.url, 'refs/pull/'+args.version+'/merge']) + ['git', 'fetch', args.url, 'refs/pull/' + args.version + '/merge']) os.chdir('../gitian-builder/inputs/bitcoin') subprocess.check_call( - ['git', 'fetch', args.url, 'refs/pull/'+args.version+'/merge']) + ['git', 'fetch', args.url, 'refs/pull/' + args.version + '/merge']) args.commit = subprocess.check_output( ['git', 'show', '-s', '--format=%H', 'FETCH_HEAD'], universal_newlines=True, encoding='utf8').strip() args.version = 'pull-' + args.version diff --git a/contrib/testgen/gen_base58_test_vectors.py b/contrib/testgen/gen_base58_test_vectors.py --- a/contrib/testgen/gen_base58_test_vectors.py +++ b/contrib/testgen/gen_base58_test_vectors.py @@ -30,14 +30,14 @@ templates = [ # prefix, payload_size, suffix, metadata # None = N/A - ((PUBKEY_ADDRESS,), 20, (), (False, False, 'pubkey', None)), - ((SCRIPT_ADDRESS,), 20, (), (False, False, 'script', None)), - ((PUBKEY_ADDRESS_TEST,), 20, (), (False, True, 'pubkey', None)), - ((SCRIPT_ADDRESS_TEST,), 20, (), (False, True, 'script', None)), - ((PRIVKEY,), 32, (), (True, False, None, False)), - ((PRIVKEY,), 32, (1,), (True, False, None, True)), - ((PRIVKEY_TEST,), 32, (), (True, True, None, False)), - ((PRIVKEY_TEST,), 32, (1,), (True, True, None, True)) + ((PUBKEY_ADDRESS,), 20, (), (False, False, 'pubkey', None)), + ((SCRIPT_ADDRESS,), 20, (), (False, False, 'script', None)), + ((PUBKEY_ADDRESS_TEST,), 20, (), (False, True, 'pubkey', None)), + ((SCRIPT_ADDRESS_TEST,), 20, (), (False, True, 'script', None)), + ((PRIVKEY,), 32, (), (True, False, None, False)), + ((PRIVKEY,), 32, (1,), (True, False, None, True)), + ((PRIVKEY_TEST,), 32, (), (True, True, None, False)), + ((PRIVKEY_TEST,), 32, (1,), (True, True, None, True)) ] diff --git a/test/functional/abc-mempool-coherence-on-activations.py b/test/functional/abc-mempool-coherence-on-activations.py --- a/test/functional/abc-mempool-coherence-on-activations.py +++ b/test/functional/abc-mempool-coherence-on-activations.py @@ -359,7 +359,7 @@ node.p2p.send_blocks_and_test(reorg_blocks, node) # reorg finishes after the fork assert_equal(node.getblockheader(node.getbestblockhash())['mediantime'], - ACTIVATION_TIME+2) + ACTIVATION_TIME + 2) # In old mempool: tx_chain2, tx_post1 # Recovered from blocks: tx_chain0, tx_chain1, tx_post0 # Lost from blocks: tx_pre0 diff --git a/test/functional/abc-minimaldata-activation.py b/test/functional/abc-minimaldata-activation.py --- a/test/functional/abc-minimaldata-activation.py +++ b/test/functional/abc-minimaldata-activation.py @@ -165,7 +165,7 @@ # Spend transaction txspend = CTransaction() txspend.vout.append( - CTxOut(value-1000, CScript([OP_TRUE]))) + CTxOut(value - 1000, CScript([OP_TRUE]))) txspend.vin.append( CTxIn(COutPoint(txfund.sha256, 0), b'')) diff --git a/test/functional/abc-schnorr.py b/test/functional/abc-schnorr.py --- a/test/functional/abc-schnorr.py +++ b/test/functional/abc-schnorr.py @@ -56,7 +56,7 @@ # This 64-byte signature is used to test exclusion & banning according to # the above error messages. # Tests of real 64 byte ECDSA signatures can be found in script_tests. -sig64 = b'\0'*64 +sig64 = b'\0' * 64 class SchnorrTest(BitcoinTestFramework): @@ -170,7 +170,7 @@ # Spend transaction txspend = CTransaction() txspend.vout.append( - CTxOut(value-1000, CScript([OP_TRUE]))) + CTxOut(value - 1000, CScript([OP_TRUE]))) txspend.vin.append( CTxIn(COutPoint(txfund.sha256, 0), b'')) diff --git a/test/functional/abc-schnorrmultisig-activation.py b/test/functional/abc-schnorrmultisig-activation.py --- a/test/functional/abc-schnorrmultisig-activation.py +++ b/test/functional/abc-schnorrmultisig-activation.py @@ -73,7 +73,7 @@ # This 64-byte signature is used to test exclusion & banning according to # the above error messages. # Tests of real 64 byte ECDSA signatures can be found in script_tests. -sig64 = b'\0'*64 +sig64 = b'\0' * 64 class SchnorrTest(BitcoinTestFramework): @@ -193,7 +193,7 @@ # Spend transaction txspend = CTransaction() txspend.vout.append( - CTxOut(value-1000, CScript([OP_TRUE]))) + CTxOut(value - 1000, CScript([OP_TRUE]))) txspend.vin.append( CTxIn(COutPoint(txfund.sha256, 0), b'')) diff --git a/test/functional/abc-wallet-standardness.py b/test/functional/abc-wallet-standardness.py --- a/test/functional/abc-wallet-standardness.py +++ b/test/functional/abc-wallet-standardness.py @@ -101,7 +101,7 @@ balance_change = std_node.getbalance() - balance_initial # try spending the funds using the wallet. - outamount = (amount-spendfee) * SATOSHI + outamount = (amount - spendfee) * SATOSHI if outamount < 546 * SATOSHI: # If the final amount would be too small, then just donate # to miner fees. diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py --- a/test/functional/feature_cltv.py +++ b/test/functional/feature_cltv.py @@ -180,7 +180,7 @@ tip = block.hash block_time += 1 block = create_block( - block.sha256, create_coinbase(CLTV_HEIGHT+1), block_time) + block.sha256, create_coinbase(CLTV_HEIGHT + 1), block_time) block.nVersion = 4 block.vtx.append(spendtx) block.hashMerkleRoot = block.calc_merkle_root() diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -41,7 +41,7 @@ # Create the directory and ensure the config file now works os.mkdir(new_data_dir) - self.start_node(0, ['-conf='+conf_file, '-wallet=w1']) + self.start_node(0, ['-conf=' + conf_file, '-wallet=w1']) self.stop_node(0) assert os.path.exists(os.path.join( new_data_dir, 'regtest', 'wallets', 'w1')) @@ -49,8 +49,8 @@ # Ensure command line argument overrides datadir in conf os.mkdir(new_data_dir_2) self.nodes[0].datadir = new_data_dir_2 - self.start_node(0, ['-datadir='+new_data_dir_2, - '-conf='+conf_file, '-wallet=w2']) + self.start_node(0, ['-datadir=' + new_data_dir_2, + '-conf=' + conf_file, '-wallet=w2']) assert os.path.exists(os.path.join( new_data_dir_2, 'regtest', 'wallets', 'w2')) diff --git a/test/functional/feature_minchainwork.py b/test/functional/feature_minchainwork.py --- a/test/functional/feature_minchainwork.py +++ b/test/functional/feature_minchainwork.py @@ -39,8 +39,8 @@ # peers, so ensure that we're mining on an outbound peer and testing # block relay to inbound peers. self.setup_nodes() - for i in range(self.num_nodes-1): - connect_nodes(self.nodes[i+1], self.nodes[i]) + for i in range(self.num_nodes - 1): + connect_nodes(self.nodes[i + 1], self.nodes[i]) def run_test(self): # Start building a chain on node0. node2 shouldn't be able to sync until node1's diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py --- a/test/functional/interface_rest.py +++ b/test/functional/interface_rest.py @@ -280,7 +280,7 @@ hex_response = self.test_rest_request( "/tx/{}".format(tx_hash), req_type=ReqType.HEX, ret_type=RetType.OBJ) assert_greater_than_or_equal( - int(hex_response.getheader('content-length')), json_obj['size']*2) + int(hex_response.getheader('content-length')), json_obj['size'] * 2) self.log.info("Test tx inclusion in the /mempool and /block URIs") diff --git a/test/functional/mining_prioritisetransaction.py b/test/functional/mining_prioritisetransaction.py --- a/test/functional/mining_prioritisetransaction.py +++ b/test/functional/mining_prioritisetransaction.py @@ -84,7 +84,7 @@ # we add the minimum fee back. tx_fee = self.nodes[0].gettransaction(high_fee_tx)['fee'] self.nodes[0].prioritisetransaction( - high_fee_tx, -1e15, int(tx_fee*COIN) + self.nodes[0].calculate_fee_from_txid(high_fee_tx)) + high_fee_tx, -1e15, int(tx_fee * COIN) + self.nodes[0].calculate_fee_from_txid(high_fee_tx)) # Add everything back to mempool self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) diff --git a/test/functional/p2p_unrequested_blocks.py b/test/functional/p2p_unrequested_blocks.py --- a/test/functional/p2p_unrequested_blocks.py +++ b/test/functional/p2p_unrequested_blocks.py @@ -165,7 +165,7 @@ # 4b. Now send another block that builds on the forking chain. block_h3 = create_block( - block_h2f.sha256, create_coinbase(3), block_h2f.nTime+1) + block_h2f.sha256, create_coinbase(3), block_h2f.nTime + 1) block_h3.solve() test_node.send_message(msg_block(block_h3)) @@ -190,7 +190,7 @@ all_blocks = [] for i in range(288): next_block = create_block( - tip.sha256, create_coinbase(i + 4), tip.nTime+1) + tip.sha256, create_coinbase(i + 4), tip.nTime + 1) next_block.solve() all_blocks.append(next_block) tip = next_block @@ -271,20 +271,20 @@ # 8. Create a chain which is invalid at a height longer than the # current chain, but which has more blocks on top of that block_289f = create_block( - all_blocks[284].sha256, create_coinbase(289), all_blocks[284].nTime+1) + all_blocks[284].sha256, create_coinbase(289), all_blocks[284].nTime + 1) block_289f.solve() block_290f = create_block( - block_289f.sha256, create_coinbase(290), block_289f.nTime+1) + block_289f.sha256, create_coinbase(290), block_289f.nTime + 1) block_290f.solve() block_291 = create_block( - block_290f.sha256, create_coinbase(291), block_290f.nTime+1) + block_290f.sha256, create_coinbase(291), block_290f.nTime + 1) # block_291 spends a coinbase below maturity! block_291.vtx.append(create_transaction( block_290f.vtx[0], 0, b"42", 1)) block_291.hashMerkleRoot = block_291.calc_merkle_root() block_291.solve() block_292 = create_block( - block_291.sha256, create_coinbase(292), block_291.nTime+1) + block_291.sha256, create_coinbase(292), block_291.nTime + 1) block_292.solve() # Now send all the headers on the chain and enough blocks to trigger reorg @@ -334,7 +334,7 @@ # Now send a new header on the invalid chain, indicating we're forked off, and expect to get disconnected block_293 = create_block( - block_292.sha256, create_coinbase(293), block_292.nTime+1) + block_292.sha256, create_coinbase(293), block_292.nTime + 1) block_293.solve() headers_message = msg_headers() headers_message.headers.append(CBlockHeader(block_293)) diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -85,7 +85,7 @@ [{"txid": txid, "vout": vout}], [{self.final: outval}]) rawtx2 = node2.signrawtransactionwithkey( - rawtx, self.priv[0:self.nsigs-1], prevtxs) + rawtx, self.priv[0:self.nsigs - 1], prevtxs) rawtx3 = node2.signrawtransactionwithkey( rawtx2["hex"], [self.priv[-1]], prevtxs) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -117,7 +117,7 @@ vout2 = find_output(self.nodes[2], txid2, 13) # Create a psbt spending outputs from nodes 1 and 2 - psbt_orig = self.nodes[0].createpsbt([{"txid": txid1, "vout": vout1}, { + psbt_orig = self.nodes[0].createpsbt([{"txid": txid1, "vout": vout1}, { "txid": txid2, "vout": vout2}], {self.nodes[0].getnewaddress(): 25.999}) # Update psbts, should only have data for one input and not the other diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -388,7 +388,7 @@ self.nodes[0].generate(1) self.sync_all() assert_equal(self.nodes[0].getbalance( - ), bal+Decimal('50.00000000')+Decimal('2.19000000')) # block reward + tx + ), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx # getrawtransaction tests # 1. valid parameters - only supply txid @@ -513,8 +513,9 @@ tx.vout.append(CTxOut(0, b'\x4c\x10TRUNC')) self.nodes[0].decoderawtransaction(ToHex(tx)) # giant pushes and long scripts - tx.vin.append(CTxIn(COutPoint(42, 0), CScript([b'giant push'*10000]))) - tx.vout.append(CTxOut(0, CScript([b'giant push'*10000]))) + tx.vin.append( + CTxIn(COutPoint(42, 0), CScript([b'giant push' * 10000]))) + tx.vout.append(CTxOut(0, CScript([b'giant push' * 10000]))) self.nodes[0].decoderawtransaction(ToHex(tx)) self.log.info('Refuse garbage after transaction') diff --git a/test/functional/rpc_txoutproof.py b/test/functional/rpc_txoutproof.py --- a/test/functional/rpc_txoutproof.py +++ b/test/functional/rpc_txoutproof.py @@ -116,7 +116,7 @@ # single-transaction block tweaked_proof.txn.nTransactions = 1 tweaked_proof.txn.vHash = [tweaked_proof.header.hashMerkleRoot] - tweaked_proof.txn.vBits = [True] + [False]*7 + tweaked_proof.txn.vBits = [True] + [False] * 7 for n in self.nodes: assert not n.verifytxoutproof(ToHex(tweaked_proof)) diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py --- a/test/functional/rpc_users.py +++ b/test/functional/rpc_users.py @@ -46,7 +46,7 @@ with open(os.path.join(get_datadir_path(self.options.tmpdir, 0), "bitcoin.conf"), 'a', encoding='utf8') as f: f.write(rpcauth + "\n") f.write(rpcauth2 + "\n") - f.write(rpcauth3+"\n") + f.write(rpcauth3 + "\n") with open(os.path.join(get_datadir_path(self.options.tmpdir, 1), "bitcoin.conf"), 'a', encoding='utf8') as f: f.write(rpcuser + "\n") f.write(rpcpassword + "\n") diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -177,7 +177,7 @@ def send_big_transactions(node, utxos, num, fee_multiplier): from .cashaddr import decode txids = [] - padding = "1"*512 + padding = "1" * 512 addrHash = decode(node.getnewaddress())[2] for _ in range(num): @@ -186,7 +186,7 @@ txid = int(utxo['txid'], 16) ctx.vin.append(CTxIn(COutPoint(txid, int(utxo["vout"])), b"")) ctx.vout.append( - CTxOut(int(satoshi_round(utxo['amount']*COIN)), + CTxOut(int(satoshi_round(utxo['amount'] * COIN)), CScript([OP_DUP, OP_HASH160, addrHash, OP_EQUALVERIFY, OP_CHECKSIG]))) for i in range(0, 127): ctx.vout.append(CTxOut(0, CScript( diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py --- a/test/functional/test_framework/mininode.py +++ b/test/functional/test_framework/mininode.py @@ -193,16 +193,17 @@ "got garbage {}".format(repr(self.recvbuf))) if len(self.recvbuf) < 4 + 12 + 4 + 4: return None - command = self.recvbuf[4:4+12].split(b"\x00", 1)[0] - msglen = struct.unpack("> 1, e+1 + a1, e = a1 >> 1, e + 1 if e & 1 == 0 or n & 7 == 1 or n & 7 == 7: s = 1 else: @@ -131,13 +131,13 @@ assert len(algo16) in (0, 16) assert len(ndata) in (0, 32) - V = b'\x01'*32 - K = b'\x00'*32 + V = b'\x01' * 32 + K = b'\x00' * 32 blob = bytes(privkeybytes) + msg32 + ndata + algo16 # initialize - K = hmac.HMAC(K, V+b'\x00'+blob, 'sha256').digest() + K = hmac.HMAC(K, V + b'\x00' + blob, 'sha256').digest() V = hmac.HMAC(K, V, 'sha256').digest() - K = hmac.HMAC(K, V+b'\x01'+blob, 'sha256').digest() + K = hmac.HMAC(K, V + b'\x01' + blob, 'sha256').digest() V = hmac.HMAC(K, V, 'sha256').digest() # loop forever until an in-range k is found k = 0 @@ -151,7 +151,7 @@ k = int.from_bytes(T, 'big') if k > 0 and k < SECP256K1_ORDER: break - K = hmac.HMAC(K, V+b'\x00', 'sha256').digest() + K = hmac.HMAC(K, V + b'\x00', 'sha256').digest() V = hmac.HMAC(K, V, 'sha256').digest() return k @@ -202,7 +202,7 @@ rbytes + pubkeybuf + msg32).digest(), 'big') privkey = int.from_bytes(privkeybytes, 'big') - s = (k + e*privkey) % SECP256K1_ORDER + s = (k + e * privkey) % SECP256K1_ORDER return rbytes + s.to_bytes(32, 'big') diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -602,7 +602,7 @@ [test_name + " " + " ".join(p) for p in params]) result = [t for t in tests_with_params if get_test_time(t) <= cutoff] - result.sort(key=lambda x: (-get_test_time(x), x)) + result.sort(key=lambda x: (-get_test_time(x), x)) return result @@ -750,7 +750,7 @@ # we only save test that have passed - timings for failed test might be # wrong (timeouts or early fails) passed_results = [t for t in test_results if t.status == 'Passed'] - new_timings = list(map(lambda t: {'name': t.name, 'time': t.time}, + new_timings = list(map(lambda t: {'name': t.name, 'time': t.time}, passed_results)) merged_timings = self.get_merged_timings(new_timings) diff --git a/test/functional/wallet_groups.py b/test/functional/wallet_groups.py --- a/test/functional/wallet_groups.py +++ b/test/functional/wallet_groups.py @@ -79,7 +79,7 @@ # scriptPubKey for i in range(5): raw_tx = self.nodes[0].createrawtransaction( - [{"txid": "0"*64, "vout": 0}], [{addr2[0]: 0.05}]) + [{"txid": "0" * 64, "vout": 0}], [{addr2[0]: 0.05}]) tx = FromHex(CTransaction(), raw_tx) tx.vin = [] tx.vout = [tx.vout[0]] * 2000