1
0

sweep command (does not broadcast)

This commit is contained in:
ThomasV
2014-04-25 17:23:26 +02:00
parent 9723a5e9ec
commit e552930d34
2 changed files with 36 additions and 14 deletions

View File

@@ -425,6 +425,25 @@ class Transaction:
return s
@classmethod
def pay_script(self, addr):
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 += '88ac' # op_equalverify, op_checksig
elif addrtype == 5:
script = 'a9' # op_hash_160
script += '14' # push 0x14 bytes
script += hash_160.encode('hex')
script += '87' # op_equal
else:
raise
return script
@classmethod
def serialize( klass, inputs, outputs, for_sig = None ):
@@ -475,20 +494,7 @@ class Transaction:
for output in outputs:
addr, amount = output
s += int_to_hex( amount, 8) # amount
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 += '88ac' # op_equalverify, op_checksig
elif addrtype == 5:
script = 'a9' # op_hash_160
script += '14' # push 0x14 bytes
script += hash_160.encode('hex')
script += '87' # op_equal
else:
raise
script = klass.pay_script(addr)
s += var_int( len(script)/2 ) # script length
s += script # script
s += int_to_hex(0,4) # lock time