|
|
@ -561,7 +561,7 @@ class Transaction: |
|
|
|
for privkey in privkeys: |
|
|
|
pubkey = public_key_from_private_key(privkey) |
|
|
|
address = address_from_private_key(privkey) |
|
|
|
u = network.synchronous_get(('blockchain.address.listunspent',[address])) |
|
|
|
u = network.synchronous_get(('blockchain.address.listunspent', [address])) |
|
|
|
pay_script = klass.pay_script(TYPE_ADDRESS, address) |
|
|
|
for item in u: |
|
|
|
item['scriptPubKey'] = pay_script |
|
|
@ -669,7 +669,7 @@ class Transaction: |
|
|
|
s += int_to_hex(txin['prevout_n'], 4) |
|
|
|
# Script length, script, sequence |
|
|
|
script = self.input_script(txin, i, for_sig) |
|
|
|
s += var_int(len(script) / 2) |
|
|
|
s += var_int(len(script)/2) |
|
|
|
s += script |
|
|
|
s += "ffffffff" |
|
|
|
return s |
|
|
@ -682,27 +682,27 @@ class Transaction: |
|
|
|
def serialize(self, for_sig=None): |
|
|
|
inputs = self.inputs() |
|
|
|
outputs = self.outputs() |
|
|
|
s = int_to_hex(1,4) # version |
|
|
|
s += var_int( len(inputs) ) # number of inputs |
|
|
|
s = int_to_hex(1, 4) # version |
|
|
|
s += var_int(len(inputs)) # number of inputs |
|
|
|
for i, txin in enumerate(inputs): |
|
|
|
s += self.serialize_input(txin, i, for_sig) |
|
|
|
s += var_int( len(outputs) ) # number of outputs |
|
|
|
s += var_int(len(outputs)) # number of outputs |
|
|
|
for output in outputs: |
|
|
|
output_type, addr, amount = output |
|
|
|
s += int_to_hex( amount, 8) # amount |
|
|
|
s += int_to_hex(amount, 8) # amount |
|
|
|
script = self.pay_script(output_type, addr) |
|
|
|
s += var_int( len(script)/2 ) # script length |
|
|
|
s += script # script |
|
|
|
s += int_to_hex(0,4) # lock time |
|
|
|
s += var_int(len(script)/2) # script length |
|
|
|
s += script # script |
|
|
|
s += int_to_hex(0, 4) # lock time |
|
|
|
if for_sig is not None and for_sig != -1: |
|
|
|
s += int_to_hex(1, 4) # hash type |
|
|
|
s += int_to_hex(1, 4) # hash type |
|
|
|
return s |
|
|
|
|
|
|
|
def tx_for_sig(self,i): |
|
|
|
return self.serialize(for_sig = i) |
|
|
|
|
|
|
|
def hash(self): |
|
|
|
return Hash(self.raw.decode('hex') )[::-1].encode('hex') |
|
|
|
return Hash(self.raw.decode('hex'))[::-1].encode('hex') |
|
|
|
|
|
|
|
def add_inputs(self, inputs): |
|
|
|
self._inputs.extend(inputs) |
|
|
|