I have been conducting research on the web and Bitcoin Stack Exchange to find a method for obtaining the source address of a transaction. I have come across multiple answers, some suggesting the use of APIs, while others focus solely on P2PKH sigscript.
In my case, the sigscript is a P2PK signature. I have utilized online transaction decoders, which parse the hexstring in a similar manner to how I have implemented it in my code. However, I have noticed that these decoders do not provide the source address. Interestingly, block explorers do display the source address. I am curious to know how block explorers obtain this information and how to calculate or retrieve the source address using the Bitcoin protocol itself, without relying on block explorer APIs.
prevtxid :
201,151,165,229,110,16,65,2,250,32,156,106,133,45,217,6,96,162,11,45,156,53,36,35,237,206,37,133,127,205,55,4
sigscript :
71,48,68,2,32,78,69,225,105,50,184,175,81,73,97,161,211,
161,162,95,223,63,79,119,50,233,214,36,198,198,21,72,171,
95,184,205,65,2,32,24,21,34,236,142,202,7,222,72,96,164,
172,221,18,144,157,131,28,197,108,187,172,70,34,8,34,33,
168,118,141,29,9,1
printf
, format of"%x"
orhex.Encode()
. It is shorter and often easier for readers to recognise.