support for OP_RETURN
This commit is contained in:
@@ -428,9 +428,10 @@ def get_address_from_output_script(bytes):
|
||||
|
||||
|
||||
|
||||
push_script = lambda x: op_push(len(x)/2) + x
|
||||
|
||||
class Transaction:
|
||||
|
||||
|
||||
def __init__(self, raw):
|
||||
self.raw = raw
|
||||
self.deserialize()
|
||||
@@ -505,16 +506,17 @@ class Transaction:
|
||||
|
||||
@classmethod
|
||||
def pay_script(self, addr):
|
||||
if addr.startswith('OP_RETURN:'):
|
||||
h = addr[10:].encode('hex')
|
||||
return '6a' + push_script(h)
|
||||
addrtype, hash_160 = bc_address_to_hash_160(addr)
|
||||
if addrtype == 0:
|
||||
script = '76a9' # op_dup, op_hash_160
|
||||
script += '14' # push 0x14 bytes
|
||||
script += hash_160.encode('hex')
|
||||
script += push_script(hash_160.encode('hex'))
|
||||
script += '88ac' # op_equalverify, op_checksig
|
||||
elif addrtype == 5:
|
||||
script = 'a9' # op_hash_160
|
||||
script += '14' # push 0x14 bytes
|
||||
script += hash_160.encode('hex')
|
||||
script += push_script(hash_160.encode('hex'))
|
||||
script += '87' # op_equal
|
||||
else:
|
||||
raise
|
||||
@@ -524,7 +526,6 @@ class Transaction:
|
||||
@classmethod
|
||||
def serialize( klass, inputs, outputs, for_sig = None ):
|
||||
|
||||
push_script = lambda x: op_push(len(x)/2) + x
|
||||
s = int_to_hex(1,4) # version
|
||||
s += var_int( len(inputs) ) # number of inputs
|
||||
for i in range(len(inputs)):
|
||||
|
||||
@@ -350,7 +350,7 @@ class Abstract_Wallet:
|
||||
raise Exception("Address not found", address)
|
||||
|
||||
def getpubkeys(self, addr):
|
||||
assert is_valid(addr) and self.is_mine(addr)
|
||||
assert is_address(addr) and self.is_mine(addr)
|
||||
account, sequence = self.get_address_index(addr)
|
||||
a = self.accounts[account]
|
||||
return a.get_pubkeys( sequence )
|
||||
@@ -779,7 +779,9 @@ class Abstract_Wallet:
|
||||
|
||||
def make_unsigned_transaction(self, outputs, fee=None, change_addr=None, domain=None, coins=None ):
|
||||
for address, x in outputs:
|
||||
assert is_valid(address), "Address " + address + " is invalid!"
|
||||
if address.startswith('OP_RETURN:'):
|
||||
continue
|
||||
assert is_address(address), "Address " + address + " is invalid!"
|
||||
amount = sum( map(lambda x:x[1], outputs) )
|
||||
inputs, total, fee = self.choose_tx_inputs( amount, fee, len(outputs), domain, coins )
|
||||
if not inputs:
|
||||
|
||||
Reference in New Issue
Block a user