-
Notifications
You must be signed in to change notification settings - Fork 4
/
tx.go
45 lines (38 loc) · 853 Bytes
/
tx.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
package memo
import (
"github.com/jchavannes/btcd/txscript"
"github.com/jchavannes/btcd/wire"
"github.com/memocash/index/ref/bitcoin/tx/hs"
)
type TxInput struct {
PkScript []byte
PkHash []byte
Value int64
PrevOutHash []byte
PrevOutIndex uint32
}
func (t TxInput) GetHashIndexString() string {
return hs.GetHashIndexString(t.PrevOutHash, t.PrevOutIndex)
}
func (t TxInput) GetDisasmString() string {
s, _ := txscript.DisasmString(t.PkScript)
return s
}
type Tx struct {
SelfPkHash []byte
MsgTx *wire.MsgTx
Inputs []*TxInput
Outputs []*Output
OpReturn *Output
AncestorsNC uint
}
func (tx Tx) GetHash() []byte {
txHash := tx.MsgTx.TxHash()
return txHash.CloneBytes()
}
func (tx Tx) GetType() OutputType {
if tx.OpReturn != nil {
return tx.OpReturn.GetType()
}
return OutputTypeUnknown
}