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
/
definitions.go
170 lines (151 loc) · 5.56 KB
/
definitions.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
package bux
import (
"time"
)
// Defaults for engine functionality
const (
changeOutputSize = uint64(35) // Average size in bytes of a change output
databaseLongReadTimeout = 30 * time.Second // For all "GET" or "SELECT" methods
defaultBroadcastTimeout = 25 * time.Second // Default timeout for broadcasting
defaultCacheLockTTL = 20 // in Seconds
defaultCacheLockTTW = 10 // in Seconds
defaultDatabaseReadTimeout = 20 * time.Second // For all "GET" or "SELECT" methods
defaultDraftTxExpiresIn = 20 * time.Second // Default TTL for draft transactions
defaultHTTPTimeout = 20 * time.Second // Default timeout for HTTP requests
defaultOverheadSize = uint64(8) // 8 bytes is the default overhead in a transaction = 4 bytes version + 4 bytes nLockTime
defaultQueryTxTimeout = 10 * time.Second // Default timeout for syncing on-chain information
defaultUserAgent = "bux: " + version // Default user agent
dustLimit = uint64(1) // Dust limit
mongoTestVersion = "6.0.4" // Mongo Testing Version
sqliteTestVersion = "3.37.0" // SQLite Testing Version (dummy version for now)
version = "v0.14.2" // bux version
)
// All the base models
const (
ModelAccessKey ModelName = "access_key"
ModelDestination ModelName = "destination"
ModelDraftTransaction ModelName = "draft_transaction"
ModelMetadata ModelName = "metadata"
ModelNameEmpty ModelName = "empty"
ModelPaymailAddress ModelName = "paymail_address"
ModelSyncTransaction ModelName = "sync_transaction"
ModelTransaction ModelName = "transaction"
ModelUtxo ModelName = "utxo"
ModelXPub ModelName = "xpub"
)
// AllModelNames is a list of all models
var AllModelNames = []ModelName{
ModelAccessKey,
ModelDestination,
ModelMetadata,
ModelPaymailAddress,
ModelPaymailAddress,
ModelSyncTransaction,
ModelTransaction,
ModelUtxo,
ModelXPub,
}
// Internal table names
const (
tableAccessKeys = "access_keys"
tableDestinations = "destinations"
tableDraftTransactions = "draft_transactions"
tablePaymailAddresses = "paymail_addresses"
tableSyncTransactions = "sync_transactions"
tableTransactions = "transactions"
tableUTXOs = "utxos"
tableXPubs = "xpubs"
)
const (
// ReferenceIDField is used for Paymail
ReferenceIDField = "reference_id"
// Internal field names
aliasField = "alias"
broadcastStatusField = "broadcast_status"
createdAtField = "created_at"
currentBalanceField = "current_balance"
domainField = "domain"
draftIDField = "draft_id"
idField = "id"
metadataField = "metadata"
nextExternalNumField = "next_external_num"
nextInternalNumField = "next_internal_num"
p2pStatusField = "p2p_status"
satoshisField = "satoshis"
spendingTxIDField = "spending_tx_id"
statusField = "status"
syncStatusField = "sync_status"
typeField = "type"
xPubIDField = "xpub_id"
xPubMetadataField = "xpub_metadata"
blockHeightField = "block_height"
blockHashField = "block_hash"
merkleProofField = "merkle_proof"
bumpField = "bump"
// Universal statuses
statusCanceled = "canceled"
statusComplete = "complete"
statusDraft = "draft"
statusError = "error"
statusExpired = "expired"
statusPending = "pending"
statusProcessing = "processing"
statusReady = "ready"
statusSkipped = "skipped"
// Paymail / Handles
cacheKeyAddressResolution = "paymail-address-resolution-"
cacheKeyCapabilities = "paymail-capabilities-"
cacheTTLAddressResolution = 2 * time.Minute
cacheTTLCapabilities = 60 * time.Minute
defaultSenderPaymail = "buxorg@bux.com"
handleHandcashPrefix = "$"
handleMaxLength = 25
handleRelayPrefix = "1"
p2pMetadataField = "p2p_tx_metadata"
// Misc
gormTypeText = "text"
migrateList = "migrate"
modelList = "models"
)
// Cache keys for model caching
const (
cacheKeyDestinationModel = "destination-id-%s" // model-id-<destination_id>
cacheKeyDestinationModelByAddress = "destination-address-%s" // model-address-<address>
cacheKeyDestinationModelByLockingScript = "destination-locking-script-%s" // model-locking-script-<script>
cacheKeyXpubModel = "xpub-id-%s" // model-id-<xpub_id>
)
// BaseModels is the list of models for loading the engine and AutoMigration (defaults)
var BaseModels = []interface{}{
// Base extended HD-key table
&Xpub{
Model: *NewBaseModel(ModelXPub),
},
// Access keys (extend access from xPub)
&AccessKey{
Model: *NewBaseModel(ModelAccessKey),
},
// Draft transactions are created before the final transaction is completed
&DraftTransaction{
Model: *NewBaseModel(ModelDraftTransaction),
},
// Finalized transactions (related to Draft)
&Transaction{
Model: *NewBaseModel(ModelTransaction),
},
// Sync configuration for transactions (on-chain) (related to Transaction)
&SyncTransaction{
Model: *NewBaseModel(ModelSyncTransaction),
},
// Various types of destinations (common is: P2PKH Address)
&Destination{
Model: *NewBaseModel(ModelDestination),
},
// Unspent outputs from known transactions
&Utxo{
Model: *NewBaseModel(ModelUtxo),
},
// Paymail addresses related to XPubs (automatically added when paymail is enabled)
/*&PaymailAddress{
Model: *NewBaseModel(ModelPaymailAddress),
},*/
}