1 // Copyright (c) 2014 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
5 // NOTE: This file is intended to house the RPC websocket notifications that are
6 // supported by a wallet server.
11 // AccountBalanceNtfnMethod is the method used for account balance
13 AccountBalanceNtfnMethod = "accountbalance"
15 // BtcdConnectedNtfnMethod is the method used for notifications when
16 // a wallet server is connected to a chain server.
17 BtcdConnectedNtfnMethod = "btcdconnected"
19 // WalletLockStateNtfnMethod is the method used to notify the lock state
20 // of a wallet has changed.
21 WalletLockStateNtfnMethod = "walletlockstate"
23 // NewTxNtfnMethod is the method used to notify that a wallet server has
24 // added a new transaction to the transaciton store.
25 NewTxNtfnMethod = "newtx"
28 // AccountBalanceNtfn defines the accountbalance JSON-RPC notification.
29 type AccountBalanceNtfn struct {
31 Balance float64 // In BTC
32 Confirmed bool // Whether Balance is confirmed or unconfirmed.
35 // NewAccountBalanceNtfn returns a new instance which can be used to issue an
36 // accountbalance JSON-RPC notification.
37 func NewAccountBalanceNtfn(account string, balance float64, confirmed bool) *AccountBalanceNtfn {
38 return &AccountBalanceNtfn{
45 // BtcdConnectedNtfn defines the btcdconnected JSON-RPC notification.
46 type BtcdConnectedNtfn struct {
50 // NewBtcdConnectedNtfn returns a new instance which can be used to issue a
51 // btcdconnected JSON-RPC notification.
52 func NewBtcdConnectedNtfn(connected bool) *BtcdConnectedNtfn {
53 return &BtcdConnectedNtfn{
58 // WalletLockStateNtfn defines the walletlockstate JSON-RPC notification.
59 type WalletLockStateNtfn struct {
63 // NewWalletLockStateNtfn returns a new instance which can be used to issue a
64 // walletlockstate JSON-RPC notification.
65 func NewWalletLockStateNtfn(locked bool) *WalletLockStateNtfn {
66 return &WalletLockStateNtfn{
71 // NewTxNtfn defines the newtx JSON-RPC notification.
72 type NewTxNtfn struct {
74 Details ListTransactionsResult
77 // NewNewTxNtfn returns a new instance which can be used to issue a newtx
78 // JSON-RPC notification.
79 func NewNewTxNtfn(account string, details ListTransactionsResult) *NewTxNtfn {
87 // The commands in this file are only usable with a wallet server via
88 // websockets and are notifications.
89 flags := UFWalletOnly | UFWebsocketOnly | UFNotification
91 MustRegisterCmd(AccountBalanceNtfnMethod, (*AccountBalanceNtfn)(nil), flags)
92 MustRegisterCmd(BtcdConnectedNtfnMethod, (*BtcdConnectedNtfn)(nil), flags)
93 MustRegisterCmd(WalletLockStateNtfnMethod, (*WalletLockStateNtfn)(nil), flags)
94 MustRegisterCmd(NewTxNtfnMethod, (*NewTxNtfn)(nil), flags)