<blockquote>
<p>How to determine the transaction type using transaction hash?</p>
</blockquote>
<p>There is no concept of type in the Bitcoin network. Therefore, neither transactions nor outputs nor inputs have a type. However, the outputs (locking scripts) are most often of a certain standard form, and the inputs then consume those standard outputs. Therefore, some group of output and input types is actually defined from those standard forms of output and input. It is important to understand that these types (P2PKH, P2SH etc.) exist only for end users and not for the Bitcoin network. The type of input or output is not indicated anywhere in the transaction.</p>
<p>Here you can see all types of output: <a href="https://bitcoin.stackexchange.com/a/107873/140802">link</a></p>
<p>Here you can see how to determine the input type: <a href="https://bitcoin.stackexchange.com/a/119805/140802">link</a></p>
<p>Based on everything written, the conclusion is that there is no transaction type, but only input and output type (although this is not part of the network). What we could potentially define as the type of transaction is whether it is a segregated witness (segwit) transaction or not, that is, whether some of the inputs consume a segwit output or such an input does not exist in the transaction. Such a transaction can be recognized very easily when looking at its raw (serialized) form. Namely, the value of the fifth byte is 0x00 and the value of the sixth byte is 0x01. If the fifth and sixth bytes are not set to these values, it is a non-segwit transaction.</p>
<blockquote>
<p>Is there any way to identify the transaction type using the following data in Bitcoin blockchain:</p>
</blockquote>
<p>No, you cannot determine either the output type, the input type, or the transaction type based on the given fields.</p>

CC BY-SA 4.0
2023-10-01T14:03:26.853Z
I'm in need of a data filtering process to identify anomalies within transactions. Additionally, I'm looking for a method to exclude transactions that don't fit the anomaly criteria. Any recommendations for achieving this? This data will be used to train a machine learning model.
Dev Sapariya
CC BY-SA 4.0
2023-10-01T14:07:36.020Z
@DevSapariya What type of anomalies are you referring to?
dassd
CC BY-SA 4.0
2023-10-02T18:03:11.207Z
Hey @DevSapariya, it sounds like you are trying to do something that you have not explained in your question. Since Filip wrote such a nice comprehensive answer to your question that was asking about your approach to solve your problem, perhaps you should create a new topic to ask about the actual problem you’re trying to solve rather than your approach to solve your problem. :)
Murch
CC BY-SA 4.0
2023-10-03T06:17:20.577Z
Anomalies indicate whether a specific transaction is involved in any illegal activities. My goal is to employ machine learning to cluster these transactions.
Dev Sapariya
CC BY-SA 4.0
2023-10-03T06:19:45.880Z
I should exclude transactions that are not person-to-person since they cannot be used for illegal activities.
Dev Sapariya
CC BY-SA 4.0
2023-10-01T09:23:57.187Z
2023-10-02T18:01:39.757Z
2023-10-02T18:01:39.757Z
dassd
<p>Is there any way to identify the transaction type using the following data in Bitcoin blockchain:</p>
<ul>
<li>InputCount</li>
<li>OutputCount</li>
<li>Transaction Version</li>
<li>Transaction Size</li>
<li>Transaction Weight</li>
<li>Transaction Lock Time</li>
</ul>
<p>I am using <a href="https://ide.bitquery.io/" rel="nofollow noreferrer">https://ide.bitquery.io/</a> for getting the data</p>

<bitcoin-core><transactions>
How to determine the transaction type using transaction hash?
Dev Sapariya
# How to determine the transaction type using transaction hash?

(Asked by: username_0 on 2023-10-01)

Is there any way to identify the transaction type using the following data in Bitcoin blockchain:

* InputCount
* OutputCount
* Transaction Version
* Transaction Size
* Transaction Weight
* Transaction Lock Time

I am using <https://ide.bitquery.io/> for getting the data

**Tags:** bitcoin-core, transactions


---

## 1 answers

### Answer by username_1 on 2023-10-01. Score: 2

> How to determine the transaction type using transaction hash?

There is no concept of type in the Bitcoin network. Therefore, neither transactions nor outputs nor inputs have a type. However, the outputs (locking scripts) are most often of a certain standard form, and the inputs then consume those standard outputs. Therefore, some group of output and input types is actually defined from those standard forms of output and input. It is important to understand that these types (P2PKH, P2SH etc.) exist only for end users and not for the Bitcoin network. The type of input or output is not indicated anywhere in the transaction.

Here you can see all types of output: [link](https://bitcoin.stackexchange.com/a/107873/140802)

Here you can see how to determine the input type: [link](https://bitcoin.stackexchange.com/a/119805/140802)

Based on everything written, the conclusion is that there is no transaction type, but only input and output type (although this is not part of the network). What we could potentially define as the type of transaction is whether it is a segregated witness (segwit) transaction or not, that is, whether some of the inputs consume a segwit output or such an input does not exist in the transaction. Such a transaction can be recognized very easily when looking at its raw (serialized) form. Namely, the value of the fifth byte is 0x00 and the value of the sixth byte is 0x01. If the fifth and sixth bytes are not set to these values, it is a non-segwit transaction.

> Is there any way to identify the transaction type using the following data in Bitcoin blockchain:

No, you cannot determine either the output type, the input type, or the transaction type based on the given fields.

> **Comments:**
> **username_0**: I'm in need of a data filtering process to identify anomalies within transactions. Additionally, I'm looking for a method to exclude transactions that don't fit the anomaly criteria. Any recommendations for achieving this? This data will be used to train a machine learning model.  
> **username_1**: @username_0 What type of anomalies are you referring to?  
> **username_2**: Hey @username_0, it sounds like you are trying to do something that you have not explained in your question. Since Filip wrote such a nice comprehensive answer to your question that was asking about your approach to solve your problem, perhaps you should create a new topic to ask about the actual problem you’re trying to solve rather than your approach to solve your problem. :)  
> **username_0**: Anomalies indicate whether a specific transaction is involved in any illegal activities. My goal is to employ machine learning to cluster these transactions.  
> **username_0**: I should exclude transactions that are not person-to-person since they cannot be used for illegal activities.  

---

