-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (33 loc) · 997 Bytes
/
Copy pathmain.go
File metadata and controls
36 lines (33 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"flag"
"fmt"
"log"
"net/http"
)
var (
port = flag.Int("p", 7080, "Listen port")
dbPath = flag.String("db", "./data.db", "Path to DB")
rpcURL = flag.String("rpc", "http://[::1]:7076", "RPC URL")
powURL = flag.String("pow", "", "RPC Proof-of-Work URL")
wsURL = flag.String("ws", "ws://[::1]:7078", "WebSocket URL")
callbackURL = flag.String("cb", "", "Callback URL when payment is fulfilled")
)
func main() {
flag.Parse()
if err := initDB(); err != nil {
log.Fatal(err)
}
w, err := loadWallet()
if err != nil {
log.Fatal(err)
}
go scavenger(w)
ws := newWSMux(*wsURL)
http.HandleFunc("/payment/new", newPaymentHandler(w))
http.HandleFunc("/payment/wait", waitPaymentHandler(w, ws))
http.HandleFunc("/payment/cancel", cancelPaymentHandler(w))
http.HandleFunc("/payment/pay", handoffPaymentHandler)
http.HandleFunc("/payment/status", statusPaymentHandler)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
}