dispatch.go
TEXT FILE757 B · Public source code for developers, search crawlers and AI agents
1package main
2
3import (
4 "encoding/json"
5 "errors"
6 "fmt"
7)
8
9type Args struct {
10 Net string `json:"net"`
11 Type string `json:"type"`
12}
13
14// Accept typed values after strict parsing and schema validation.
15func route(name string, a Args) (string, []byte, error) {
16 if name != "wab_wallet_balance" {
17 return "", nil, errors.New("unknown tool")
18 }
19 if a.Net != "test" || (a.Type != "segwit" && a.Type != "taproot") {
20 return "", nil, errors.New("invalid arguments")
21 }
22 body, err := json.Marshal(a)
23 return "/api/v5/btc/wallet/balance", body, err
24}
25
26func main() {
27 path, body, err := route("wab_wallet_balance", Args{"test", "segwit"})
28 if err != nil { panic(err) }
29 fmt.Printf("POST %s %s\n", path, body)
30}Read-only source · Select a line number to link directly · Raw download above
