Added arbitrary outputs

write your own output scripts should you be so inclined.
This commit is contained in:
dabura667 2015-01-18 02:37:44 +09:00
parent 9a6d98f899
commit b741dd89ca
2 changed files with 24 additions and 17 deletions

View File

@ -73,6 +73,12 @@ class PayToEdit(ScanQRTextEdit):
amount = 0
else:
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'
address = self.parse_address(x)
amount = self.parse_amount(y)

View File

@ -424,7 +424,7 @@ def get_address_from_output_script(bytes):
if match_decoded(decoded, match):
return 'op_return', decoded[1][1]
return "(None)", "(None)"
return 'custom', bytes
@ -567,8 +567,7 @@ class Transaction:
if output_type == 'op_return':
h = addr.encode('hex')
return '6a' + push_script(h)
else:
assert output_type == 'address'
elif output_type == 'address':
addrtype, hash_160 = bc_address_to_hash_160(addr)
if addrtype == 0:
script = '76a9' # op_dup, op_hash_160
@ -580,6 +579,8 @@ class Transaction:
script += '87' # op_equal
else:
raise
else:
script = addr.encode('hex')
return script
def input_script(self, txin, i, for_sig):
@ -759,7 +760,7 @@ class Transaction:
elif type == 'op_return':
addr = 'OP_RETURN ' + x.encode('hex')
else:
addr = "(None)"
addr = 'CUSTOM ' + x.encode('hex')
o.append((addr,v)) # consider using yield (addr, v)
return o