aboutsummaryrefslogtreecommitdiffstats
path: root/gosrc/requests.go
blob: 7be1d49ccd3825d456f8d9e28f83293e8a94b7d5 (plain)
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
//   SMITH            (  //       /
//   requests          ( )/       /
//   by salade         )(/        /
//  ________________  ( /)        /
// ()__)____________)))))   :^}   /

package main

import (
	"fmt"
	"log"
	"strings"
)

// sign request with given private key
func sign_request(body string, key string) string {
	fmt.Println("signing request : ", body)

	// run pipeline
	out2, err := RunStrings("/usr/bin/echo", "-n", body, "|", "/usr/bin/openssl", "dgst", "-sha256", "-hmac", key)
	if err != nil {
		log.Fatal("error: failed to sign request", err)
	}

	// remove unwanted characters
	tok := strings.Index(out2, "(")
	last := len(out2) - 1
	first := tok + len("(stdin)= ")
	out2 = out2[first:last]
	return out2
}

// create body given choice ex :
// GET /sapi/v1/capital/config/getall ||
// POST /sapi/v1/asset/dust-btc
func make_body(order string, ticker string, price string) string {
	ret := "GET /sapi/v1/capital/config/getall"
	return ret
}