-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnode.go
61 lines (52 loc) · 1.13 KB
/
node.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package lightning
type Invoice struct {
RHash string
PaymentRequest string
Settled bool
MSat int64
Memo string
}
type InvoicesClient struct {
Invoices chan *Invoice
Id uint32
cancelChan chan struct{}
node Node
}
func (c *InvoicesClient) Cancel() {
c.node.unsubscribeInvoices(c)
}
type StatusClient struct {
Status chan Status
Id uint32
cancelChan chan struct{}
node Node
}
func (c *StatusClient) Cancel() {
c.node.unsubscribeStatus(c)
}
type InvoiceRequest struct {
MSat int64
Memo string
}
type Status int
const (
StatusStopped Status = iota
StatusUninitialized
StatusLocked
StatusStarted
StatusFailed
)
type Node interface {
Start() error
Stop() error
GetInvoice(rHash string) (*Invoice, error)
AddInvoice(request *InvoiceRequest) (*Invoice, error)
SubscribeInvoices() (*InvoicesClient, error)
SubscribeStatus() *StatusClient
unsubscribeInvoices(client *InvoicesClient)
unsubscribeStatus(client *StatusClient)
Status() Status
Unlock(password string) error
Init(password string, mnemonics []string) error
GenerateSeed() ([]string, error)
}