Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Alternative Bitcoin Core integration #565

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bitcoin/secp256k1_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def json_changebase(obj, changer):


def deserialize(tx):
if isinstance(tx, str) and re.match('^[0-9a-fA-F]*$', tx):
if isinstance(tx, basestring) and re.match('^[0-9a-fA-F]*$', tx):
#tx = bytes(bytearray.fromhex(tx))
return json_changebase(
deserialize(binascii.unhexlify(tx)), lambda x: safe_hexlify(x))
Expand Down Expand Up @@ -158,7 +158,7 @@ def signature_form(tx, i, script, hashcode=SIGHASH_ALL):
return newtx

def txhash(tx, hashcode=None):
if isinstance(tx, str) and re.match('^[0-9a-fA-F]*$', tx):
if isinstance(tx, basestring) and re.match('^[0-9a-fA-F]*$', tx):
tx = changebase(tx, 16, 256)
if hashcode:
return dbl_sha256(from_string_to_bytes(tx) + encode(
Expand Down Expand Up @@ -238,7 +238,7 @@ def p2sh_scriptaddr(script, magicbyte=5):


def deserialize_script(script):
if isinstance(script, str) and re.match('^[0-9a-fA-F]*$', script):
if isinstance(script, basestring) and re.match('^[0-9a-fA-F]*$', script):
return json_changebase(
deserialize_script(binascii.unhexlify(script)),
lambda x: safe_hexlify(x))
Expand Down Expand Up @@ -372,10 +372,10 @@ def apply_multisignatures(*args):
tx, i, script = args[0], int(args[1]), args[2]
sigs = args[3] if isinstance(args[3], list) else list(args[3:])

if isinstance(script, str) and re.match('^[0-9a-fA-F]*$', script):
if isinstance(script, basestring) and re.match('^[0-9a-fA-F]*$', script):
script = binascii.unhexlify(script)
sigs = [binascii.unhexlify(x) if x[:2] == '30' else x for x in sigs]
if isinstance(tx, str) and re.match('^[0-9a-fA-F]*$', tx):
if isinstance(tx, basestring) and re.match('^[0-9a-fA-F]*$', tx):
return safe_hexlify(apply_multisignatures(
binascii.unhexlify(tx), i, script, sigs))

Expand Down
10 changes: 5 additions & 5 deletions bitcoin/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def json_changebase(obj, changer):


def deserialize(tx):
if isinstance(tx, str) and re.match('^[0-9a-fA-F]*$', tx):
if isinstance(tx, basestring) and re.match('^[0-9a-fA-F]*$', tx):
#tx = bytes(bytearray.fromhex(tx))
return json_changebase(
deserialize(binascii.unhexlify(tx)), lambda x: safe_hexlify(x))
Expand Down Expand Up @@ -179,7 +179,7 @@ def der_decode_sig(sig):


def txhash(tx, hashcode=None):
if isinstance(tx, str) and re.match('^[0-9a-fA-F]*$', tx):
if isinstance(tx, basestring) and re.match('^[0-9a-fA-F]*$', tx):
tx = changebase(tx, 16, 256)
if hashcode:
return dbl_sha256(from_string_to_bytes(tx) + encode(
Expand Down Expand Up @@ -248,7 +248,7 @@ def p2sh_scriptaddr(script, magicbyte=5):


def deserialize_script(script):
if isinstance(script, str) and re.match('^[0-9a-fA-F]*$', script):
if isinstance(script, basestring) and re.match('^[0-9a-fA-F]*$', script):
return json_changebase(
deserialize_script(binascii.unhexlify(script)),
lambda x: safe_hexlify(x))
Expand Down Expand Up @@ -380,10 +380,10 @@ def apply_multisignatures(*args):
tx, i, script = args[0], int(args[1]), args[2]
sigs = args[3] if isinstance(args[3], list) else list(args[3:])

if isinstance(script, str) and re.match('^[0-9a-fA-F]*$', script):
if isinstance(script, basestring) and re.match('^[0-9a-fA-F]*$', script):
script = binascii.unhexlify(script)
sigs = [binascii.unhexlify(x) if x[:2] == '30' else x for x in sigs]
if isinstance(tx, str) and re.match('^[0-9a-fA-F]*$', tx):
if isinstance(tx, basestring) and re.match('^[0-9a-fA-F]*$', tx):
return safe_hexlify(apply_multisignatures(
binascii.unhexlify(tx), i, script, sigs))

Expand Down
Loading