func walletSpendHandler(gateway *daemon.Gateway) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { sdst := r.FormValue("dst") if sdst == "" { Error400(w, "Missing destination address \"dst\"") return } dst, err := coin.DecodeBase58Address(sdst) if err != nil { Error400(w, "Invalid destination address") return } sfee := r.FormValue("fee") fee, err := strconv.ParseUint(sfee, 10, 64) if err != nil { Error400(w, "Invalid \"fee\" value") return } scoins := r.FormValue("coins") shours := r.FormValue("hours") coins, err := strconv.ParseUint(scoins, 10, 64) if err != nil { Error400(w, "Invalid \"coins\" value") return } hours, err := strconv.ParseUint(shours, 10, 64) if err != nil { Error400(w, "Invalid \"hours\" value") return } SendOr404(w, gateway.Spend(visor.NewBalance(coins, hours), fee, dst)) } }