Browse Source

Added arbitrary outputs

write your own output scripts should you be so inclined.
283
dabura667 10 years ago
parent
commit
b741dd89ca
  1. 6
      gui/qt/paytoedit.py
  2. 9
      lib/transaction.py

6
gui/qt/paytoedit.py

@ -73,6 +73,12 @@ class PayToEdit(ScanQRTextEdit):
amount = 0 amount = 0
else: else:
x, y = line.split(',') x, y = line.split(',')
n = re.match('^CUSTOM_OUT\s+([0-9a-fA-F]+)$', x.strip())
if n:
_type = 'custom'
address = n.group(1).decode('hex')
amount = self.parse_amount(y)
else:
_type = 'address' _type = 'address'
address = self.parse_address(x) address = self.parse_address(x)
amount = self.parse_amount(y) amount = self.parse_amount(y)

9
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 "(None)", "(None)" return 'custom', bytes
@ -567,8 +567,7 @@ class Transaction:
if output_type == 'op_return': if output_type == 'op_return':
h = addr.encode('hex') h = addr.encode('hex')
return '6a' + push_script(h) return '6a' + push_script(h)
else: elif output_type == 'address':
assert 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:
script = '76a9' # op_dup, op_hash_160 script = '76a9' # op_dup, op_hash_160
@ -580,6 +579,8 @@ class Transaction:
script += '87' # op_equal script += '87' # op_equal
else: else:
raise raise
else:
script = addr.encode('hex')
return script return script
def input_script(self, txin, i, for_sig): def input_script(self, txin, i, for_sig):
@ -759,7 +760,7 @@ class Transaction:
elif type == 'op_return': elif type == 'op_return':
addr = 'OP_RETURN ' + x.encode('hex') addr = 'OP_RETURN ' + x.encode('hex')
else: else:
addr = "(None)" addr = 'CUSTOM ' + 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