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
161 lines (140 loc) · 4.75 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
package bux
import (
"time"
"github.com/BuxOrg/bux/utils"
)
// Defaults for engine functionality
const (
databaseLongReadTimeout = 30 * time.Second // For all "GET" or "SELECT" methods
defaultCacheLockTTL = 20 // in Seconds
defaultCacheLockTTW = 10 // in Seconds
defaultDatabaseReadTimeout = 10 * time.Second // For all "GET" or "SELECT" methods
defaultDraftTxExpiresIn = 30 * time.Second // Default TTL for draft transactions
defaultOverheadSize = uint64(10) // 10 bytes is the default overhead in a transaction
defaultUserAgent = "bux: " + version // Default user agent
dustLimit = uint64(512) // Dust limit
mongoTestVersion = "4.2.1" // Mongo Testing Version
sqliteTestVersion = "3.37.0" // SQLite Testing Version (dummy version for now)
version = "v0.1.1" // bux version
)
// All the base models
const (
ModelAccessKey ModelName = "access_key"
ModelDestination ModelName = "destination"
ModelDraftTransaction ModelName = "draft_transaction"
ModelIncomingTransaction ModelName = "incoming_transaction"
ModelMetadata ModelName = "metadata"
ModelNameEmpty ModelName = "empty"
ModelSyncTransaction ModelName = "sync_transaction"
ModelTransaction ModelName = "transaction"
ModelUtxo ModelName = "utxo"
ModelXPub ModelName = "xpub"
)
var (
// AllModelNames is a list of all models
AllModelNames = []ModelName{
ModelAccessKey,
ModelDestination,
ModelIncomingTransaction,
ModelMetadata,
ModelSyncTransaction,
ModelTransaction,
ModelUtxo,
ModelXPub,
}
)
// Internal table names
const (
tableAccessKeys = "access_keys"
tableDestinations = "destinations"
tableDraftTransactions = "draft_transactions"
tableIncomingTransactions = "incoming_transactions"
tableSyncTransactions = "sync_transactions"
tableTransactions = "transactions"
tableUTXOs = "utxos"
tableXPubs = "xpubs"
)
const (
// ReferenceIDField is used for Paymail
ReferenceIDField = "reference_id"
// Internal field names
broadcastStatusField = "broadcast_status"
currentBalanceField = "current_balance"
draftIDField = "draft_id"
idField = "id"
metadataField = "metadata"
nextExternalNumField = "next_external_num"
nextInternalNumField = "next_internal_num"
spendingTxIDField = "spending_tx_id"
statusField = "status"
syncStatusField = "sync_status"
typeField = "type"
xPubIDField = "xpub_id"
xPubMetadataField = "xpub_metadata"
// 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
defaultAddressResolutionPurpose = "bux Address Resolution"
defaultSenderPaymail = "bitcoinschema@moneybutton.com"
handleHandcashPrefix = "$"
handleMaxLength = 25
handleRelayPrefix = "1"
// Misc
gormTypeText = "text"
migrateList = "migrate"
modelList = "models"
)
var (
// defaultFee is used when a fee is not provided the draft transaction
defaultFee = &utils.FeeUnit{
Satoshis: 1,
Bytes: 2,
}
// BaseModels is the list of models for loading the engine and AutoMigration (defaults)
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),
},
// Incoming transactions (external & unknown) (related to Transaction & Draft)
&IncomingTransaction{
Model: *NewBaseModel(ModelIncomingTransaction),
},
// 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),
},
}
)