-
Notifications
You must be signed in to change notification settings - Fork 7
/
relampago.go
66 lines (53 loc) · 1.56 KB
/
relampago.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
62
63
64
65
66
package relampago
import "time"
type Wallet interface {
Kind() string
GetInfo() (WalletInfo, error)
CreateInvoice(InvoiceParams) (InvoiceData, error)
GetInvoiceStatus(string) (InvoiceStatus, error)
PaidInvoicesStream() (<-chan InvoiceStatus, error)
MakePayment(PaymentParams) (PaymentData, error)
GetPaymentStatus(string) (PaymentStatus, error)
PaymentsStream() (<-chan PaymentStatus, error)
}
type WalletInfo struct {
Balance int64 `json:"balance"`
}
type InvoiceParams struct {
Msatoshi int64 `json:"msatoshi"`
Description string `json:"description"`
DescriptionHash []byte `json:"descriptionHash"`
Expiry *time.Duration `json:"expiry"`
}
type InvoiceData struct {
CheckingID string `json:"checkingID"`
Preimage string `json:"preimage"`
Invoice string `json:"invoice"`
}
type InvoiceStatus struct {
CheckingID string `json:"checkingID"`
Exists bool `json:"exists"`
Paid bool `json:"paid"`
MSatoshiReceived int64 `json:"msatoshiReceived"`
}
type PaymentParams struct {
Invoice string `json:"invoice"`
CustomAmount int64 `json:"customAmount"`
}
type PaymentData struct {
CheckingID string `json:"checkingID"`
}
type Status string
const (
Unknown Status = "unknown"
NeverTried Status = "never-tried"
Pending Status = "pending"
Failed Status = "failed"
Complete Status = "complete"
)
type PaymentStatus struct {
CheckingID string `json:"checkingID"`
Status Status `json:"status"`
FeePaid int64 `json:"feePaid"`
Preimage string `json:"preimage"`
}