-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathratesClient.go
More file actions
42 lines (38 loc) · 1.16 KB
/
Copy pathratesClient.go
File metadata and controls
42 lines (38 loc) · 1.16 KB
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
package ptcpayclient
//***********************************************
//* Copyright (c) 2021 Ulbora Labs LLC
//* Copyright (c) 2021 Ken Williamson
//***********************************************
import (
"encoding/hex"
"fmt"
"net/http"
"strings"
)
//GetRates GetRates
func (a *BTCPayClient) GetRates(currencyPairs []string, storeID string) *RateResponse {
var rtn RateResponse
args := strings.Join(currencyPairs[:], ",")
var url = a.host + "/rates?currencyPairs=" + args + "&storeID=" + storeID + "&token=" + a.tokens.Token
a.log.Debug("url: ", url)
//aJSON, err := json.Marshal(req)
//if err == nil {
var headers Headers
//create signed headers
urlb := []byte(url)
signVal, _ := a.crypto.Sign(urlb, a.kp)
headers.Set("X-Identity", a.crypto.GetPublicKey(a.kp))
headers.Set("X-Signature", hex.EncodeToString(signVal))
fmt.Println("headers: ", headers)
req := a.buildRequest(http.MethodGet, url, headers, nil)
suc, stat := a.proxy.Do(req, &rtn)
a.log.Debug("suc: ", suc)
a.log.Debug("stat: ", stat)
//rtn.Code = int64(stat)
if !suc || stat != http.StatusOK {
a.log.Debug("proxy call failed to : ", url)
}
//}
a.log.Debug("rtn: ", rtn)
return &rtn
}