Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getAddress(key):
publicKeyHash = RIPEMD160(SHA256(key.getPublicKey()))
return base58.encodeBase58Check(publicKeyHash, 0) #PUBKEY_ADDRESS = 0
elements = tx_out.scriptPubKey.elements
print ' script:'
for e in elements:
if isinstance(e, str):
s = e.encode("hex")
else:
s = '0x%0x' % e
print ' ', s
if len(elements) == 5 and \
elements[0:2] == [btx.OP.DUP, btx.OP.HASH160] and \
elements[3:5] == [btx.OP.EQUALVERIFY, btx.OP.CHECKSIG] and \
isinstance(elements[2], str):
address = base58.encodeBase58Check(elements[2], 0) #PUBKEY_ADDRESS = 0
print ' Address: ', address
else:
print ' Unrecognized script type'
print ''
fee = sum(amounts) - sum([tx_out.amount for tx_out in tx.tx_out])
print 'Tx fee: %s BCC' % str(decimal.Decimal(fee)/BCC)