Browse Source

use 4-spaces indentation

283
thomasv 12 years ago
parent
commit
ad6dac8d05
  1. 8
      lib/deserialize.py

8
lib/deserialize.py

@ -35,8 +35,10 @@ class BCDataStream(object):
def map_file(self, file, start): # Initialize with bytes from file def map_file(self, file, start): # Initialize with bytes from file
self.input = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) self.input = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
self.read_cursor = start self.read_cursor = start
def seek_file(self, position): def seek_file(self, position):
self.read_cursor = position self.read_cursor = position
def close_file(self): def close_file(self):
self.input.close() self.input.close()
@ -264,6 +266,7 @@ opcodes = Enumeration("Opcodes", [
("OP_INVALIDOPCODE", 0xFFFF), ("OP_INVALIDOPCODE", 0xFFFF),
]) ])
def script_GetOp(bytes): def script_GetOp(bytes):
i = 0 i = 0
while i < len(bytes): while i < len(bytes):
@ -291,9 +294,11 @@ def script_GetOp(bytes):
yield (opcode, vch, i) yield (opcode, vch, i)
def script_GetOpName(opcode): def script_GetOpName(opcode):
return (opcodes.whatis(opcode)).replace("OP_", "") return (opcodes.whatis(opcode)).replace("OP_", "")
def decode_script(bytes): def decode_script(bytes):
result = '' result = ''
for (opcode, vch, i) in script_GetOp(bytes): for (opcode, vch, i) in script_GetOp(bytes):
@ -305,6 +310,7 @@ def decode_script(bytes):
result += script_GetOpName(opcode) result += script_GetOpName(opcode)
return result return result
def match_decoded(decoded, to_match): def match_decoded(decoded, to_match):
if len(decoded) != len(to_match): if len(decoded) != len(to_match):
return False; return False;
@ -377,3 +383,5 @@ def get_address_from_output_script(bytes):
return hash_160_to_bc_address(decoded[1][1],5) return hash_160_to_bc_address(decoded[1][1],5)
return "(None)" return "(None)"

Loading…
Cancel
Save