chainsvrwscmds.go raw

   1  package btcjson
   2  
   3  // AuthenticateCmd defines the authenticate JSON-RPC command.
   4  type AuthenticateCmd struct {
   5  	Username   string
   6  	Passphrase string
   7  }
   8  
   9  // NewAuthenticateCmd returns a new instance which can be used to issue an authenticate JSON-RPC command.
  10  func NewAuthenticateCmd(username, passphrase string) *AuthenticateCmd {
  11  	return &AuthenticateCmd{
  12  		Username:   username,
  13  		Passphrase: passphrase,
  14  	}
  15  }
  16  
  17  // NotifyBlocksCmd defines the notifyblocks JSON-RPC command.
  18  type NotifyBlocksCmd struct{}
  19  
  20  // NewNotifyBlocksCmd returns a new instance which can be used to issue a notifyblocks JSON-RPC command.
  21  func NewNotifyBlocksCmd() *NotifyBlocksCmd {
  22  	return &NotifyBlocksCmd{}
  23  }
  24  
  25  // StopNotifyBlocksCmd defines the stopnotifyblocks JSON-RPC command.
  26  type StopNotifyBlocksCmd struct{}
  27  
  28  // NewStopNotifyBlocksCmd returns a new instance which can be used to issue a stopnotifyblocks JSON-RPC command.
  29  func NewStopNotifyBlocksCmd() *StopNotifyBlocksCmd {
  30  	return &StopNotifyBlocksCmd{}
  31  }
  32  
  33  // NotifyNewTransactionsCmd defines the notifynewtransactions JSON-RPC command.
  34  type NotifyNewTransactionsCmd struct {
  35  	Verbose *bool `jsonrpcdefault:"false"`
  36  }
  37  
  38  // NewNotifyNewTransactionsCmd returns a new instance which can be used to issue a notifynewtransactions JSON-RPC
  39  // command. The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use
  40  // the default value.
  41  func NewNotifyNewTransactionsCmd(verbose *bool) *NotifyNewTransactionsCmd {
  42  	return &NotifyNewTransactionsCmd{
  43  		Verbose: verbose,
  44  	}
  45  }
  46  
  47  // SessionCmd defines the session JSON-RPC command.
  48  type SessionCmd struct{}
  49  
  50  // NewSessionCmd returns a new instance which can be used to issue a session JSON-RPC command.
  51  func NewSessionCmd() *SessionCmd {
  52  	return &SessionCmd{}
  53  }
  54  
  55  // StopNotifyNewTransactionsCmd defines the stopnotifynewtransactions JSON-RPC command.
  56  type StopNotifyNewTransactionsCmd struct{}
  57  
  58  // NewStopNotifyNewTransactionsCmd returns a new instance which can be used to issue a stopnotifynewtransactions
  59  // JSON-RPC command. The parameters which are pointers indicate they are optional. Passing nil for optional parameters
  60  // will use the default value.
  61  func NewStopNotifyNewTransactionsCmd() *StopNotifyNewTransactionsCmd {
  62  	return &StopNotifyNewTransactionsCmd{}
  63  }
  64  
  65  // NotifyReceivedCmd defines the notifyreceived JSON-RPC command. NOTE: Deprecated. Use LoadTxFilterCmd instead.
  66  type NotifyReceivedCmd struct {
  67  	Addresses []string
  68  }
  69  
  70  // NewNotifyReceivedCmd returns a new instance which can be used to issue a notifyreceived JSON-RPC command.
  71  //
  72  // NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
  73  func NewNotifyReceivedCmd(addresses []string) *NotifyReceivedCmd {
  74  	return &NotifyReceivedCmd{
  75  		Addresses: addresses,
  76  	}
  77  }
  78  
  79  // OutPoint describes a transaction outpoint that will be marshalled to and from JSON.
  80  type OutPoint struct {
  81  	Hash  string `json:"hash"`
  82  	Index uint32 `json:"index"`
  83  }
  84  
  85  // LoadTxFilterCmd defines the loadtxfilter request parameters to load or reload a transaction filter.
  86  //
  87  // NOTE: This is a pod extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
  88  type LoadTxFilterCmd struct {
  89  	Reload    bool
  90  	Addresses []string
  91  	OutPoints []OutPoint
  92  }
  93  
  94  // NewLoadTxFilterCmd returns a new instance which can be used to issue a loadtxfilter JSON-RPC command.
  95  //
  96  // NOTE: This is a pod extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
  97  func NewLoadTxFilterCmd(reload bool, addresses []string, outPoints []OutPoint) *LoadTxFilterCmd {
  98  	return &LoadTxFilterCmd{
  99  		Reload:    reload,
 100  		Addresses: addresses,
 101  		OutPoints: outPoints,
 102  	}
 103  }
 104  
 105  // NotifySpentCmd defines the notifyspent JSON-RPC command.
 106  //
 107  // NOTE: Deprecated. Use LoadTxFilterCmd instead.
 108  type NotifySpentCmd struct {
 109  	OutPoints []OutPoint
 110  }
 111  
 112  // NewNotifySpentCmd returns a new instance which can be used to issue a notifyspent JSON-RPC command.
 113  //
 114  // NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
 115  func NewNotifySpentCmd(outPoints []OutPoint) *NotifySpentCmd {
 116  	return &NotifySpentCmd{
 117  		OutPoints: outPoints,
 118  	}
 119  }
 120  
 121  // StopNotifyReceivedCmd defines the stopnotifyreceived JSON-RPC command.
 122  //
 123  // NOTE: Deprecated. Use LoadTxFilterCmd instead.
 124  type StopNotifyReceivedCmd struct {
 125  	Addresses []string
 126  }
 127  
 128  // NewStopNotifyReceivedCmd returns a new instance which can be used to issue a stopnotifyreceived JSON-RPC command.
 129  //
 130  // NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
 131  func NewStopNotifyReceivedCmd(addresses []string) *StopNotifyReceivedCmd {
 132  	return &StopNotifyReceivedCmd{
 133  		Addresses: addresses,
 134  	}
 135  }
 136  
 137  // StopNotifySpentCmd defines the stopnotifyspent JSON-RPC command.
 138  //
 139  // NOTE: Deprecated. Use LoadTxFilterCmd instead.
 140  type StopNotifySpentCmd struct {
 141  	OutPoints []OutPoint
 142  }
 143  
 144  // NewStopNotifySpentCmd returns a new instance which can be used to issue a stopnotifyspent JSON-RPC command.
 145  //
 146  // NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
 147  func NewStopNotifySpentCmd(outPoints []OutPoint) *StopNotifySpentCmd {
 148  	return &StopNotifySpentCmd{
 149  		OutPoints: outPoints,
 150  	}
 151  }
 152  
 153  // RescanCmd defines the rescan JSON-RPC command. NOTE: Deprecated. Use RescanBlocksCmd instead.
 154  type RescanCmd struct {
 155  	BeginBlock string
 156  	Addresses  []string
 157  	OutPoints  []OutPoint
 158  	EndBlock   *string
 159  }
 160  
 161  // NewRescanCmd returns a new instance which can be used to issue a rescan JSON-RPC command. The parameters which are
 162  // pointers indicate they are optional. Passing nil for optional parameters will use the default value.
 163  //
 164  // NOTE: Deprecated. Use NewRescanBlocksCmd instead.
 165  func NewRescanCmd(beginBlock string, addresses []string, outPoints []OutPoint, endBlock *string) *RescanCmd {
 166  	return &RescanCmd{
 167  		BeginBlock: beginBlock,
 168  		Addresses:  addresses,
 169  		OutPoints:  outPoints,
 170  		EndBlock:   endBlock,
 171  	}
 172  }
 173  
 174  // RescanBlocksCmd defines the rescan JSON-RPC command.
 175  //
 176  // NOTE: This is a pod extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
 177  type RescanBlocksCmd struct {
 178  	// Block hashes as a string array.
 179  	BlockHashes []string
 180  }
 181  
 182  // NewRescanBlocksCmd returns a new instance which can be used to issue a rescan JSON-RPC command.
 183  //
 184  // NOTE: This is a pod extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
 185  func NewRescanBlocksCmd(blockHashes []string) *RescanBlocksCmd {
 186  	return &RescanBlocksCmd{BlockHashes: blockHashes}
 187  }
 188  func init() {
 189  	
 190  	// The commands in this file are only usable by websockets.
 191  	flags := UFWebsocketOnly
 192  	MustRegisterCmd("authenticate", (*AuthenticateCmd)(nil), flags)
 193  	MustRegisterCmd("loadtxfilter", (*LoadTxFilterCmd)(nil), flags)
 194  	MustRegisterCmd("notifyblocks", (*NotifyBlocksCmd)(nil), flags)
 195  	MustRegisterCmd("notifynewtransactions", (*NotifyNewTransactionsCmd)(nil), flags)
 196  	MustRegisterCmd("notifyreceived", (*NotifyReceivedCmd)(nil), flags)
 197  	MustRegisterCmd("notifyspent", (*NotifySpentCmd)(nil), flags)
 198  	MustRegisterCmd("session", (*SessionCmd)(nil), flags)
 199  	MustRegisterCmd("stopnotifyblocks", (*StopNotifyBlocksCmd)(nil), flags)
 200  	MustRegisterCmd("stopnotifynewtransactions", (*StopNotifyNewTransactionsCmd)(nil), flags)
 201  	MustRegisterCmd("stopnotifyspent", (*StopNotifySpentCmd)(nil), flags)
 202  	MustRegisterCmd("stopnotifyreceived", (*StopNotifyReceivedCmd)(nil), flags)
 203  	MustRegisterCmd("rescan", (*RescanCmd)(nil), flags)
 204  	MustRegisterCmd("rescanblocks", (*RescanBlocksCmd)(nil), flags)
 205  }
 206