mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #10781: Python cleanups
78214588d
Use for-loop instead of list comprehension (practicalswift)823979436
Use the variable name _ for unused return values (practicalswift)2e6080bbf
Remove unused variables and/or function calls (practicalswift)9b94054b7
Avoid reference to undefined name: stderr does not exist, sys.stderr does (practicalswift)51cb6b822
Use print(...) instead of undefined printf(...) (practicalswift)25cd520fc
Use sys.exit(...) instead of exit(...): exit(...) should not be used in programs (practicalswift) Pull request description: Python cleanups: * Avoid reference to undefined name: `stderr` does not exist, `sys.stderr` does * Use `print(...)` instead of undefined `printf(...)` * Avoid redefinition of variable (`tx`) in list comprehension * Remove unused variables and/or function calls * Use `sys.exit(...)` instead of `exit(...)`: [`exit(...)` should not be used in programs](https://github.com/bitcoin/bitcoin/pull/10753#discussion_r125935027) Tree-SHA512: 1238dfbc1d20f7edadea5e5406a589f293065638f6234809f0d5b6ba746dffe3d276bc5884c7af388a6c798c61a8759faaccf57f381225644754c0f61914eb4b
This commit is contained in:
parent
62b2f3a317
commit
561ec27683
@ -12,6 +12,7 @@ Author: @MarcoFalke
|
|||||||
|
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
FOLDER_GREP = 'src'
|
FOLDER_GREP = 'src'
|
||||||
FOLDER_TEST = 'src/test/'
|
FOLDER_TEST = 'src/test/'
|
||||||
@ -39,7 +40,7 @@ def main():
|
|||||||
print("Args unknown : {}".format(len(args_unknown)))
|
print("Args unknown : {}".format(len(args_unknown)))
|
||||||
print(args_unknown)
|
print(args_unknown)
|
||||||
|
|
||||||
exit(len(args_need_doc))
|
sys.exit(len(args_need_doc))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -20,6 +20,7 @@ from sys import stdin,stdout,stderr
|
|||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import json,codecs
|
import json,codecs
|
||||||
try:
|
try:
|
||||||
from urllib.request import Request,urlopen
|
from urllib.request import Request,urlopen
|
||||||
@ -158,11 +159,11 @@ def main():
|
|||||||
if repo is None:
|
if repo is None:
|
||||||
print("ERROR: No repository configured. Use this command to set:", file=stderr)
|
print("ERROR: No repository configured. Use this command to set:", file=stderr)
|
||||||
print("git config githubmerge.repository <owner>/<repo>", file=stderr)
|
print("git config githubmerge.repository <owner>/<repo>", file=stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
if signingkey is None:
|
if signingkey is None:
|
||||||
print("ERROR: No GPG signing key set. Set one using:",file=stderr)
|
print("ERROR: No GPG signing key set. Set one using:",file=stderr)
|
||||||
print("git config --global user.signingkey <key>",file=stderr)
|
print("git config --global user.signingkey <key>",file=stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
host_repo = host+":"+repo # shortcut for push/pull target
|
host_repo = host+":"+repo # shortcut for push/pull target
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ def main():
|
|||||||
# Receive pull information from github
|
# Receive pull information from github
|
||||||
info = retrieve_pr_info(repo,pull)
|
info = retrieve_pr_info(repo,pull)
|
||||||
if info is None:
|
if info is None:
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
title = info['title'].strip()
|
title = info['title'].strip()
|
||||||
body = info['body'].strip()
|
body = info['body'].strip()
|
||||||
# precedence order for destination branch argument:
|
# precedence order for destination branch argument:
|
||||||
@ -194,27 +195,27 @@ def main():
|
|||||||
subprocess.check_call([GIT,'checkout','-q',branch])
|
subprocess.check_call([GIT,'checkout','-q',branch])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot check out branch %s." % (branch), file=stderr)
|
print("ERROR: Cannot check out branch %s." % (branch), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/pull/'+pull+'/*:refs/heads/pull/'+pull+'/*'])
|
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/pull/'+pull+'/*:refs/heads/pull/'+pull+'/*'])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot find pull request #%s on %s." % (pull,host_repo), file=stderr)
|
print("ERROR: Cannot find pull request #%s on %s." % (pull,host_repo), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+head_branch], stdout=devnull, stderr=stdout)
|
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+head_branch], stdout=devnull, stderr=stdout)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot find head of pull request #%s on %s." % (pull,host_repo), file=stderr)
|
print("ERROR: Cannot find head of pull request #%s on %s." % (pull,host_repo), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+merge_branch], stdout=devnull, stderr=stdout)
|
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+merge_branch], stdout=devnull, stderr=stdout)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot find merge of pull request #%s on %s." % (pull,host_repo), file=stderr)
|
print("ERROR: Cannot find merge of pull request #%s on %s." % (pull,host_repo), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/heads/'+branch+':refs/heads/'+base_branch])
|
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/heads/'+branch+':refs/heads/'+base_branch])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot find branch %s on %s." % (branch,host_repo), file=stderr)
|
print("ERROR: Cannot find branch %s on %s." % (branch,host_repo), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
subprocess.check_call([GIT,'checkout','-q',base_branch])
|
subprocess.check_call([GIT,'checkout','-q',base_branch])
|
||||||
subprocess.call([GIT,'branch','-q','-D',local_merge_branch], stderr=devnull)
|
subprocess.call([GIT,'branch','-q','-D',local_merge_branch], stderr=devnull)
|
||||||
subprocess.check_call([GIT,'checkout','-q','-b',local_merge_branch])
|
subprocess.check_call([GIT,'checkout','-q','-b',local_merge_branch])
|
||||||
@ -236,30 +237,30 @@ def main():
|
|||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot be merged cleanly.",file=stderr)
|
print("ERROR: Cannot be merged cleanly.",file=stderr)
|
||||||
subprocess.check_call([GIT,'merge','--abort'])
|
subprocess.check_call([GIT,'merge','--abort'])
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
logmsg = subprocess.check_output([GIT,'log','--pretty=format:%s','-n','1']).decode('utf-8')
|
logmsg = subprocess.check_output([GIT,'log','--pretty=format:%s','-n','1']).decode('utf-8')
|
||||||
if logmsg.rstrip() != firstline.rstrip():
|
if logmsg.rstrip() != firstline.rstrip():
|
||||||
print("ERROR: Creating merge failed (already merged?).",file=stderr)
|
print("ERROR: Creating merge failed (already merged?).",file=stderr)
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
|
|
||||||
symlink_files = get_symlink_files()
|
symlink_files = get_symlink_files()
|
||||||
for f in symlink_files:
|
for f in symlink_files:
|
||||||
print("ERROR: File %s was a symlink" % f)
|
print("ERROR: File %s was a symlink" % f)
|
||||||
if len(symlink_files) > 0:
|
if len(symlink_files) > 0:
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
|
|
||||||
# Put tree SHA512 into the message
|
# Put tree SHA512 into the message
|
||||||
try:
|
try:
|
||||||
first_sha512 = tree_sha512sum()
|
first_sha512 = tree_sha512sum()
|
||||||
message += '\n\nTree-SHA512: ' + first_sha512
|
message += '\n\nTree-SHA512: ' + first_sha512
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
printf("ERROR: Unable to compute tree hash")
|
print("ERROR: Unable to compute tree hash")
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'commit','--amend','-m',message.encode('utf-8')])
|
subprocess.check_call([GIT,'commit','--amend','-m',message.encode('utf-8')])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
printf("ERROR: Cannot update message.",file=stderr)
|
print("ERROR: Cannot update message.", file=stderr)
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
|
|
||||||
print_merge_details(pull, title, branch, base_branch, head_branch)
|
print_merge_details(pull, title, branch, base_branch, head_branch)
|
||||||
print()
|
print()
|
||||||
@ -268,7 +269,7 @@ def main():
|
|||||||
if testcmd:
|
if testcmd:
|
||||||
if subprocess.call(testcmd,shell=True):
|
if subprocess.call(testcmd,shell=True):
|
||||||
print("ERROR: Running %s failed." % testcmd,file=stderr)
|
print("ERROR: Running %s failed." % testcmd,file=stderr)
|
||||||
exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
# Show the created merge.
|
# Show the created merge.
|
||||||
diff = subprocess.check_output([GIT,'diff',merge_branch+'..'+local_merge_branch])
|
diff = subprocess.check_output([GIT,'diff',merge_branch+'..'+local_merge_branch])
|
||||||
@ -279,7 +280,7 @@ def main():
|
|||||||
if reply.lower() == 'ignore':
|
if reply.lower() == 'ignore':
|
||||||
print("Difference with github ignored.",file=stderr)
|
print("Difference with github ignored.",file=stderr)
|
||||||
else:
|
else:
|
||||||
exit(6)
|
sys.exit(6)
|
||||||
else:
|
else:
|
||||||
# Verify the result manually.
|
# Verify the result manually.
|
||||||
print("Dropping you on a shell so you can try building/testing the merged source.",file=stderr)
|
print("Dropping you on a shell so you can try building/testing the merged source.",file=stderr)
|
||||||
@ -292,7 +293,7 @@ def main():
|
|||||||
second_sha512 = tree_sha512sum()
|
second_sha512 = tree_sha512sum()
|
||||||
if first_sha512 != second_sha512:
|
if first_sha512 != second_sha512:
|
||||||
print("ERROR: Tree hash changed unexpectedly",file=stderr)
|
print("ERROR: Tree hash changed unexpectedly",file=stderr)
|
||||||
exit(8)
|
sys.exit(8)
|
||||||
|
|
||||||
# Sign the merge commit.
|
# Sign the merge commit.
|
||||||
print_merge_details(pull, title, branch, base_branch, head_branch)
|
print_merge_details(pull, title, branch, base_branch, head_branch)
|
||||||
@ -306,7 +307,7 @@ def main():
|
|||||||
print("Error while signing, asking again.",file=stderr)
|
print("Error while signing, asking again.",file=stderr)
|
||||||
elif reply == 'x':
|
elif reply == 'x':
|
||||||
print("Not signing off on merge, exiting.",file=stderr)
|
print("Not signing off on merge, exiting.",file=stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Put the result in branch.
|
# Put the result in branch.
|
||||||
subprocess.check_call([GIT,'checkout','-q',branch])
|
subprocess.check_call([GIT,'checkout','-q',branch])
|
||||||
@ -326,7 +327,7 @@ def main():
|
|||||||
subprocess.check_call([GIT,'push',host_repo,'refs/heads/'+branch])
|
subprocess.check_call([GIT,'push',host_repo,'refs/heads/'+branch])
|
||||||
break
|
break
|
||||||
elif reply == 'x':
|
elif reply == 'x':
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -211,5 +211,5 @@ if __name__ == '__main__':
|
|||||||
except IOError:
|
except IOError:
|
||||||
print('%s: cannot open' % filename)
|
print('%s: cannot open' % filename)
|
||||||
retval = 1
|
retval = 1
|
||||||
exit(retval)
|
sys.exit(retval)
|
||||||
|
|
||||||
|
@ -158,6 +158,6 @@ if __name__ == '__main__':
|
|||||||
print('%s: NEEDED library %s is not allowed' % (filename, library_name))
|
print('%s: NEEDED library %s is not allowed' % (filename, library_name))
|
||||||
retval = 1
|
retval = 1
|
||||||
|
|
||||||
exit(retval)
|
sys.exit(retval)
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ def check_at_repository_root():
|
|||||||
if not os.path.exists('.git'):
|
if not os.path.exists('.git'):
|
||||||
print('No .git directory found')
|
print('No .git directory found')
|
||||||
print('Execute this script at the root of the repository', file=sys.stderr)
|
print('Execute this script at the root of the repository', file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def fetch_all_translations():
|
def fetch_all_translations():
|
||||||
if subprocess.call([TX, 'pull', '-f', '-a']):
|
if subprocess.call([TX, 'pull', '-f', '-a']):
|
||||||
print('Error while fetching translations', file=sys.stderr)
|
print('Error while fetching translations', file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def find_format_specifiers(s):
|
def find_format_specifiers(s):
|
||||||
'''Find all format specifiers in a string.'''
|
'''Find all format specifiers in a string.'''
|
||||||
|
@ -87,7 +87,7 @@ def get_block_hashes(settings, max_blocks_per_call=10000):
|
|||||||
for x,resp_obj in enumerate(reply):
|
for x,resp_obj in enumerate(reply):
|
||||||
if rpc.response_is_error(resp_obj):
|
if rpc.response_is_error(resp_obj):
|
||||||
print('JSON-RPC: error at height', height+x, ': ', resp_obj['error'], file=sys.stderr)
|
print('JSON-RPC: error at height', height+x, ': ', resp_obj['error'], file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
assert(resp_obj['id'] == x) # assume replies are in-sequence
|
assert(resp_obj['id'] == x) # assume replies are in-sequence
|
||||||
if settings['rev_hash_bytes'] == 'true':
|
if settings['rev_hash_bytes'] == 'true':
|
||||||
resp_obj['result'] = hex_switchEndian(resp_obj['result'])
|
resp_obj['result'] = hex_switchEndian(resp_obj['result'])
|
||||||
@ -140,7 +140,7 @@ if __name__ == '__main__':
|
|||||||
if 'datadir' in settings and not use_userpass:
|
if 'datadir' in settings and not use_userpass:
|
||||||
use_datadir = True
|
use_datadir = True
|
||||||
if not use_userpass and not use_datadir:
|
if not use_userpass and not use_datadir:
|
||||||
print("Missing datadir or username and/or password in cfg file", file=stderr)
|
print("Missing datadir or username and/or password in cfg file", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
settings['port'] = int(settings['port'])
|
settings['port'] = int(settings['port'])
|
||||||
|
@ -114,7 +114,7 @@ def process_nodes(g, f, structname, defaultport):
|
|||||||
def main():
|
def main():
|
||||||
if len(sys.argv)<2:
|
if len(sys.argv)<2:
|
||||||
print(('Usage: %s <path_to_nodes_txt>' % sys.argv[0]), file=sys.stderr)
|
print(('Usage: %s <path_to_nodes_txt>' % sys.argv[0]), file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
g = sys.stdout
|
g = sys.stdout
|
||||||
indir = sys.argv[1]
|
indir = sys.argv[1]
|
||||||
g.write('#ifndef DASH_CHAINPARAMSSEEDS_H\n')
|
g.write('#ifndef DASH_CHAINPARAMSSEEDS_H\n')
|
||||||
|
@ -32,7 +32,7 @@ import sys
|
|||||||
|
|
||||||
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 5):
|
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 5):
|
||||||
print("This example only works with Python 3.5 and greater")
|
print("This example only works with Python 3.5 and greater")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
port = 28332
|
port = 28332
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import sys
|
|||||||
|
|
||||||
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 4):
|
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 4):
|
||||||
print("This example only works with Python 3.4 and greater")
|
print("This example only works with Python 3.4 and greater")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
port = 28332
|
port = 28332
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ XGETTEXT=os.getenv('XGETTEXT', 'xgettext')
|
|||||||
if not XGETTEXT:
|
if not XGETTEXT:
|
||||||
print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr)
|
print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr)
|
||||||
print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr)
|
print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE)
|
child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE)
|
||||||
(out, err) = child.communicate()
|
(out, err) = child.communicate()
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ class BIP68Test(BitcoinTestFramework):
|
|||||||
tx = FromHex(CTransaction(), rawtxfund)
|
tx = FromHex(CTransaction(), rawtxfund)
|
||||||
tx.nVersion = 2
|
tx.nVersion = 2
|
||||||
tx_signed = self.nodes[1].signrawtransaction(ToHex(tx))["hex"]
|
tx_signed = self.nodes[1].signrawtransaction(ToHex(tx))["hex"]
|
||||||
tx_id = self.nodes[1].sendrawtransaction(tx_signed)
|
self.nodes[1].sendrawtransaction(tx_signed)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
BIP68Test().main()
|
BIP68Test().main()
|
||||||
|
@ -310,7 +310,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
##############################################
|
##############################################
|
||||||
# test a fundrawtransaction with invalid vin #
|
# test a fundrawtransaction with invalid vin #
|
||||||
##############################################
|
##############################################
|
||||||
listunspent = self.nodes[2].listunspent()
|
|
||||||
inputs = [ {'txid' : "1c7f966dab21119bac53213a2bc7532bff1fa844c124fd750a7d0b1332440bd1", 'vout' : 0} ] #invalid vin!
|
inputs = [ {'txid' : "1c7f966dab21119bac53213a2bc7532bff1fa844c124fd750a7d0b1332440bd1", 'vout' : 0} ] #invalid vin!
|
||||||
outputs = { self.nodes[0].getnewaddress() : 10}
|
outputs = { self.nodes[0].getnewaddress() : 10}
|
||||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
|
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||||
|
@ -167,7 +167,6 @@ class ImportRescanTest(BitcoinTestFramework):
|
|||||||
variant.check()
|
variant.check()
|
||||||
|
|
||||||
# Create new transactions sending to each address.
|
# Create new transactions sending to each address.
|
||||||
fee = self.nodes[0].getnetworkinfo()["relayfee"]
|
|
||||||
for i, variant in enumerate(IMPORT_VARIANTS):
|
for i, variant in enumerate(IMPORT_VARIANTS):
|
||||||
variant.sent_amount = 10 - (2 * i + 1) / 8.0
|
variant.sent_amount = 10 - (2 * i + 1) / 8.0
|
||||||
variant.sent_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.sent_amount)
|
variant.sent_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.sent_amount)
|
||||||
|
@ -20,16 +20,7 @@ class ImportMultiTest (BitcoinTestFramework):
|
|||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||||
|
|
||||||
# keyword definition
|
|
||||||
PRIV_KEY = 'privkey'
|
|
||||||
PUB_KEY = 'pubkey'
|
|
||||||
ADDRESS_KEY = 'address'
|
|
||||||
SCRIPT_KEY = 'script'
|
|
||||||
|
|
||||||
|
|
||||||
node0_address1 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
|
node0_address1 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
|
||||||
node0_address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
|
|
||||||
node0_address3 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
|
|
||||||
|
|
||||||
#Check only one address
|
#Check only one address
|
||||||
assert_equal(node0_address1['ismine'], True)
|
assert_equal(node0_address1['ismine'], True)
|
||||||
@ -241,7 +232,6 @@ class ImportMultiTest (BitcoinTestFramework):
|
|||||||
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
|
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||||
transaction = self.nodes[1].gettransaction(transactionid)
|
|
||||||
|
|
||||||
self.log.info("Should import a p2sh")
|
self.log.info("Should import a p2sh")
|
||||||
result = self.nodes[1].importmulti([{
|
result = self.nodes[1].importmulti([{
|
||||||
@ -269,7 +259,6 @@ class ImportMultiTest (BitcoinTestFramework):
|
|||||||
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
|
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||||
transaction = self.nodes[1].gettransaction(transactionid)
|
|
||||||
|
|
||||||
self.log.info("Should import a p2sh with respective redeem script")
|
self.log.info("Should import a p2sh with respective redeem script")
|
||||||
result = self.nodes[1].importmulti([{
|
result = self.nodes[1].importmulti([{
|
||||||
@ -297,7 +286,6 @@ class ImportMultiTest (BitcoinTestFramework):
|
|||||||
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
|
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||||
transaction = self.nodes[1].gettransaction(transactionid)
|
|
||||||
|
|
||||||
self.log.info("Should import a p2sh with respective redeem script and private keys")
|
self.log.info("Should import a p2sh with respective redeem script and private keys")
|
||||||
result = self.nodes[1].importmulti([{
|
result = self.nodes[1].importmulti([{
|
||||||
@ -325,7 +313,6 @@ class ImportMultiTest (BitcoinTestFramework):
|
|||||||
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
|
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||||
transaction = self.nodes[1].gettransaction(transactionid)
|
|
||||||
|
|
||||||
self.log.info("Should import a p2sh with respective redeem script and private keys")
|
self.log.info("Should import a p2sh with respective redeem script and private keys")
|
||||||
result = self.nodes[1].importmulti([{
|
result = self.nodes[1].importmulti([{
|
||||||
|
@ -21,7 +21,6 @@ class ImportPrunedFundsTest(BitcoinTestFramework):
|
|||||||
address1 = self.nodes[0].getnewaddress()
|
address1 = self.nodes[0].getnewaddress()
|
||||||
# pubkey
|
# pubkey
|
||||||
address2 = self.nodes[0].getnewaddress()
|
address2 = self.nodes[0].getnewaddress()
|
||||||
address2_pubkey = self.nodes[0].validateaddress(address2)['pubkey'] # Using pubkey
|
|
||||||
# privkey
|
# privkey
|
||||||
address3 = self.nodes[0].getnewaddress()
|
address3 = self.nodes[0].getnewaddress()
|
||||||
address3_privkey = self.nodes[0].dumpprivkey(address3) # Using privkey
|
address3_privkey = self.nodes[0].dumpprivkey(address3) # Using privkey
|
||||||
@ -74,13 +73,13 @@ class ImportPrunedFundsTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
#Import with affiliated address with no rescan
|
#Import with affiliated address with no rescan
|
||||||
self.nodes[1].importaddress(address2, "add2", False)
|
self.nodes[1].importaddress(address2, "add2", False)
|
||||||
result2 = self.nodes[1].importprunedfunds(rawtxn2, proof2)
|
self.nodes[1].importprunedfunds(rawtxn2, proof2)
|
||||||
balance2 = self.nodes[1].getbalance("add2", 0, False, True)
|
balance2 = self.nodes[1].getbalance("add2", 0, False, True)
|
||||||
assert_equal(balance2, Decimal('0.05'))
|
assert_equal(balance2, Decimal('0.05'))
|
||||||
|
|
||||||
#Import with private key with no rescan
|
#Import with private key with no rescan
|
||||||
self.nodes[1].importprivkey(privkey=address3_privkey, label="add3", rescan=False)
|
self.nodes[1].importprivkey(privkey=address3_privkey, label="add3", rescan=False)
|
||||||
result3 = self.nodes[1].importprunedfunds(rawtxn3, proof3)
|
self.nodes[1].importprunedfunds(rawtxn3, proof3)
|
||||||
balance3 = self.nodes[1].getbalance("add3", 0, False, False)
|
balance3 = self.nodes[1].getbalance("add3", 0, False, False)
|
||||||
assert_equal(balance3, Decimal('0.025'))
|
assert_equal(balance3, Decimal('0.025'))
|
||||||
balance3 = self.nodes[1].getbalance("*", 0, False, True)
|
balance3 = self.nodes[1].getbalance("*", 0, False, True)
|
||||||
|
@ -211,7 +211,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
|||||||
value = send_value
|
value = send_value
|
||||||
|
|
||||||
# Create tx1
|
# Create tx1
|
||||||
(tx1_id, tx1_value) = self.chain_transaction(self.nodes[0], tx0_id, 0, value, fee, 1)
|
tx1_id, _ = self.chain_transaction(self.nodes[0], tx0_id, 0, value, fee, 1)
|
||||||
|
|
||||||
# Create tx2-7
|
# Create tx2-7
|
||||||
vout = 1
|
vout = 1
|
||||||
|
@ -258,7 +258,8 @@ class CompactBlocksTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Store the raw block in our internal format.
|
# Store the raw block in our internal format.
|
||||||
block = FromHex(CBlock(), node.getblock("%02x" % block_hash, False))
|
block = FromHex(CBlock(), node.getblock("%02x" % block_hash, False))
|
||||||
[tx.calc_sha256() for tx in block.vtx]
|
for tx in block.vtx:
|
||||||
|
tx.calc_sha256()
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
|
||||||
# Wait until the block was announced (via compact blocks)
|
# Wait until the block was announced (via compact blocks)
|
||||||
|
@ -398,7 +398,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
yield rejected(RejectResult(16, b'bad-cb-length'))
|
yield rejected(RejectResult(16, b'bad-cb-length'))
|
||||||
|
|
||||||
# Extend the b26 chain to make sure bitcoind isn't accepting b26
|
# Extend the b26 chain to make sure bitcoind isn't accepting b26
|
||||||
b27 = block(27, spend=out[7])
|
block(27, spend=out[7])
|
||||||
yield rejected(False)
|
yield rejected(False)
|
||||||
|
|
||||||
# Now try a too-large-coinbase script
|
# Now try a too-large-coinbase script
|
||||||
@ -410,7 +410,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
yield rejected(RejectResult(16, b'bad-cb-length'))
|
yield rejected(RejectResult(16, b'bad-cb-length'))
|
||||||
|
|
||||||
# Extend the b28 chain to make sure bitcoind isn't accepting b28
|
# Extend the b28 chain to make sure bitcoind isn't accepting b28
|
||||||
b29 = block(29, spend=out[7])
|
block(29, spend=out[7])
|
||||||
yield rejected(False)
|
yield rejected(False)
|
||||||
|
|
||||||
# b30 has a max-sized coinbase scriptSig.
|
# b30 has a max-sized coinbase scriptSig.
|
||||||
@ -582,7 +582,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
|
|
||||||
# same as b40, but one less sigop
|
# same as b40, but one less sigop
|
||||||
tip(39)
|
tip(39)
|
||||||
b41 = block(41, spend=None)
|
block(41, spend=None)
|
||||||
update_block(41, b40.vtx[1:-1])
|
update_block(41, b40.vtx[1:-1])
|
||||||
b41_sigops_to_fill = b40_sigops_to_fill - 1
|
b41_sigops_to_fill = b40_sigops_to_fill - 1
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
@ -928,7 +928,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
# -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) -> b65 (19)
|
# -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) -> b65 (19)
|
||||||
#
|
#
|
||||||
tip(64)
|
tip(64)
|
||||||
b65 = block(65)
|
block(65)
|
||||||
tx1 = create_and_sign_tx(out[19].tx, out[19].n, out[19].tx.vout[0].nValue)
|
tx1 = create_and_sign_tx(out[19].tx, out[19].n, out[19].tx.vout[0].nValue)
|
||||||
tx2 = create_and_sign_tx(tx1, 0, 0)
|
tx2 = create_and_sign_tx(tx1, 0, 0)
|
||||||
update_block(65, [tx1, tx2])
|
update_block(65, [tx1, tx2])
|
||||||
@ -940,7 +940,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
# -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) -> b65 (19)
|
# -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) -> b65 (19)
|
||||||
# \-> b66 (20)
|
# \-> b66 (20)
|
||||||
tip(65)
|
tip(65)
|
||||||
b66 = block(66)
|
block(66)
|
||||||
tx1 = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue)
|
tx1 = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue)
|
||||||
tx2 = create_and_sign_tx(tx1, 0, 1)
|
tx2 = create_and_sign_tx(tx1, 0, 1)
|
||||||
update_block(66, [tx2, tx1])
|
update_block(66, [tx2, tx1])
|
||||||
@ -953,7 +953,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
tip(65)
|
tip(65)
|
||||||
b67 = block(67)
|
block(67)
|
||||||
tx1 = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue)
|
tx1 = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue)
|
||||||
tx2 = create_and_sign_tx(tx1, 0, 1)
|
tx2 = create_and_sign_tx(tx1, 0, 1)
|
||||||
tx3 = create_and_sign_tx(tx1, 0, 2)
|
tx3 = create_and_sign_tx(tx1, 0, 2)
|
||||||
@ -973,7 +973,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
# this succeeds
|
# this succeeds
|
||||||
#
|
#
|
||||||
tip(65)
|
tip(65)
|
||||||
b68 = block(68, additional_coinbase_value=10)
|
block(68, additional_coinbase_value=10)
|
||||||
tx = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue-9)
|
tx = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue-9)
|
||||||
update_block(68, [tx])
|
update_block(68, [tx])
|
||||||
yield rejected(RejectResult(16, b'bad-cb-amount'))
|
yield rejected(RejectResult(16, b'bad-cb-amount'))
|
||||||
@ -1176,7 +1176,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
#
|
#
|
||||||
# -> b81 (26) -> b82 (27) -> b83 (28)
|
# -> b81 (26) -> b82 (27) -> b83 (28)
|
||||||
#
|
#
|
||||||
b83 = block(83)
|
block(83)
|
||||||
op_codes = [OP_IF, OP_INVALIDOPCODE, OP_ELSE, OP_TRUE, OP_ENDIF]
|
op_codes = [OP_IF, OP_INVALIDOPCODE, OP_ELSE, OP_TRUE, OP_ENDIF]
|
||||||
script = CScript(op_codes)
|
script = CScript(op_codes)
|
||||||
tx1 = create_and_sign_tx(out[28].tx, out[28].n, out[28].tx.vout[0].nValue, script)
|
tx1 = create_and_sign_tx(out[28].tx, out[28].n, out[28].tx.vout[0].nValue, script)
|
||||||
@ -1196,7 +1196,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||||||
# \-> b85 (29) -> b86 (30) \-> b89a (32)
|
# \-> b85 (29) -> b86 (30) \-> b89a (32)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
b84 = block(84)
|
block(84)
|
||||||
tx1 = create_tx(out[29].tx, out[29].n, 0, CScript([OP_RETURN]))
|
tx1 = create_tx(out[29].tx, out[29].n, 0, CScript([OP_RETURN]))
|
||||||
tx1.vout.append(CTxOut(0, CScript([OP_TRUE])))
|
tx1.vout.append(CTxOut(0, CScript([OP_TRUE])))
|
||||||
tx1.vout.append(CTxOut(0, CScript([OP_TRUE])))
|
tx1.vout.append(CTxOut(0, CScript([OP_TRUE])))
|
||||||
|
@ -46,16 +46,16 @@ class PreciousTest(BitcoinTestFramework):
|
|||||||
self.log.info("Ensure submitblock can in principle reorg to a competing chain")
|
self.log.info("Ensure submitblock can in principle reorg to a competing chain")
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
assert_equal(self.nodes[0].getblockcount(), 1)
|
assert_equal(self.nodes[0].getblockcount(), 1)
|
||||||
(hashY, hashZ) = self.nodes[1].generate(2)
|
hashZ = self.nodes[1].generate(2)[-1]
|
||||||
assert_equal(self.nodes[1].getblockcount(), 2)
|
assert_equal(self.nodes[1].getblockcount(), 2)
|
||||||
node_sync_via_rpc(self.nodes[0:3])
|
node_sync_via_rpc(self.nodes[0:3])
|
||||||
assert_equal(self.nodes[0].getbestblockhash(), hashZ)
|
assert_equal(self.nodes[0].getbestblockhash(), hashZ)
|
||||||
|
|
||||||
self.log.info("Mine blocks A-B-C on Node 0")
|
self.log.info("Mine blocks A-B-C on Node 0")
|
||||||
(hashA, hashB, hashC) = self.nodes[0].generate(3)
|
hashC = self.nodes[0].generate(3)[-1]
|
||||||
assert_equal(self.nodes[0].getblockcount(), 5)
|
assert_equal(self.nodes[0].getblockcount(), 5)
|
||||||
self.log.info("Mine competing blocks E-F-G on Node 1")
|
self.log.info("Mine competing blocks E-F-G on Node 1")
|
||||||
(hashE, hashF, hashG) = self.nodes[1].generate(3)
|
hashG = self.nodes[1].generate(3)[-1]
|
||||||
assert_equal(self.nodes[1].getblockcount(), 5)
|
assert_equal(self.nodes[1].getblockcount(), 5)
|
||||||
assert(hashC != hashG)
|
assert(hashC != hashG)
|
||||||
self.log.info("Connect nodes and check no reorg occurs")
|
self.log.info("Connect nodes and check no reorg occurs")
|
||||||
|
@ -61,7 +61,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
addr2Obj = self.nodes[2].validateaddress(addr2)
|
addr2Obj = self.nodes[2].validateaddress(addr2)
|
||||||
|
|
||||||
mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey']])
|
mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey']])
|
||||||
mSigObjValid = self.nodes[2].validateaddress(mSigObj)
|
|
||||||
|
|
||||||
#use balance deltas instead of absolute values
|
#use balance deltas instead of absolute values
|
||||||
bal = self.nodes[2].getbalance()
|
bal = self.nodes[2].getbalance()
|
||||||
@ -85,7 +84,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
addr3Obj = self.nodes[2].validateaddress(addr3)
|
addr3Obj = self.nodes[2].validateaddress(addr3)
|
||||||
|
|
||||||
mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey']])
|
mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey']])
|
||||||
mSigObjValid = self.nodes[2].validateaddress(mSigObj)
|
|
||||||
|
|
||||||
txId = self.nodes[0].sendtoaddress(mSigObj, 2.2)
|
txId = self.nodes[0].sendtoaddress(mSigObj, 2.2)
|
||||||
decTx = self.nodes[0].gettransaction(txId)
|
decTx = self.nodes[0].gettransaction(txId)
|
||||||
|
@ -26,12 +26,6 @@ def bn2bin(v):
|
|||||||
i -= 1
|
i -= 1
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def bin2bn(s):
|
|
||||||
l = 0
|
|
||||||
for ch in s:
|
|
||||||
l = (l << 8) | ch
|
|
||||||
return l
|
|
||||||
|
|
||||||
def bn2mpi(v):
|
def bn2mpi(v):
|
||||||
have_ext = False
|
have_ext = False
|
||||||
if v.bit_length() > 0:
|
if v.bit_length() > 0:
|
||||||
@ -54,30 +48,6 @@ def bn2mpi(v):
|
|||||||
v_bin[0] |= 0x80
|
v_bin[0] |= 0x80
|
||||||
return s + ext + v_bin
|
return s + ext + v_bin
|
||||||
|
|
||||||
def mpi2bn(s):
|
|
||||||
if len(s) < 4:
|
|
||||||
return None
|
|
||||||
s_size = bytes(s[:4])
|
|
||||||
v_len = struct.unpack(b">I", s_size)[0]
|
|
||||||
if len(s) != (v_len + 4):
|
|
||||||
return None
|
|
||||||
if v_len == 0:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
v_str = bytearray(s[4:])
|
|
||||||
neg = False
|
|
||||||
i = v_str[0]
|
|
||||||
if i & 0x80:
|
|
||||||
neg = True
|
|
||||||
i &= ~0x80
|
|
||||||
v_str[0] = i
|
|
||||||
|
|
||||||
v = bin2bn(v_str)
|
|
||||||
|
|
||||||
if neg:
|
|
||||||
return -v
|
|
||||||
return v
|
|
||||||
|
|
||||||
# bitcoin-specific little endian format, with implicit size
|
# bitcoin-specific little endian format, with implicit size
|
||||||
def mpi2vch(s):
|
def mpi2vch(s):
|
||||||
r = s[4:] # strip size
|
r = s[4:] # strip size
|
||||||
@ -86,12 +56,3 @@ def mpi2vch(s):
|
|||||||
|
|
||||||
def bn2vch(v):
|
def bn2vch(v):
|
||||||
return bytes(mpi2vch(bn2mpi(v)))
|
return bytes(mpi2vch(bn2mpi(v)))
|
||||||
|
|
||||||
def vch2mpi(s):
|
|
||||||
r = struct.pack(b">I", len(s)) # size
|
|
||||||
r += s[::-1] # reverse string, converting LE->BE
|
|
||||||
return r
|
|
||||||
|
|
||||||
def vch2bn(s):
|
|
||||||
return mpi2bn(vch2mpi(s))
|
|
||||||
|
|
||||||
|
@ -143,16 +143,6 @@ class TxStore(object):
|
|||||||
return None
|
return None
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def get_transaction(self, txhash):
|
|
||||||
ret = None
|
|
||||||
serialized_tx = self.get(txhash)
|
|
||||||
if serialized_tx is not None:
|
|
||||||
f = BytesIO(serialized_tx)
|
|
||||||
ret = CTransaction()
|
|
||||||
ret.deserialize(f)
|
|
||||||
ret.calc_sha256()
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def add_transaction(self, tx):
|
def add_transaction(self, tx):
|
||||||
tx.calc_sha256()
|
tx.calc_sha256()
|
||||||
try:
|
try:
|
||||||
|
@ -54,8 +54,8 @@ MAX_BLOCK_SIZE = 1000000
|
|||||||
COIN = 100000000 # 1 btc in satoshis
|
COIN = 100000000 # 1 btc in satoshis
|
||||||
|
|
||||||
NODE_NETWORK = (1 << 0)
|
NODE_NETWORK = (1 << 0)
|
||||||
NODE_GETUTXO = (1 << 1)
|
# NODE_GETUTXO = (1 << 1)
|
||||||
NODE_BLOOM = (1 << 2)
|
# NODE_BLOOM = (1 << 2)
|
||||||
|
|
||||||
MSG_TX = 1
|
MSG_TX = 1
|
||||||
MSG_BLOCK = 2
|
MSG_BLOCK = 2
|
||||||
@ -1516,9 +1516,6 @@ class NodeConnCB(object):
|
|||||||
# before acquiring the global lock and delivering the next message.
|
# before acquiring the global lock and delivering the next message.
|
||||||
self.deliver_sleep_time = None
|
self.deliver_sleep_time = None
|
||||||
|
|
||||||
# Remember the services our peer has advertised
|
|
||||||
self.peer_services = None
|
|
||||||
|
|
||||||
# Message receiving methods
|
# Message receiving methods
|
||||||
|
|
||||||
def deliver(self, conn, message):
|
def deliver(self, conn, message):
|
||||||
@ -1544,10 +1541,6 @@ class NodeConnCB(object):
|
|||||||
sys.exc_info()[0]))
|
sys.exc_info()[0]))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def set_deliver_sleep_time(self, value):
|
|
||||||
with mininode_lock:
|
|
||||||
self.deliver_sleep_time = value
|
|
||||||
|
|
||||||
def get_deliver_sleep_time(self):
|
def get_deliver_sleep_time(self):
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
return self.deliver_sleep_time
|
return self.deliver_sleep_time
|
||||||
|
@ -15,17 +15,17 @@ import array
|
|||||||
import os
|
import os
|
||||||
from binascii import unhexlify, hexlify
|
from binascii import unhexlify, hexlify
|
||||||
|
|
||||||
STATE_ESTABLISHED = '01'
|
# STATE_ESTABLISHED = '01'
|
||||||
STATE_SYN_SENT = '02'
|
# STATE_SYN_SENT = '02'
|
||||||
STATE_SYN_RECV = '03'
|
# STATE_SYN_RECV = '03'
|
||||||
STATE_FIN_WAIT1 = '04'
|
# STATE_FIN_WAIT1 = '04'
|
||||||
STATE_FIN_WAIT2 = '05'
|
# STATE_FIN_WAIT2 = '05'
|
||||||
STATE_TIME_WAIT = '06'
|
# STATE_TIME_WAIT = '06'
|
||||||
STATE_CLOSE = '07'
|
# STATE_CLOSE = '07'
|
||||||
STATE_CLOSE_WAIT = '08'
|
# STATE_CLOSE_WAIT = '08'
|
||||||
STATE_LAST_ACK = '09'
|
# STATE_LAST_ACK = '09'
|
||||||
STATE_LISTEN = '0A'
|
STATE_LISTEN = '0A'
|
||||||
STATE_CLOSING = '0B'
|
# STATE_CLOSING = '0B'
|
||||||
|
|
||||||
def get_socket_inodes(pid):
|
def get_socket_inodes(pid):
|
||||||
'''
|
'''
|
||||||
|
@ -24,9 +24,7 @@ import struct
|
|||||||
|
|
||||||
from .bignum import bn2vch
|
from .bignum import bn2vch
|
||||||
|
|
||||||
MAX_SCRIPT_SIZE = 10000
|
|
||||||
MAX_SCRIPT_ELEMENT_SIZE = 520
|
MAX_SCRIPT_ELEMENT_SIZE = 520
|
||||||
MAX_SCRIPT_OPCODES = 201
|
|
||||||
|
|
||||||
OPCODE_NAMES = {}
|
OPCODE_NAMES = {}
|
||||||
|
|
||||||
@ -243,131 +241,6 @@ OP_PUBKEY = CScriptOp(0xfe)
|
|||||||
|
|
||||||
OP_INVALIDOPCODE = CScriptOp(0xff)
|
OP_INVALIDOPCODE = CScriptOp(0xff)
|
||||||
|
|
||||||
VALID_OPCODES = {
|
|
||||||
OP_1NEGATE,
|
|
||||||
OP_RESERVED,
|
|
||||||
OP_1,
|
|
||||||
OP_2,
|
|
||||||
OP_3,
|
|
||||||
OP_4,
|
|
||||||
OP_5,
|
|
||||||
OP_6,
|
|
||||||
OP_7,
|
|
||||||
OP_8,
|
|
||||||
OP_9,
|
|
||||||
OP_10,
|
|
||||||
OP_11,
|
|
||||||
OP_12,
|
|
||||||
OP_13,
|
|
||||||
OP_14,
|
|
||||||
OP_15,
|
|
||||||
OP_16,
|
|
||||||
|
|
||||||
OP_NOP,
|
|
||||||
OP_VER,
|
|
||||||
OP_IF,
|
|
||||||
OP_NOTIF,
|
|
||||||
OP_VERIF,
|
|
||||||
OP_VERNOTIF,
|
|
||||||
OP_ELSE,
|
|
||||||
OP_ENDIF,
|
|
||||||
OP_VERIFY,
|
|
||||||
OP_RETURN,
|
|
||||||
|
|
||||||
OP_TOALTSTACK,
|
|
||||||
OP_FROMALTSTACK,
|
|
||||||
OP_2DROP,
|
|
||||||
OP_2DUP,
|
|
||||||
OP_3DUP,
|
|
||||||
OP_2OVER,
|
|
||||||
OP_2ROT,
|
|
||||||
OP_2SWAP,
|
|
||||||
OP_IFDUP,
|
|
||||||
OP_DEPTH,
|
|
||||||
OP_DROP,
|
|
||||||
OP_DUP,
|
|
||||||
OP_NIP,
|
|
||||||
OP_OVER,
|
|
||||||
OP_PICK,
|
|
||||||
OP_ROLL,
|
|
||||||
OP_ROT,
|
|
||||||
OP_SWAP,
|
|
||||||
OP_TUCK,
|
|
||||||
|
|
||||||
OP_CAT,
|
|
||||||
OP_SUBSTR,
|
|
||||||
OP_LEFT,
|
|
||||||
OP_RIGHT,
|
|
||||||
OP_SIZE,
|
|
||||||
|
|
||||||
OP_INVERT,
|
|
||||||
OP_AND,
|
|
||||||
OP_OR,
|
|
||||||
OP_XOR,
|
|
||||||
OP_EQUAL,
|
|
||||||
OP_EQUALVERIFY,
|
|
||||||
OP_RESERVED1,
|
|
||||||
OP_RESERVED2,
|
|
||||||
|
|
||||||
OP_1ADD,
|
|
||||||
OP_1SUB,
|
|
||||||
OP_2MUL,
|
|
||||||
OP_2DIV,
|
|
||||||
OP_NEGATE,
|
|
||||||
OP_ABS,
|
|
||||||
OP_NOT,
|
|
||||||
OP_0NOTEQUAL,
|
|
||||||
|
|
||||||
OP_ADD,
|
|
||||||
OP_SUB,
|
|
||||||
OP_MUL,
|
|
||||||
OP_DIV,
|
|
||||||
OP_MOD,
|
|
||||||
OP_LSHIFT,
|
|
||||||
OP_RSHIFT,
|
|
||||||
|
|
||||||
OP_BOOLAND,
|
|
||||||
OP_BOOLOR,
|
|
||||||
OP_NUMEQUAL,
|
|
||||||
OP_NUMEQUALVERIFY,
|
|
||||||
OP_NUMNOTEQUAL,
|
|
||||||
OP_LESSTHAN,
|
|
||||||
OP_GREATERTHAN,
|
|
||||||
OP_LESSTHANOREQUAL,
|
|
||||||
OP_GREATERTHANOREQUAL,
|
|
||||||
OP_MIN,
|
|
||||||
OP_MAX,
|
|
||||||
|
|
||||||
OP_WITHIN,
|
|
||||||
|
|
||||||
OP_RIPEMD160,
|
|
||||||
OP_SHA1,
|
|
||||||
OP_SHA256,
|
|
||||||
OP_HASH160,
|
|
||||||
OP_HASH256,
|
|
||||||
OP_CODESEPARATOR,
|
|
||||||
OP_CHECKSIG,
|
|
||||||
OP_CHECKSIGVERIFY,
|
|
||||||
OP_CHECKMULTISIG,
|
|
||||||
OP_CHECKMULTISIGVERIFY,
|
|
||||||
|
|
||||||
OP_NOP1,
|
|
||||||
OP_CHECKLOCKTIMEVERIFY,
|
|
||||||
OP_CHECKSEQUENCEVERIFY,
|
|
||||||
OP_NOP4,
|
|
||||||
OP_NOP5,
|
|
||||||
OP_NOP6,
|
|
||||||
OP_NOP7,
|
|
||||||
OP_NOP8,
|
|
||||||
OP_NOP9,
|
|
||||||
OP_NOP10,
|
|
||||||
|
|
||||||
OP_SMALLINTEGER,
|
|
||||||
OP_PUBKEYS,
|
|
||||||
OP_PUBKEYHASH,
|
|
||||||
OP_PUBKEY,
|
|
||||||
}
|
|
||||||
|
|
||||||
OPCODE_NAMES.update({
|
OPCODE_NAMES.update({
|
||||||
OP_0 : 'OP_0',
|
OP_0 : 'OP_0',
|
||||||
OP_PUSHDATA1 : 'OP_PUSHDATA1',
|
OP_PUSHDATA1 : 'OP_PUSHDATA1',
|
||||||
@ -487,124 +360,6 @@ OPCODE_NAMES.update({
|
|||||||
OP_INVALIDOPCODE : 'OP_INVALIDOPCODE',
|
OP_INVALIDOPCODE : 'OP_INVALIDOPCODE',
|
||||||
})
|
})
|
||||||
|
|
||||||
OPCODES_BY_NAME = {
|
|
||||||
'OP_0' : OP_0,
|
|
||||||
'OP_PUSHDATA1' : OP_PUSHDATA1,
|
|
||||||
'OP_PUSHDATA2' : OP_PUSHDATA2,
|
|
||||||
'OP_PUSHDATA4' : OP_PUSHDATA4,
|
|
||||||
'OP_1NEGATE' : OP_1NEGATE,
|
|
||||||
'OP_RESERVED' : OP_RESERVED,
|
|
||||||
'OP_1' : OP_1,
|
|
||||||
'OP_2' : OP_2,
|
|
||||||
'OP_3' : OP_3,
|
|
||||||
'OP_4' : OP_4,
|
|
||||||
'OP_5' : OP_5,
|
|
||||||
'OP_6' : OP_6,
|
|
||||||
'OP_7' : OP_7,
|
|
||||||
'OP_8' : OP_8,
|
|
||||||
'OP_9' : OP_9,
|
|
||||||
'OP_10' : OP_10,
|
|
||||||
'OP_11' : OP_11,
|
|
||||||
'OP_12' : OP_12,
|
|
||||||
'OP_13' : OP_13,
|
|
||||||
'OP_14' : OP_14,
|
|
||||||
'OP_15' : OP_15,
|
|
||||||
'OP_16' : OP_16,
|
|
||||||
'OP_NOP' : OP_NOP,
|
|
||||||
'OP_VER' : OP_VER,
|
|
||||||
'OP_IF' : OP_IF,
|
|
||||||
'OP_NOTIF' : OP_NOTIF,
|
|
||||||
'OP_VERIF' : OP_VERIF,
|
|
||||||
'OP_VERNOTIF' : OP_VERNOTIF,
|
|
||||||
'OP_ELSE' : OP_ELSE,
|
|
||||||
'OP_ENDIF' : OP_ENDIF,
|
|
||||||
'OP_VERIFY' : OP_VERIFY,
|
|
||||||
'OP_RETURN' : OP_RETURN,
|
|
||||||
'OP_TOALTSTACK' : OP_TOALTSTACK,
|
|
||||||
'OP_FROMALTSTACK' : OP_FROMALTSTACK,
|
|
||||||
'OP_2DROP' : OP_2DROP,
|
|
||||||
'OP_2DUP' : OP_2DUP,
|
|
||||||
'OP_3DUP' : OP_3DUP,
|
|
||||||
'OP_2OVER' : OP_2OVER,
|
|
||||||
'OP_2ROT' : OP_2ROT,
|
|
||||||
'OP_2SWAP' : OP_2SWAP,
|
|
||||||
'OP_IFDUP' : OP_IFDUP,
|
|
||||||
'OP_DEPTH' : OP_DEPTH,
|
|
||||||
'OP_DROP' : OP_DROP,
|
|
||||||
'OP_DUP' : OP_DUP,
|
|
||||||
'OP_NIP' : OP_NIP,
|
|
||||||
'OP_OVER' : OP_OVER,
|
|
||||||
'OP_PICK' : OP_PICK,
|
|
||||||
'OP_ROLL' : OP_ROLL,
|
|
||||||
'OP_ROT' : OP_ROT,
|
|
||||||
'OP_SWAP' : OP_SWAP,
|
|
||||||
'OP_TUCK' : OP_TUCK,
|
|
||||||
'OP_CAT' : OP_CAT,
|
|
||||||
'OP_SUBSTR' : OP_SUBSTR,
|
|
||||||
'OP_LEFT' : OP_LEFT,
|
|
||||||
'OP_RIGHT' : OP_RIGHT,
|
|
||||||
'OP_SIZE' : OP_SIZE,
|
|
||||||
'OP_INVERT' : OP_INVERT,
|
|
||||||
'OP_AND' : OP_AND,
|
|
||||||
'OP_OR' : OP_OR,
|
|
||||||
'OP_XOR' : OP_XOR,
|
|
||||||
'OP_EQUAL' : OP_EQUAL,
|
|
||||||
'OP_EQUALVERIFY' : OP_EQUALVERIFY,
|
|
||||||
'OP_RESERVED1' : OP_RESERVED1,
|
|
||||||
'OP_RESERVED2' : OP_RESERVED2,
|
|
||||||
'OP_1ADD' : OP_1ADD,
|
|
||||||
'OP_1SUB' : OP_1SUB,
|
|
||||||
'OP_2MUL' : OP_2MUL,
|
|
||||||
'OP_2DIV' : OP_2DIV,
|
|
||||||
'OP_NEGATE' : OP_NEGATE,
|
|
||||||
'OP_ABS' : OP_ABS,
|
|
||||||
'OP_NOT' : OP_NOT,
|
|
||||||
'OP_0NOTEQUAL' : OP_0NOTEQUAL,
|
|
||||||
'OP_ADD' : OP_ADD,
|
|
||||||
'OP_SUB' : OP_SUB,
|
|
||||||
'OP_MUL' : OP_MUL,
|
|
||||||
'OP_DIV' : OP_DIV,
|
|
||||||
'OP_MOD' : OP_MOD,
|
|
||||||
'OP_LSHIFT' : OP_LSHIFT,
|
|
||||||
'OP_RSHIFT' : OP_RSHIFT,
|
|
||||||
'OP_BOOLAND' : OP_BOOLAND,
|
|
||||||
'OP_BOOLOR' : OP_BOOLOR,
|
|
||||||
'OP_NUMEQUAL' : OP_NUMEQUAL,
|
|
||||||
'OP_NUMEQUALVERIFY' : OP_NUMEQUALVERIFY,
|
|
||||||
'OP_NUMNOTEQUAL' : OP_NUMNOTEQUAL,
|
|
||||||
'OP_LESSTHAN' : OP_LESSTHAN,
|
|
||||||
'OP_GREATERTHAN' : OP_GREATERTHAN,
|
|
||||||
'OP_LESSTHANOREQUAL' : OP_LESSTHANOREQUAL,
|
|
||||||
'OP_GREATERTHANOREQUAL' : OP_GREATERTHANOREQUAL,
|
|
||||||
'OP_MIN' : OP_MIN,
|
|
||||||
'OP_MAX' : OP_MAX,
|
|
||||||
'OP_WITHIN' : OP_WITHIN,
|
|
||||||
'OP_RIPEMD160' : OP_RIPEMD160,
|
|
||||||
'OP_SHA1' : OP_SHA1,
|
|
||||||
'OP_SHA256' : OP_SHA256,
|
|
||||||
'OP_HASH160' : OP_HASH160,
|
|
||||||
'OP_HASH256' : OP_HASH256,
|
|
||||||
'OP_CODESEPARATOR' : OP_CODESEPARATOR,
|
|
||||||
'OP_CHECKSIG' : OP_CHECKSIG,
|
|
||||||
'OP_CHECKSIGVERIFY' : OP_CHECKSIGVERIFY,
|
|
||||||
'OP_CHECKMULTISIG' : OP_CHECKMULTISIG,
|
|
||||||
'OP_CHECKMULTISIGVERIFY' : OP_CHECKMULTISIGVERIFY,
|
|
||||||
'OP_NOP1' : OP_NOP1,
|
|
||||||
'OP_CHECKLOCKTIMEVERIFY' : OP_CHECKLOCKTIMEVERIFY,
|
|
||||||
'OP_CHECKSEQUENCEVERIFY' : OP_CHECKSEQUENCEVERIFY,
|
|
||||||
'OP_NOP4' : OP_NOP4,
|
|
||||||
'OP_NOP5' : OP_NOP5,
|
|
||||||
'OP_NOP6' : OP_NOP6,
|
|
||||||
'OP_NOP7' : OP_NOP7,
|
|
||||||
'OP_NOP8' : OP_NOP8,
|
|
||||||
'OP_NOP9' : OP_NOP9,
|
|
||||||
'OP_NOP10' : OP_NOP10,
|
|
||||||
'OP_SMALLINTEGER' : OP_SMALLINTEGER,
|
|
||||||
'OP_PUBKEYS' : OP_PUBKEYS,
|
|
||||||
'OP_PUBKEYHASH' : OP_PUBKEYHASH,
|
|
||||||
'OP_PUBKEY' : OP_PUBKEY,
|
|
||||||
}
|
|
||||||
|
|
||||||
class CScriptInvalidError(Exception):
|
class CScriptInvalidError(Exception):
|
||||||
"""Base class for CScript exceptions"""
|
"""Base class for CScript exceptions"""
|
||||||
pass
|
pass
|
||||||
|
@ -91,7 +91,7 @@ class Socks5Connection(object):
|
|||||||
self.conn.sendall(bytearray([0x01, 0x00]))
|
self.conn.sendall(bytearray([0x01, 0x00]))
|
||||||
|
|
||||||
# Read connect request
|
# Read connect request
|
||||||
(ver,cmd,rsv,atyp) = recvall(self.conn, 4)
|
ver, cmd, _, atyp = recvall(self.conn, 4)
|
||||||
if ver != 0x05:
|
if ver != 0x05:
|
||||||
raise IOError('Invalid socks version %i in connect request' % ver)
|
raise IOError('Invalid socks version %i in connect request' % ver)
|
||||||
if cmd != Command.CONNECT:
|
if cmd != Command.CONNECT:
|
||||||
|
@ -105,7 +105,7 @@ class WalletDumpTest(BitcoinTestFramework):
|
|||||||
self.nodes[0].keypoolrefill()
|
self.nodes[0].keypoolrefill()
|
||||||
self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.encrypted.dump")
|
self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.encrypted.dump")
|
||||||
|
|
||||||
found_addr, found_addr_chg, found_addr_rsv, hd_master_addr_enc = \
|
found_addr, found_addr_chg, found_addr_rsv, _ = \
|
||||||
read_dump(tmpdir + "/node0/wallet.encrypted.dump", addrs, hd_master_addr_unenc)
|
read_dump(tmpdir + "/node0/wallet.encrypted.dump", addrs, hd_master_addr_unenc)
|
||||||
assert_equal(found_addr, test_addr_count)
|
assert_equal(found_addr, test_addr_count)
|
||||||
# TODO clarify if we want the behavior that is tested below in Dash (only when HD seed was generated and not user-provided)
|
# TODO clarify if we want the behavior that is tested below in Dash (only when HD seed was generated and not user-provided)
|
||||||
|
@ -216,7 +216,7 @@ class WalletTest(BitcoinTestFramework):
|
|||||||
signedRawTx = self.nodes[1].signrawtransaction(rawTx)
|
signedRawTx = self.nodes[1].signrawtransaction(rawTx)
|
||||||
decRawTx = self.nodes[1].decoderawtransaction(signedRawTx['hex'])
|
decRawTx = self.nodes[1].decoderawtransaction(signedRawTx['hex'])
|
||||||
zeroValueTxid= decRawTx['txid']
|
zeroValueTxid= decRawTx['txid']
|
||||||
sendResp = self.nodes[1].sendrawtransaction(signedRawTx['hex'])
|
self.nodes[1].sendrawtransaction(signedRawTx['hex'])
|
||||||
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[1].generate(1) #mine a block
|
self.nodes[1].generate(1) #mine a block
|
||||||
|
Loading…
Reference in New Issue
Block a user