# HBTBD: A Heterogeneous Bitcoin Transaction Behavior Dataset for Anti-Money Laundering
## 2 Related Work
### Metapath-Type Division  
The metapath describes the relationship between two transaction entities and the shared wallet address. In this framework, depending on the division of wallet address types in Section 3.4, we use Algorithm2 to define three metapath types to distinguish the subtle differences in Bitcoin transactions in detail, as shown in Figure 4.  
As can be seen from the directed relationship in Figure 4, although Bitcoin transaction nodes are all connected to wallet addresses, different connection directions express different meanings. Algorithm2 describes the metapath-type division method; the pseudocode is shown below.  
Figure 3: Bitcoin wallet address types.  
```
1:The Bitcoin transaction node data: Txnode_List, Three types of Bitcoin wallet address node: \(Add\_A\_A\_Add\_B\_Add\_C\)
2:Metapath of various types: Metapathlist_A\_Metapathlist_B,Metapathlist_C
3:functionGET_INFO(\(tx\)) //using API [[https://chain.api.btc.com/v3/tx/](https://chain.api.btc.com/v3/tx/)]([https://chain.api.btc.com/v3/tx/](https://chain.api.btc.com/v3/tx/))\(\backslash\){txhash\(\backslash\)} (accessed on 26 July 2023) to get jsonfile
4:return\(tx\_jsonfile\)
5:endfunction
6:for each \(out\_edge\in Out\_Edges\)do
7:\(TransInfo\)=GET_INFO(\(tx\))
8:for each \(add\_in\)\(TransInfo\_InputAddress\)do
9:\(add\) = add_in;
10:\(In\_Edges\).append([\(add\_tx\)])
11:endfor;
12:for each \(add\_out\in TransInfo\_OutputAddress\)do
13:\(add\) = add_out
14:\(Out\_Edges\).append([\(tx\_add\)])
15:endfor
16:endfor
17:for each \(out\_edge\in Out\_Edges\)do
18:for each \(in\_edge\in In\_Edges\)do
19:if\(out\_edge\_add\)=\(in\_edge\_add\)then
20:\(add\) = \(out\_edge\_add\)
21:\(tx1\_node\) = \(out\_edge\_tx\)
22:\(tx2\_node\) = \(in\_edge\_tx\)
23:if\(addnode\in Add\_A\)then
24:\(Metapathlist\_A\_append([\)tx1\_node,addnode,tx2\_node\(]))
25:endif
26:if\(addnode\in Add\_B\)then
27:\(Metapathlist\_B\_append([\)tx1\_node,addnode,tx2\_node\(]))
28:endif
29:endif
30:endif
31:endfor
32:endfor
```  
**Algorithm 2** Metapath Type Division  
In all the edges of the Bitcoin transaction entities and the Bitcoin wallet address, we define the edge of the connection direction from the Bitcoin wallet address node to the Bitcoin transaction entity node as the In_Edge (line 8), inversely, as the Out_Edge (line 12). Then, we define the metapath type by classifying the combinatorial cases of In_Edge and Out_Edge (lines 15 to 32).  
From the perspective of the Bitcoin transaction, in metapath A, both \(Tx_{1}\) and \(Tx_{2}\) have output to the common wallet address, which is more consistent with the situation of the centralized transfer of transactions (lines 21, 22). In metapath B, \(Tx_{1}\) and \(Tx_{2}\) show obvious one-way flow characteristics (lines 24, 25). In metapath C, both \(Tx_{1}\) and \(Tx_{2}\) have input from the common wallet address, which is more consistent with decentralized transaction transfer-out scenarios (lines 27, 28). Therefore, through the metapath setting, different means of the transaction can be reflected, aiming to input more characteristics of Bitcoin transactions into the model.