diff --git a/lib/coins.py b/lib/coins.py index ec84b96..5c89832 100644 --- a/lib/coins.py +++ b/lib/coins.py @@ -77,6 +77,11 @@ class Coin(object): raise CoinError('invalid address: {}'.format(addr)) return result + @classmethod + def hash168_to_address(cls, hash168): + '''Return an address given a 21-byte hash.''' + return Base58.encode_check(hash168) + @classmethod def P2PKH_address_from_hash160(cls, hash_bytes): '''Return a P2PKH address given a public key.''' diff --git a/server/block_processor.py b/server/block_processor.py index 47aa0e1..908b245 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -762,3 +762,12 @@ class BlockProcessor(LoggedClass): '''Returns all the UTXOs for an address sorted by height and position in the block.''' return sorted(self.get_utxos(hash168, limit=None)) + + def get_utxo_hash168(self, tx_hash, index): + '''Returns the hash168 for a UTXO.''' + hash168 = None + if 0 <= index <= 65535: + hash168 = self.utxo_cache(tx_hash, struct.pack('