From 0404cbc062cd8b239e4a41bab25df281412ed5cc Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Sat, 30 Jun 2018 15:12:47 -0400 Subject: [PATCH] decode message from client --- shyftRingWalletConn/app.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/shyftRingWalletConn/app.go b/shyftRingWalletConn/app.go index 2390bfb997..41bc953391 100644 --- a/shyftRingWalletConn/app.go +++ b/shyftRingWalletConn/app.go @@ -3,9 +3,10 @@ package main //@NOTE SHYFT main func for api, sets up router and spins up a server //to run server 'go run shyftRingWalletConn/*.go' import ( -"net" -"fmt" -"os" + "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 {