Exemplo n.º 1
0
 def load_tx(self, ec, tx, statement_line, info):
     outputs = []
     for tx_out in tx.outputs:
         script = tx_out.output_script
         if script.type() == bitcoin.payment_type.pubkey_hash:
             pkh = bitcoin.short_hash(str(script.operations()[2].data))
             outputs.append(bitcoin.public_key_hash_to_address(pkh))
         else:
             outputs.append("Unknown")
     info["outputs"] = outputs
     info["inputs"] = [None for i in range(len(tx.inputs))]
     if info["is_input"] == 1:
         info["inputs"][info["index"]] = self.address
     else:
         our_output = tx.outputs[info["index"]]
         info["value"] = our_output.value
         with statement_line.lock:
             statement_line.raw_output_script = \
                 str(bitcoin.save_script(our_output.output_script))
     if not [empty_in for empty_in in info["inputs"] if empty_in is None]:
         # We have the sole input
         assert(info["is_input"] == 1)
         with statement_line.lock:
             statement_line.input_loaded = info
         self.finish_if_done()
     for tx_idx, tx_in in enumerate(tx.inputs):
         if info["is_input"] == 1 and info["index"] == tx_idx:
             continue
         self.chain.fetch_transaction(
             tx_in.previous_output.hash,
             bitcoin.bind(self.load_input, bitcoin._1, bitcoin._2, tx_in.previous_output.index, statement_line, info, tx_idx)
         )
Exemplo n.º 2
0
 def load_tx(self, ec, tx, statement_line, info):
     outputs = []
     for tx_out in tx.outputs:
         script = tx_out.output_script
         if script.type() == bitcoin.payment_type.pubkey_hash:
             pkh = bitcoin.short_hash(str(script.operations()[2].data))
             outputs.append(bitcoin.public_key_hash_to_address(pkh))
         else:
             outputs.append("Unknown")
     info["outputs"] = outputs
     info["inputs"] = [None for i in range(len(tx.inputs))]
     if info["is_input"] == 1:
         info["inputs"][info["index"]] = self.address
     else:
         our_output = tx.outputs[info["index"]]
         info["value"] = our_output.value
         with statement_line.lock:
             statement_line.raw_output_script = \
                 str(bitcoin.save_script(our_output.output_script))
     if not [empty_in for empty_in in info["inputs"] if empty_in is None]:
         # We have the sole input
         assert (info["is_input"] == 1)
         with statement_line.lock:
             statement_line.input_loaded = info
         self.finish_if_done()
     for tx_idx, tx_in in enumerate(tx.inputs):
         if info["is_input"] == 1 and info["index"] == tx_idx:
             continue
         self.chain.fetch_transaction(
             tx_in.previous_output.hash,
             bitcoin.bind(self.load_input, bitcoin._1, bitcoin._2,
                          tx_in.previous_output.index, statement_line, info,
                          tx_idx))
Exemplo n.º 3
0
 def load_input(self, ec, tx, index, statement_line, info, inputs_index):
     script = tx.outputs[index].output_script
     if script.type() == bitcoin.payment_type.pubkey_hash:
         pkh = bitcoin.short_hash(str(script.operations()[2].data))
         info["inputs"][inputs_index] = \
             bitcoin.public_key_hash_to_address(pkh)
     else:
         info["inputs"][inputs_index] = "Unknown"
     if not [empty_in for empty_in in info["inputs"] if empty_in is None]:
         with statement_line.lock:
             if info["is_input"] == 1:
                 statement_line.input_loaded = info
             else:
                 statement_line.output_loaded = info
     self.finish_if_done()
Exemplo n.º 4
0
 def load_input(self, ec, tx, index, statement_line, info, inputs_index):
     script = tx.outputs[index].output_script
     if script.type() == bitcoin.payment_type.pubkey_hash:
         pkh = bitcoin.short_hash(str(script.operations()[2].data))
         info["inputs"][inputs_index] = \
             bitcoin.public_key_hash_to_address(pkh)
     else:
         info["inputs"][inputs_index] = "Unknown"
     if not [empty_in for empty_in in info["inputs"] if empty_in is None]:
         with statement_line.lock:
             if info["is_input"] == 1:
                 statement_line.input_loaded = info
             else:
                 statement_line.output_loaded = info
     self.finish_if_done()