1
+ // txhelpers.go contains helper functions for working with transactions and
2
+ // blocks (e.g. checking for a transaction in a block).
3
+
1
4
package main
2
5
3
6
import (
7
+ "sort"
8
+
4
9
"github.com/decred/dcrd/chaincfg/chainhash"
5
10
"github.com/decred/dcrd/txscript"
6
11
"github.com/decred/dcrrpcclient"
7
12
"github.com/decred/dcrutil"
8
- "sort"
9
13
)
10
14
11
15
// TxAction is what is happening to the transaction (mined or inserted into
@@ -19,7 +23,7 @@ const (
19
23
// removed? invalidated?
20
24
)
21
25
22
- func txhashInSlice (txs []* dcrutil.Tx , txHash * chainhash.Hash ) * dcrutil.Tx {
26
+ func TxhashInSlice (txs []* dcrutil.Tx , txHash * chainhash.Hash ) * dcrutil.Tx {
23
27
if len (txs ) < 1 {
24
28
return nil
25
29
}
@@ -33,21 +37,21 @@ func txhashInSlice(txs []*dcrutil.Tx, txHash *chainhash.Hash) *dcrutil.Tx {
33
37
return nil
34
38
}
35
39
36
- // includesTx checks if a block contains a transaction hash
37
- func includesStakeTx (txHash * chainhash.Hash , block * dcrutil.Block ) (int , int8 ) {
40
+ // includesStakeTx checks if a block contains a stake transaction hash
41
+ func IncludesStakeTx (txHash * chainhash.Hash , block * dcrutil.Block ) (int , int8 ) {
38
42
blockTxs := block .STransactions ()
39
43
40
- if tx := txhashInSlice (blockTxs , txHash ); tx != nil {
44
+ if tx := TxhashInSlice (blockTxs , txHash ); tx != nil {
41
45
return tx .Index (), tx .Tree ()
42
46
}
43
47
return - 1 , - 1
44
48
}
45
49
46
50
// includesTx checks if a block contains a transaction hash
47
- func includesTx (txHash * chainhash.Hash , block * dcrutil.Block ) (int , int8 ) {
51
+ func IncludesTx (txHash * chainhash.Hash , block * dcrutil.Block ) (int , int8 ) {
48
52
blockTxs := block .Transactions ()
49
53
50
- if tx := txhashInSlice (blockTxs , txHash ); tx != nil {
54
+ if tx := TxhashInSlice (blockTxs , txHash ); tx != nil {
51
55
return tx .Index (), tx .Tree ()
52
56
}
53
57
return - 1 , - 1
0 commit comments