Browse Source

Change type to 'script' and remove OP_RETURN

283
dabura667 10 years ago
parent
commit
d166927fd0
  1. 10
      gui/qt/paytoedit.py
  2. 13
      lib/transaction.py

10
gui/qt/paytoedit.py

@ -66,16 +66,10 @@ class PayToEdit(ScanQRTextEdit):
self.setStyleSheet("QWidget { background-color:#ffcccc;}") self.setStyleSheet("QWidget { background-color:#ffcccc;}")
def parse_address_and_amount(self, line): def parse_address_and_amount(self, line):
m = re.match('^OP_RETURN\s+([0-9a-fA-F]+)$', line.strip())
if m:
_type = 'op_return'
address = m.group(1).decode('hex')
amount = 0
else:
x, y = line.split(',') x, y = line.split(',')
n = re.match('^CUSTOM_OUT\s+([0-9a-fA-F]+)$', x.strip()) n = re.match('^SCRIPT\s+([0-9a-fA-F]+)$', x.strip())
if n: if n:
_type = 'custom' _type = 'script'
address = n.group(1).decode('hex') address = n.group(1).decode('hex')
amount = self.parse_amount(y) amount = self.parse_amount(y)
else: else:

13
lib/transaction.py

@ -424,7 +424,7 @@ def get_address_from_output_script(bytes):
if match_decoded(decoded, match): if match_decoded(decoded, match):
return 'op_return', decoded[1][1] return 'op_return', decoded[1][1]
return 'custom', bytes return 'script', bytes
@ -564,9 +564,8 @@ class Transaction:
@classmethod @classmethod
def pay_script(self, output_type, addr): def pay_script(self, output_type, addr):
if output_type == 'op_return': if output_type == 'script':
h = addr.encode('hex') return addr.encode('hex')
return '6a' + push_script(h)
elif output_type == 'address': elif output_type == 'address':
addrtype, hash_160 = bc_address_to_hash_160(addr) addrtype, hash_160 = bc_address_to_hash_160(addr)
if addrtype == 0: if addrtype == 0:
@ -580,7 +579,7 @@ class Transaction:
else: else:
raise raise
else: else:
script = addr.encode('hex') raise
return script return script
def input_script(self, txin, i, for_sig): def input_script(self, txin, i, for_sig):
@ -757,10 +756,8 @@ class Transaction:
addr = x addr = x
elif type == 'pubkey': elif type == 'pubkey':
addr = public_key_to_bc_address(x.decode('hex')) addr = public_key_to_bc_address(x.decode('hex'))
elif type == 'op_return':
addr = 'OP_RETURN ' + x.encode('hex')
else: else:
addr = 'CUSTOM ' + x.encode('hex') addr = 'SCRIPT ' + x.encode('hex')
o.append((addr,v)) # consider using yield (addr, v) o.append((addr,v)) # consider using yield (addr, v)
return o return o

Loading…
Cancel
Save