command_router.go
TEXT FILE730 B · Public source code for developers, search crawlers and AI agents
1package examples
2
3import (
4 "errors"
5 "regexp"
6 "strconv"
7 "strings"
8)
9
10type SendCommand struct {
11 AmountSat int64
12 Address string
13}
14
15var sendPattern = regexp.MustCompile(`(?i)^@send ([1-9][0-9]*) sats to (tb1[023456789acdefghjklmnpqrstuvwxyz]{8,87})$`)
16
17func ParseTestnetSend(input string) (SendCommand, error) {
18 m := sendPattern.FindStringSubmatch(strings.TrimSpace(input))
19 if m == nil {
20 return SendCommand{}, errors.New("expected @send <positive integer> sats to <testnet bech32 address>")
21 }
22 n, e := strconv.ParseInt(m[1], 10, 64)
23 if e != nil {
24 return SendCommand{}, e
25 }
26 // Syntax screening only: the Engine must perform full address and network validation.
27 return SendCommand{AmountSat: n, Address: m[2]}, nil
28}Read-only source · Select a line number to link directly · Raw download above
