Skip to content

Commit 166bc8c

Browse files
committed
rfq: introduce, use tls module
Introduces rfq/tls.go, which contains a basic TLSConfig type and default value of such. The default value, which for now only indicates that certificate verification should be skipped, is used in place of the 'dialInsecure' bool when setting up the price oracle RPC.
1 parent 4ffe39f commit 166bc8c

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

rfq/oracle.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func insecureServerDialOpts() ([]grpc.DialOption, error) {
214214

215215
// NewRpcPriceOracle creates a new RPC price oracle handle given the address
216216
// of the price oracle RPC server.
217-
func NewRpcPriceOracle(addrStr string, dialInsecure bool) (*RpcPriceOracle,
217+
func NewRpcPriceOracle(addrStr string, tlsConfig *TLSConfig) (*RpcPriceOracle,
218218
error) {
219219

220220
addr, err := ParsePriceOracleAddress(addrStr)
@@ -228,6 +228,9 @@ func NewRpcPriceOracle(addrStr string, dialInsecure bool) (*RpcPriceOracle,
228228
return nil, err
229229
}
230230

231+
// Determine whether we should skip certificate verification.
232+
dialInsecure := tlsConfig.InsecureSkipVerify
233+
231234
// Allow connecting to a non-TLS (h2c, http over cleartext) gRPC server,
232235
// should be used for testing only.
233236
if dialInsecure {

rfq/oracle_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func runQuerySalePriceTest(t *testing.T, tc *testCaseQuerySalePrice) {
141141

142142
// Create a new RPC price oracle client and connect to the mock service.
143143
serviceAddr := fmt.Sprintf("rfqrpc://%s", testServiceAddress)
144-
client, err := NewRpcPriceOracle(serviceAddr, true)
144+
client, err := NewRpcPriceOracle(serviceAddr, DefaultTLSConfig())
145145
require.NoError(t, err)
146146

147147
// Query for an ask price.
@@ -251,7 +251,7 @@ func runQueryPurchasePriceTest(t *testing.T, tc *testCaseQueryPurchasePrice) {
251251

252252
// Create a new RPC price oracle client and connect to the mock service.
253253
serviceAddr := fmt.Sprintf("rfqrpc://%s", testServiceAddress)
254-
client, err := NewRpcPriceOracle(serviceAddr, true)
254+
client, err := NewRpcPriceOracle(serviceAddr, DefaultTLSConfig())
255255
require.NoError(t, err)
256256

257257
// Query for an ask price.

rfq/tls.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package rfq
2+
3+
// TLSConfig represents TLS configuration options for oracle connections.
4+
type TLSConfig struct {
5+
// InsecureSkipVerify disables certificate verification.
6+
InsecureSkipVerify bool
7+
}
8+
9+
// DefaultTLSConfig returns a default TLS configuration.
10+
func DefaultTLSConfig() *TLSConfig {
11+
return &TLSConfig{
12+
InsecureSkipVerify: true,
13+
}
14+
}

tapcfg/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
462462

463463
default:
464464
priceOracle, err = rfq.NewRpcPriceOracle(
465-
rfqCfg.PriceOracleAddress, false,
465+
rfqCfg.PriceOracleAddress, rfq.DefaultTLSConfig(),
466466
)
467467
if err != nil {
468468
return nil, fmt.Errorf("unable to create price "+

0 commit comments

Comments
 (0)