refactor broadcasttx function

This commit is contained in:
Tim Williams 2018-06-12 14:11:40 -04:00
parent 26de99f4d5
commit 84fe574331

View file

@ -273,12 +273,10 @@ func BroadcastTx(w http.ResponseWriter, r *http.Request) {
} }
tx_hash := dat["result"] tx_hash := dat["result"]
if(tx_hash == nil) { if(tx_hash == nil) {
errObj := dat["error"] errMap := dat["error"].(map[string]interface{})
errObj2 := errObj.(map[string]interface{})
fmt.Println()
w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, "ERROR:", errObj2["message"]) fmt.Fprintln(w, "ERROR:", errMap["message"])
} else { } else {
w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)