diff --git a/endpoints.go b/endpoints.go index 99a655d..e485626 100644 --- a/endpoints.go +++ b/endpoints.go @@ -599,3 +599,25 @@ func PostTx() { erpc.MarshalSend(w, x) }) } + +// NetworkReturn is a simple struct that is used as helper to return network config +type NetworkReturn struct { + Network string +} + +// GetNetwork checks which network the wrapper is running on +func GetNetwork(mainnet bool) { + http.HandleFunc("/network", func(w http.ResponseWriter, r *http.Request) { + err := erpc.CheckGet(w, r) + if err != nil { + log.Println(err) + return + } + var x NetworkReturn + x.Network = "Testnet" + if mainnet { + x.Network = "Mainnet" + } + erpc.MarshalSend(w, x) + }) +} \ No newline at end of file diff --git a/main.go b/main.go index bba659a..8499646 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,7 @@ func startHandlers() { PostTx() RelayTxid() RelayGetRequest() + GetNetwork(opts.Mainnet) } func main() {