Documentation ¶
Overview ¶
NOTE: This file is intended to house the RPC commands that are supported by a chain server.
Index ¶
- Variables
- type AddNodeSubCmd
- type CallLogResult
- type CallResult
- type ContractTemplate
- type ContractTemplateDetail
- type CreateRawTransactionResult
- type DecodeScriptResult
- type ErrorCode
- type FeeItemResult
- type FeeResult
- type GetBalanceResult
- type GetBalancesResult
- type GetBestBlockResult
- type GetBlockChainInfoResult
- type GetBlockHeaderVerboseResult
- type GetBlockTemplateResultAux
- type GetBlockVerboseResult
- type GetConsensusMiningInfoResult
- type GetMergeUtxoResult
- type GetNetTotalsResult
- type GetRawMempoolVerboseResult
- type GetSignUpStatusResult
- type ListUnspentResult
- type LockEntryResult
- type LogResult
- type MsgSignResult
- type PrevOut
- type RPCError
- type RPCErrorCode
- type ReceiptResult
- type RunTxResult
- type ScriptPubKeyResult
- type ScriptSig
- type SearchRawTransactionsResult
- type TestCallData
- type TestResult
- type TransactionInput
- type TransactionOutput
- type TxRawDecodeResult
- type TxRawResult
- type TxResult
- type UnspentPageResult
- type Vin
- type VinPrevOut
- type Vout
Constants ¶
This section is empty.
Variables ¶
var (
ErrRPCInternal = &RPCError{
Code: -32603,
Message: "Internal error",
}
)
Standard JSON-RPC 2.0 errors.
Functions ¶
This section is empty.
Types ¶
type AddNodeSubCmd ¶
type AddNodeSubCmd string
AddNodeSubCmd defines the type used in the addnode JSON-RPC command for the sub command field.
const ( // ANAdd indicates the specified host should be added as a persistent // peer. ANAdd AddNodeSubCmd = "add" // ANRemove indicates the specified peer should be removed. ANRemove AddNodeSubCmd = "remove" // ANOneTry indicates the specified host should try to connect once, // but it should not be made persistent. ANOneTry AddNodeSubCmd = "onetry" )
type CallLogResult ¶
type CallLogResult struct { EventName string `json:"eventname"` Log interface{} `json:"log"` }
type CallResult ¶
type CallResult struct { Result interface{} `json:"result"` Logs []CallLogResult `json:"logs"` Name string `json:"name,omitempty"` GasUsed uint64 `json:"gasused,omitempty"` }
type ContractTemplate ¶
type ContractTemplateDetail ¶
type DecodeScriptResult ¶
type DecodeScriptResult struct { Asm string `json:"asm"` ReqSigs int32 `json:"reqSigs,omitempty"` Type string `json:"type"` Addresses []string `json:"addresses,omitempty"` P2sh string `json:"p2sh,omitempty"` }
DecodeScriptResult models the data returned from the decodescript command.
type ErrorCode ¶
type ErrorCode int
ErrorCode identifies a kind of error. These error codes are NOT used for JSON-RPC response errors.
const ( // ErrDuplicateMethod indicates a command with the specified method // already exists. ErrDuplicateMethod ErrorCode = iota // ErrInvalidUsageFlags indicates one or more unrecognized flag bits // were specified. ErrInvalidUsageFlags // ErrInvalidType indicates a type was passed that is not the required // type. ErrInvalidType // ErrEmbeddedType indicates the provided command struct contains an // embedded type which is not not supported. ErrEmbeddedType // ErrUnexportedField indiciates the provided command struct contains an // unexported field which is not supported. ErrUnexportedField // ErrUnsupportedFieldType indicates the type of a field in the provided // command struct is not one of the supported types. ErrUnsupportedFieldType // ErrNonOptionalField indicates a non-optional field was specified // after an optional field. ErrNonOptionalField // ErrNonOptionalDefault indicates a 'jsonrpcdefault' struct tag was // specified for a non-optional field. ErrNonOptionalDefault // ErrMismatchedDefault indicates a 'jsonrpcdefault' struct tag contains // a value that doesn't match the type of the field. ErrMismatchedDefault // ErrUnregisteredMethod indicates a method was specified that has not // been registered. ErrUnregisteredMethod // ErrMissingDescription indicates a description required to generate // help is missing. ErrMissingDescription // ErrNumParams inidcates the number of params supplied do not // match the requirements of the associated command. ErrNumParams )
These constants are used to identify a specific RuleError.
type FeeItemResult ¶
type GetBalanceResult ¶
type GetBalancesResult ¶
type GetBalancesResult struct { Address string `json:"address"` Assets []GetBalanceResult `json:"assets"` }
type GetBestBlockResult ¶
GetBestBlockResult models the data from the getbestblock command.
type GetBlockChainInfoResult ¶
type GetBlockChainInfoResult struct { Chain string `json:"chain"` Blocks int32 `json:"blocks"` BestBlockHash string `json:"bestblockhash"` MedianTime int64 `json:"mediantime"` Round int32 `json:"round"` Slot int16 `json:"slot"` }
GetBlockChainInfoResult models the data returned from the getblockchaininfo command.
type GetBlockHeaderVerboseResult ¶
type GetBlockHeaderVerboseResult struct { Hash string `json:"hash"` Confirmations int64 `json:"confirmations"` Height int32 `json:"height"` Version int32 `json:"version"` // VersionHex string `json:"versionHex"` MerkleRoot string `json:"merkleroot"` StateRoot string `json:"stateroot"` Time int64 `json:"time"` PreviousHash string `json:"previousblockhash,omitempty"` NextHash string `json:"nextblockhash,omitempty"` GasLimit int64 `json:"gaslimist,omitempty"` GasUsed int64 `json:"gasused,omitempty"` }
GetBlockHeaderVerboseResult models the data from the getblockheader command when the verbose flag is set. When the verbose flag is not set, getblockheader returns a hex-encoded string.
type GetBlockTemplateResultAux ¶
type GetBlockTemplateResultAux struct {
Flags string `json:"flags"`
}
GetBlockTemplateResultAux models the coinbaseaux field of the getblocktemplate command.
type GetBlockVerboseResult ¶
type GetBlockVerboseResult struct { Hash string `json:"hash"` Confirmations int64 `json:"confirmations"` Size int32 `json:"size"` Height int64 `json:"height"` Version int32 `json:"version"` MerkleRoot string `json:"merkleroot"` Tx []string `json:"tx,omitempty"` RawTx []TxResult `json:"rawtx,omitempty"` Time int64 `json:"time"` TxCount uint64 `json:"txCount"` PreviousHash string `json:"previousblockhash"` StateRoot string `json:"stateroot"` NextHash string `json:"nextblockhash,omitempty"` Vtxs []TxResult `json:"vtxs,omitempty"` Receipts []*ReceiptResult `json:"receipts,omitempty"` Round uint32 `json:"round"` Slot uint16 `json:"slot"` GasLimit uint64 `json:"gaslimit,omitempty"` GasUsed uint64 `json:"gasused,omitempty"` Reward int64 `json:"reward,omitempty"` FeeList []FeeResult `json:"FeeList,omitempty"` PreSigList []MsgSignResult `json:"presiglist,omitempty"` Weight uint16 `json:"weight"` }
GetBlockVerboseResult models the data from the getblock command when the verbose flag is set. When the verbose flag is not set, getblock returns a hex-encoded string.
type GetMergeUtxoResult ¶
type GetNetTotalsResult ¶
type GetNetTotalsResult struct { TotalBytesRecv uint64 `json:"totalbytesrecv"` TotalBytesSent uint64 `json:"totalbytessent"` TimeMillis int64 `json:"timemillis"` }
GetNetTotalsResult models the data returned from the getnettotals command.
type GetRawMempoolVerboseResult ¶
type GetRawMempoolVerboseResult struct { Size int32 `json:"size"` Fee int64 `json:"fee"` Time int64 `json:"time"` Height int64 `json:"height"` Depends []string `json:"depends"` }
GetRawMempoolVerboseResult models the data returned from the getrawmempool command when the verbose flag is set. When the verbose flag is not set, getrawmempool returns an array of transaction hashes.
type GetSignUpStatusResult ¶
type ListUnspentResult ¶
type ListUnspentResult struct { TxID string `json:"txid"` Vout uint32 `json:"vout"` Address string `json:"address"` Height int32 `json:"height"` ScriptPubKey string `json:"scriptPubKey"` //RedeemScript string `json:"redeemScript,omitempty"` Amount int64 `json:"amount"` Confirmations int64 `json:"confirmations"` Spendable bool `json:"spendable"` Assets string `json:"assets"` ListLockEntry []*LockEntryResult `json:"locks"` }
ListUnspentResult models a successful response from the listunspent request.
type LockEntryResult ¶
type LogResult ¶
type LogResult struct { // Consensus fields: // address of the contract that generated the event Address string `json:"address" gencodec:"required"` // list of topics provided by the contract. Topics []string `json:"topics" gencodec:"required"` // supplied by the contract, usually ABI-encoded Data string `json:"data" gencodec:"required"` // Derived fields. These fields are filled in by the node // but not secured by consensus. // block in which the transaction was included BlockNumber uint64 `json:"blockNumber"` // hash of the transaction TxHash string `json:"transactionHash" gencodec:"required"` // index of the transaction in the block TxIndex uint `json:"transactionIndex" gencodec:"required"` // hash of the block in which the transaction was included BlockHash string `json:"blockHash"` // index of the log in the receipt Index uint `json:"logIndex" gencodec:"required"` // The Removed field is true if this log was reverted due to a chain reorganisation. // You must pay attention to this field if you receive logs through a filter query. Removed bool `json:"removed"` }
type MsgSignResult ¶
type MsgSignResult struct { BlockHeight int32 `json:"blockheight"` BlockHash string `json:"blockhash"` Signer string `json:"signer"` Signature string `json:"signature"` }
MsgSignResult models the data from the GetBlock command.
type PrevOut ¶
type PrevOut struct { Addresses []string `json:"addresses,omitempty"` Value int64 `json:"value"` Asset string `json:"asset"` Data string `json:"data"` }
PrevOut represents previous output for an input Vin.
type RPCError ¶
type RPCError struct { Code RPCErrorCode `json:"code,omitempty"` Message string `json:"message,omitempty"` }
RPCError represents an error that is used as a part of a JSON-RPC Response object.
func NewRPCError ¶
func NewRPCError(code RPCErrorCode, message string) *RPCError
NewRPCError constructs and returns a new JSON-RPC error that is suitable for use in a JSON-RPC Response object.
type RPCErrorCode ¶
type RPCErrorCode int
RPCErrorCode represents an error code to be used as a part of an RPCError which is in turn used in a JSON-RPC Response object.
A specific type is used to help ensure the wrong errors aren't used.
const ( ErrRPCMisc RPCErrorCode = -11 ErrRPCInvalidOutPutAmount RPCErrorCode = -12 ErrRPCInvalidAddressOrKey RPCErrorCode = -13 ErrRPCInvalidParameter RPCErrorCode = -14 ErrRPCDeserialization RPCErrorCode = -15 )
General application defined JSON errors.
const ( ErrRPCBlockNotFound RPCErrorCode = -200 ErrRPCBlockHeaderNotFound RPCErrorCode = -201 ErrRPCBlockHeightNotFound RPCErrorCode = -202 ErrRPCBlockHashNotFound RPCErrorCode = -203 ErrRPCNoTxInfo RPCErrorCode = -204 ErrRPCInvalidTxVout RPCErrorCode = -205 ErrRPCDecodeHexString RPCErrorCode = -206 )
Specific Errors related to commands. These are the ones a user of the RPC server are most likely to see. Generally, the codes should match one of the more general errors above.
type ReceiptResult ¶
type ReceiptResult struct { // Consensus fields PostState string `json:"root"` Status uint64 `json:"status"` CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"` Bloom string `json:"logsBloom" gencodec:"required"` Logs []*LogResult `json:"logs" gencodec:"required"` // Implementation fields (don't reorder!) TxHash string `json:"transactionHash" gencodec:"required"` ContractAddress string `json:"contractAddress"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` }
type RunTxResult ¶
type RunTxResult struct { Receipt *types.Receipt `json:"receipt"` GasUsed uint64 `json:"gasUsed"` VTX *TxRawDecodeResult `json:"vtx"` }
type ScriptPubKeyResult ¶
type ScriptPubKeyResult struct { Asm string `json:"asm"` Hex string `json:"hex,omitempty"` ReqSigs int32 `json:"reqSigs,omitempty"` Type string `json:"type"` Addresses []string `json:"addresses,omitempty"` }
ScriptPubKeyResult models the scriptPubKey data of a tx script. It is defined separately since it is used by multiple commands.
type ScriptSig ¶
ScriptSig models a signature script. It is defined separately since it only applies to non-coinbase. Therefore the field in the Vin structure needs to be a pointer.
type SearchRawTransactionsResult ¶
type SearchRawTransactionsResult struct { Hex string `json:"hex,omitempty"` Txid string `json:"txid"` Hash string `json:"hash"` Size string `json:"size"` Vsize string `json:"vsize"` Version uint32 `json:"version"` LockTime uint32 `json:"locktime"` Vin []VinPrevOut `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockhash,omitempty"` Confirmations int64 `json:"confirmations,omitempty"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime,omitempty"` GasLimit int64 `json:"gaslimit,omitempty"` GasUsed int64 `json:"gasused,omitempty"` Fee []FeeResult `json:"fee,omitempty"` }
SearchRawTransactionsResult models the data from the searchrawtransaction command.
type TestCallData ¶
type TestResult ¶
type TestResult struct {
List []CallResult `json:"list"`
}
type TransactionInput ¶
type TransactionInput struct { Txid string `json:"txid"` Vout uint32 `json:"vout"` Assets string `json:"assets"` ScriptPubKey string `json:"scriptpubkey"` }
TransactionInput represents the inputs to a transaction. Specifically a transaction hash and output number pair.
type TransactionOutput ¶
type TxRawDecodeResult ¶
type TxRawDecodeResult struct { Txid string `json:"txid"` Version uint32 `json:"version"` Locktime uint32 `json:"locktime"` Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` }
TxRawDecodeResult models the data from the decoderawtransaction command.
type TxRawResult ¶
type TxRawResult struct { Hex string `json:"hex"` Txid string `json:"txid"` Hash string `json:"hash,omitempty"` Size int32 `json:"size,omitempty"` Version uint32 `json:"version"` LockTime uint32 `json:"locktime"` Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockhash,omitempty"` Confirmations int64 `json:"confirmations,omitempty"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime,omitempty"` Fee []FeeResult `json:"fee,omitempty"` GasLimit int64 `json:"gaslimit"` }
TxRawResult models the data from the getrawtransaction command.
type TxResult ¶
type TxResult struct { Hex string `json:"hex"` Txid string `json:"txid"` Hash string `json:"hash,omitempty"` Size int32 `json:"size,omitempty"` Version uint32 `json:"version"` LockTime uint32 `json:"locktime"` Vin []VinPrevOut `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockhash,omitempty"` Confirmations int64 `json:"confirmations,omitempty"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime,omitempty"` Fee []FeeResult `json:"fee,omitempty"` GasLimit int64 `json:"gaslimit"` GasUsed int64 `json:"gasused"` }
TxRawResult models the data from the getrawtransaction command.
type UnspentPageResult ¶
type UnspentPageResult struct { ListUnspent []*ListUnspentResult `json:"utxos"` Count int32 `json:"count"` }
type Vin ¶
type Vin struct { Coinbase string `json:"coinbase"` Txid string `json:"txid"` Vout uint32 `json:"vout"` ScriptSig *ScriptSig `json:"scriptSig"` Sequence uint32 `json:"sequence"` }
Vin models parts of the tx data. It is defined separately since getrawtransaction, decoderawtransaction, and searchrawtransaction use the same structure.
type VinPrevOut ¶
type VinPrevOut struct { Coinbase string `json:"coinbase"` Txid string `json:"txid"` Vout uint32 `json:"vout"` ScriptSig *ScriptSig `json:"scriptSig"` PrevOut *PrevOut `json:"prevOut,omitempty"` Sequence uint32 `json:"sequence"` }
VinPrevOut is like Vin except it includes PrevOut. It is used by searchrawtransaction
type Vout ¶
type Vout struct { Value int64 `json:"value"` N uint32 `json:"n"` ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"` Data string `json:"data"` Asset string `json:"asset"` }
Vout models parts of the tx data. It is defined separately since both getrawtransaction and decoderawtransaction use the same structure.