forked from marcetin/parallelcoin
-
Notifications
You must be signed in to change notification settings - Fork 5
/
walletsvrwsntfns.go
76 lines (66 loc) · 2.64 KB
/
walletsvrwsntfns.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
67
68
69
70
71
72
73
74
75
76
package btcjson
const (
// AccountBalanceNtfnMethod is the method used for account balance notifications.
AccountBalanceNtfnMethod = "accountbalance"
// PodConnectedNtfnMethod is the method used for notifications when a wallet server is connected to a chain server.
PodConnectedNtfnMethod = "podconnected"
// WalletLockStateNtfnMethod is the method used to notify the lock state of a wallet has changed.
WalletLockStateNtfnMethod = "walletlockstate"
// NewTxNtfnMethod is the method used to notify that a wallet server has added a new transaction to the transaction
// store.
NewTxNtfnMethod = "newtx"
)
// AccountBalanceNtfn defines the accountbalance JSON-RPC notification.
type AccountBalanceNtfn struct {
Account string
Balance float64 // In DUO
Confirmed bool // Whether Balance is confirmed or unconfirmed.
}
// NewAccountBalanceNtfn returns a new instance which can be used to issue an accountbalance JSON-RPC notification.
func NewAccountBalanceNtfn(account string, balance float64, confirmed bool) *AccountBalanceNtfn {
return &AccountBalanceNtfn{
Account: account,
Balance: balance,
Confirmed: confirmed,
}
}
// PodConnectedNtfn defines the podconnected JSON-RPC notification.
type PodConnectedNtfn struct {
Connected bool
}
// NewPodConnectedNtfn returns a new instance which can be used to issue a podconnected JSON-RPC notification.
func NewPodConnectedNtfn(connected bool) *PodConnectedNtfn {
return &PodConnectedNtfn{
Connected: connected,
}
}
// WalletLockStateNtfn defines the walletlockstate JSON-RPC notification.
type WalletLockStateNtfn struct {
Locked bool
}
// NewWalletLockStateNtfn returns a new instance which can be used to issue a walletlockstate JSON-RPC notification.
func NewWalletLockStateNtfn(locked bool) *WalletLockStateNtfn {
return &WalletLockStateNtfn{
Locked: locked,
}
}
// NewTxNtfn defines the newtx JSON-RPC notification.
type NewTxNtfn struct {
Account string
Details ListTransactionsResult
}
// NewNewTxNtfn returns a new instance which can be used to issue a newtx JSON-RPC notification.
func NewNewTxNtfn(account string, details ListTransactionsResult) *NewTxNtfn {
return &NewTxNtfn{
Account: account,
Details: details,
}
}
func init() {
// The commands in this file are only usable with a wallet server via websockets and are notifications.
flags := UFWalletOnly | UFWebsocketOnly | UFNotification
MustRegisterCmd(AccountBalanceNtfnMethod, (*AccountBalanceNtfn)(nil), flags)
MustRegisterCmd(PodConnectedNtfnMethod, (*PodConnectedNtfn)(nil), flags)
MustRegisterCmd(WalletLockStateNtfnMethod, (*WalletLockStateNtfn)(nil), flags)
MustRegisterCmd(NewTxNtfnMethod, (*NewTxNtfn)(nil), flags)
}