-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
definitions.go
81 lines (71 loc) · 3.21 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
package paymail
import (
"time"
"github.com/go-resty/resty/v2"
)
// Defaults for paymail functions
const (
defaultDNSPort = "53" // Default port for DNS / NameServer checks
defaultDNSTimeout = 5 * time.Second // In seconds
defaultHTTPTimeout = 20 * time.Second // Default timeout for all GET requests in seconds
defaultNameServer = "8.8.8.8" // Default DNS NameServer
defaultNameServerNetwork = "udp" // Default for NS dialer
defaultRetryCount = 2 // Default retry count for HTTP requests
defaultSSLDeadline = 10 * time.Second // Default deadline in seconds
defaultSSLTimeout = 10 * time.Second // Default timeout in seconds
defaultUserAgent = "go-paymail: " + version // Default user agent
defaultNetwork = byte(Mainnet) // Default network
version = "v0.10.3" // Go-Paymail version
)
// Public defaults for paymail specs
/*
http://bsvalias.org/02-01-host-discovery.html
Service bsvalias
Proto tcp
Name <domain>.<tld>.
TTL 3600 (see notes)
Class IN
Priority 10
Weight 10
Port 443
Target <endpoint-discovery-host>
Max SRV Records: 1
*/
const (
DefaultBsvAliasVersion = "1.0" // Default version number for bsvalias
DefaultPort = 443 // Default port (from specs)
DefaultPriority = 10 // Default priority (from specs)
DefaultProtocol = "tcp" // Default protocol (from specs)
DefaultServiceName = "bsvalias" // Default service name (from specs)
DefaultWeight = 10 // Default weight (from specs)
PubKeyLength = 66 // Required length for a valid PubKey (pki)
)
// StandardResponse is the standard fields returned on all responses
type StandardResponse struct {
Body []byte `json:"-"` // Body of the response request
StatusCode int `json:"-"` // Status code returned on the request
Tracing resty.TraceInfo `json:"-"` // Trace information if enabled on the request
}
/*
Example error response
{
"code": "not-found",
"message": "Paymail not found: mrz@mneybutton.com"
}
*/
// ServerError is the standard error response from a paymail server
type ServerError struct {
Code string `json:"code"` // Shows the corresponding code
Message string `json:"message"` // Shows the error message returned by the server
}
// AddressInformation is an internal struct for paymail addresses and their corresponding information
type AddressInformation struct {
Alias string `json:"alias"` // Alias or handle of the paymail
Avatar string `json:"avatar"` // This is the url of the user (public profile)
Domain string `json:"domain"` // Domain of the paymail
ID string `json:"id"` // Global unique identifier
LastAddress string `json:"last_address"` // This is used as a temp address for now (should be via xPub)
Name string `json:"name"` // This is the name of the user (public profile)
PrivateKey string `json:"-"` // PrivateKey hex encoded
PubKey string `json:"pubkey"` // PublicKey hex encoded
}