This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
generated from mrz1836/go-template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
interface.go
176 lines (163 loc) · 8.72 KB
/
interface.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package bux
import (
"context"
"net/http"
"time"
"github.com/BuxOrg/bux/cachestore"
"github.com/BuxOrg/bux/chainstate"
"github.com/BuxOrg/bux/datastore"
"github.com/BuxOrg/bux/logger"
"github.com/BuxOrg/bux/notifications"
"github.com/BuxOrg/bux/taskmanager"
"github.com/libsv/go-bc"
"github.com/tonicpow/go-paymail"
)
// AccessKeyService is the access key actions
type AccessKeyService interface {
GetAccessKey(ctx context.Context, xPubID, pubAccessKey string) (*AccessKey, error)
GetAccessKeys(ctx context.Context, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams, opts ...ModelOps) ([]*AccessKey, error)
GetAccessKeysCount(ctx context.Context, metadata *Metadata,
conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetAccessKeysByXPubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams, opts ...ModelOps) ([]*AccessKey, error)
GetAccessKeysByXPubIDCount(ctx context.Context, xPubID string, metadata *Metadata,
conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
NewAccessKey(ctx context.Context, rawXpubKey string, opts ...ModelOps) (*AccessKey, error)
RevokeAccessKey(ctx context.Context, rawXpubKey, id string, opts ...ModelOps) (*AccessKey, error)
}
// TransactionService is the transaction actions
type TransactionService interface {
GetTransaction(ctx context.Context, xPubID, txID string) (*Transaction, error)
GetTransactions(ctx context.Context, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Transaction, error)
GetTransactionsCount(ctx context.Context, metadata *Metadata,
conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetTransactionsByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams) ([]*Transaction, error)
GetTransactionsByXpubIDCount(ctx context.Context, xPubID string, metadata *Metadata,
conditions *map[string]interface{}) (int64, error)
NewTransaction(ctx context.Context, rawXpubKey string, config *TransactionConfig,
opts ...ModelOps) (*DraftTransaction, error)
RecordTransaction(ctx context.Context, xPubKey, txHex, draftID string,
opts ...ModelOps) (*Transaction, error)
RecordMonitoredTransaction(ctx context.Context, txHex string, opts ...ModelOps) (*Transaction, error)
UpdateTransactionMetadata(ctx context.Context, xPubID, id string, metadata Metadata) (*Transaction, error)
}
// BlockHeaderService is the block header actions
type BlockHeaderService interface {
RecordBlockHeader(ctx context.Context, hash string, height uint32, bh bc.BlockHeader, opts ...ModelOps) (*BlockHeader, error)
GetBlockHeaders(ctx context.Context, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams, opts ...ModelOps) ([]*BlockHeader, error)
GetBlockHeadersCount(ctx context.Context, metadata *Metadata,
conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetUnsyncedBlockHeaders(ctx context.Context) ([]*BlockHeader, error)
GetLastBlockHeader(ctx context.Context) (*BlockHeader, error)
GetBlockHeaderByHeight(ctx context.Context, height uint32) (*BlockHeader, error)
}
// DestinationService is the destination actions
type DestinationService interface {
GetDestinationByID(ctx context.Context, xPubID, id string) (*Destination, error)
GetDestinationByAddress(ctx context.Context, xPubID, address string) (*Destination, error)
GetDestinationByLockingScript(ctx context.Context, xPubID, lockingScript string) (*Destination, error)
GetDestinations(ctx context.Context, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Destination, error)
GetDestinationsCount(ctx context.Context, metadata *Metadata,
conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetDestinationsByXpubID(ctx context.Context, xPubID string, usingMetadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams) ([]*Destination, error)
GetDestinationsByXpubIDCount(ctx context.Context, xPubID string, usingMetadata *Metadata,
conditions *map[string]interface{}) (int64, error)
NewDestination(ctx context.Context, xPubKey string, chain uint32, destinationType string, monitor bool,
opts ...ModelOps) (*Destination, error)
NewDestinationForLockingScript(ctx context.Context, xPubID, lockingScript string, monitor bool,
opts ...ModelOps) (*Destination, error)
UpdateDestinationMetadataByID(ctx context.Context, xPubID, id string, metadata Metadata) (*Destination, error)
UpdateDestinationMetadataByLockingScript(ctx context.Context, xPubID, lockingScript string, metadata Metadata) (*Destination, error)
UpdateDestinationMetadataByAddress(ctx context.Context, xPubID, address string, metadata Metadata) (*Destination, error)
}
// DraftTransactionService is the draft transactions actions
type DraftTransactionService interface {
GetDraftTransactions(ctx context.Context, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams, opts ...ModelOps) ([]*DraftTransaction, error)
GetDraftTransactionsCount(ctx context.Context, metadata *Metadata,
conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
}
// UTXOService is the utxo actions
type UTXOService interface {
GetUtxo(ctx context.Context, xPubKey, txID string, outputIndex uint32) (*Utxo, error)
GetUtxos(ctx context.Context, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Utxo, error)
GetUtxosCount(ctx context.Context, metadata *Metadata,
conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{},
queryParams *datastore.QueryParams) ([]*Utxo, error)
}
// XPubService is the xPub actions
type XPubService interface {
GetXpub(ctx context.Context, xPubKey string) (*Xpub, error)
GetXpubByID(ctx context.Context, xPubID string) (*Xpub, error)
ImportXpub(ctx context.Context, xPubKey string, opts ...ModelOps) (*ImportResults, error)
NewXpub(ctx context.Context, xPubKey string, opts ...ModelOps) (*Xpub, error)
UpdateXpubMetadata(ctx context.Context, xPubID string, metadata Metadata) (*Xpub, error)
}
// PaymailService is the paymail actions
type PaymailService interface {
GetPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (*PaymailAddress, error)
GetPaymailAddressesByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata,
conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*PaymailAddress, error)
NewPaymailAddress(ctx context.Context, key, address, publicName, avatar string, opts ...ModelOps) (*PaymailAddress, error)
DeletePaymailAddress(ctx context.Context, address string, opts ...ModelOps) error
UpdatePaymailAddress(ctx context.Context, address, publicName, avatar string,
opts ...ModelOps) (*PaymailAddress, error)
UpdatePaymailAddressMetadata(ctx context.Context, address string,
metadata Metadata, opts ...ModelOps) (*PaymailAddress, error)
}
// HTTPInterface is the HTTP client interface
type HTTPInterface interface {
Do(req *http.Request) (*http.Response, error)
}
// ClientServices is the client related services
type ClientServices interface {
Cachestore() cachestore.ClientInterface
Chainstate() chainstate.ClientInterface
Datastore() datastore.ClientInterface
HTTPClient() HTTPInterface
Logger() logger.Interface
Notifications() notifications.ClientInterface
PaymailClient() paymail.ClientInterface
Taskmanager() taskmanager.ClientInterface
}
// ClientInterface is the client (bux engine) interface comprised of all services
type ClientInterface interface {
AccessKeyService
AdminInterface
ClientServices
DestinationService
DraftTransactionService
PaymailService
TransactionService
BlockHeaderService
UTXOService
XPubService
AddModels(ctx context.Context, autoMigrate bool, models ...interface{}) error
AuthenticateRequest(ctx context.Context, req *http.Request, adminXPubs []string,
adminRequired, requireSigning, signingDisabled bool) (*http.Request, error)
Close(ctx context.Context) error
Debug(on bool)
DefaultModelOptions(opts ...ModelOps) []ModelOps
DefaultSyncConfig() *SyncConfig
EnableNewRelic()
GetOrStartTxn(ctx context.Context, name string) context.Context
GetPaymailConfig() *PaymailServerOptions
GetTaskPeriod(name string) time.Duration
ImportBlockHeadersFromURL() string
IsDebug() bool
IsITCEnabled() bool
IsIUCEnabled() bool
IsNewRelicEnabled() bool
ModifyTaskPeriod(name string, period time.Duration) error
SetNotificationsClient(notifications.ClientInterface)
UserAgent() string
Version() string
}