-
Notifications
You must be signed in to change notification settings - Fork 13
/
dash_core_verifier.go
47 lines (43 loc) · 1.29 KB
/
dash_core_verifier.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
package light
import (
"github.com/dashpay/dashd-go/btcjson"
rpc "github.com/dashpay/dashd-go/rpcclient"
)
// DashCoreVerifier is used to verify signatures of light blocks
type DashCoreVerifier struct {
endpoint *rpc.Client
host string
rpcUsername string
rpcPassword string
defaultQuorumType btcjson.LLMQType
}
// NewDashCoreVerifierClient returns an instance of SignerClient.
// it will start the endpoint (if not already started)
func NewDashCoreVerifierClient(
host string,
rpcUsername string,
rpcPassword string,
defaultQuorumType btcjson.LLMQType,
) (*DashCoreVerifier, error) {
// Connect to local dash core RPC server using HTTP POST mode.
connCfg := &rpc.ConnConfig{
Host: host,
User: rpcUsername,
Pass: rpcPassword,
HTTPPostMode: true, // Dash core only supports HTTP POST mode
DisableTLS: true, // Dash core does not provide TLS by default
}
// Notice the notification parameter is nil since notifications are
// not supported in HTTP POST mode.
client, err := rpc.New(connCfg, nil)
if err != nil {
return nil, err
}
return &DashCoreVerifier{
endpoint: client,
host: host,
rpcUsername: rpcUsername,
rpcPassword: rpcPassword,
defaultQuorumType: defaultQuorumType,
}, nil
}