-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx_in.go
executable file
·67 lines (57 loc) · 1.11 KB
/
tx_in.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package decode
import (
"encoding/hex"
"github.com/MetaID-Labs/metaid-parser/util"
)
type TxIn struct {
inType int
TxID []byte
Vout []byte
scriptSig []byte
sequence []byte
lockScript []byte
}
const (
TypeEmpty = 0
TypeP2PK = 1
TypeP2PKH = 2
TypeP2WPKH = 3
TypeBech32 = 4
TypeMultiSig = 5
)
const (
Type_Empty = "Empty"
Type_P2PK = "P2PK"
Type_P2PKH = "P2PKH"
Type_P2PSH = "P2PSH"
Type_P2WPKH = "P2WPKH"
Type_Bech32 = "Bech32"
Type_MultiSig = "MultiSig"
Type_NullData = "NullData"
)
func (in TxIn) GetUTXOType() int {
return in.inType
}
func (in TxIn) GetUTXOTypeStr() string {
switch in.inType {
case TypeEmpty:
return Type_Empty
case TypeP2PK:
return Type_P2PK
case TypeP2PKH:
return Type_P2PKH
}
return ""
}
func (in TxIn) GetTxID() string {
return util.ReverseBytesToHex(in.TxID)
}
func (in TxIn) GetVout() uint32 {
return util.LittleEndianBytesToUint32(in.Vout)
}
func (in TxIn) GetScriptSig() string {
return hex.EncodeToString(in.scriptSig)
}
func (in TxIn) GetSequence() uint32 {
return util.LittleEndianBytesToUint32(in.sequence)
}