<p>The <code>txin hex</code> is just the normal hex for a transaction whose output(s) you are spending. It's not something you can compute from the <code>tx hex</code> itself (if you could, you would't need to provide it). It's there because to validate a transaction input you need to know what output(s) it is spending, and those are part of the earlier transaction(s).</p>

CC BY-SA 4.0
2023-06-26T17:07:56.700Z
Thank you. I still do not understand, if the `--tx=<hex>` has more than one input that reference the _same_ `--txin=<reftx hex>`, which tx's input script btcdeb is going to pick to debug?
Alec Matusis
CC BY-SA 4.0
2023-06-26T17:22:53.310Z
I do not know the answer to that.
Pieter Wuille
CC BY-SA 4.0
2023-06-22T17:57:16.510Z
2023-06-22T17:57:16.510Z
Pieter Wuille
<p>I am trying to understand how <a href="https://github.com/bitcoin-core/btcdeb/blob/master/doc/btcdeb.md" rel="nofollow noreferrer">btcdeb</a> (Bitcoin script debugger from Bitcoin core) works.
In the usecase of <code>btcdeb --tx=&lt;tx hex&gt; --txin=&lt;txin hex&gt;</code>, how does one obtain the hex of the input of interest? In the example there:</p>
<pre><code>$ btcdeb --tx=010000000001019086ce64fce1bb086395faf6fac37c73f32ba4ea89330432bf8ee8035e9315aa0100000000ffffffff021353b9030000000017a914c3f413d0918853a8e23766678d2e3c2e5c8138bb8725e4973100000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d040047304402207f874ef00f11dcc9a621acad9354f3fca1bf90c43878f607b7e2d358088487e7022052a01b47b8eef5e1c96a6affdc3dac46fdc11b60612464dc8c5921a852090d2701483045022100c56ab2abb17fdf565417228763bc9f2940a6465042fd62fbd9f4c7406345d7f702201cb1a56b45181f8347713627b325ec5df48fc1aee6bdaf937cbb804d7409b10c016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000 \
txin=0100000000010170a6ee35199eae2d8ea659561374fa704f8fd95188ff5931157e4598dd0c44020100000000ffffffff0280f0fa02000000001976a914eec426a744f7a3b2ffd346925ac832e248834dd788ac4013543500000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004730440220054c0b331a31496d9123aeabe8415b8d2f877f1cf67709120af4eb1e09de59e002206cdf84e733e23be531aff202f868d200773e22aa0037033a74fc6752df2fd19601483045022100b54fa12828d13b58cb654dd910b9e8b36d471d644d8f66516577990ca099ee19022048ea2ac78f964d1b823af70c13c5607a29b14bb2348022190b3c280f51ec5df2016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000 
</code></pre>
<p>the hex of the txin (<code>0100000000010170a...</code>, 383Bytes) is actually longer than the hex for the whole tx itself (<code>010000000001019...</code>, 381Bytes). How was the hex for txin obtained?</p>
<p>When I run <code>bitcoin-cli decoderawtransaction &lt;txin hex&gt;</code> to see what txin hex is, it gives full JSON of the whole transaction, same as running <code>bitcoin-cli decoderawtransaction &lt;tx hex&gt;</code></p>

<script><transaction-input><serialization>
How to get the hex for a tx input (for btcdeb tool)
Alec Matusis
# How to get the hex for a tx input (for btcdeb tool)

(Asked by: username_0 on 2023-06-22)

I am trying to understand how btcdeb (Bitcoin script debugger from Bitcoin core) works.
In the usecase of btcdeb --tx= --txin=, how does one obtain the hex of the input of interest? In the example there:
$ btcdeb --tx=010000000001019086ce64fce1bb086395faf6fac37c73f32ba4ea89330432bf8ee8035e9315aa0100000000ffffffff021353b9030000000017a914c3f413d0918853a8e23766678d2e3c2e5c8138bb8725e4973100000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d040047304402207f874ef00f11dcc9a621acad9354f3fca1bf90c43878f607b7e2d358088487e7022052a01b47b8eef5e1c96a6affdc3dac46fdc11b60612464dc8c5921a852090d2701483045022100c56ab2abb17fdf565417228763bc9f2940a6465042fd62fbd9f4c7406345d7f702201cb1a56b45181f8347713627b325ec5df48fc1aee6bdaf937cbb804d7409b10c016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000 \
txin=0100000000010170a6ee35199eae2d8ea659561374fa704f8fd95188ff5931157e4598dd0c44020100000000ffffffff0280f0fa02000000001976a914eec426a744f7a3b2ffd346925ac832e248834dd788ac4013543500000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004730440220054c0b331a31496d9123aeabe8415b8d2f877f1cf67709120af4eb1e09de59e002206cdf84e733e23be531aff202f868d200773e22aa0037033a74fc6752df2fd19601483045022100b54fa12828d13b58cb654dd910b9e8b36d471d644d8f66516577990ca099ee19022048ea2ac78f964d1b823af70c13c5607a29b14bb2348022190b3c280f51ec5df2016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000 

the hex of the txin (0100000000010170a..., 383Bytes) is actually longer than the hex for the whole tx itself (010000000001019..., 381Bytes). How was the hex for txin obtained?
When I run bitcoin-cli decoderawtransaction  to see what txin hex is, it gives full JSON of the whole transaction, same as running bitcoin-cli decoderawtransaction

**Tags:** script, transaction-input, serialization


---

## 1 answers

### Answer by username_1 on 2023-06-22. Score: 1 | Accepted answer

The `txin hex` is just the normal hex for a transaction whose output(s) you are spending. It's not something you can compute from the `tx hex` itself (if you could, you would't need to provide it). It's there because to validate a transaction input you need to know what output(s) it is spending, and those are part of the earlier transaction(s).

> **Comments:**
> **username_0**: Thank you. I still do not understand, if the `--tx=<hex>` has more than one input that reference the _same_ `--txin=<reftx hex>`, which tx's input script btcdeb is going to pick to debug?  
> **username_1**: I do not know the answer to that.  

---

