Documentation ¶
Overview ¶
Package btcjson provides primitives for working with the bitcoin JSON-RPC API.
Overview ¶
When communicating via the JSON-RPC protocol, all of the commands need to be marshalled to and from the the wire in the appropriate format. This package provides data structures and primitives to ease this process.
In addition, it also provides some additional features such as custom command registration, command categorization, and reflection-based help generation.
JSON-RPC Protocol Overview ¶
This information is not necessary in order to use this package, but it does provide some intuition into what the marshalling and unmarshalling that is discussed below is doing under the hood.
As defined by the JSON-RPC spec, there are effectively two forms of messages on the wire:
Request Objects {"jsonrpc":"1.0","id":"SOMEID","method":"SOMEMETHOD","params":[SOMEPARAMS]} NOTE: Notifications are the same format except the id field is null.
Response Objects {"result":SOMETHING,"error":null,"id":"SOMEID"} {"result":null,"error":{"code":SOMEINT,"message":SOMESTRING},"id":"SOMEID"}
For requests, the params field can vary in what it contains depending on the method (a.k.a. command) being sent. Each parameter can be as simple as an int or a complex structure containing many nested fields. The id field is used to identify a request and will be included in the associated response.
When working with asynchronous transports, such as websockets, spontaneous notifications are also possible. As indicated, they are the same as a request object, except they have the id field set to null. Therefore, servers will ignore requests with the id field set to null, while clients can choose to consume or ignore them.
Unfortunately, the original Bitcoin JSON-RPC API (and hence anything compatible with it) doesn't always follow the spec and will sometimes return an error string in the result field with a null error for certain commands. However, for the most part, the error field will be set as described on failure.
Marshalling and Unmarshalling ¶
Based upon the discussion above, it should be easy to see how the types of this package map into the required parts of the protocol
- Request Objects (type Request)
- Commands (type <Foo>Cmd)
- Notifications (type <Foo>Ntfn)
- Response Objects (type Response)
- Result (type <Foo>Result)
To simplify the marshalling of the requests and responses, the MarshalCmd and MarshalResponse functions are provided. They return the raw bytes ready to be sent across the wire.
Unmarshalling a received Request object is a two step process:
- Unmarshal the raw bytes into a Request struct instance via json.Unmarshal
- Use UnmarshalCmd on the Result field of the unmarshalled Request to create a concrete command or notification instance with all struct fields set accordingly
This approach is used since it provides the caller with access to the additional fields in the request that are not part of the command such as the ID.
Unmarshalling a received Response object is also a two step process:
- Unmarhsal the raw bytes into a Response struct instance via json.Unmarshal
- Depending on the ID, unmarshal the Result field of the unmarshalled Response to create a concrete type instance
As above, this approach is used since it provides the caller with access to the fields in the response such as the ID and Error.
Command Creation ¶
This package provides two approaches for creating a new command. This first, and preferred, method is to use one of the New<Foo>Cmd functions. This allows static compile-time checking to help ensure the parameters stay in sync with the struct definitions.
The second approach is the NewCmd function which takes a method (command) name and variable arguments. The function includes full checking to ensure the parameters are accurate according to provided method, however these checks are, obviously, run-time which means any mistakes won't be found until the code is actually executed. However, it is quite useful for user-supplied commands that are intentionally dynamic.
Custom Command Registration ¶
The command handling of this package is built around the concept of registered commands. This is true for the wide variety of commands already provided by the package, but it also means caller can easily provide custom commands with all of the same functionality as the built-in commands. Use the RegisterCmd function for this purpose.
A list of all registered methods can be obtained with the RegisteredCmdMethods function.
Command Inspection ¶
All registered commands are registered with flags that identify information such as whether the command applies to a chain server, wallet server, or is a notification along with the method name to use. These flags can be obtained with the MethodUsageFlags flags, and the method can be obtained with the CmdMethod function.
Help Generation ¶
To facilitate providing consistent help to users of the RPC server, this package exposes the GenerateHelp and function which uses reflection on registered commands or notifications, as well as the provided expected result types, to generate the final help text.
In addition, the MethodUsageText function is provided to generate consistent one-line usage for registered commands and notifications using reflection.
Errors ¶
There are 2 distinct type of errors supported by this package:
- General errors related to marshalling or unmarshalling or improper use of the package (type Error)
- RPC errors which are intended to be returned across the wire as a part of the JSON-RPC response (type RPCError)
The first category of errors (type Error) typically indicates a programmer error and can be avoided by properly using the API. Errors of this type will be returned from the various functions available in this package. They identify issues such as unsupported field types, attempts to register malformed commands, and attempting to create a new command with an improper number of parameters. The specific reason for the error can be detected by type asserting it to a *btcjson.Error and accessing the ErrorCode field.
The second category of errors (type RPCError), on the other hand, are useful for returning errors to RPC clients. Consequently, they are used in the previously described Response type.
Example (UnmarshalResponse) ¶
This example demonstrates how to unmarshal a JSON-RPC response and then unmarshal the result field in the response to a concrete type.
// Ordinarily this would be read from the wire, but for this example, // it is hard coded here for clarity. This is an example response to a // getblockheight request. data := []byte(`{"result":350001,"error":null,"id":1}`) // Unmarshal the raw bytes from the wire into a JSON-RPC response. var response btcjson.Response if err := jsoniter.Unmarshal(data, &response); err != nil { fmt.Println("Malformed JSON-RPC response:", err) return } // Check the response for an error from the server. For example, the // server might return an error if an invalid/unknown block hash is // requested. if response.Error != nil { fmt.Println(response.Error) return } // Unmarshal the result into the expected type for the response. var blockHeight int32 if err := jsoniter.Unmarshal(response.Result, &blockHeight); err != nil { fmt.Printf("Unexpected result type: %T\n", response.Result) return } fmt.Println("Block height:", blockHeight)
Output: Block height: 350001
Index ¶
- Constants
- Variables
- func Bool(v bool) *bool
- func CmdMethod(cmd interface{}) (string, er.R)
- func Float64(v float64) *float64
- func GenerateHelp(method string, descs map[string]string, resultTypes ...interface{}) (string, er.R)
- func Int(v int) *int
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func IsValidIDType(id interface{}) bool
- func MarshalCmd(id interface{}, cmd interface{}) ([]byte, er.R)
- func MarshalResponse(id interface{}, result interface{}, rpcErr er.R) ([]byte, er.R)
- func MethodUsageText(method string) (string, er.R)
- func MustRegisterCmd(method string, cmd interface{}, flags UsageFlag)
- func NewCmd(method string, args ...interface{}) (interface{}, er.R)
- func NewErrRPCInternal() er.R
- func NewRPCError(code *er.ErrorCode, message string, err er.R) er.R
- func RegisterCmd(method string, cmd interface{}, flags UsageFlag) er.R
- func RegisteredCmdMethods() []string
- func String(v string) *string
- func Uint(v uint) *uint
- func Uint32(v uint32) *uint32
- func Uint64(v uint64) *uint64
- func UnmarshalCmd(r *Request) (interface{}, er.R)
- type AccountBalanceNtfn
- type AddMultisigAddressCmd
- type AddNodeCmd
- type AddNodeSubCmd
- type AddP2shScriptCmd
- type AddWitnessAddressCmd
- type AddressVoteInfo
- type AuthenticateCmd
- type Bip9SoftForkDescription
- type BlockConnectedNtfn
- type BlockDetails
- type BlockDisconnectedNtfn
- type BtcdConnectedNtfn
- type CheckPcAnnCmd
- type CheckPcAnnResult
- type CheckPcShareCmd
- type CheckPcShareCmdStructure
- type ConfigureMiningPayoutsCmd
- type CreateEncryptedWalletCmd
- type CreateMultiSigResult
- type CreateMultisigCmd
- type CreateRawTransactionCmd
- type CreateTransactionCmd
- type DebugLevelCmd
- type DecodeRawTransactionCmd
- type DecodeScriptCmd
- type DecodeScriptResult
- type DumpPrivKeyCmd
- type EchoCmd
- type EstimateFeeCmd
- type EstimateSmartFeeCmd
- type EstimateSmartFeeMode
- type EstimateSmartFeeResult
- type ExportWatchingWalletCmd
- type FilteredBlockConnectedNtfn
- type FilteredBlockDisconnectedNtfn
- type GenerateCmd
- type GetAddedNodeInfoCmd
- type GetAddedNodeInfoResult
- type GetAddedNodeInfoResultAddr
- type GetAddressBalancesCmd
- type GetAddressBalancesResult
- type GetBalanceCmd
- type GetBestBlockCmd
- type GetBestBlockHashCmd
- type GetBestBlockResult
- type GetBlockChainInfoCmd
- type GetBlockChainInfoResult
- type GetBlockCmd
- type GetBlockCountCmd
- type GetBlockHashCmd
- type GetBlockHeaderCmd
- type GetBlockHeaderVerboseResult
- type GetBlockTemplateCmd
- type GetBlockTemplateResult
- type GetBlockTemplateResultAux
- type GetBlockTemplateResultTx
- type GetBlockVerboseResult
- type GetCFilterCmd
- type GetCFilterHeaderCmd
- type GetChainTipsCmd
- type GetConnectionCountCmd
- type GetCurrentNetCmd
- type GetDifficultyCmd
- type GetGenerateCmd
- type GetHashesPerSecCmd
- type GetHeadersCmd
- type GetInfoCmd
- type GetMempoolEntryCmd
- type GetMempoolInfoCmd
- type GetMempoolInfoResult
- type GetMiningInfoCmd
- type GetMiningInfoResult
- type GetMiningPayoutsCmd
- type GetMiningPayoutsResult
- type GetNetTotalsCmd
- type GetNetTotalsResult
- type GetNetworkHashPSCmd
- type GetNetworkInfoCmd
- type GetNetworkInfoNetworks
- type GetNetworkInfoResult
- type GetNetworkStewardCmd
- type GetNetworkStewardResult
- type GetNetworkStewardVoteCmd
- type GetNetworkStewardVoteResult
- type GetNewAddressCmd
- type GetPeerInfoCmd
- type GetPeerInfoResult
- type GetRawBlockTemplateCmd
- type GetRawBlockTemplateResult
- type GetRawMempoolCmd
- type GetRawMempoolVerboseResult
- type GetRawTransactionCmd
- type GetReceivedByAddressCmd
- type GetSecretCmd
- type GetTransactionCmd
- type GetTransactionDetailsResult
- type GetTransactionResult
- type GetTxOutCmd
- type GetTxOutProofCmd
- type GetTxOutResult
- type GetTxOutSetInfoCmd
- type GetUnconfirmedBalanceCmd
- type GetWalletSeedCmd
- type GetWorkCmd
- type HelpCmd
- type ImportPrivKeyCmd
- type InfoChainResult
- type InfoWalletResult
- type InvalidateBlockCmd
- type ListAddressTransactionsCmd
- type ListAllTransactionsCmd
- type ListLockUnspentCmd
- type ListReceivedByAddressCmd
- type ListReceivedByAddressResult
- type ListSinceBlockCmd
- type ListSinceBlockResult
- type ListTransactionsCmd
- type ListTransactionsResult
- type ListUnspentCmd
- type ListUnspentResult
- type LoadTxFilterCmd
- type LockUnspentCmd
- type LockedUnspent
- type MaintenanceStats
- type NeutrinoBan
- type NeutrinoInfo
- type NeutrinoQuery
- type NewTxNtfn
- type NodeCmd
- type NodeSubCmd
- type NotifyBlocksCmd
- type NotifyNewTransactionsCmd
- type NotifyReceivedCmd
- type NotifySpentCmd
- type OutPoint
- type PingCmd
- type PreciousBlockCmd
- type PrevOut
- type RPCErr
- type RawTxInput
- type ReconsiderBlockCmd
- type RecoverAddressesCmd
- type RecvTxNtfn
- type RedeemingTxNtfn
- type RelevantTxAcceptedNtfn
- type Request
- type RescanBlocksCmd
- type RescanCmd
- type RescanFinishedNtfn
- type RescanProgressNtfn
- type RescannedBlock
- type Response
- type ResyncCmd
- type ScriptSig
- type SearchRawTransactionsCmd
- type SendFromCmd
- type SendManyCmd
- type SendRawTransactionCmd
- type SendToAddressCmd
- type SendVoteCmd
- type SessionCmd
- type SessionResult
- type SetGenerateCmd
- type SetNetworkStewardVoteCmd
- type SetNetworkStewardVoteResult
- type SetTxFeeCmd
- type SignMessageCmd
- type SignRawTransactionCmd
- type SignRawTransactionError
- type SignRawTransactionResult
- type SoftForkDescription
- type StopCmd
- type StopNotifyBlocksCmd
- type StopNotifyNewTransactionsCmd
- type StopNotifyReceivedCmd
- type StopNotifySpentCmd
- type StopResyncCmd
- type SubmitBlockCmd
- type SubmitBlockOptions
- type TemplateRequest
- type TransactionInput
- type TxAcceptedNtfn
- type TxAcceptedVerboseNtfn
- type TxRawDecodeResult
- type TxRawResult
- type UptimeCmd
- type UsageFlag
- type ValidateAddressChainResult
- type ValidateAddressCmd
- type ValidateAddressWalletResult
- type VerifyChainCmd
- type VerifyMessageCmd
- type VerifyTxOutProofCmd
- type VersionCmd
- type VersionResult
- type Vin
- type VinPrevOut
- type Vote
- type Vout
- type WalletInfoResult
- type WalletIsLockedCmd
- type WalletLockCmd
- type WalletLockStateNtfn
- type WalletMempoolCmd
- type WalletMempoolItem
- type WalletMempoolRes
- type WalletPassphraseChangeCmd
- type WalletPassphraseCmd
- type WalletStats
Examples ¶
Constants ¶
const ( // BlockConnectedNtfnMethod is the legacy, deprecated method used for // notifications from the chain server that a block has been connected. // // NOTE: Deprecated. Use FilteredBlockConnectedNtfnMethod instead. BlockConnectedNtfnMethod = "blockconnected" // BlockDisconnectedNtfnMethod is the legacy, deprecated method used for // notifications from the chain server that a block has been // disconnected. // // NOTE: Deprecated. Use FilteredBlockDisconnectedNtfnMethod instead. BlockDisconnectedNtfnMethod = "blockdisconnected" // FilteredBlockConnectedNtfnMethod is the new method used for // notifications from the chain server that a block has been connected. FilteredBlockConnectedNtfnMethod = "filteredblockconnected" // FilteredBlockDisconnectedNtfnMethod is the new method used for // notifications from the chain server that a block has been // disconnected. FilteredBlockDisconnectedNtfnMethod = "filteredblockdisconnected" // RecvTxNtfnMethod is the legacy, deprecated method used for // notifications from the chain server that a transaction which pays to // a registered address has been processed. // // NOTE: Deprecated. Use RelevantTxAcceptedNtfnMethod and // FilteredBlockConnectedNtfnMethod instead. RecvTxNtfnMethod = "recvtx" // RedeemingTxNtfnMethod is the legacy, deprecated method used for // notifications from the chain server that a transaction which spends a // registered outpoint has been processed. // // NOTE: Deprecated. Use RelevantTxAcceptedNtfnMethod and // FilteredBlockConnectedNtfnMethod instead. RedeemingTxNtfnMethod = "redeemingtx" // RescanFinishedNtfnMethod is the legacy, deprecated method used for // notifications from the chain server that a legacy, deprecated rescan // operation has finished. // // NOTE: Deprecated. Not used with rescanblocks command. RescanFinishedNtfnMethod = "rescanfinished" // RescanProgressNtfnMethod is the legacy, deprecated method used for // notifications from the chain server that a legacy, deprecated rescan // operation this is underway has made progress. // // NOTE: Deprecated. Not used with rescanblocks command. RescanProgressNtfnMethod = "rescanprogress" // TxAcceptedNtfnMethod is the method used for notifications from the // chain server that a transaction has been accepted into the mempool. TxAcceptedNtfnMethod = "txaccepted" // TxAcceptedVerboseNtfnMethod is the method used for notifications from // the chain server that a transaction has been accepted into the // mempool. This differs from TxAcceptedNtfnMethod in that it provides // more details in the notification. TxAcceptedVerboseNtfnMethod = "txacceptedverbose" // RelevantTxAcceptedNtfnMethod is the new method used for notifications // from the chain server that inform a client that a transaction that // matches the loaded filter was accepted by the mempool. RelevantTxAcceptedNtfnMethod = "relevanttxaccepted" )
const ( // AccountBalanceNtfnMethod is the method used for account balance // notifications. AccountBalanceNtfnMethod = "accountbalance" // BtcdConnectedNtfnMethod is the method used for notifications when // a wallet server is connected to a chain server. BtcdConnectedNtfnMethod = "pktdconnected" // WalletLockStateNtfnMethod is the method used to notify the lock state // of a wallet has changed. WalletLockStateNtfnMethod = "walletlockstate" // NewTxNtfnMethod is the method used to notify that a wallet server has // added a new transaction to the transaction store. NewTxNtfnMethod = "newtx" )
Variables ¶
var ( ErrDuplicateMethod = InternalErr.CodeWithDetail("ErrDuplicateMethod", "a command with the specified method already exists.") ErrInvalidUsageFlags = InternalErr.CodeWithDetail("ErrInvalidUsageFlags", "one or more unrecognized flag bits were specified.") ErrInvalidType = InternalErr.CodeWithDetail("ErrInvalidType", "a type was passed that is not the required type") ErrEmbeddedType = InternalErr.CodeWithDetail("ErrEmbeddedType", "provided command struct contains an embedded type which is not not supported") ErrUnexportedField = InternalErr.CodeWithDetail("ErrUnexportedField", "provided command struct contains an unexported field which is not supported") ErrUnsupportedFieldType = InternalErr.CodeWithDetail("ErrUnsupportedFieldType", "the type of a field in the provided command struct is not one of the supported types") ErrNonOptionalField = InternalErr.CodeWithDetail("ErrNonOptionalField", "a non-optional field was specified after an optional field") ErrNonOptionalDefault = InternalErr.CodeWithDetail("ErrNonOptionalDefault", "a 'jsonrpcdefault' struct tag was specified for a non-optional field") ErrMismatchedDefault = InternalErr.CodeWithDetail("ErrMismatchedDefault", "a 'jsonrpcdefault' struct tag contains a value that doesn't match the type of the field") ErrUnregisteredMethod = InternalErr.CodeWithDetail("ErrUnregisteredMethod", "a method was specified that has not been registered") ErrMissingDescription = InternalErr.CodeWithDetail("ErrMissingDescription", "a description required to generate help is missing") ErrNumParams = InternalErr.CodeWithDetail("ErrNumParams", "the number of params supplied do not match the requirements of the associated command") )
var ( ErrRPCInvalidRequest = Err.CodeWithNumber("ErrRPCInvalidRequest", -32600) ErrRPCMethodNotFound = Err.CodeWithNumber("ErrRPCMethodNotFound", -32601) ErrRPCInvalidParams = Err.CodeWithNumber("ErrRPCInvalidParams", -32602) ErrRPCInternal = Err.CodeWithNumber("ErrRPCInternal", -32603) ErrRPCParse = Err.CodeWithNumber("ErrRPCParse", -32700) )
Standard JSON-RPC 2.0 errors.
var ( ErrRPCMisc = Err.CodeWithNumber("ErrRPCMisc", -1) ErrRPCType = Err.CodeWithNumber("ErrRPCType", -3) ErrRPCInvalidAddressOrKey = Err.CodeWithNumber("ErrRPCInvalidAddressOrKey", -5) ErrRPCInvalidParameter = Err.CodeWithNumber("ErrRPCInvalidParameter", -8) ErrRPCDatabase = Err.CodeWithNumber("ErrRPCDatabase", -20) ErrRPCDeserialization = Err.CodeWithNumber("ErrRPCDeserialization", -22) ErrRPCVerify = Err.CodeWithNumber("ErrRPCVerify", -25) ErrRPCInWarmup = Err.CodeWithNumber("RPCErrorCode", -28) )
General application defined JSON errors.
var ( ErrRPCClientInInitialDownload = Err.CodeWithNumber("ErrRPCClientInInitialDownload", -10) ErrRPCClientNodeNotAdded = Err.CodeWithNumber("ErrRPCClientNodeNotAdded", -24) )
Peer-to-peer client errors.
var ( ErrRPCWallet = Err.CodeWithNumber("ErrRPCWallet", -4) ErrRPCWalletInvalidAccountName = Err.CodeWithNumber("ErrRPCWalletInvalidAccountName", -11) ErrRPCWalletUnlockNeeded = Err.CodeWithNumberAndDetail("ErrRPCWalletUnlockNeeded", -13, "Enter the wallet passphrase with walletpassphrase first") ErrRPCWalletPassphraseIncorrect = Err.CodeWithNumberAndDetail("ErrRPCWalletPassphraseIncorrect", -14, "Incorrect passphrase") )
Wallet JSON errors
var ( ErrRPCBlockNotFound = Err.CodeWithNumber("ErrRPCBlockNotFound", -5) ErrRPCDifficulty = Err.CodeWithNumber("ErrRPCDifficulty", -5) ErrRPCOutOfRange = Err.CodeWithNumber("ErrRPCOutOfRange", -1) ErrBlockHeightOutOfRange = Err.CodeWithNumber("ErrBlockHeightOutOfRange", -8) ErrRPCNoTxInfo = Err.CodeWithNumberAndDetail("ErrRPCNoTxInfo", -5, "No information for transaction") ErrRPCNoCFIndex = Err.CodeWithNumber("ErrRPCNoCFIndex", -5) ErrRPCInvalidTxVout = Err.CodeWithNumber("ErrRPCInvalidTxVout", -5) ErrRPCDecodeHexString = Err.CodeWithNumber("ErrRPCDecodeHexString", -22) ErrRPCTxError = Err.CodeWithNumber("ErrRPCTxError", -25) ErrRPCTxRejected = Err.CodeWithNumber("ErrRPCTxRejected", -26) ErrRPCTxAlreadyInChain = Err.CodeWithNumber("ErrRPCTxAlreadyInChain", -27) )
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.
var ( ErrRPCNoWallet = Err.CodeWithNumber("ErrRPCNoWallet", -1) ErrRPCUnimplemented = Err.CodeWithNumber("ErrRPCUnimplemented", -1) )
Errors that are specific to pktd.
var Err er.ErrorType = er.NewErrorType("btcjson.Err")
Err is an error type for the btcjson errors
var InternalErr er.ErrorType = er.NewErrorType("btcjson.InternalErr")
InternalErr is a type for the json errors which are not response types
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func CmdMethod ¶
CmdMethod returns the method for the passed command. The provided command type must be a registered type. All commands provided by this package are registered by default.
func Float64 ¶
Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func GenerateHelp ¶
func GenerateHelp(method string, descs map[string]string, resultTypes ...interface{}) (string, er.R)
GenerateHelp generates and returns help output for the provided method and result types given a map to provide the appropriate keys for the method synopsis, field descriptions, conditions, and result descriptions. The method must be associated with a registered type. All commands provided by this package are registered by default.
The resultTypes must be pointer-to-types which represent the specific types of values the command returns. For example, if the command only returns a boolean value, there should only be a single entry of (*bool)(nil). Note that each type must be a single pointer to the type. Therefore, it is recommended to simply pass a nil pointer cast to the appropriate type as previously shown.
The provided descriptions map must contain all of the keys or an error will be returned which includes the missing key, or the final missing key when there is more than one key missing. The generated help in the case of such an error will use the key in place of the description.
The following outlines the required keys:
"<method>--synopsis" Synopsis for the command "<method>-<lowerfieldname>" Description for each command argument "<typename>-<lowerfieldname>" Description for each object field "<method>--condition<#>" Description for each result condition "<method>--result<#>" Description for each primitive result num
Notice that the "special" keys synopsis, condition<#>, and result<#> are preceded by a double dash to ensure they don't conflict with field names.
The condition keys are only required when there is more than on result type, and the result key for a given result type is only required if it's not an object.
For example, consider the 'help' command itself. There are two possible returns depending on the provided parameters. So, the help would be generated by calling the function as follows:
GenerateHelp("help", descs, (*string)(nil), (*string)(nil)).
The following keys would then be required in the provided descriptions map:
"help--synopsis": "Returns a list of all commands or help for ...." "help-command": "The command to retrieve help for", "help--condition0": "no command provided" "help--condition1": "command specified" "help--result0": "List of commands" "help--result1": "Help for specified command"
func Int ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func Int32 ¶
Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func Int64 ¶
Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func IsValidIDType ¶
func IsValidIDType(id interface{}) bool
IsValidIDType checks that the ID field (which can go in any of the JSON-RPC requests, responses, or notifications) is valid. JSON-RPC 1.0 allows any valid JSON type. JSON-RPC 2.0 (which bitcoind follows for some parts) only allows string, number, or null, so this function restricts the allowed types to that list. This function is only provided in case the caller is manually marshalling for some reason. The functions which accept an ID in this package already call this function to ensure the provided id is valid.
func MarshalCmd ¶
MarshalCmd marshals the passed command to a JSON-RPC request byte slice that is suitable for transmission to an RPC server. The provided command type must be a registered type. All commands provided by this package are registered by default.
Example ¶
This example demonstrates how to create and marshal a command into a JSON-RPC request.
package main import ( "fmt" "github.com/pkt-cash/pktd/btcjson" ) func main() { // Create a new getblock command. Notice the nil parameter indicates // to use the default parameter for that fields. This is a common // pattern used in all of the New<Foo>Cmd functions in this package for // optional fields. Also, notice the call to btcjson.Bool which is a // convenience function for creating a pointer out of a primitive for // optional parameters. blockHash := "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" gbCmd := btcjson.NewGetBlockCmd(blockHash, btcjson.Bool(false), nil) // Marshal the command to the format suitable for sending to the RPC // server. Typically the client would increment the id here which is // request so the response can be identified. id := 1 marshalledBytes, err := btcjson.MarshalCmd(id, gbCmd) if err != nil { fmt.Println(err) return } // Display the marshalled command. Ordinarily this would be sent across // the wire to the RPC server, but for this example, just display it. fmt.Printf("%s\n", marshalledBytes) }
Output: {"jsonrpc":"1.0","method":"getblock","params":["000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",false],"id":1}
func MarshalResponse ¶
MarshalResponse marshals the passed id, result, and RPCError to a JSON-RPC response byte slice that is suitable for transmission to a JSON-RPC client.
Example ¶
This example demonstrates how to marshal a JSON-RPC response.
package main import ( "fmt" "github.com/pkt-cash/pktd/btcjson" ) func main() { // Marshal a new JSON-RPC response. For example, this is a response // to a getblockheight request. marshalledBytes, err := btcjson.MarshalResponse(1, 350001, nil) if err != nil { fmt.Println(err) return } // Display the marshalled response. Ordinarily this would be sent // across the wire to the RPC client, but for this example, just display // it. fmt.Printf("%s\n", marshalledBytes) }
Output: {"result":350001,"error":null,"id":1}
func MethodUsageText ¶
MethodUsageText returns a one-line usage string for the provided method. The provided method must be associated with a registered type. All commands provided by this package are registered by default.
func MustRegisterCmd ¶
MustRegisterCmd performs the same function as RegisterCmd except it panics if there is an error. This should only be called from package init functions.
func NewCmd ¶
NewCmd provides a generic mechanism to create a new command that can marshal to a JSON-RPC request while respecting the requirements of the provided method. The method must have been registered with the package already along with its type definition. All methods associated with the commands exported by this package are already registered by default.
The arguments are most efficient when they are the exact same type as the underlying field in the command struct associated with the the method, however this function also will perform a variety of conversions to make it more flexible. This allows, for example, command line args which are strings to be passed unaltered. In particular, the following conversions are supported:
- Conversion between any size signed or unsigned integer so long as the value does not overflow the destination type
- Conversion between float32 and float64 so long as the value does not overflow the destination type
- Conversion from string to boolean for everything strconv.ParseBool recognizes
- Conversion from string to any size integer for everything strconv.ParseInt and strconv.ParseUint recognizes
- Conversion from string to any size float for everything strconv.ParseFloat recognizes
- Conversion from string to arrays, slices, structs, and maps by treating the string as marshalled JSON and calling jsoniter.Unmarshal into the destination field
func NewErrRPCInternal ¶
func NewRPCError ¶
NewRPCError constructs and returns a new JSON-RPC error that is suitable for use in a JSON-RPC Response object.
func RegisterCmd ¶
RegisterCmd registers a new command that will automatically marshal to and from JSON-RPC with full type checking and positional parameter support. It also accepts usage flags which identify the circumstances under which the command can be used.
This package automatically registers all of the exported commands by default using this function, however it is also exported so callers can easily register custom types.
The type format is very strict since it needs to be able to automatically marshal to and from JSON-RPC 1.0. The following enumerates the requirements:
- The provided command must be a single pointer to a struct
- All fields must be exported
- The order of the positional parameters in the marshalled JSON will be in the same order as declared in the struct definition
- Struct embedding is not supported
- Struct fields may NOT be channels, functions, complex, or interface
- A field in the provided struct with a pointer is treated as optional
- Multiple indirections (i.e **int) are not supported
- Once the first optional field (pointer) is encountered, the remaining fields must also be optional fields (pointers) as required by positional params
- A field that has a 'jsonrpcdefault' struct tag must be an optional field (pointer)
NOTE: This function only needs to be able to examine the structure of the passed struct, so it does not need to be an actual instance. Therefore, it is recommended to simply pass a nil pointer cast to the appropriate type. For example, (*FooCmd)(nil).
func RegisteredCmdMethods ¶
func RegisteredCmdMethods() []string
RegisteredCmdMethods returns a sorted list of methods for all registered commands.
func String ¶
String is a helper routine that allocates a new string value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func Uint ¶
Uint is a helper routine that allocates a new uint value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func Uint32 ¶
Uint32 is a helper routine that allocates a new uint32 value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func Uint64 ¶
Uint64 is a helper routine that allocates a new uint64 value to store v and returns a pointer to it. This is useful when assigning optional parameters.
func UnmarshalCmd ¶
UnmarshalCmd unmarshals a JSON-RPC request into a suitable concrete command so long as the method type contained within the marshalled request is registered.
Example ¶
This example demonstrates how to unmarshal a JSON-RPC request and then unmarshal the concrete request into a concrete command.
// Ordinarily this would be read from the wire, but for this example, // it is hard coded here for clarity. data := []byte(`{"jsonrpc":"1.0","method":"getblock","params":["000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",false],"id":1}`) // Unmarshal the raw bytes from the wire into a JSON-RPC request. var request btcjson.Request if err := jsoniter.Unmarshal(data, &request); err != nil { fmt.Println(err) return } // Typically there isn't any need to examine the request fields directly // like this as the caller already knows what response to expect based // on the command it sent. However, this is done here to demonstrate // why the unmarshal process is two steps. if request.ID == nil { fmt.Println("Unexpected notification") return } if request.Method != "getblock" { fmt.Println("Unexpected method") return } // Unmarshal the request into a concrete command. cmd, err := btcjson.UnmarshalCmd(&request) if err != nil { fmt.Println(err) return } // Type assert the command to the appropriate type. gbCmd, ok := cmd.(*btcjson.GetBlockCmd) if !ok { fmt.Printf("Incorrect command type: %T\n", cmd) return } // Display the fields in the concrete command. fmt.Println("Hash:", gbCmd.Hash) fmt.Println("Verbose:", *gbCmd.Verbose) fmt.Println("VerboseTx:", *gbCmd.VerboseTx)
Output: Hash: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f Verbose: false VerboseTx: false
Types ¶
type AccountBalanceNtfn ¶
type AccountBalanceNtfn struct { Account string Balance float64 // In BTC Confirmed bool // Whether Balance is confirmed or unconfirmed. }
AccountBalanceNtfn defines the accountbalance JSON-RPC notification.
func NewAccountBalanceNtfn ¶
func NewAccountBalanceNtfn(account string, balance float64, confirmed bool) *AccountBalanceNtfn
NewAccountBalanceNtfn returns a new instance which can be used to issue an accountbalance JSON-RPC notification.
type AddMultisigAddressCmd ¶
AddMultisigAddressCmd defines the addmutisigaddress JSON-RPC command.
type AddNodeCmd ¶
type AddNodeCmd struct { Addr string SubCmd AddNodeSubCmd `jsonrpcusage:"\"add|remove|onetry\""` }
AddNodeCmd defines the addnode JSON-RPC command.
func NewAddNodeCmd ¶
func NewAddNodeCmd(addr string, subCmd AddNodeSubCmd) *AddNodeCmd
NewAddNodeCmd returns a new instance which can be used to issue an addnode JSON-RPC command.
type AddNodeSubCmd ¶
type AddNodeSubCmd string
AddNodeSubCmd defines the type used in the addnode JSON-RPC command for the sub command field.
const ( // ANRemove indicates the specified peer should be removed. ANRemove AddNodeSubCmd = "remove" )
type AddP2shScriptCmd ¶
type AddWitnessAddressCmd ¶
type AddWitnessAddressCmd struct {
Address string
}
AddWitnessAddressCmd defines the addwitnessaddress JSON-RPC command.
func NewAddWitnessAddressCmd ¶
func NewAddWitnessAddressCmd(address string) *AddWitnessAddressCmd
NewAddWitnessAddressCmd returns a new instance which can be used to issue a addwitnessaddress JSON-RPC command.
type AddressVoteInfo ¶
type AddressVoteInfo struct { // True this the address has indicated it's candidacy in the most recent vote IsCandidate bool `json:"is_candidate,omitempty"` // Who the address voted for, empty string if they voted for themselves or nobody VoteFor string `json:"vote_for,omitempty"` // The transaction ID of the vote VoteTxid string `json:"vote_txid,omitempty"` // The number of the block where this address voted VoteBlock int32 `json:"vote_block,omitempty"` // The block at which the vote will expire ExpirationBlock int32 `json:"expiration_block,omitempty"` // The estimated date/time when the vote will expire (as seconds since the epoch) EstimatedExpirationSec int64 `json:"estimated_expiration_sec,omitempty"` }
type AuthenticateCmd ¶
AuthenticateCmd defines the authenticate JSON-RPC command.
func NewAuthenticateCmd ¶
func NewAuthenticateCmd(username, passphrase string) *AuthenticateCmd
NewAuthenticateCmd returns a new instance which can be used to issue an authenticate JSON-RPC command.
type Bip9SoftForkDescription ¶
type Bip9SoftForkDescription struct { Status string `json:"status"` Bit uint8 `json:"bit"` StartTime int64 `json:"startTime"` Timeout int64 `json:"timeout"` Since int32 `json:"since"` }
Bip9SoftForkDescription describes the current state of a defined BIP0009 version bits soft-fork.
type BlockConnectedNtfn ¶
BlockConnectedNtfn defines the blockconnected JSON-RPC notification.
NOTE: Deprecated. Use FilteredBlockConnectedNtfn instead.
func NewBlockConnectedNtfn ¶
func NewBlockConnectedNtfn(hash string, height int32, time int64) *BlockConnectedNtfn
NewBlockConnectedNtfn returns a new instance which can be used to issue a blockconnected JSON-RPC notification.
NOTE: Deprecated. Use NewFilteredBlockConnectedNtfn instead.
type BlockDetails ¶
type BlockDetails struct { Height int32 `json:"height"` Hash string `json:"hash"` Index int `json:"index"` Time int64 `json:"time"` }
BlockDetails describes details of a tx in a block.
type BlockDisconnectedNtfn ¶
BlockDisconnectedNtfn defines the blockdisconnected JSON-RPC notification.
NOTE: Deprecated. Use FilteredBlockDisconnectedNtfn instead.
func NewBlockDisconnectedNtfn ¶
func NewBlockDisconnectedNtfn(hash string, height int32, time int64) *BlockDisconnectedNtfn
NewBlockDisconnectedNtfn returns a new instance which can be used to issue a blockdisconnected JSON-RPC notification.
NOTE: Deprecated. Use NewFilteredBlockDisconnectedNtfn instead.
type BtcdConnectedNtfn ¶
type BtcdConnectedNtfn struct {
Connected bool
}
BtcdConnectedNtfn defines the pktdconnected JSON-RPC notification.
func NewBtcdConnectedNtfn ¶
func NewBtcdConnectedNtfn(connected bool) *BtcdConnectedNtfn
NewBtcdConnectedNtfn returns a new instance which can be used to issue a pktdconnected JSON-RPC notification.
type CheckPcAnnCmd ¶
type CheckPcAnnResult ¶
type CheckPcAnnResult struct {
WorkHash string `json:"workhash"`
}
type CheckPcShareCmd ¶
type CheckPcShareCmd struct {
}type CheckPcShareCmdStructure ¶
type CheckPcShareCmdStructure struct {}
type CreateEncryptedWalletCmd ¶
type CreateEncryptedWalletCmd struct {
Passphrase string
}
CreateEncryptedWalletCmd defines the createencryptedwallet JSON-RPC command.
func NewCreateEncryptedWalletCmd ¶
func NewCreateEncryptedWalletCmd(passphrase string) *CreateEncryptedWalletCmd
NewCreateEncryptedWalletCmd returns a new instance which can be used to issue a createencryptedwallet JSON-RPC command.
type CreateMultiSigResult ¶
type CreateMultiSigResult struct { Address string `json:"address"` RedeemScript string `json:"redeemScript"` }
CreateMultiSigResult models the data returned from the createmultisig command.
type CreateMultisigCmd ¶
CreateMultisigCmd defines the createmultisig JSON-RPC command.
func NewCreateMultisigCmd ¶
func NewCreateMultisigCmd(nRequired int, keys []string) *CreateMultisigCmd
NewCreateMultisigCmd returns a new instance which can be used to issue a createmultisig JSON-RPC command.
type CreateRawTransactionCmd ¶
type CreateRawTransactionCmd struct { Inputs []TransactionInput Amounts map[string]float64 `jsonrpcusage:"{\"address\":amount,...}"` // In BTC LockTime *int64 }
CreateRawTransactionCmd defines the createrawtransaction JSON-RPC command.
func NewCreateRawTransactionCmd ¶
func NewCreateRawTransactionCmd(inputs []TransactionInput, amounts map[string]float64, lockTime *int64) *CreateRawTransactionCmd
NewCreateRawTransactionCmd returns a new instance which can be used to issue a createrawtransaction JSON-RPC command.
Amounts are in BTC.
type CreateTransactionCmd ¶
type DebugLevelCmd ¶
type DebugLevelCmd struct {
LevelSpec string
}
DebugLevelCmd defines the debuglevel JSON-RPC command. This command is not a standard Bitcoin command. It is an extension for pktd.
func NewDebugLevelCmd ¶
func NewDebugLevelCmd(levelSpec string) *DebugLevelCmd
NewDebugLevelCmd returns a new DebugLevelCmd which can be used to issue a debuglevel JSON-RPC command. This command is not a standard Bitcoin command. It is an extension for pktd.
type DecodeRawTransactionCmd ¶
DecodeRawTransactionCmd defines the decoderawtransaction JSON-RPC command.
func NewDecodeRawTransactionCmd ¶
func NewDecodeRawTransactionCmd(hexTx string) *DecodeRawTransactionCmd
NewDecodeRawTransactionCmd returns a new instance which can be used to issue a decoderawtransaction JSON-RPC command.
type DecodeScriptCmd ¶
type DecodeScriptCmd struct {
HexScript string
}
DecodeScriptCmd defines the decodescript JSON-RPC command.
func NewDecodeScriptCmd ¶
func NewDecodeScriptCmd(hexScript string) *DecodeScriptCmd
NewDecodeScriptCmd returns a new instance which can be used to issue a decodescript JSON-RPC command.
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"` Vote *Vote `json:"vote,omitempty"` }
DecodeScriptResult models the data returned from the decodescript command.
type DumpPrivKeyCmd ¶
type DumpPrivKeyCmd struct {
Address string
}
DumpPrivKeyCmd defines the dumpprivkey JSON-RPC command.
func NewDumpPrivKeyCmd ¶
func NewDumpPrivKeyCmd(address string) *DumpPrivKeyCmd
NewDumpPrivKeyCmd returns a new instance which can be used to issue a dumpprivkey JSON-RPC command.
type EchoCmd ¶
This is dumb, but the json serializer wants to work with a struct and echo demands an array of anything and responds with the same
type EstimateFeeCmd ¶
type EstimateFeeCmd struct {
NumBlocks int64
}
EstimateFeeCmd defines the estimatefee JSON-RPC command.
func NewEstimateFeeCmd ¶
func NewEstimateFeeCmd(numBlocks int64) *EstimateFeeCmd
NewEstimateFeeCmd returns a new instance which can be used to issue a estimatefee JSON-RPC command.
type EstimateSmartFeeCmd ¶
type EstimateSmartFeeCmd struct { ConfTarget int64 EstimateMode *EstimateSmartFeeMode `jsonrpcdefault:"\"CONSERVATIVE\""` }
EstimateSmartFeeCmd defines the estimatesmartfee JSON-RPC command.
type EstimateSmartFeeMode ¶
type EstimateSmartFeeMode string
EstimateSmartFeeMode defines the different fee estimation modes available for the estimatesmartfee JSON-RPC command.
var ( EstimateModeUnset EstimateSmartFeeMode = "UNSET" EstimateModeEconomical EstimateSmartFeeMode = "ECONOMICAL" EstimateModeConservative EstimateSmartFeeMode = "CONSERVATIVE" )
type EstimateSmartFeeResult ¶
type EstimateSmartFeeResult struct { FeeRate *float64 `json:"feerate,omitempty"` Errors []string `json:"errors,omitempty"` Blocks int64 `json:"blocks"` }
EstimateSmartFeeResult models the data returned buy the chain server estimatesmartfee command
type ExportWatchingWalletCmd ¶
ExportWatchingWalletCmd defines the exportwatchingwallet JSON-RPC command.
func NewExportWatchingWalletCmd ¶
func NewExportWatchingWalletCmd(account *string, download *bool) *ExportWatchingWalletCmd
NewExportWatchingWalletCmd returns a new instance which can be used to issue a exportwatchingwallet JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type FilteredBlockConnectedNtfn ¶
FilteredBlockConnectedNtfn defines the filteredblockconnected JSON-RPC notification.
func NewFilteredBlockConnectedNtfn ¶
func NewFilteredBlockConnectedNtfn(height int32, header string, subscribedTxs []string) *FilteredBlockConnectedNtfn
NewFilteredBlockConnectedNtfn returns a new instance which can be used to issue a filteredblockconnected JSON-RPC notification.
type FilteredBlockDisconnectedNtfn ¶
FilteredBlockDisconnectedNtfn defines the filteredblockdisconnected JSON-RPC notification.
func NewFilteredBlockDisconnectedNtfn ¶
func NewFilteredBlockDisconnectedNtfn(height int32, header string) *FilteredBlockDisconnectedNtfn
NewFilteredBlockDisconnectedNtfn returns a new instance which can be used to issue a filteredblockdisconnected JSON-RPC notification.
type GenerateCmd ¶
type GenerateCmd struct {
NumBlocks uint32
}
GenerateCmd defines the generate JSON-RPC command.
func NewGenerateCmd ¶
func NewGenerateCmd(numBlocks uint32) *GenerateCmd
NewGenerateCmd returns a new instance which can be used to issue a generate JSON-RPC command.
type GetAddedNodeInfoCmd ¶
GetAddedNodeInfoCmd defines the getaddednodeinfo JSON-RPC command.
func NewGetAddedNodeInfoCmd ¶
func NewGetAddedNodeInfoCmd(dns bool, node *string) *GetAddedNodeInfoCmd
NewGetAddedNodeInfoCmd returns a new instance which can be used to issue a getaddednodeinfo JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetAddedNodeInfoResult ¶
type GetAddedNodeInfoResult struct { AddedNode string `json:"addednode"` Connected *bool `json:"connected,omitempty"` Addresses *[]GetAddedNodeInfoResultAddr `json:"addresses,omitempty"` }
GetAddedNodeInfoResult models the data from the getaddednodeinfo command.
type GetAddedNodeInfoResultAddr ¶
type GetAddedNodeInfoResultAddr struct { Address string `json:"address"` Connected string `json:"connected"` }
GetAddedNodeInfoResultAddr models the data of the addresses portion of the getaddednodeinfo command.
type GetAddressBalancesCmd ¶
GetAddressBalances defines the getaddressbalances JSON-RPC command.
type GetAddressBalancesResult ¶
type GetAddressBalancesResult struct { Address string `json:"address"` Total float64 `json:"total"` Stotal string `json:"stotal"` Spendable float64 `json:"spendable"` Sspendable string `json:"sspendable"` ImmatureReward float64 `json:"immaturereward"` SimmatureReward string `json:"simmaturereward"` Unconfirmed float64 `json:"unconfirmed"` Sunconfirmed string `json:"sunconfirmed"` OutputCount int32 `json:"outputcount"` Vote *AddressVoteInfo `json:"vote,omitempty"` }
type GetBalanceCmd ¶
type GetBalanceCmd struct {
MinConf *int `jsonrpcdefault:"1"`
}
GetBalanceCmd defines the getbalance JSON-RPC command.
type GetBestBlockCmd ¶
type GetBestBlockCmd struct{}
GetBestBlockCmd defines the getbestblock JSON-RPC command.
func NewGetBestBlockCmd ¶
func NewGetBestBlockCmd() *GetBestBlockCmd
NewGetBestBlockCmd returns a new instance which can be used to issue a getbestblock JSON-RPC command.
type GetBestBlockHashCmd ¶
type GetBestBlockHashCmd struct{}
GetBestBlockHashCmd defines the getbestblockhash JSON-RPC command.
func NewGetBestBlockHashCmd ¶
func NewGetBestBlockHashCmd() *GetBestBlockHashCmd
NewGetBestBlockHashCmd returns a new instance which can be used to issue a getbestblockhash JSON-RPC command.
type GetBestBlockResult ¶
GetBestBlockResult models the data from the getbestblock command.
type GetBlockChainInfoCmd ¶
type GetBlockChainInfoCmd struct{}
GetBlockChainInfoCmd defines the getblockchaininfo JSON-RPC command.
func NewGetBlockChainInfoCmd ¶
func NewGetBlockChainInfoCmd() *GetBlockChainInfoCmd
NewGetBlockChainInfoCmd returns a new instance which can be used to issue a getblockchaininfo JSON-RPC command.
type GetBlockChainInfoResult ¶
type GetBlockChainInfoResult struct { Chain string `json:"chain"` Blocks int32 `json:"blocks"` Headers int32 `json:"headers"` BestBlockHash string `json:"bestblockhash"` InitialBlockDownload bool `json:"initialblockdownload"` Difficulty float64 `json:"difficulty"` MedianTime int64 `json:"mediantime"` VerificationProgress float64 `json:"verificationprogress"` Pruned bool `json:"pruned"` PruneHeight int32 `json:"pruneheight,omitempty"` ChainWork string `json:"chainwork,omitempty"` SoftForks []*SoftForkDescription `json:"softforks"` Bip9SoftForks map[string]*Bip9SoftForkDescription `json:"bip9_softforks"` }
GetBlockChainInfoResult models the data returned from the getblockchaininfo command.
type GetBlockCmd ¶
type GetBlockCmd struct { Hash string Verbose *bool `jsonrpcdefault:"true"` VerboseTx *bool `jsonrpcdefault:"false"` VerbosePcp *bool `jsonrpcdefault:"false"` }
GetBlockCmd defines the getblock JSON-RPC command.
func NewGetBlockCmd ¶
func NewGetBlockCmd(hash string, verbose, verboseTx *bool) *GetBlockCmd
NewGetBlockCmd returns a new instance which can be used to issue a getblock JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetBlockCountCmd ¶
type GetBlockCountCmd struct{}
GetBlockCountCmd defines the getblockcount JSON-RPC command.
func NewGetBlockCountCmd ¶
func NewGetBlockCountCmd() *GetBlockCountCmd
NewGetBlockCountCmd returns a new instance which can be used to issue a getblockcount JSON-RPC command.
type GetBlockHashCmd ¶
type GetBlockHashCmd struct {
Index int64
}
GetBlockHashCmd defines the getblockhash JSON-RPC command.
func NewGetBlockHashCmd ¶
func NewGetBlockHashCmd(index int64) *GetBlockHashCmd
NewGetBlockHashCmd returns a new instance which can be used to issue a getblockhash JSON-RPC command.
type GetBlockHeaderCmd ¶
GetBlockHeaderCmd defines the getblockheader JSON-RPC command.
func NewGetBlockHeaderCmd ¶
func NewGetBlockHeaderCmd(hash string, verbose *bool) *GetBlockHeaderCmd
NewGetBlockHeaderCmd returns a new instance which can be used to issue a getblockheader JSON-RPC 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"` Time int64 `json:"time"` Nonce uint64 `json:"nonce"` Bits string `json:"bits"` Difficulty float64 `json:"difficulty"` PreviousHash string `json:"previousblockhash,omitempty"` NextHash string `json:"nextblockhash,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 GetBlockTemplateCmd ¶
type GetBlockTemplateCmd struct {
Request *TemplateRequest
}
GetBlockTemplateCmd defines the getblocktemplate JSON-RPC command.
func NewGetBlockTemplateCmd ¶
func NewGetBlockTemplateCmd(request *TemplateRequest) *GetBlockTemplateCmd
NewGetBlockTemplateCmd returns a new instance which can be used to issue a getblocktemplate JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetBlockTemplateResult ¶
type GetBlockTemplateResult struct { // Base fields from BIP 0022. CoinbaseAux is optional. One of // CoinbaseTxn or CoinbaseValue must be specified, but not both. Bits string `json:"bits"` CurTime int64 `json:"curtime"` Height int64 `json:"height"` PreviousHash string `json:"previousblockhash"` SigOpLimit int64 `json:"sigoplimit,omitempty"` SizeLimit int64 `json:"sizelimit,omitempty"` WeightLimit int64 `json:"weightlimit,omitempty"` Transactions []GetBlockTemplateResultTx `json:"transactions"` Version int32 `json:"version"` CoinbaseAux *GetBlockTemplateResultAux `json:"coinbaseaux,omitempty"` CoinbaseTxn *GetBlockTemplateResultTx `json:"coinbasetxn,omitempty"` CoinbaseValue *int64 `json:"coinbasevalue,omitempty"` WorkID string `json:"workid,omitempty"` // Witness commitment defined in BIP 0141. DefaultWitnessCommitment string `json:"default_witness_commitment,omitempty"` // Optional long polling from BIP 0022. LongPollID string `json:"longpollid,omitempty"` LongPollURI string `json:"longpolluri,omitempty"` SubmitOld *bool `json:"submitold,omitempty"` // Basic pool extension from BIP 0023. Target string `json:"target,omitempty"` Expires int64 `json:"expires,omitempty"` // Mutations from BIP 0023. MaxTime int64 `json:"maxtime,omitempty"` MinTime int64 `json:"mintime,omitempty"` Mutable []string `json:"mutable,omitempty"` NonceRange string `json:"noncerange,omitempty"` // Block proposal from BIP 0023. Capabilities []string `json:"capabilities,omitempty"` RejectReasion string `json:"reject-reason,omitempty"` }
GetBlockTemplateResult models the data returned from the getblocktemplate command.
type GetBlockTemplateResultAux ¶
type GetBlockTemplateResultAux struct {
Flags string `json:"flags"`
}
GetBlockTemplateResultAux models the coinbaseaux field of the getblocktemplate command.
type GetBlockTemplateResultTx ¶
type GetBlockTemplateResultTx struct { Data string `json:"data"` Hash string `json:"hash"` Depends []int64 `json:"depends"` Fee int64 `json:"fee"` SigOps int64 `json:"sigops"` Weight int64 `json:"weight"` }
GetBlockTemplateResultTx models the transactions field of the getblocktemplate command.
type GetBlockVerboseResult ¶
type GetBlockVerboseResult struct { Hash string `json:"hash"` Confirmations int64 `json:"confirmations"` StrippedSize int32 `json:"strippedsize"` Size int32 `json:"size"` Weight int32 `json:"weight"` Height int64 `json:"height"` Version int32 `json:"version"` VersionHex string `json:"versionHex"` MerkleRoot string `json:"merkleroot"` Tx []string `json:"tx,omitempty"` RawTx []TxRawResult `json:"rawtx,omitempty"` Time int64 `json:"time"` Nonce uint32 `json:"nonce"` Bits string `json:"bits"` Difficulty float64 `json:"difficulty"` PreviousHash string `json:"previousblockhash"` NextHash string `json:"nextblockhash,omitempty"` PcpHex string `json:"packetcryptproof,omitempty"` PcpVersion *int `json:"packetcryptversion,omitempty"` PcAnnCount *uint64 `json:"packetcryptanncount,omitempty"` PcOrigAnnWork *[]int32 `json:"packetcryptorigannwork,omitempty"` PcAnnBits string `json:"packetcryptannbits,omitempty"` PcAnnDifficulty *float64 `json:"packetcryptanndifficulty,omitempty"` PcBlkDifficulty *float64 `json:"packetcryptblkdifficulty,omitempty"` PcBlkBits string `json:"packetcryptblkbits,omitempty"` BlockReward string `json:"sblockreward"` NetworkSteward string `json:"networksteward,omitempty"` BlocksUntilRetarget int32 `json:"blocksuntilretarget"` RetargetEstimate *float64 `json:"retargetestimate,omitempty"` }
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 GetCFilterCmd ¶
type GetCFilterCmd struct { Hash string FilterType wire.FilterType }
GetCFilterCmd defines the getcfilter JSON-RPC command.
func NewGetCFilterCmd ¶
func NewGetCFilterCmd(hash string, filterType wire.FilterType) *GetCFilterCmd
NewGetCFilterCmd returns a new instance which can be used to issue a getcfilter JSON-RPC command.
type GetCFilterHeaderCmd ¶
type GetCFilterHeaderCmd struct { Hash string FilterType wire.FilterType }
GetCFilterHeaderCmd defines the getcfilterheader JSON-RPC command.
func NewGetCFilterHeaderCmd ¶
func NewGetCFilterHeaderCmd(hash string, filterType wire.FilterType) *GetCFilterHeaderCmd
NewGetCFilterHeaderCmd returns a new instance which can be used to issue a getcfilterheader JSON-RPC command.
type GetChainTipsCmd ¶
type GetChainTipsCmd struct{}
GetChainTipsCmd defines the getchaintips JSON-RPC command.
func NewGetChainTipsCmd ¶
func NewGetChainTipsCmd() *GetChainTipsCmd
NewGetChainTipsCmd returns a new instance which can be used to issue a getchaintips JSON-RPC command.
type GetConnectionCountCmd ¶
type GetConnectionCountCmd struct{}
GetConnectionCountCmd defines the getconnectioncount JSON-RPC command.
func NewGetConnectionCountCmd ¶
func NewGetConnectionCountCmd() *GetConnectionCountCmd
NewGetConnectionCountCmd returns a new instance which can be used to issue a getconnectioncount JSON-RPC command.
type GetCurrentNetCmd ¶
type GetCurrentNetCmd struct{}
GetCurrentNetCmd defines the getcurrentnet JSON-RPC command.
func NewGetCurrentNetCmd ¶
func NewGetCurrentNetCmd() *GetCurrentNetCmd
NewGetCurrentNetCmd returns a new instance which can be used to issue a getcurrentnet JSON-RPC command.
type GetDifficultyCmd ¶
type GetDifficultyCmd struct{}
GetDifficultyCmd defines the getdifficulty JSON-RPC command.
func NewGetDifficultyCmd ¶
func NewGetDifficultyCmd() *GetDifficultyCmd
NewGetDifficultyCmd returns a new instance which can be used to issue a getdifficulty JSON-RPC command.
type GetGenerateCmd ¶
type GetGenerateCmd struct{}
GetGenerateCmd defines the getgenerate JSON-RPC command.
func NewGetGenerateCmd ¶
func NewGetGenerateCmd() *GetGenerateCmd
NewGetGenerateCmd returns a new instance which can be used to issue a getgenerate JSON-RPC command.
type GetHashesPerSecCmd ¶
type GetHashesPerSecCmd struct{}
GetHashesPerSecCmd defines the gethashespersec JSON-RPC command.
func NewGetHashesPerSecCmd ¶
func NewGetHashesPerSecCmd() *GetHashesPerSecCmd
NewGetHashesPerSecCmd returns a new instance which can be used to issue a gethashespersec JSON-RPC command.
type GetHeadersCmd ¶
type GetHeadersCmd struct { BlockLocators []string `json:"blocklocators"` HashStop string `json:"hashstop"` }
GetHeadersCmd defines the getheaders JSON-RPC command.
NOTE: This is a btcsuite extension ported from github.com/decred/dcrd/dcrjson.
func NewGetHeadersCmd ¶
func NewGetHeadersCmd(blockLocators []string, hashStop string) *GetHeadersCmd
NewGetHeadersCmd returns a new instance which can be used to issue a getheaders JSON-RPC command.
NOTE: This is a btcsuite extension ported from github.com/decred/dcrd/dcrjson.
type GetInfoCmd ¶
type GetInfoCmd struct{}
GetInfoCmd defines the getinfo JSON-RPC command.
func NewGetInfoCmd ¶
func NewGetInfoCmd() *GetInfoCmd
NewGetInfoCmd returns a new instance which can be used to issue a getinfo JSON-RPC command.
type GetMempoolEntryCmd ¶
type GetMempoolEntryCmd struct {
TxID string
}
GetMempoolEntryCmd defines the getmempoolentry JSON-RPC command.
func NewGetMempoolEntryCmd ¶
func NewGetMempoolEntryCmd(txHash string) *GetMempoolEntryCmd
NewGetMempoolEntryCmd returns a new instance which can be used to issue a getmempoolentry JSON-RPC command.
type GetMempoolInfoCmd ¶
type GetMempoolInfoCmd struct{}
GetMempoolInfoCmd defines the getmempoolinfo JSON-RPC command.
func NewGetMempoolInfoCmd ¶
func NewGetMempoolInfoCmd() *GetMempoolInfoCmd
NewGetMempoolInfoCmd returns a new instance which can be used to issue a getmempool JSON-RPC command.
type GetMempoolInfoResult ¶
GetMempoolInfoResult models the data returned from the getmempoolinfo command.
type GetMiningInfoCmd ¶
type GetMiningInfoCmd struct{}
GetMiningInfoCmd defines the getmininginfo JSON-RPC command.
func NewGetMiningInfoCmd ¶
func NewGetMiningInfoCmd() *GetMiningInfoCmd
NewGetMiningInfoCmd returns a new instance which can be used to issue a getmininginfo JSON-RPC command.
type GetMiningInfoResult ¶
type GetMiningInfoResult struct { Blocks int64 `json:"blocks"` CurrentBlockSize uint64 `json:"currentblocksize"` CurrentBlockWeight uint64 `json:"currentblockweight"` CurrentBlockTx uint64 `json:"currentblocktx"` Difficulty float64 `json:"difficulty"` Errors string `json:"errors"` Generate bool `json:"generate"` GenProcLimit int32 `json:"genproclimit"` HashesPerSec int64 `json:"hashespersec"` NetworkHashPS float64 `json:"networkhashps"` PooledTx uint64 `json:"pooledtx"` TestNet bool `json:"testnet"` }
GetMiningInfoResult models the data from the getmininginfo command.
type GetMiningPayoutsCmd ¶
type GetMiningPayoutsCmd struct{}
GetMiningPayoutsCmd defines the getminingpayouts JSON-RPC command.
type GetMiningPayoutsResult ¶
type GetNetTotalsCmd ¶
type GetNetTotalsCmd struct{}
GetNetTotalsCmd defines the getnettotals JSON-RPC command.
func NewGetNetTotalsCmd ¶
func NewGetNetTotalsCmd() *GetNetTotalsCmd
NewGetNetTotalsCmd returns a new instance which can be used to issue a getnettotals JSON-RPC command.
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 GetNetworkHashPSCmd ¶
type GetNetworkHashPSCmd struct { Blocks *int `jsonrpcdefault:"120"` Height *int `jsonrpcdefault:"-1"` }
GetNetworkHashPSCmd defines the getnetworkhashps JSON-RPC command.
func NewGetNetworkHashPSCmd ¶
func NewGetNetworkHashPSCmd(numBlocks, height *int) *GetNetworkHashPSCmd
NewGetNetworkHashPSCmd returns a new instance which can be used to issue a getnetworkhashps JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetNetworkInfoCmd ¶
type GetNetworkInfoCmd struct{}
GetNetworkInfoCmd defines the getnetworkinfo JSON-RPC command.
func NewGetNetworkInfoCmd ¶
func NewGetNetworkInfoCmd() *GetNetworkInfoCmd
NewGetNetworkInfoCmd returns a new instance which can be used to issue a getnetworkinfo JSON-RPC command.
type GetNetworkInfoNetworks ¶
type GetNetworkInfoResult ¶
type GetNetworkInfoResult struct { Version int32 `json:"version"` Subversion string `json:"subversion"` Protocolversion int32 `json:"protocolversion"` Localservices string `json:"localservices"` Localservicesnames []string `json:"localservicesnames"` Localrelay bool `json:"localrelay"` Timeoffset int64 `json:"timeoffset"` Networkactive bool `json:"networkactive"` Connections int32 `json:"connections"` Networks []GetNetworkInfoNetworks `json:"networks"` Relayfee float64 `json:"relayfee"` Incrementalfee float64 `json:"incrementalfee"` Localaddresses []string `json:"localaddresses"` }
type GetNetworkStewardCmd ¶
type GetNetworkStewardCmd struct{}
GetNetworkStewardCmd defines the getnetworksteward JSON-RPC command.
type GetNetworkStewardResult ¶
type GetNetworkStewardResult struct { Script string `json:"script"` VotesAgainst int64 `json:"votesagainst"` TotalPossible int64 `json:"totalpossible"` }
GetNetworkStewardResult models the data returned from the getnetworksteward command.
type GetNetworkStewardVoteCmd ¶
type GetNetworkStewardVoteCmd struct{}
type GetNetworkStewardVoteResult ¶
type GetNetworkStewardVoteResult struct { VoteFor string `json:"votefor,omitempty"` VoteAgainst string `json:"voteagainst,omitempty"` }
GetNetworkStewardVoteResult is the result of the wallet command getnetworkstewardvote
type GetNewAddressCmd ¶
type GetNewAddressCmd struct {
Legacy *bool
}
GetNewAddressCmd defines the getnewaddress JSON-RPC command.
type GetPeerInfoCmd ¶
type GetPeerInfoCmd struct{}
GetPeerInfoCmd defines the getpeerinfo JSON-RPC command.
func NewGetPeerInfoCmd ¶
func NewGetPeerInfoCmd() *GetPeerInfoCmd
NewGetPeerInfoCmd returns a new instance which can be used to issue a getpeer JSON-RPC command.
type GetPeerInfoResult ¶
type GetPeerInfoResult struct { ID int32 `json:"id"` Addr string `json:"addr"` AddrLocal string `json:"addrlocal,omitempty"` Services string `json:"services"` RelayTxes bool `json:"relaytxes"` LastSend int64 `json:"lastsend"` LastRecv int64 `json:"lastrecv"` BytesSent uint64 `json:"bytessent"` BytesRecv uint64 `json:"bytesrecv"` ConnTime int64 `json:"conntime"` TimeOffset int64 `json:"timeoffset"` PingTime float64 `json:"pingtime"` PingWait float64 `json:"pingwait,omitempty"` Version uint32 `json:"version"` SubVer string `json:"subver"` Inbound bool `json:"inbound"` StartingHeight int32 `json:"startingheight"` CurrentHeight int32 `json:"currentheight,omitempty"` BanScore int32 `json:"banscore"` FeeFilter int64 `json:"feefilter"` SyncNode bool `json:"syncnode"` }
GetPeerInfoResult models the data returned from the getpeerinfo command.
type GetRawBlockTemplateCmd ¶
type GetRawBlockTemplateCmd struct{}
type GetRawMempoolCmd ¶
type GetRawMempoolCmd struct {
Verbose *bool `jsonrpcdefault:"false"`
}
GetRawMempoolCmd defines the getmempool JSON-RPC command.
func NewGetRawMempoolCmd ¶
func NewGetRawMempoolCmd(verbose *bool) *GetRawMempoolCmd
NewGetRawMempoolCmd returns a new instance which can be used to issue a getrawmempool JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetRawMempoolVerboseResult ¶
type GetRawMempoolVerboseResult struct { Size int32 `json:"size"` Vsize int32 `json:"vsize"` Fee float64 `json:"fee"` Time int64 `json:"time"` Height int64 `json:"height"` StartingPriority float64 `json:"startingpriority"` CurrentPriority float64 `json:"currentpriority"` 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 GetRawTransactionCmd ¶
GetRawTransactionCmd defines the getrawtransaction JSON-RPC command.
NOTE: This field is an int versus a bool to remain compatible with Bitcoin Core even though it really should be a bool.
func NewGetRawTransactionCmd ¶
func NewGetRawTransactionCmd(txHash string, verbose *bool) *GetRawTransactionCmd
NewGetRawTransactionCmd returns a new instance which can be used to issue a getrawtransaction JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetReceivedByAddressCmd ¶
GetReceivedByAddressCmd defines the getreceivedbyaddress JSON-RPC command.
func NewGetReceivedByAddressCmd ¶
func NewGetReceivedByAddressCmd(address string, minConf *int) *GetReceivedByAddressCmd
NewGetReceivedByAddressCmd returns a new instance which can be used to issue a getreceivedbyaddress JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetSecretCmd ¶
type GetSecretCmd struct {
Name string
}
type GetTransactionCmd ¶
GetTransactionCmd defines the gettransaction JSON-RPC command.
func NewGetTransactionCmd ¶
func NewGetTransactionCmd(txHash string, includeWatchOnly *bool) *GetTransactionCmd
NewGetTransactionCmd returns a new instance which can be used to issue a gettransaction JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetTransactionDetailsResult ¶
type GetTransactionDetailsResult struct { Account string `json:"account"` Address string `json:"address,omitempty"` Amount float64 `json:"amount"` Category string `json:"category"` InvolvesWatchOnly bool `json:"involveswatchonly,omitempty"` Fee *float64 `json:"fee,omitempty"` Vout uint32 `json:"vout"` }
GetTransactionDetailsResult models the details data from the gettransaction command.
This models the "short" version of the ListTransactionsResult type, which excludes fields common to the transaction. These common fields are instead part of the GetTransactionResult.
type GetTransactionResult ¶
type GetTransactionResult struct { Amount float64 `json:"amount"` Fee float64 `json:"fee,omitempty"` Confirmations int64 `json:"confirmations"` BlockHash string `json:"blockhash"` BlockIndex int64 `json:"blockindex"` BlockTime int64 `json:"blocktime"` TxID string `json:"txid"` WalletConflicts []string `json:"walletconflicts"` Time int64 `json:"time"` TimeReceived int64 `json:"timereceived"` Details []GetTransactionDetailsResult `json:"details"` Hex string `json:"hex"` }
GetTransactionResult models the data from the gettransaction command.
type GetTxOutCmd ¶
GetTxOutCmd defines the gettxout JSON-RPC command.
func NewGetTxOutCmd ¶
func NewGetTxOutCmd(txHash string, vout uint32, includeMempool *bool) *GetTxOutCmd
NewGetTxOutCmd returns a new instance which can be used to issue a gettxout JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetTxOutProofCmd ¶
GetTxOutProofCmd defines the gettxoutproof JSON-RPC command.
func NewGetTxOutProofCmd ¶
func NewGetTxOutProofCmd(txIDs []string, blockHash *string) *GetTxOutProofCmd
NewGetTxOutProofCmd returns a new instance which can be used to issue a gettxoutproof JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetTxOutResult ¶
type GetTxOutResult struct { BestBlock string `json:"bestblock"` Confirmations int64 `json:"confirmations"` ValueCoins float64 `json:"value"` Svalue string `json:"svalue"` Address string `json:"address"` Vote *Vote `json:"vote,omitempty"` Coinbase bool `json:"coinbase"` }
GetTxOutResult models the data from the gettxout command.
type GetTxOutSetInfoCmd ¶
type GetTxOutSetInfoCmd struct{}
GetTxOutSetInfoCmd defines the gettxoutsetinfo JSON-RPC command.
func NewGetTxOutSetInfoCmd ¶
func NewGetTxOutSetInfoCmd() *GetTxOutSetInfoCmd
NewGetTxOutSetInfoCmd returns a new instance which can be used to issue a gettxoutsetinfo JSON-RPC command.
type GetUnconfirmedBalanceCmd ¶
type GetUnconfirmedBalanceCmd struct {
Account *string
}
GetUnconfirmedBalanceCmd defines the getunconfirmedbalance JSON-RPC command.
func NewGetUnconfirmedBalanceCmd ¶
func NewGetUnconfirmedBalanceCmd(account *string) *GetUnconfirmedBalanceCmd
NewGetUnconfirmedBalanceCmd returns a new instance which can be used to issue a getunconfirmedbalance JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetWalletSeedCmd ¶
type GetWalletSeedCmd struct{}
type GetWorkCmd ¶
type GetWorkCmd struct {
Data *string
}
GetWorkCmd defines the getwork JSON-RPC command.
func NewGetWorkCmd ¶
func NewGetWorkCmd(data *string) *GetWorkCmd
NewGetWorkCmd returns a new instance which can be used to issue a getwork JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type HelpCmd ¶
type HelpCmd struct {
Command *string
}
HelpCmd defines the help JSON-RPC command.
func NewHelpCmd ¶
NewHelpCmd returns a new instance which can be used to issue a help JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ImportPrivKeyCmd ¶
type ImportPrivKeyCmd struct { PrivKey string Label *string Rescan *bool `jsonrpcdefault:"true"` Legacy *bool `jsonrpcdefault:"false"` }
ImportPrivKeyCmd defines the importprivkey JSON-RPC command.
func NewImportPrivKeyCmd ¶
func NewImportPrivKeyCmd(privKey string, label *string, rescan *bool) *ImportPrivKeyCmd
NewImportPrivKeyCmd returns a new instance which can be used to issue a importprivkey JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type InfoChainResult ¶
type InfoChainResult struct { Version int32 `json:"version"` ProtocolVersion int32 `json:"protocolversion"` Blocks int32 `json:"blocks"` TimeOffset int64 `json:"timeoffset"` Connections int32 `json:"connections"` Difficulty float64 `json:"difficulty"` TestNet bool `json:"testnet"` RelayFee float64 `json:"relayfee"` Errors string `json:"errors"` }
InfoChainResult models the data returned by the chain server getinfo command.
type InfoWalletResult ¶
type InfoWalletResult struct { Version int32 `json:"version"` ProtocolVersion int32 `json:"protocolversion"` WalletVersion int32 `json:"walletversion"` Balance float64 `json:"balance"` Blocks int32 `json:"blocks"` TimeOffset int64 `json:"timeoffset"` Connections int32 `json:"connections"` Difficulty float64 `json:"difficulty"` TestNet bool `json:"testnet"` KeypoolOldest int64 `json:"keypoololdest"` KeypoolSize int32 `json:"keypoolsize"` UnlockedUntil int64 `json:"unlocked_until"` PaytxFee float64 `json:"paytxfee"` RelayFee float64 `json:"relayfee"` Errors string `json:"errors"` }
InfoWalletResult models the data returned by the wallet server getinfo command.
type InvalidateBlockCmd ¶
type InvalidateBlockCmd struct {
BlockHash string
}
InvalidateBlockCmd defines the invalidateblock JSON-RPC command.
func NewInvalidateBlockCmd ¶
func NewInvalidateBlockCmd(blockHash string) *InvalidateBlockCmd
NewInvalidateBlockCmd returns a new instance which can be used to issue a invalidateblock JSON-RPC command.
type ListAddressTransactionsCmd ¶
ListAddressTransactionsCmd defines the listaddresstransactions JSON-RPC command.
func NewListAddressTransactionsCmd ¶
func NewListAddressTransactionsCmd(addresses []string, account *string) *ListAddressTransactionsCmd
NewListAddressTransactionsCmd returns a new instance which can be used to issue a listaddresstransactions JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ListAllTransactionsCmd ¶
type ListAllTransactionsCmd struct {
Account *string
}
ListAllTransactionsCmd defines the listalltransactions JSON-RPC command.
func NewListAllTransactionsCmd ¶
func NewListAllTransactionsCmd(account *string) *ListAllTransactionsCmd
NewListAllTransactionsCmd returns a new instance which can be used to issue a listalltransactions JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ListLockUnspentCmd ¶
type ListLockUnspentCmd struct{}
ListLockUnspentCmd defines the listlockunspent JSON-RPC command.
func NewListLockUnspentCmd ¶
func NewListLockUnspentCmd() *ListLockUnspentCmd
NewListLockUnspentCmd returns a new instance which can be used to issue a listlockunspent JSON-RPC command.
type ListReceivedByAddressCmd ¶
type ListReceivedByAddressCmd struct { MinConf *int `jsonrpcdefault:"1"` IncludeEmpty *bool `jsonrpcdefault:"false"` IncludeWatchOnly *bool `jsonrpcdefault:"false"` }
ListReceivedByAddressCmd defines the listreceivedbyaddress JSON-RPC command.
func NewListReceivedByAddressCmd ¶
func NewListReceivedByAddressCmd(minConf *int, includeEmpty, includeWatchOnly *bool) *ListReceivedByAddressCmd
NewListReceivedByAddressCmd returns a new instance which can be used to issue a listreceivedbyaddress JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ListReceivedByAddressResult ¶
type ListReceivedByAddressResult struct { Account string `json:"account"` Address string `json:"address"` Amount float64 `json:"amount"` Confirmations uint64 `json:"confirmations"` TxIDs []string `json:"txids,omitempty"` InvolvesWatchonly bool `json:"involvesWatchonly,omitempty"` }
ListReceivedByAddressResult models the data from the listreceivedbyaddress command.
type ListSinceBlockCmd ¶
type ListSinceBlockCmd struct { BlockHash *string TargetConfirmations *int `jsonrpcdefault:"1"` IncludeWatchOnly *bool `jsonrpcdefault:"false"` }
ListSinceBlockCmd defines the listsinceblock JSON-RPC command.
func NewListSinceBlockCmd ¶
func NewListSinceBlockCmd(blockHash *string, targetConfirms *int, includeWatchOnly *bool) *ListSinceBlockCmd
NewListSinceBlockCmd returns a new instance which can be used to issue a listsinceblock JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ListSinceBlockResult ¶
type ListSinceBlockResult struct { Transactions []ListTransactionsResult `json:"transactions"` LastBlock string `json:"lastblock"` }
ListSinceBlockResult models the data from the listsinceblock command.
type ListTransactionsCmd ¶
ListTransactionsCmd defines the listtransactions JSON-RPC command.
type ListTransactionsResult ¶
type ListTransactionsResult struct { Abandoned bool `json:"abandoned"` Account string `json:"account"` Address string `json:"address,omitempty"` Amount float64 `json:"amount"` BIP125Replaceable string `json:"bip125-replaceable,omitempty"` BlockHash string `json:"blockhash,omitempty"` BlockIndex *int64 `json:"blockindex,omitempty"` BlockTime int64 `json:"blocktime,omitempty"` Category string `json:"category"` Confirmations int64 `json:"confirmations"` Fee *float64 `json:"fee,omitempty"` Generated bool `json:"generated,omitempty"` InvolvesWatchOnly bool `json:"involveswatchonly,omitempty"` Time int64 `json:"time"` TimeReceived int64 `json:"timereceived"` Trusted bool `json:"trusted"` TxID string `json:"txid"` Vout uint32 `json:"vout"` WalletConflicts []string `json:"walletconflicts"` Comment string `json:"comment,omitempty"` OtherAccount string `json:"otheraccount,omitempty"` }
ListTransactionsResult models the data from the listtransactions command.
type ListUnspentCmd ¶
type ListUnspentCmd struct { MinConf *int `jsonrpcdefault:"1"` MaxConf *int `jsonrpcdefault:"9999999"` Addresses *[]string }
ListUnspentCmd defines the listunspent JSON-RPC command.
func NewListUnspentCmd ¶
func NewListUnspentCmd(minConf, maxConf *int, addresses *[]string) *ListUnspentCmd
NewListUnspentCmd returns a new instance which can be used to issue a listunspent JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ListUnspentResult ¶
type ListUnspentResult struct { TxID string `json:"txid"` Vout uint32 `json:"vout"` Address string `json:"address"` ScriptPubKey string `json:"scriptPubKey"` Amount float64 `json:"amount"` Confirmations int64 `json:"confirmations"` Height int64 `json:"height"` BlockHash string `json:"blockHash"` Spendable bool `json:"spendable"` }
ListUnspentResult models a successful response from the listunspent request.
type LoadTxFilterCmd ¶
LoadTxFilterCmd defines the loadtxfilter request parameters to load or reload a transaction filter.
NOTE: This is a pktd extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
func NewLoadTxFilterCmd ¶
func NewLoadTxFilterCmd(reload bool, addresses []string, outPoints []OutPoint) *LoadTxFilterCmd
NewLoadTxFilterCmd returns a new instance which can be used to issue a loadtxfilter JSON-RPC command.
NOTE: This is a pktd extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
type LockUnspentCmd ¶
type LockUnspentCmd struct { Unlock bool Transactions []TransactionInput LockName *string }
LockUnspentCmd defines the lockunspent JSON-RPC command.
func NewLockUnspentCmd ¶
func NewLockUnspentCmd(unlock bool, transactions []TransactionInput) *LockUnspentCmd
NewLockUnspentCmd returns a new instance which can be used to issue a lockunspent JSON-RPC command.
type LockedUnspent ¶
type MaintenanceStats ¶
type NeutrinoBan ¶
type NeutrinoInfo ¶
type NeutrinoInfo struct { Peers []peer.PeerDesc Bans []NeutrinoBan Queries []NeutrinoQuery }
type NeutrinoQuery ¶
type NewTxNtfn ¶
type NewTxNtfn struct { Account string Details ListTransactionsResult }
NewTxNtfn defines the newtx JSON-RPC notification.
func NewNewTxNtfn ¶
func NewNewTxNtfn(account string, details ListTransactionsResult) *NewTxNtfn
NewNewTxNtfn returns a new instance which can be used to issue a newtx JSON-RPC notification.
type NodeCmd ¶
type NodeCmd struct { SubCmd NodeSubCmd `jsonrpcusage:"\"connect|remove|disconnect\""` Target string ConnectSubCmd *string `jsonrpcusage:"\"perm|temp\""` }
NodeCmd defines the dropnode JSON-RPC command.
func NewNodeCmd ¶
func NewNodeCmd(subCmd NodeSubCmd, target string, connectSubCmd *string) *NodeCmd
NewNodeCmd returns a new instance which can be used to issue a `node` JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type NodeSubCmd ¶
type NodeSubCmd string
NodeSubCmd defines the type used in the addnode JSON-RPC command for the sub command field.
const ( // NConnect indicates the specified host that should be connected to. NConnect NodeSubCmd = "connect" // NRemove indicates the specified peer that should be removed as a // persistent peer. NRemove NodeSubCmd = "remove" // NDisconnect indicates the specified peer should be disonnected. NDisconnect NodeSubCmd = "disconnect" )
type NotifyBlocksCmd ¶
type NotifyBlocksCmd struct{}
NotifyBlocksCmd defines the notifyblocks JSON-RPC command.
func NewNotifyBlocksCmd ¶
func NewNotifyBlocksCmd() *NotifyBlocksCmd
NewNotifyBlocksCmd returns a new instance which can be used to issue a notifyblocks JSON-RPC command.
type NotifyNewTransactionsCmd ¶
type NotifyNewTransactionsCmd struct {
Verbose *bool `jsonrpcdefault:"false"`
}
NotifyNewTransactionsCmd defines the notifynewtransactions JSON-RPC command.
func NewNotifyNewTransactionsCmd ¶
func NewNotifyNewTransactionsCmd(verbose *bool) *NotifyNewTransactionsCmd
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.
type NotifyReceivedCmd ¶
type NotifyReceivedCmd struct {
Addresses []string
}
NotifyReceivedCmd defines the notifyreceived JSON-RPC command.
NOTE: Deprecated. Use LoadTxFilterCmd instead.
func NewNotifyReceivedCmd ¶
func NewNotifyReceivedCmd(addresses []string) *NotifyReceivedCmd
NewNotifyReceivedCmd returns a new instance which can be used to issue a notifyreceived JSON-RPC command.
NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
type NotifySpentCmd ¶
type NotifySpentCmd struct {
OutPoints []OutPoint
}
NotifySpentCmd defines the notifyspent JSON-RPC command.
NOTE: Deprecated. Use LoadTxFilterCmd instead.
func NewNotifySpentCmd ¶
func NewNotifySpentCmd(outPoints []OutPoint) *NotifySpentCmd
NewNotifySpentCmd returns a new instance which can be used to issue a notifyspent JSON-RPC command.
NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
type PingCmd ¶
type PingCmd struct{}
PingCmd defines the ping JSON-RPC command.
func NewPingCmd ¶
func NewPingCmd() *PingCmd
NewPingCmd returns a new instance which can be used to issue a ping JSON-RPC command.
type PreciousBlockCmd ¶
type PreciousBlockCmd struct {
BlockHash string
}
PreciousBlockCmd defines the preciousblock JSON-RPC command.
func NewPreciousBlockCmd ¶
func NewPreciousBlockCmd(blockHash string) *PreciousBlockCmd
NewPreciousBlockCmd returns a new instance which can be used to issue a preciousblock JSON-RPC command.
type PrevOut ¶
type PrevOut struct { Address string `json:"address"` ValueCoins float64 `json:"value"` Svalue string `json:"svalue"` }
PrevOut represents previous output for an input Vin.
type RPCErr ¶
type RPCErr struct { Code int `json:"code,omitempty"` Message string `json:"message,omitempty"` Stack []string `json:"stack,omitempty"` }
RPCErr represents an error that is used as a part of a JSON-RPC Response object. Unlike an er.R, this object is able to be serialized.
func SerializeError ¶
type RawTxInput ¶
type RawTxInput struct { Txid string `json:"txid"` Vout uint32 `json:"vout"` ScriptPubKey string `json:"scriptPubKey"` RedeemScript string `json:"redeemScript"` }
RawTxInput models the data needed for raw transaction input that is used in the SignRawTransactionCmd struct.
type ReconsiderBlockCmd ¶
type ReconsiderBlockCmd struct {
BlockHash string
}
ReconsiderBlockCmd defines the reconsiderblock JSON-RPC command.
func NewReconsiderBlockCmd ¶
func NewReconsiderBlockCmd(blockHash string) *ReconsiderBlockCmd
NewReconsiderBlockCmd returns a new instance which can be used to issue a reconsiderblock JSON-RPC command.
type RecoverAddressesCmd ¶
RecoverAddressesCmd defines the recoveraddresses JSON-RPC command.
func NewRecoverAddressesCmd ¶
func NewRecoverAddressesCmd(account string, n int) *RecoverAddressesCmd
NewRecoverAddressesCmd returns a new instance which can be used to issue a recoveraddresses JSON-RPC command.
type RecvTxNtfn ¶
type RecvTxNtfn struct { HexTx string Block *BlockDetails }
RecvTxNtfn defines the recvtx JSON-RPC notification.
NOTE: Deprecated. Use RelevantTxAcceptedNtfn and FilteredBlockConnectedNtfn instead.
func NewRecvTxNtfn ¶
func NewRecvTxNtfn(hexTx string, block *BlockDetails) *RecvTxNtfn
NewRecvTxNtfn returns a new instance which can be used to issue a recvtx JSON-RPC notification.
NOTE: Deprecated. Use NewRelevantTxAcceptedNtfn and NewFilteredBlockConnectedNtfn instead.
type RedeemingTxNtfn ¶
type RedeemingTxNtfn struct { HexTx string Block *BlockDetails }
RedeemingTxNtfn defines the redeemingtx JSON-RPC notification.
NOTE: Deprecated. Use RelevantTxAcceptedNtfn and FilteredBlockConnectedNtfn instead.
func NewRedeemingTxNtfn ¶
func NewRedeemingTxNtfn(hexTx string, block *BlockDetails) *RedeemingTxNtfn
NewRedeemingTxNtfn returns a new instance which can be used to issue a redeemingtx JSON-RPC notification.
NOTE: Deprecated. Use NewRelevantTxAcceptedNtfn and NewFilteredBlockConnectedNtfn instead.
type RelevantTxAcceptedNtfn ¶
type RelevantTxAcceptedNtfn struct {
Transaction string `json:"transaction"`
}
RelevantTxAcceptedNtfn defines the parameters to the relevanttxaccepted JSON-RPC notification.
func NewRelevantTxAcceptedNtfn ¶
func NewRelevantTxAcceptedNtfn(txHex string) *RelevantTxAcceptedNtfn
NewRelevantTxAcceptedNtfn returns a new instance which can be used to issue a relevantxaccepted JSON-RPC notification.
type Request ¶
type Request struct { Jsonrpc string `json:"jsonrpc"` Method string `json:"method"` Params []jsoniter.RawMessage `json:"params"` ID interface{} `json:"id"` }
Request is a type for raw JSON-RPC 1.0 requests. The Method field identifies the specific command type which in turns leads to different parameters. Callers typically will not use this directly since this package provides a statically typed command infrastructure which handles creation of these requests, however this struct it being exported in case the caller wants to construct raw requests for some reason.
func NewRequest ¶
NewRequest returns a new JSON-RPC 1.0 request object given the provided id, method, and parameters. The parameters are marshalled into a jsoniter.RawMessage for the Params field of the returned request object. This function is only provided in case the caller wants to construct raw requests for some reason.
Typically callers will instead want to create a registered concrete command type with the NewCmd or New<Foo>Cmd functions and call the MarshalCmd function with that command to generate the marshalled JSON-RPC request.
type RescanBlocksCmd ¶
type RescanBlocksCmd struct { // Block hashes as a string array. BlockHashes []string }
RescanBlocksCmd defines the rescan JSON-RPC command.
NOTE: This is a pktd extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
func NewRescanBlocksCmd ¶
func NewRescanBlocksCmd(blockHashes []string) *RescanBlocksCmd
NewRescanBlocksCmd returns a new instance which can be used to issue a rescan JSON-RPC command.
NOTE: This is a pktd extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
type RescanCmd ¶
type RescanCmd struct { BeginBlock string Addresses []string OutPoints []OutPoint EndBlock *string }
RescanCmd defines the rescan JSON-RPC command.
NOTE: Deprecated. Use RescanBlocksCmd instead.
func NewRescanCmd ¶
func NewRescanCmd(beginBlock string, addresses []string, outPoints []OutPoint, endBlock *string) *RescanCmd
NewRescanCmd returns a new instance which can be used to issue a rescan JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
NOTE: Deprecated. Use NewRescanBlocksCmd instead.
type RescanFinishedNtfn ¶
RescanFinishedNtfn defines the rescanfinished JSON-RPC notification.
NOTE: Deprecated. Not used with rescanblocks command.
func NewRescanFinishedNtfn ¶
func NewRescanFinishedNtfn(hash string, height int32, time int64) *RescanFinishedNtfn
NewRescanFinishedNtfn returns a new instance which can be used to issue a rescanfinished JSON-RPC notification.
NOTE: Deprecated. Not used with rescanblocks command.
type RescanProgressNtfn ¶
RescanProgressNtfn defines the rescanprogress JSON-RPC notification.
NOTE: Deprecated. Not used with rescanblocks command.
func NewRescanProgressNtfn ¶
func NewRescanProgressNtfn(hash string, height int32, time int64) *RescanProgressNtfn
NewRescanProgressNtfn returns a new instance which can be used to issue a rescanprogress JSON-RPC notification.
NOTE: Deprecated. Not used with rescanblocks command.
type RescannedBlock ¶
type RescannedBlock struct { Hash string `json:"hash"` Transactions []string `json:"transactions"` }
RescannedBlock contains the hash and all discovered transactions of a single rescanned block.
NOTE: This is a btcsuite extension ported from github.com/decred/dcrd/dcrjson.
type Response ¶
type Response struct { Result jsoniter.RawMessage `json:"result"` Error *RPCErr `json:"error"` ID *interface{} `json:"id"` }
Response is the general form of a JSON-RPC response. The type of the Result field varies from one command to the next, so it is implemented as an interface. The ID field has to be a pointer for Go to put a null in it when empty.
func NewResponse ¶
NewResponse returns a new JSON-RPC response object given the provided id, marshalled result, and RPC error. This function is only provided in case the caller wants to construct raw responses for some reason.
Typically callers will instead want to create the fully marshalled JSON-RPC response to send over the wire with the MarshalResponse function.
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 SearchRawTransactionsCmd ¶
type SearchRawTransactionsCmd struct { Address string Verbose *int `jsonrpcdefault:"1"` Skip *int `jsonrpcdefault:"0"` Count *int `jsonrpcdefault:"100"` VinExtra *int `jsonrpcdefault:"0"` Reverse *bool `jsonrpcdefault:"false"` FilterAddrs *[]string }
SearchRawTransactionsCmd defines the searchrawtransactions JSON-RPC command.
func NewSearchRawTransactionsCmd ¶
func NewSearchRawTransactionsCmd(address string, verbose, skip, count *int, vinExtra *int, reverse *bool, filterAddrs *[]string) *SearchRawTransactionsCmd
NewSearchRawTransactionsCmd returns a new instance which can be used to issue a sendrawtransaction JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SendFromCmd ¶
type SendFromCmd struct { ToAddress string Amount float64 // In BTC FromAddresses *[]string MinConf *int `jsonrpcdefault:"1"` Comment *string CommentTo *string MaxInputs *int MinHeight *int }
SendFromCmd defines the sendfrom JSON-RPC command.
func NewSendFromCmd ¶
func NewSendFromCmd(fromAddresses *[]string, toAddress string, amount float64, minConf *int, comment, commentTo *string) *SendFromCmd
NewSendFromCmd returns a new instance which can be used to issue a sendfrom JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SendManyCmd ¶
type SendManyCmd struct { Amounts map[string]float64 `jsonrpcusage:"{\"address\":amount,...}"` // In BTC FromAddresses *[]string MinConf *int `jsonrpcdefault:"1"` Comment *string MaxInputs *int }
SendManyCmd defines the sendmany JSON-RPC command.
func NewSendManyCmd ¶
func NewSendManyCmd(fromAddresses *[]string, amounts map[string]float64, minConf *int, comment *string) *SendManyCmd
NewSendManyCmd returns a new instance which can be used to issue a sendmany JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SendRawTransactionCmd ¶
SendRawTransactionCmd defines the sendrawtransaction JSON-RPC command.
func NewSendRawTransactionCmd ¶
func NewSendRawTransactionCmd(hexTx string, allowHighFees *bool) *SendRawTransactionCmd
NewSendRawTransactionCmd returns a new instance which can be used to issue a sendrawtransaction JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SendToAddressCmd ¶
SendToAddressCmd defines the sendtoaddress JSON-RPC command.
func NewSendToAddressCmd ¶
func NewSendToAddressCmd(address string, amount float64, comment, commentTo *string) *SendToAddressCmd
NewSendToAddressCmd returns a new instance which can be used to issue a sendtoaddress JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SendVoteCmd ¶
type SendVoteCmd struct { // The address to use for casting the vote FromAddress string // The address to vote for becoming Network Steward // If this is the empty string then it will be considered that there is no vote // Casting a non-vote is useful to withdraw a pervious vote without casting a new one. VoteFor string // True if you want to candidate for possibly becoming the Network Steward. IsCandidate *bool // Do not source funds from any payment with less than this number of confirmations // default 1 = anything which is in the blockchain at all MinConf *uint32 // Do not source funds from any more inputs than this // default 0 = no limit MaxInputs *uint32 // Do not source funds from any payments OLDER (lower block height) than this number // default 0 = no limit MinHeight *uint32 }
type SessionResult ¶
type SessionResult struct {
SessionID uint64 `json:"sessionid"`
}
SessionResult models the data from the session command.
type SetGenerateCmd ¶
SetGenerateCmd defines the setgenerate JSON-RPC command.
func NewSetGenerateCmd ¶
func NewSetGenerateCmd(generate bool, genProcLimit *int) *SetGenerateCmd
NewSetGenerateCmd returns a new instance which can be used to issue a setgenerate JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SetNetworkStewardVoteCmd ¶
type SetNetworkStewardVoteCmd struct { VoteFor *string `json:"votefor"` VoteAgainst *string `json:"voteagainst"` }
SetNetworkStewardVoteCmd is the argument to the wallet command setnetworkstewardvote
type SetNetworkStewardVoteResult ¶
type SetNetworkStewardVoteResult struct{}
SetNetworkStewardVoteResult is the result of the wallet command setnetworkstewardvote
type SetTxFeeCmd ¶
type SetTxFeeCmd struct {
Amount float64 // In BTC
}
SetTxFeeCmd defines the settxfee JSON-RPC command.
func NewSetTxFeeCmd ¶
func NewSetTxFeeCmd(amount float64) *SetTxFeeCmd
NewSetTxFeeCmd returns a new instance which can be used to issue a settxfee JSON-RPC command.
type SignMessageCmd ¶
SignMessageCmd defines the signmessage JSON-RPC command.
func NewSignMessageCmd ¶
func NewSignMessageCmd(address, message string) *SignMessageCmd
NewSignMessageCmd returns a new instance which can be used to issue a signmessage JSON-RPC command.
type SignRawTransactionCmd ¶
type SignRawTransactionCmd struct { RawTx string Inputs *[]RawTxInput PrivKeys *[]string Flags *string `jsonrpcdefault:"\"ALL\""` }
SignRawTransactionCmd defines the signrawtransaction JSON-RPC command.
func NewSignRawTransactionCmd ¶
func NewSignRawTransactionCmd(hexEncodedTx string, inputs *[]RawTxInput, privKeys *[]string, flags *string) *SignRawTransactionCmd
NewSignRawTransactionCmd returns a new instance which can be used to issue a signrawtransaction JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SignRawTransactionError ¶
type SignRawTransactionError struct { TxID string `json:"txid"` Vout uint32 `json:"vout"` ScriptSig string `json:"scriptSig"` Sequence uint32 `json:"sequence"` Error string `json:"error"` }
SignRawTransactionError models the data that contains script verification errors from the signrawtransaction request.
type SignRawTransactionResult ¶
type SignRawTransactionResult struct { Hex string `json:"hex"` Complete bool `json:"complete"` Errors []SignRawTransactionError `json:"errors,omitempty"` }
SignRawTransactionResult models the data from the signrawtransaction command.
type SoftForkDescription ¶
type SoftForkDescription struct { ID string `json:"id"` Version uint32 `json:"version"` Reject struct { Status bool `json:"status"` } `json:"reject"` }
SoftForkDescription describes the current state of a soft-fork which was deployed using a super-majority block signaling.
type StopCmd ¶
type StopCmd struct{}
StopCmd defines the stop JSON-RPC command.
func NewStopCmd ¶
func NewStopCmd() *StopCmd
NewStopCmd returns a new instance which can be used to issue a stop JSON-RPC command.
type StopNotifyBlocksCmd ¶
type StopNotifyBlocksCmd struct{}
StopNotifyBlocksCmd defines the stopnotifyblocks JSON-RPC command.
func NewStopNotifyBlocksCmd ¶
func NewStopNotifyBlocksCmd() *StopNotifyBlocksCmd
NewStopNotifyBlocksCmd returns a new instance which can be used to issue a stopnotifyblocks JSON-RPC command.
type StopNotifyNewTransactionsCmd ¶
type StopNotifyNewTransactionsCmd struct{}
StopNotifyNewTransactionsCmd defines the stopnotifynewtransactions JSON-RPC command.
func NewStopNotifyNewTransactionsCmd ¶
func NewStopNotifyNewTransactionsCmd() *StopNotifyNewTransactionsCmd
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.
type StopNotifyReceivedCmd ¶
type StopNotifyReceivedCmd struct {
Addresses []string
}
StopNotifyReceivedCmd defines the stopnotifyreceived JSON-RPC command.
NOTE: Deprecated. Use LoadTxFilterCmd instead.
func NewStopNotifyReceivedCmd ¶
func NewStopNotifyReceivedCmd(addresses []string) *StopNotifyReceivedCmd
NewStopNotifyReceivedCmd returns a new instance which can be used to issue a stopnotifyreceived JSON-RPC command.
NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
type StopNotifySpentCmd ¶
type StopNotifySpentCmd struct {
OutPoints []OutPoint
}
StopNotifySpentCmd defines the stopnotifyspent JSON-RPC command.
NOTE: Deprecated. Use LoadTxFilterCmd instead.
func NewStopNotifySpentCmd ¶
func NewStopNotifySpentCmd(outPoints []OutPoint) *StopNotifySpentCmd
NewStopNotifySpentCmd returns a new instance which can be used to issue a stopnotifyspent JSON-RPC command.
NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
type StopResyncCmd ¶
type StopResyncCmd struct{}
type SubmitBlockCmd ¶
type SubmitBlockCmd struct { HexBlock string Options *SubmitBlockOptions }
SubmitBlockCmd defines the submitblock JSON-RPC command.
func NewSubmitBlockCmd ¶
func NewSubmitBlockCmd(hexBlock string, options *SubmitBlockOptions) *SubmitBlockCmd
NewSubmitBlockCmd returns a new instance which can be used to issue a submitblock JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SubmitBlockOptions ¶
type SubmitBlockOptions struct { // must be provided if server provided a workid with template. WorkID string `json:"workid,omitempty"` }
SubmitBlockOptions represents the optional options struct provided with a SubmitBlockCmd command.
type TemplateRequest ¶
type TemplateRequest struct { Mode string `json:"mode,omitempty"` Capabilities []string `json:"capabilities,omitempty"` // Optional long polling. LongPollID string `json:"longpollid,omitempty"` // Optional template tweaking. SigOpLimit and SizeLimit can be int64 // or bool. SigOpLimit interface{} `json:"sigoplimit,omitempty"` SizeLimit interface{} `json:"sizelimit,omitempty"` MaxVersion uint32 `json:"maxversion,omitempty"` // Basic pool extension from BIP 0023. Target string `json:"target,omitempty"` // Block proposal from BIP 0023. Data is only provided when Mode is // "proposal". Data string `json:"data,omitempty"` WorkID string `json:"workid,omitempty"` }
TemplateRequest is a request object as defined in BIP22 (https://en.bitcoin.it/wiki/BIP_0022), it is optionally provided as an pointer argument to GetBlockTemplateCmd.
func (*TemplateRequest) UnmarshalJSON ¶
func (t *TemplateRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON provides a custom Unmarshal method for TemplateRequest. This is necessary because the SigOpLimit and SizeLimit fields can only be specific types.
type TransactionInput ¶
TransactionInput represents the inputs to a transaction. Specifically a transaction hash and output number pair.
type TxAcceptedNtfn ¶
TxAcceptedNtfn defines the txaccepted JSON-RPC notification.
func NewTxAcceptedNtfn ¶
func NewTxAcceptedNtfn(txHash string, amount float64) *TxAcceptedNtfn
NewTxAcceptedNtfn returns a new instance which can be used to issue a txaccepted JSON-RPC notification.
type TxAcceptedVerboseNtfn ¶
type TxAcceptedVerboseNtfn struct {
RawTx TxRawResult
}
TxAcceptedVerboseNtfn defines the txacceptedverbose JSON-RPC notification.
func NewTxAcceptedVerboseNtfn ¶
func NewTxAcceptedVerboseNtfn(rawTx TxRawResult) *TxAcceptedVerboseNtfn
NewTxAcceptedVerboseNtfn returns a new instance which can be used to issue a txacceptedverbose JSON-RPC notification.
type TxRawDecodeResult ¶
type TxRawDecodeResult struct { Txid string `json:"txid"` Version int32 `json:"version"` Locktime uint32 `json:"locktime"` Sfee string `json:"sfee"` Size int32 `json:"size"` Vsize int32 `json:"vsize"` Vin []VinPrevOut `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"` Vsize int32 `json:"vsize,omitempty"` Version int32 `json:"version"` LockTime uint32 `json:"locktime"` Vin []VinPrevOut `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockhash,omitempty"` Confirmations uint64 `json:"confirmations,omitempty"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime,omitempty"` }
TxRawResult models the data from the getrawtransaction command.
type UptimeCmd ¶
type UptimeCmd struct{}
UptimeCmd defines the uptime JSON-RPC command.
func NewUptimeCmd ¶
func NewUptimeCmd() *UptimeCmd
NewUptimeCmd returns a new instance which can be used to issue an uptime JSON-RPC command.
type UsageFlag ¶
type UsageFlag uint32
UsageFlag define flags that specify additional properties about the circumstances under which a command can be used.
const ( // UFWalletOnly indicates that the command can only be used with an RPC // server that supports wallet commands. UFWalletOnly UsageFlag = 1 << iota // UFWebsocketOnly indicates that the command can only be used when // communicating with an RPC server over websockets. This typically // applies to notifications and notification registration functions // since neiher makes since when using a single-shot HTTP-POST request. UFWebsocketOnly // UFNotification indicates that the command is actually a notification. // This means when it is marshalled, the ID must be nil. UFNotification )
func MethodUsageFlags ¶
MethodUsageFlags returns the usage flags for the passed command method. The provided method must be associated with a registered type. All commands provided by this package are registered by default.
type ValidateAddressChainResult ¶
type ValidateAddressChainResult struct { IsValid bool `json:"isvalid"` Address string `json:"address,omitempty"` }
ValidateAddressChainResult models the data returned by the chain server validateaddress command.
type ValidateAddressCmd ¶
type ValidateAddressCmd struct {
Address string
}
ValidateAddressCmd defines the validateaddress JSON-RPC command.
func NewValidateAddressCmd ¶
func NewValidateAddressCmd(address string) *ValidateAddressCmd
NewValidateAddressCmd returns a new instance which can be used to issue a validateaddress JSON-RPC command.
type ValidateAddressWalletResult ¶
type ValidateAddressWalletResult struct { IsValid bool `json:"isvalid"` Address string `json:"address,omitempty"` IsMine bool `json:"ismine,omitempty"` IsWatchOnly bool `json:"iswatchonly,omitempty"` IsScript bool `json:"isscript,omitempty"` PubKey string `json:"pubkey,omitempty"` IsCompressed bool `json:"iscompressed,omitempty"` Account string `json:"account,omitempty"` Addresses []string `json:"addresses,omitempty"` Hex string `json:"hex,omitempty"` Script string `json:"script,omitempty"` SigsRequired int32 `json:"sigsrequired,omitempty"` }
ValidateAddressWalletResult models the data returned by the wallet server validateaddress command.
type VerifyChainCmd ¶
type VerifyChainCmd struct { CheckLevel *int32 `jsonrpcdefault:"3"` CheckDepth *int32 `jsonrpcdefault:"288"` // 0 = all }
VerifyChainCmd defines the verifychain JSON-RPC command.
func NewVerifyChainCmd ¶
func NewVerifyChainCmd(checkLevel, checkDepth *int32) *VerifyChainCmd
NewVerifyChainCmd returns a new instance which can be used to issue a verifychain JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type VerifyMessageCmd ¶
VerifyMessageCmd defines the verifymessage JSON-RPC command.
func NewVerifyMessageCmd ¶
func NewVerifyMessageCmd(address, signature, message string) *VerifyMessageCmd
NewVerifyMessageCmd returns a new instance which can be used to issue a verifymessage JSON-RPC command.
type VerifyTxOutProofCmd ¶
type VerifyTxOutProofCmd struct {
Proof string
}
VerifyTxOutProofCmd defines the verifytxoutproof JSON-RPC command.
func NewVerifyTxOutProofCmd ¶
func NewVerifyTxOutProofCmd(proof string) *VerifyTxOutProofCmd
NewVerifyTxOutProofCmd returns a new instance which can be used to issue a verifytxoutproof JSON-RPC command.
type VersionCmd ¶
type VersionCmd struct{}
VersionCmd defines the version JSON-RPC command.
NOTE: This is a btcsuite extension ported from github.com/decred/dcrd/dcrjson.
func NewVersionCmd ¶
func NewVersionCmd() *VersionCmd
NewVersionCmd returns a new instance which can be used to issue a JSON-RPC version command.
NOTE: This is a btcsuite extension ported from github.com/decred/dcrd/dcrjson.
type VersionResult ¶
type VersionResult struct { VersionString string `json:"versionstring"` Major uint32 `json:"major"` Minor uint32 `json:"minor"` Patch uint32 `json:"patch"` Prerelease string `json:"prerelease"` BuildMetadata string `json:"buildmetadata"` }
VersionResult models objects included in the version response. In the actual result, these objects are keyed by the program or API name.
NOTE: This is a btcsuite extension ported from github.com/decred/dcrd/dcrjson.
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"` Witness []string `json:"txinwitness"` }
Vin models parts of the tx data. It is defined separately since getrawtransaction, decoderawtransaction, and searchrawtransaction use the same structure.
func (*Vin) HasWitness ¶
HasWitness returns a bool to show if a Vin has any witness data associated with it or not.
func (*Vin) IsCoinBase ¶
IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.
func (*Vin) MarshalJSON ¶
MarshalJSON provides a custom Marshal method for Vin.
type VinPrevOut ¶
type VinPrevOut struct { Coinbase string `json:"coinbase"` Txid string `json:"txid"` Vout uint32 `json:"vout"` ScriptSig *ScriptSig `json:"scriptSig"` Witness []string `json:"txinwitness"` PrevOut *PrevOut `json:"prevOut"` Sequence uint32 `json:"sequence"` }
VinPrevOut is like Vin except it includes PrevOut. It is used by searchrawtransaction
func (*VinPrevOut) HasWitness ¶
func (v *VinPrevOut) HasWitness() bool
HasWitness returns a bool to show if a Vin has any witness data associated with it or not.
func (*VinPrevOut) IsCoinBase ¶
func (v *VinPrevOut) IsCoinBase() bool
IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.
func (*VinPrevOut) MarshalJSON ¶
func (v *VinPrevOut) MarshalJSON() ([]byte, error)
MarshalJSON provides a custom Marshal method for VinPrevOut.
type Vout ¶
type Vout struct { ValueCoins float64 `json:"value"` Svalue string `json:"svalue"` N uint32 `json:"n"` Address string `json:"address"` Vote *Vote `json:"vote,omitempty"` }
Vout models parts of the tx data. It is defined separately since both getrawtransaction and decoderawtransaction use the same structure.
type WalletInfoResult ¶
type WalletInfoResult struct { CurrentBlockHash string CurrentHeight int32 CurrentBlockTimestamp time.Time BackendBlockHash string BackendHeight int32 BackendBlockTimestamp time.Time IsSyncing bool Backend string WalletVersion int32 WalletStats *WalletStats RPCInfo *InfoWalletResult NeutrinoInfo *NeutrinoInfo }
type WalletIsLockedCmd ¶
type WalletIsLockedCmd struct{}
WalletIsLockedCmd defines the walletislocked JSON-RPC command.
func NewWalletIsLockedCmd ¶
func NewWalletIsLockedCmd() *WalletIsLockedCmd
NewWalletIsLockedCmd returns a new instance which can be used to issue a walletislocked JSON-RPC command.
type WalletLockCmd ¶
type WalletLockCmd struct{}
WalletLockCmd defines the walletlock JSON-RPC command.
func NewWalletLockCmd ¶
func NewWalletLockCmd() *WalletLockCmd
NewWalletLockCmd returns a new instance which can be used to issue a walletlock JSON-RPC command.
type WalletLockStateNtfn ¶
type WalletLockStateNtfn struct {
Locked bool
}
WalletLockStateNtfn defines the walletlockstate JSON-RPC notification.
func NewWalletLockStateNtfn ¶
func NewWalletLockStateNtfn(locked bool) *WalletLockStateNtfn
NewWalletLockStateNtfn returns a new instance which can be used to issue a walletlockstate JSON-RPC notification.
type WalletMempoolCmd ¶
type WalletMempoolCmd struct{}
type WalletMempoolItem ¶
type WalletMempoolRes ¶
type WalletMempoolRes []WalletMempoolItem
type WalletPassphraseChangeCmd ¶
WalletPassphraseChangeCmd defines the walletpassphrase JSON-RPC command.
func NewWalletPassphraseChangeCmd ¶
func NewWalletPassphraseChangeCmd(oldPassphrase, newPassphrase string) *WalletPassphraseChangeCmd
NewWalletPassphraseChangeCmd returns a new instance which can be used to issue a walletpassphrasechange JSON-RPC command.
type WalletPassphraseCmd ¶
WalletPassphraseCmd defines the walletpassphrase JSON-RPC command.
func NewWalletPassphraseCmd ¶
func NewWalletPassphraseCmd(passphrase string, timeout int64) *WalletPassphraseCmd
NewWalletPassphraseCmd returns a new instance which can be used to issue a walletpassphrase JSON-RPC command.
type WalletStats ¶
type WalletStats struct { MaintenanceInProgress bool MaintenanceName string MaintenanceCycles int MaintenanceLastBlockVisited int TimeOfLastMaintenance time.Time // If we're currently in a resync Syncing bool SyncStarted *time.Time SyncRemainingSeconds int64 SyncCurrentBlock int32 SyncFrom int32 SyncTo int32 // General info BirthdayBlock int32 }