kaspad/rpcmodel/rpc_websocket_commands.go
stasatdaglabs f46dec449d [NOD-510] Change all references to Bitcoin to Kaspa (#531)
* [NOD-510] Change coinbase flags to kaspad.

* [NOD-510] Removed superfluous spaces after periods in comments.

* [NOD-510] Rename btcd -> kaspad in the root folder.

* [NOD-510] Rename BtcEncode -> KaspaEncode and BtcDecode -> KaspaDecode.

* [NOD-510] Rename BtcEncode -> KaspaEncode and BtcDecode -> KaspaDecode.

* [NOD-510] Continue renaming btcd -> kaspad.

* [NOD-510] Rename btcjson -> kaspajson.

* [NOD-510] Rename file names inside kaspajson.

* [NOD-510] Rename kaspajson -> jsonrpc.

* [NOD-510] Finish renaming in addrmgr.

* [NOD-510] Rename package btcec to ecc.

* [NOD-510] Finish renaming stuff in blockdag.

* [NOD-510] Rename stuff in cmd.

* [NOD-510] Rename stuff in config.

* [NOD-510] Rename stuff in connmgr.

* [NOD-510] Rename stuff in dagconfig.

* [NOD-510] Rename stuff in database.

* [NOD-510] Rename stuff in docker.

* [NOD-510] Rename stuff in integration.

* [NOD-510] Rename jsonrpc to rpcmodel.

* [NOD-510] Rename stuff in limits.

* [NOD-510] Rename stuff in logger.

* [NOD-510] Rename stuff in mempool.

* [NOD-510] Rename stuff in mining.

* [NOD-510] Rename stuff in netsync.

* [NOD-510] Rename stuff in peer.

* [NOD-510] Rename stuff in release.

* [NOD-510] Rename stuff in rpcclient.

* [NOD-510] Rename stuff in server.

* [NOD-510] Rename stuff in signal.

* [NOD-510] Rename stuff in txscript.

* [NOD-510] Rename stuff in util.

* [NOD-510] Rename stuff in wire.

* [NOD-510] Fix failing tests.

* [NOD-510] Fix merge errors.

* [NOD-510] Fix go vet errors.

* [NOD-510] Remove merged file that's no longer relevant.

* [NOD-510] Add a comment above Op0.

* [NOD-510] Fix some comments referencing Bitcoin Core.

* [NOD-510] Fix some more comments referencing Bitcoin Core.

* [NOD-510] Fix bitcoin -> kaspa.

* [NOD-510] Fix more bitcoin -> kaspa.

* [NOD-510] Fix comments, remove DisconnectBlock in addrindex.

* [NOD-510] Rename KSPD to KASD.

* [NOD-510] Fix comments and user agent.
2019-12-12 15:21:41 +02:00

153 lines
5.2 KiB
Go

// Copyright (c) 2014-2017 The btcsuite developers
// Copyright (c) 2015-2017 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
// NOTE: This file is intended to house the RPC commands that are supported by
// a kaspa rpc server, but are only available via websockets.
package rpcmodel
// AuthenticateCmd defines the authenticate JSON-RPC command.
type AuthenticateCmd struct {
Username string
Passphrase string
}
// NewAuthenticateCmd returns a new instance which can be used to issue an
// authenticate JSON-RPC command.
func NewAuthenticateCmd(username, passphrase string) *AuthenticateCmd {
return &AuthenticateCmd{
Username: username,
Passphrase: passphrase,
}
}
// NotifyBlocksCmd defines the notifyBlocks JSON-RPC command.
type NotifyBlocksCmd struct{}
// NewNotifyBlocksCmd returns a new instance which can be used to issue a
// notifyBlocks JSON-RPC command.
func NewNotifyBlocksCmd() *NotifyBlocksCmd {
return &NotifyBlocksCmd{}
}
// StopNotifyBlocksCmd defines the stopNotifyBlocks JSON-RPC command.
type StopNotifyBlocksCmd struct{}
// NewStopNotifyBlocksCmd returns a new instance which can be used to issue a
// stopNotifyBlocks JSON-RPC command.
func NewStopNotifyBlocksCmd() *StopNotifyBlocksCmd {
return &StopNotifyBlocksCmd{}
}
// NotifyChainChangesCmd defines the notifyChainChanges JSON-RPC command.
type NotifyChainChangesCmd struct{}
// NewNotifyChainChangesCmd returns a new instance which can be used to issue a
// notifyChainChanges JSON-RPC command.
func NewNotifyChainChangesCmd() *NotifyChainChangesCmd {
return &NotifyChainChangesCmd{}
}
// StopNotifyChainChangesCmd defines the stopNotifyChainChanges JSON-RPC command.
type StopNotifyChainChangesCmd struct{}
// NewStopNotifyChainChangesCmd returns a new instance which can be used to issue a
// stopNotifyChainChanges JSON-RPC command.
func NewStopNotifyChainChangesCmd() *StopNotifyChainChangesCmd {
return &StopNotifyChainChangesCmd{}
}
// NotifyNewTransactionsCmd defines the notifyNewTransactions JSON-RPC command.
type NotifyNewTransactionsCmd struct {
Verbose *bool `jsonrpcdefault:"false"`
Subnetwork *string
}
// NewNotifyNewTransactionsCmd returns a new instance which can be used to issue
// a notifyNewTransactions JSON-RPC command.
//
// The parameters which are pointers indicate they are optional. Passing nil
// for optional parameters will use the default value.
func NewNotifyNewTransactionsCmd(verbose *bool, subnetworkID *string) *NotifyNewTransactionsCmd {
return &NotifyNewTransactionsCmd{
Verbose: verbose,
Subnetwork: subnetworkID,
}
}
// SessionCmd defines the session JSON-RPC command.
type SessionCmd struct{}
// NewSessionCmd returns a new instance which can be used to issue a session
// JSON-RPC command.
func NewSessionCmd() *SessionCmd {
return &SessionCmd{}
}
// StopNotifyNewTransactionsCmd defines the stopNotifyNewTransactions JSON-RPC command.
type StopNotifyNewTransactionsCmd struct{}
// NewStopNotifyNewTransactionsCmd returns a new instance which can be used to issue
// a stopNotifyNewTransactions JSON-RPC command.
//
// The parameters which are pointers indicate they are optional. Passing nil
// for optional parameters will use the default value.
func NewStopNotifyNewTransactionsCmd() *StopNotifyNewTransactionsCmd {
return &StopNotifyNewTransactionsCmd{}
}
// Outpoint describes a transaction outpoint that will be marshalled to and
// from JSON.
type Outpoint struct {
TxID string `json:"txid"`
Index uint32 `json:"index"`
}
// LoadTxFilterCmd defines the loadTxFilter request parameters to load or
// reload a transaction filter.
type LoadTxFilterCmd struct {
Reload bool
Addresses []string
Outpoints []Outpoint
}
// NewLoadTxFilterCmd returns a new instance which can be used to issue a
// loadTxFilter JSON-RPC command.
func NewLoadTxFilterCmd(reload bool, addresses []string, outpoints []Outpoint) *LoadTxFilterCmd {
return &LoadTxFilterCmd{
Reload: reload,
Addresses: addresses,
Outpoints: outpoints,
}
}
// RescanBlocksCmd defines the rescan JSON-RPC command.
type RescanBlocksCmd struct {
// Block hashes as a string array.
BlockHashes []string
}
// NewRescanBlocksCmd returns a new instance which can be used to issue a rescan
// JSON-RPC command.
func NewRescanBlocksCmd(blockHashes []string) *RescanBlocksCmd {
return &RescanBlocksCmd{BlockHashes: blockHashes}
}
func init() {
// The commands in this file are only usable by websockets.
flags := UFWebsocketOnly
MustRegisterCommand("authenticate", (*AuthenticateCmd)(nil), flags)
MustRegisterCommand("loadTxFilter", (*LoadTxFilterCmd)(nil), flags)
MustRegisterCommand("notifyBlocks", (*NotifyBlocksCmd)(nil), flags)
MustRegisterCommand("notifyChainChanges", (*NotifyChainChangesCmd)(nil), flags)
MustRegisterCommand("notifyNewTransactions", (*NotifyNewTransactionsCmd)(nil), flags)
MustRegisterCommand("session", (*SessionCmd)(nil), flags)
MustRegisterCommand("stopNotifyBlocks", (*StopNotifyBlocksCmd)(nil), flags)
MustRegisterCommand("stopNotifyChainChanges", (*StopNotifyChainChangesCmd)(nil), flags)
MustRegisterCommand("stopNotifyNewTransactions", (*StopNotifyNewTransactionsCmd)(nil), flags)
MustRegisterCommand("rescanBlocks", (*RescanBlocksCmd)(nil), flags)
}