This repository has been archived by the owner on Oct 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccount.go
86 lines (70 loc) · 2.71 KB
/
account.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
82
83
84
85
86
package main
import (
"encoding/json"
"fmt"
"github.com/AENCO-Global/Chain-go-sdk/sdk/model/account"
"github.com/AENCO-Global/Chain-go-sdk/sdk/model/blockchain"
"github.com/AENCO-Global/Chain-go-sdk/sdk/utils"
"github.com/gorilla/mux"
"net/http"
)
type Error struct {
resp int
status string
message string
}
func accountGenerate(w http.ResponseWriter, r *http.Request) {
type KeyPair struct {
Priv string `json:"priv"`
Pub string `json:"pub"`
}
params := mux.Vars(r)
if (1 == len(params) && 64 == len(params["privateKey"]) ) || (0 == len(params)) { //Ensure there is a parameter and its the right length or Zero
keypair, _ := account.CreateFromPrivateKey(params["privateKey"],blockchain.NetworkType.TEST_NET)
messageA := KeyPair{Priv: utils.Bt2Hex(keypair.KeyPair.PrivateKey ) ,Pub: utils.Bt2Hex(keypair.KeyPair.PublicKey) }
json.NewEncoder(w).Encode(messageA)
} else {
retVals := Error{ 400, "Bad_Request","Received an invalid Private Key!, correct the error or try no Private Key to generate a new one, which is a good idea even to see what the valid one looks like." }
fmt.Fprint(w, retVals)
}
w.Header().Set("Content-Type","application/json")
}
func accountTransactionsGet(w http.ResponseWriter, r *http.Request) {
type accountDetail struct {
Meta string `json:"meta"`
Account []string `json:"account"`
}
params := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Public Key: %v\n", params["publicKey"])
}
func accountTransactionsIncomingGet(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Public Key: %v\n", params["publicKey"])
}
func accountTransactionsOutgoingGet(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Public Key: %v\n", params["publicKey"])
}
func accountTransactionsUnconfirmedGet(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Public Key: %v\n", params["publicKey"])
}
func accountTransactionsPartialGet(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Public Key: %v\n", params["publicKey"])
}
func accountMultisigGet(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Account ID: %v\n", params["accountId"])
}
func accountMultisigGraphGet(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Account ID: %v\n", params["accountId"])
}