1 package btcjson
2 3 const (
4 // AccountBalanceNtfnMethod is the method used for account balance notifications.
5 AccountBalanceNtfnMethod = "accountbalance"
6 // PodConnectedNtfnMethod is the method used for notifications when a wallet server is connected to a chain server.
7 PodConnectedNtfnMethod = "podconnected"
8 // WalletLockStateNtfnMethod is the method used to notify the lock state of a wallet has changed.
9 WalletLockStateNtfnMethod = "walletlockstate"
10 // NewTxNtfnMethod is the method used to notify that a wallet server has added a new transaction to the transaction
11 // store.
12 NewTxNtfnMethod = "newtx"
13 )
14 15 // AccountBalanceNtfn defines the accountbalance JSON-RPC notification.
16 type AccountBalanceNtfn struct {
17 Account string
18 Balance float64 // In DUO
19 Confirmed bool // Whether Balance is confirmed or unconfirmed.
20 }
21 22 // NewAccountBalanceNtfn returns a new instance which can be used to issue an accountbalance JSON-RPC notification.
23 func NewAccountBalanceNtfn(account string, balance float64, confirmed bool) *AccountBalanceNtfn {
24 return &AccountBalanceNtfn{
25 Account: account,
26 Balance: balance,
27 Confirmed: confirmed,
28 }
29 }
30 31 // PodConnectedNtfn defines the podconnected JSON-RPC notification.
32 type PodConnectedNtfn struct {
33 Connected bool
34 }
35 36 // NewPodConnectedNtfn returns a new instance which can be used to issue a podconnected JSON-RPC notification.
37 func NewPodConnectedNtfn(connected bool) *PodConnectedNtfn {
38 return &PodConnectedNtfn{
39 Connected: connected,
40 }
41 }
42 43 // WalletLockStateNtfn defines the walletlockstate JSON-RPC notification.
44 type WalletLockStateNtfn struct {
45 Locked bool
46 }
47 48 // NewWalletLockStateNtfn returns a new instance which can be used to issue a walletlockstate JSON-RPC notification.
49 func NewWalletLockStateNtfn(locked bool) *WalletLockStateNtfn {
50 return &WalletLockStateNtfn{
51 Locked: locked,
52 }
53 }
54 55 // NewTxNtfn defines the newtx JSON-RPC notification.
56 type NewTxNtfn struct {
57 Account string
58 Details ListTransactionsResult
59 }
60 61 // NewNewTxNtfn returns a new instance which can be used to issue a newtx JSON-RPC notification.
62 func NewNewTxNtfn(account string, details ListTransactionsResult) *NewTxNtfn {
63 return &NewTxNtfn{
64 Account: account,
65 Details: details,
66 }
67 }
68 func init() {
69 70 // The commands in this file are only usable with a wallet server via websockets and are notifications.
71 flags := UFWalletOnly | UFWebsocketOnly | UFNotification
72 MustRegisterCmd(AccountBalanceNtfnMethod, (*AccountBalanceNtfn)(nil), flags)
73 MustRegisterCmd(PodConnectedNtfnMethod, (*PodConnectedNtfn)(nil), flags)
74 MustRegisterCmd(WalletLockStateNtfnMethod, (*WalletLockStateNtfn)(nil), flags)
75 MustRegisterCmd(NewTxNtfnMethod, (*NewTxNtfn)(nil), flags)
76 }
77