-
Notifications
You must be signed in to change notification settings - Fork 4
/
utxo.go
52 lines (42 loc) · 1023 Bytes
/
utxo.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
package memo
import (
"bytes"
"github.com/memocash/index/ref/bitcoin/tx/hs"
)
type UTXO struct {
Input TxInput
SlpToken []byte
SlpQuantity uint64
SlpType SlpType
SellTxHash []byte
AncestorsNC uint // Ancestors not confirmed
}
func (u UTXO) IsEqual(u2 UTXO) bool {
return bytes.Equal(u.Input.PrevOutHash, u2.Input.PrevOutHash) && u.Input.PrevOutIndex == u2.Input.PrevOutIndex
}
func (u UTXO) IsPrevOutSet() bool {
return len(u.Input.PrevOutHash) > 0
}
func (u UTXO) IsSlp() bool {
return len(u.SlpToken) > 0
}
func (u UTXO) IsSellTokenInput() bool {
return len(u.SellTxHash) > 0
}
func (u UTXO) AtAncestorLimit() bool {
return u.AncestorsNC >= MaxAncestors
}
type UTXORequest struct {
TokenHash []byte
Baton bool
}
func (r UTXORequest) GetHashString() string {
return hs.GetTxString(r.TokenHash)
}
func GetNonPointerUtxos(utxos []*UTXO) []UTXO {
var nonPointerUtxos = make([]UTXO, len(utxos))
for i := range utxos {
nonPointerUtxos[i] = *utxos[i]
}
return nonPointerUtxos
}