I am writing Python script that should be able to generate raw TX messages. I understand there are libraries to do it, but I'd like to learn this from the ground up myself. As an example I took this great tutorial:
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.htmland BTC Tx specifications
https://en.bitcoin.it/wiki/Protocol_specification#tx After some time I have finally figured that to specify INPUT in my tx i need to take DOUBLE sha256 (this does not seem clearly stated in specs, it only says "hash") of FULL PREVIOUS TX (not just output section as it say in some of the articles that I won't link here because it took me hours to figure this out after following those).
My questions are following:
Tx generation method in the above tutorial is fairly old and simple (single input, single output).
- AFAIK SegWit tx message have slightly different structure. What should I change to make my TX with multiple outputs a SegWit TX?
- Are SegWit Inputs any different from non-SegWit Inputs (i.e. if i have received my coins as SegWit TX will it change how my spending TX look like)
- To sum up the question - Is current specs here https://en.bitcoin.it/wiki/Protocol_specification#tx are universal and can be applied to any and all BTC transaction?
Any links/tutorials/literature on the subject will be greatly appriciated.
Thanks.