decode message from client

This commit is contained in:
Tim Williams 2018-06-30 15:12:47 -04:00
parent 6d2dcc0f90
commit 0404cbc062

View file

@ -6,6 +6,7 @@ import (
"net"
"fmt"
"os"
"encoding/json"
)
const (
@ -44,6 +45,19 @@ func handleRequest(conn net.Conn) {
if err == nil {
fmt.Println("Message is ", string(buf[:msg]))
var dat map[string]interface{}
byt := []byte(string(buf[:msg]))
if err := json.Unmarshal(byt, &dat); err != nil {
panic(err)
}
fmt.Println(dat["address"])
fmt.Println(dat["msg"])
fmt.Println(dat["sig"])
//Ecrecover takes 2 args, bytes[] and bytes[]
// we need to pass in the hash of the message as bytes
// and the bytes array of the signature
//crypto.Ecrecover()
fmt.Println("Message is ", msg)
}
if err != nil {