def get_utxo(self, address): """Gets all the Unspent Transaction Outs from a given <address> """ script_pubkey = CBitcoinAddress(address).to_scriptPubKey() txs = self.get_response("blockchain.address.get_history", [address]) spent = {} utxos = [] for tx in txs: raw = self.get_raw_transaction(tx["tx_hash"], tx["height"]) data = CTransaction.deserialize(to_binary(raw)) for vin in data.vin: spent[(to_little_endian_hex(vin.prevout.hash), vin.prevout.n)] = 1 for outindex, vout in enumerate(data.vout): if vout.scriptPubKey == script_pubkey: utxos += [(tx["tx_hash"], outindex, vout.nValue, to_hex(vout.scriptPubKey))] return [u for u in utxos if not u[0:2] in spent]
def get_utxo(self, address): script_pubkey = CBitcoinAddress(address).to_scriptPubKey() txs = self.get_response('blockchain.address.get_history', [address]) spent = {} utxos = [] for tx in txs: print tx raw = self.get_raw_transaction(tx['tx_hash'], tx['height']) data = CTransaction.deserialize(to_binary(raw)) for vin in data.vin: spent[(to_little_endian_hex(vin.prevout.hash), vin.prevout.n)] = 1 for outindex, vout in enumerate(data.vout): if vout.scriptPubKey == script_pubkey: utxos += [(tx['tx_hash'], outindex, vout.nValue, to_hex(vout.scriptPubKey))] return [u for u in utxos if not u[0:2] in spent]
def get_tx(self, txhash): """Get the transaction object given a transaction hash. """ txhex = self.get_raw_transaction(txhash) tx = CTransaction.deserialize(to_binary(txhex)) return blockchain.CTransaction.from_bitcoincore(txhash, tx, self)
def get_tx(self, txhash): txhex = self.get_raw_transaction(txhash) tx = CTransaction.deserialize(to_binary(txhex)) return blockchain.CTransaction.from_bitcoincore(txhash, tx, self)