Why can’t this txid get the correct address? Is there any way I can get the address
{'txid': '4775e10df3521f1b9320b3ae9a7305b016078767000d9a7fff0c42f8dc0bdd9b', 'hash': '4775e10df3521f1b9320b3ae9a7305b016078767000d9a7fff0c42f8dc0bdd9b', 'version': 1, 'size': 234, 'vsize': 234, 'weight': 936, 'locktime': 0, 'vin': [{'txid': '130d9f30ec833b4f1917339c58a857063c8f9380599e453d9a29eabc5323f57a', 'vout': 0, 'scriptSig': {'asm': '30450220448f442347d3b47b6f72659c94407c01e2ce8c11db51a3c7095651ec202f2aeb022100b 65196d9a8f2923c5905f903e02643c25b14d983b0c0c88392d8e2b2d6011af1[ALL]', 'hex': '4830450220448f442347d3b47b6f72659c94407c01e2ce8c11db51a3c7095651ec202f2aeb02210 0b65196d9a8f2923c5905f903e02643c25b14d983b0c0c88392d8e2b2d6011af101'}, 'sequence': 4294967295}], 'vout': [{'value': 20.74189877, 'n': 0, 'scriptPubKey': {'asm': '04a39b9e4fbd213ef24bb9be69de4a118dd0644082e47c01fd9159d38637b83fbcdc115a5d6e970 586a012d1cfe3e3a8b1a3d04e763bdc5a071c0e827c0bd834a5 OP_CHECKSIG', 'hex': '4104a39b9e4fbd213ef24bb9be69de4a118dd0644082e47c01fd9159d38637b83fbcdc115a5d6e9 70586a012d1cfe3e3a8b1a3d04e763bdc5a071c0e827c0bd834a5ac', 'type': 'pubkey'}}, {'value': 0.05, 'n': 1, 'scriptPubKey': {'asm': 'OP_DUP OP_HASH160 06a83fbdd5df3ecd783f9506807511af3d866863 OP_EQUALVERIFY OP_CHECKSIG', 'hex': '76a91406a83fbdd5df3ecd783f9506807511af3d86686388ac', 'reqSigs': 1, 'type': 'pubkeyhash', 'addresses': ['1cCcJ9zs4aCysVH6hmDuSasazXnmmKYtM']}}], 'hex': '01000000017af52353bcea299a3d459e5980938f3c0657a8589c3317194f3b83ec309f0d1300000 000494830450220448f442347d3b47b6f72659c94407c01e2ce8c11db51a3c7095651ec202f2aeb 022100b65196d9a8f2923c5905f903e02643c25b14d983b0c0c88392d8e2b2d6011af101fffffff f0235a0a17b00000000434104a39b9e4fbd213ef24bb9be69de4a118dd0644082e47c01fd9159d3 8637b83fbcdc115a5d6e970586a012d1cfe3e3a8b1a3d04e763bdc5a071c0e827c0bd834a5ac404 b4c00000000001976a91406a83fbdd5df3ecd783f9506807511af3d86686388ac00000000', 'blockhash': '000000000000008c8471e40400e6ed162cf2efeb132735e043316f29c3e72f39', 'confirmations': 439642, 'time': 1372800859, 'blocktime': 1372800859}
I tried to write a lot of code, but still can’t get the correct address. I want to know if there is any way to get the correct address,I spent a lot of time on this issue, hoping to get a little hint, thank you very much.
# coding:utf-8
from bip32utils import Base58
import bech32
from hashlib import *
from base58 import *
import base58
import binascii
def hashStr(buffer):
return binascii.hexlify(buffer)
def SHA256D(bstr):
return sha256(sha256(bstr).digest()).digest()
def ConvertPKHToAddress(prefix, addr):
data = prefix + addr
return b58encode(data + SHA256D(data)[:4])
def PubkeyToAddress(pubkey_hex):
pubkey = bytearray.fromhex(pubkey_hex)
round1 = sha256(pubkey).digest()
h = new('ripemd160')
h.update(round1)
pubkey_hash = h.digest()
return ConvertPKHToAddress(b'\x00', pubkey_hash)
print(PubkeyToAddress('4104a39b9e4fbd213ef24bb9be69de4a118dd0644082e47c01fd9159d38637b83fbcdc115a5d6e970586a012d1cfe3e3a8b1a3d04e763bdc5a071c0e827c0bd834a5ac'))
b'16SvHaiZXXgoBxAvZPo36zsyuAxLK1qECy'