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.
package main import ( "encoding/json" "fmt" "github.com/dashpay/dashd-go/btcjson" ) func main() { // 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(`{"jsonrpc":"1.0","result":350001,"error":null,"id":1}`) // Unmarshal the raw bytes from the wire into a JSON-RPC response. var response btcjson.Response if err := json.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 := json.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, error)
- func Float64(v float64) *float64
- func GenerateHelp(method string, descs map[string]string, resultTypes ...interface{}) (string, error)
- func Int(v int) *int
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func IsValidIDType(id interface{}) bool
- func MarshalCmd(rpcVersion RPCVersion, id interface{}, cmd interface{}) ([]byte, error)
- func MarshalResponse(rpcVersion RPCVersion, id interface{}, result interface{}, rpcErr *RPCError) ([]byte, error)
- func MethodUsageText(method string) (string, error)
- func MustRegisterCmd(method string, cmd interface{}, flags UsageFlag)
- func NewCmd(method string, args ...interface{}) (interface{}, error)
- func RegisterCmd(method string, cmd interface{}, flags UsageFlag) error
- 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{}, error)
- type AccountBalanceNtfn
- type AddMultisigAddressCmd
- type AddNodeCmd
- type AddNodeSubCmd
- type AddWitnessAddressCmd
- type AllowHighFeesOrMaxFeeRate
- type AuthenticateCmd
- type BLSCmd
- type BLSResult
- type BLSSubCmd
- type BackupWalletCmd
- type BalanceDetailsResult
- type Bip9SoftForkDescription
- type BlockConnectedNtfndeprecated
- type BlockDetails
- type BlockDisconnectedNtfndeprecated
- type BtcdConnectedNtfn
- type ChangeType
- type CreateEncryptedWalletCmd
- type CreateMultiSigResult
- type CreateMultisigCmd
- type CreateNewAccountCmd
- type CreateRawTransactionCmd
- type CreateWalletCmd
- type CreateWalletResult
- type DKGSessionCounts
- type DKGSessionIndexes
- type DKGSessionMembersProTxHashes
- type DKGSessionMemeber
- type DKGSessionShared
- type DMNState
- type DebugLevelCmd
- type DecodeRawTransactionCmd
- type DecodeScriptCmd
- type DecodeScriptResult
- type DeriveAddressesCmd
- type DeriveAddressesResult
- type DescriptorRange
- type DetailLevel
- type DumpPrivKeyCmd
- type DumpWalletCmd
- type DumpWalletResult
- type EncryptWalletCmd
- type Error
- type ErrorCode
- type EstimateFeeCmd
- type EstimatePriorityCmd
- type EstimateSmartFeeCmd
- type EstimateSmartFeeMode
- type EstimateSmartFeeResult
- type ExportWatchingWalletCmd
- type FilterTypeName
- type FilteredBlockConnectedNtfn
- type FilteredBlockDisconnectedNtfn
- type FundRawTransactionCmd
- type FundRawTransactionOpts
- type FundRawTransactionResult
- type GenerateCmd
- type GenerateToAddressCmd
- type GetAccountAddressCmd
- type GetAccountCmd
- type GetAddedNodeInfoCmd
- type GetAddedNodeInfoResult
- type GetAddedNodeInfoResultAddr
- type GetAddressInfoCmd
- type GetAddressInfoResult
- type GetAddressesByAccountCmd
- type GetBalanceCmd
- type GetBalancesCmd
- type GetBalancesResult
- type GetBestBlockCmd
- type GetBestBlockHashCmd
- type GetBestBlockResult
- type GetBlockChainInfoCmd
- type GetBlockChainInfoResult
- type GetBlockCmd
- type GetBlockCountCmd
- type GetBlockFilterCmd
- type GetBlockFilterResult
- type GetBlockHashCmd
- type GetBlockHeaderCmd
- type GetBlockHeaderVerboseResult
- type GetBlockStatsCmd
- type GetBlockStatsResult
- type GetBlockTemplateCmd
- type GetBlockTemplateResult
- type GetBlockTemplateResultAux
- type GetBlockTemplateResultTx
- type GetBlockVerboseResult
- type GetBlockVerboseTxResult
- type GetCFilterCmd
- type GetCFilterHeaderCmd
- type GetChainTipsCmd
- type GetChainTxStatsCmd
- type GetChainTxStatsResult
- type GetConnectionCountCmd
- type GetCurrentNetCmd
- type GetDescriptorInfoCmd
- type GetDescriptorInfoResult
- type GetDifficultyCmd
- type GetGenerateCmd
- type GetHashesPerSecCmd
- type GetHeadersCmd
- type GetInfoCmd
- type GetMempoolEntryCmd
- type GetMempoolEntryResult
- type GetMempoolInfoCmd
- type GetMempoolInfoResult
- type GetMiningInfoCmd
- type GetMiningInfoResult
- type GetNetTotalsCmd
- type GetNetTotalsResult
- type GetNetworkHashPSCmd
- type GetNetworkInfoCmd
- type GetNetworkInfoResult
- type GetNewAddressCmd
- type GetNodeAddressesCmd
- type GetNodeAddressesResult
- type GetPeerInfoCmd
- type GetPeerInfoResult
- type GetRawChangeAddressCmd
- type GetRawMempoolCmd
- type GetRawMempoolVerboseResult
- type GetRawTransactionCmd
- type GetReceivedByAccountCmd
- type GetReceivedByAddressCmd
- type GetTransactionCmd
- type GetTransactionDetailsResult
- type GetTransactionResult
- type GetTxOutCmd
- type GetTxOutProofCmd
- type GetTxOutResult
- type GetTxOutSetInfoCmd
- type GetTxOutSetInfoResult
- type GetUnconfirmedBalanceCmd
- type GetWalletInfoCmd
- type GetWalletInfoResult
- type GetWorkCmd
- type GetWorkResult
- type HashOrHeight
- type HelpCmd
- type ImportAddressCmd
- type ImportMultiCmd
- type ImportMultiOptions
- type ImportMultiRequest
- type ImportMultiResults
- type ImportPrivKeyCmd
- type ImportPubKeyCmd
- type ImportWalletCmd
- type InfoChainResult
- type InfoWalletResult
- type InvalidateBlockCmd
- type KeyPoolRefillCmd
- type LLMQType
- type ListAccountsCmd
- type ListAddressGroupingsCmd
- type ListAddressTransactionsCmd
- type ListAllTransactionsCmd
- type ListLockUnspentCmd
- type ListReceivedByAccountCmd
- type ListReceivedByAccountResult
- type ListReceivedByAddressCmd
- type ListReceivedByAddressResult
- type ListSinceBlockCmd
- type ListSinceBlockResult
- type ListTransactionsCmd
- type ListTransactionsResult
- type ListUnspentCmd
- type ListUnspentResult
- type LoadTxFilterCmd
- type LoadWalletCmd
- type LoadWalletResult
- type LocalAddressesResult
- type LockUnspentCmd
- type MNStatusState
- type MasternodeCmd
- type MasternodeCountResult
- type MasternodeResult
- type MasternodeStatusResult
- type MasternodeSubCmd
- type MasternodelistCmd
- type MasternodelistResultJSON
- type MempoolFees
- type MinableCommitment
- type MoveCmd
- type NetworksResult
- type NewTxNtfn
- type NodeCmd
- type NodeSubCmd
- type NotifyBlocksCmd
- type NotifyNewTransactionsCmd
- type NotifyReceivedCmddeprecated
- type NotifySpentCmddeprecated
- type OutPoint
- type PingCmd
- type PreciousBlockCmd
- type PrevOut
- type ProTxCmd
- func NewProTxDiffCmd(baseBlock, block int) *ProTxCmd
- func NewProTxInfoCmd(proTxHash string) *ProTxCmd
- func NewProTxListCmd(cmdType ProTxListType, detailed bool, height int) *ProTxCmd
- func NewProTxRegisterCmd(collateralHash string, collateralIndex int, ...) *ProTxCmd
- func NewProTxRegisterFundCmd(...) *ProTxCmd
- func NewProTxRegisterPrepareCmd(collateralHash string, collateralIndex int, ...) *ProTxCmd
- func NewProTxRegisterSubmitCmd(tx, sig string) *ProTxCmd
- func NewProTxRevokeCmd(proTxHash, operatorPrivateKey string, reason int, feeSourceAddress string) *ProTxCmd
- func NewProTxUpdateRegistrarCmd(...) *ProTxCmd
- func NewProTxUpdateServiceCmd(...) *ProTxCmd
- type ProTxDiffDeletedQuorum
- type ProTxDiffMN
- type ProTxDiffNewQuorum
- type ProTxDiffResult
- type ProTxInfoResult
- type ProTxListType
- type ProTxMetaInfo
- type ProTxRegisterPrepareResult
- type ProTxState
- type ProTxSubCmd
- type ProTxWallet
- type PsbtInput
- type PsbtOutput
- type QuorumCmd
- func NewQuorumDKGStatusCmd(detailLevel DetailLevel) *QuorumCmd
- func NewQuorumGetRecSig(quorumType LLMQType, requestID, messageHash string) *QuorumCmd
- func NewQuorumHasRecSig(quorumType LLMQType, requestID, messageHash string) *QuorumCmd
- func NewQuorumInfoCmd(quorumType LLMQType, quorumHash string, includeSkShare bool) *QuorumCmd
- func NewQuorumIsConflicting(quorumType LLMQType, requestID, messageHash string) *QuorumCmd
- func NewQuorumListCmd() *QuorumCmd
- func NewQuorumMemberOfCmd(proTxHash string, scanQuorumsCount int) *QuorumCmd
- func NewQuorumPlatformSignCmd(requestID, messageHash, quorumHash string, submit bool) *QuorumCmd
- func NewQuorumSelectQuorumCmd(quorumType LLMQType, requestID string) *QuorumCmd
- func NewQuorumSignCmd(quorumType LLMQType, requestID, messageHash, quorumHash string, submit bool) *QuorumCmd
- func NewQuorumVerifyCmd(quorumType LLMQType, requestID string, messageHash string, signature string, ...) *QuorumCmd
- type QuorumCmdSubCmd
- type QuorumConnection
- type QuorumDKGStatusCountsResult
- type QuorumDKGStatusIndexesResult
- type QuorumDKGStatusMembersProTxHashesResult
- type QuorumDKGStatusResultShared
- type QuorumInfoResult
- type QuorumListResult
- type QuorumMember
- type QuorumMemberOfResult
- type QuorumSelectQuorumResult
- type QuorumSignResult
- type QuorumSignResultWithBool
- type QuorumVerifyResult
- type RPCError
- type RPCErrorCode
- type RPCVersion
- type RawTxInput
- type RawTxWitnessInput
- type ReconsiderBlockCmd
- type RecoverAddressesCmd
- type RecvTxNtfndeprecated
- type RedeemingTxNtfndeprecated
- type RelevantTxAcceptedNtfn
- type RenameAccountCmd
- type Request
- type RescanBlocksCmd
- type RescanCmddeprecated
- type RescanFinishedNtfndeprecated
- type RescanProgressNtfndeprecated
- type RescannedBlock
- type Response
- type ScanProgress
- type ScanningOrFalse
- type ScriptPubKey
- type ScriptPubKeyAddress
- type ScriptPubKeyResult
- type ScriptSig
- type SearchRawTransactionsCmd
- type SearchRawTransactionsResult
- type SendFromCmd
- type SendManyCmd
- type SendRawTransactionCmd
- type SendToAddressCmd
- type SessionCmd
- type SessionResult
- type SetAccountCmd
- type SetGenerateCmd
- type SetTxFeeCmd
- type SignMessageCmd
- type SignMessageWithPrivKeyCmd
- type SignRawTransactionCmd
- type SignRawTransactionError
- type SignRawTransactionResult
- type SignRawTransactionWithWalletCmd
- type SignRawTransactionWithWalletResult
- type SoftForkDescription
- type SoftForks
- type StopCmd
- type StopNotifyBlocksCmd
- type StopNotifyNewTransactionsCmd
- type StopNotifyReceivedCmddeprecated
- type StopNotifySpentCmddeprecated
- type SubmitBlockCmd
- type SubmitBlockOptions
- type TemplateRequest
- type TimestampOrNow
- type TransactionInput
- type TxAcceptedNtfn
- type TxAcceptedVerboseNtfn
- type TxRawDecodeResult
- type TxRawResult
- type UnifiedSoftFork
- type UnifiedSoftForks
- type UnloadWalletCmd
- type Unmarshaler
- 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 Vout
- type WalletCreateFundedPsbtCmd
- type WalletCreateFundedPsbtOpts
- type WalletCreateFundedPsbtResult
- type WalletIsLockedCmd
- type WalletLockCmd
- type WalletLockStateNtfn
- type WalletPassphraseChangeCmd
- type WalletPassphraseCmd
- type WalletProcessPsbtCmd
- type WalletProcessPsbtResult
Examples ¶
Constants ¶
const ( // BlockConnectedNtfnMethod is the legacy, deprecated method used for // notifications from the chain server that a block has been connected. // // 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. // // 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. // // 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. // // 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. // // 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. // // 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 = "btcdconnected" // 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 ( ErrRPCInvalidRequest = &RPCError{ Code: -32600, Message: "Invalid request", } ErrRPCMethodNotFound = &RPCError{ Code: -32601, Message: "Method not found", } ErrRPCInvalidParams = &RPCError{ Code: -32602, Message: "Invalid parameters", } ErrRPCInternal = &RPCError{ Code: -32603, Message: "Internal error", } ErrRPCParse = &RPCError{ Code: -32700, Message: "Parse error", } )
Standard JSON-RPC 2.0 errors.
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, error)
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 ¶
func MarshalCmd(rpcVersion RPCVersion, id interface{}, cmd interface{}) ([]byte, error)
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/dashpay/dashd-go/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.Int(0)) // 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(btcjson.RpcVersion1, 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",0],"id":1}
func MarshalResponse ¶
func MarshalResponse(rpcVersion RPCVersion, id interface{}, result interface{}, rpcErr *RPCError) ([]byte, error)
MarshalResponse marshals the passed rpc version, 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/dashpay/dashd-go/btcjson" ) func main() { // Marshal a new JSON-RPC response. For example, this is a response // to a getblockheight request. marshalledBytes, err := btcjson.MarshalResponse(btcjson.RpcVersion1, 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: {"jsonrpc":"1.0","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 json.Unmarshal into the destination field
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.
package main import ( "encoding/json" "fmt" "github.com/dashpay/dashd-go/btcjson" ) func main() { // 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",0],"id":1}`) // Unmarshal the raw bytes from the wire into a JSON-RPC request. var request btcjson.Request if err := json.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("Verbosity:", *gbCmd.Verbosity) }
Output: Hash: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f Verbosity: 0
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.
func NewAddMultisigAddressCmd ¶
func NewAddMultisigAddressCmd(nRequired int, keys []string, account *string) *AddMultisigAddressCmd
NewAddMultisigAddressCmd returns a new instance which can be used to issue a addmultisigaddress JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
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 ( // ANAdd indicates the specified host should be added as a persistent // peer. ANAdd AddNodeSubCmd = "add" // ANRemove indicates the specified peer should be removed. ANRemove AddNodeSubCmd = "remove" // ANOneTry indicates the specified host should try to connect once, // but it should not be made persistent. ANOneTry AddNodeSubCmd = "onetry" )
type 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 AllowHighFeesOrMaxFeeRate ¶
type AllowHighFeesOrMaxFeeRate struct {
Value interface{}
}
AllowHighFeesOrMaxFeeRate defines a type that can either be the legacy allowhighfees boolean field or the new maxfeerate int field.
func (AllowHighFeesOrMaxFeeRate) MarshalJSON ¶
func (a AllowHighFeesOrMaxFeeRate) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface
func (AllowHighFeesOrMaxFeeRate) String ¶
func (a AllowHighFeesOrMaxFeeRate) String() string
String returns the string representation of this struct, used for printing the marshaled default value in the help text.
func (*AllowHighFeesOrMaxFeeRate) UnmarshalJSON ¶
func (a *AllowHighFeesOrMaxFeeRate) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
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 BLSCmd ¶
type BLSCmd struct { SubCmd BLSSubCmd `jsonrpcusage:"\"generate|fromsecret\""` Secret *string `json:",omitempty"` }
func NewBLSFromSecret ¶
func NewBLSGenerate ¶
func NewBLSGenerate() *BLSCmd
type BackupWalletCmd ¶
type BackupWalletCmd struct {
Destination string
}
BackupWalletCmd defines the backupwallet JSON-RPC command
func NewBackupWalletCmd ¶
func NewBackupWalletCmd(destination string) *BackupWalletCmd
NewBackupWalletCmd returns a new instance which can be used to issue a backupwallet JSON-RPC command
type BalanceDetailsResult ¶
type BalanceDetailsResult struct { Trusted float64 `json:"trusted"` UntrustedPending float64 `json:"untrusted_pending"` Immature float64 `json:"immature"` Used *float64 `json:"used"` }
BalanceDetailsResult models the details data from the `getbalances` command.
type Bip9SoftForkDescription ¶
type Bip9SoftForkDescription struct { Status string `json:"status"` Bit uint8 `json:"bit"` StartTime1 int64 `json:"startTime"` StartTime2 int64 `json:"start_time"` Timeout int64 `json:"timeout"` Since int32 `json:"since"` MinActivationHeight int32 `json:"min_activation_height"` }
Bip9SoftForkDescription describes the current state of a defined BIP0009 version bits soft-fork.
func (*Bip9SoftForkDescription) StartTime ¶
func (d *Bip9SoftForkDescription) StartTime() int64
StartTime returns the starting time of the softfork as a Unix epoch.
type BlockConnectedNtfn
deprecated
BlockConnectedNtfn defines the blockconnected JSON-RPC notification.
Deprecated: Use FilteredBlockConnectedNtfn instead.
func NewBlockConnectedNtfn
deprecated
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.
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
deprecated
BlockDisconnectedNtfn defines the blockdisconnected JSON-RPC notification.
Deprecated: Use FilteredBlockDisconnectedNtfn instead.
func NewBlockDisconnectedNtfn
deprecated
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.
Deprecated: Use NewFilteredBlockDisconnectedNtfn instead.
type BtcdConnectedNtfn ¶
type BtcdConnectedNtfn struct {
Connected bool
}
BtcdConnectedNtfn defines the btcdconnected JSON-RPC notification.
func NewBtcdConnectedNtfn ¶
func NewBtcdConnectedNtfn(connected bool) *BtcdConnectedNtfn
NewBtcdConnectedNtfn returns a new instance which can be used to issue a btcdconnected JSON-RPC notification.
type ChangeType ¶
type ChangeType string
ChangeType defines the different output types to use for the change address of a transaction built by the node.
var ( // ChangeTypeLegacy indicates a P2PKH change address type. ChangeTypeLegacy ChangeType = "legacy" // ChangeTypeP2SHSegWit indicates a P2WPKH-in-P2SH change address type. ChangeTypeP2SHSegWit ChangeType = "p2sh-segwit" // ChangeTypeBech32 indicates a P2WPKH change address type. ChangeTypeBech32 ChangeType = "bech32" )
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 CreateNewAccountCmd ¶
type CreateNewAccountCmd struct {
Account string
}
CreateNewAccountCmd defines the createnewaccount JSON-RPC command.
func NewCreateNewAccountCmd ¶
func NewCreateNewAccountCmd(account string) *CreateNewAccountCmd
NewCreateNewAccountCmd returns a new instance which can be used to issue a createnewaccount 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. Passing in nil and the empty slice as inputs is equivalent, both gets interpreted as the empty slice.
type CreateWalletCmd ¶
type CreateWalletCmd struct { WalletName string DisablePrivateKeys *bool `jsonrpcdefault:"false"` Blank *bool `jsonrpcdefault:"false"` Passphrase *string `jsonrpcdefault:"\"\""` AvoidReuse *bool `jsonrpcdefault:"false"` }
CreateWalletCmd defines the createwallet JSON-RPC command.
func NewCreateWalletCmd ¶
func NewCreateWalletCmd(walletName string, disablePrivateKeys *bool, blank *bool, passphrase *string, avoidReuse *bool) *CreateWalletCmd
NewCreateWalletCmd returns a new instance which can be used to issue a createwallet JSON-RPC command.
type CreateWalletResult ¶
CreateWalletResult models the result of the createwallet command.
type DKGSessionCounts ¶
type DKGSessionCounts struct { BadMembers int `json:"badMembers"` WeComplain int `json:"weComplain"` ReceivedContributions int `json:"receivedContributions"` ReceivedComplaints int `json:"receivedComplaints"` ReceivedJustifications int `json:"receivedJustifications"` ReceivedPrematureCommitments int `json:"receivedPrematureCommitments"` }
DKGSessionCounts is the session section of a dkgstatus with counts
type DKGSessionIndexes ¶
type DKGSessionIndexes struct { BadMembers []int `json:"badMembers"` WeComplain []int `json:"weComplain"` ReceivedContributions []int `json:"receivedContributions"` ReceivedComplaints []int `json:"receivedComplaints"` ReceivedJustifications []int `json:"receivedJustifications"` ReceivedPrematureCommitments []int `json:"receivedPrematureCommitments"` }
DKGSessionIndexes is the session section of a dkgstatus with indexes
type DKGSessionMembersProTxHashes ¶
type DKGSessionMembersProTxHashes struct { BadMembers []DKGSessionMemeber `json:"badMembers"` WeComplain []DKGSessionMemeber `json:"weComplain"` ReceivedContributions []DKGSessionMemeber `json:"receivedContributions"` ReceivedComplaints []DKGSessionMemeber `json:"receivedComplaints"` ReceivedJustifications []DKGSessionMemeber `json:"receivedJustifications"` ReceivedPrematureCommitments []DKGSessionMemeber `json:"receivedPrematureCommitments"` AllMembers []string `json:"allMembers"` }
DKGSessionMembersProTxHashes is the session section of a dkgstatus with member info
type DKGSessionMemeber ¶
type DKGSessionMemeber struct { MemberIndex int `json:"memberIndex"` ProTxHash string `json:"proTxHash"` }
DKGSessionMemeber is a memeber in in dkgstatus
type DKGSessionShared ¶
type DKGSessionShared struct {}
type DMNState ¶
type DMNState struct { Service string `json:"service"` RegisteredHeight int `json:"registeredHeight"` LastPaidHeight int `json:"lastPaidHeight"` PoSePenalty int `json:"PoSePenalty"` PoSeRevivedHeight int `json:"PoSeRevivedHeight"` PoSeBanHeight int `json:"PoSeBanHeight"` RevocationReason int `json:"revocationReason"` OwnerAddress string `json:"ownerAddress"` VotingAddress string `json:"votingAddress"` PayoutAddress string `json:"payoutAddress"` PubKeyOperator string `json:"pubKeyOperator"` }
DMNState is used in masternode status
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 btcd.
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 btcd.
type DecodeRawTransactionCmd ¶
type DecodeRawTransactionCmd struct {
HexTx string
}
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"` }
DecodeScriptResult models the data returned from the decodescript command.
type DeriveAddressesCmd ¶
type DeriveAddressesCmd struct { Descriptor string Range *DescriptorRange }
DeriveAddressesCmd defines the deriveaddresses JSON-RPC command.
func NewDeriveAddressesCmd ¶
func NewDeriveAddressesCmd(descriptor string, descriptorRange *DescriptorRange) *DeriveAddressesCmd
NewDeriveAddressesCmd returns a new instance which can be used to issue a deriveaddresses JSON-RPC command.
type DeriveAddressesResult ¶
type DeriveAddressesResult []string
DeriveAddressesResult models the data from the deriveaddresses command.
type DescriptorRange ¶
type DescriptorRange struct {
Value interface{}
}
DescriptorRange specifies the limits of a ranged Descriptor.
Descriptors are typically ranged when specified in the form of generic HD chain paths.
Example of a ranged descriptor: pkh(tpub.../*)
The value can be an int to specify the end of the range, or the range itself, as []int{begin, end}.
func (DescriptorRange) MarshalJSON ¶
func (r DescriptorRange) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for DescriptorRange
func (*DescriptorRange) UnmarshalJSON ¶
func (r *DescriptorRange) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for DescriptorRange
type DetailLevel ¶
type DetailLevel int
DetailLevel is the level of detail used in dkgstatus
const ( DetailLevelCounts DetailLevel = 0 DetailLevelIndexes DetailLevel = 1 DetailLevelMembersProTxHashes DetailLevel = 2 )
Detail Levels for dkgstatsu
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 DumpWalletCmd ¶
type DumpWalletCmd struct {
Filename string
}
DumpWalletCmd defines the dumpwallet JSON-RPC command.
func NewDumpWalletCmd ¶
func NewDumpWalletCmd(filename string) *DumpWalletCmd
NewDumpWalletCmd returns a new instance which can be used to issue a dumpwallet JSON-RPC command.
type DumpWalletResult ¶
type DumpWalletResult struct {
Filename string `json:"filename"`
}
DumpWalletResult models the data from the dumpwallet command
type EncryptWalletCmd ¶
type EncryptWalletCmd struct {
Passphrase string
}
EncryptWalletCmd defines the encryptwallet JSON-RPC command.
func NewEncryptWalletCmd ¶
func NewEncryptWalletCmd(passphrase string) *EncryptWalletCmd
NewEncryptWalletCmd returns a new instance which can be used to issue a encryptwallet JSON-RPC command.
type Error ¶
type Error struct { ErrorCode ErrorCode // Describes the kind of error Description string // Human readable description of the issue }
Error identifies a general error. This differs from an RPCError in that this error typically is used more by the consumers of the package as opposed to RPCErrors which are intended to be returned to the client across the wire via a JSON-RPC Response. The caller can use type assertions to determine the specific error and access the ErrorCode field.
type ErrorCode ¶
type ErrorCode int
ErrorCode identifies a kind of error. These error codes are NOT used for JSON-RPC response errors.
const ( // ErrDuplicateMethod indicates a command with the specified method // already exists. ErrDuplicateMethod ErrorCode = iota // ErrInvalidUsageFlags indicates one or more unrecognized flag bits // were specified. ErrInvalidUsageFlags // ErrInvalidType indicates a type was passed that is not the required // type. ErrInvalidType // ErrEmbeddedType indicates the provided command struct contains an // embedded type which is not not supported. ErrEmbeddedType // ErrUnexportedField indiciates the provided command struct contains an // unexported field which is not supported. ErrUnexportedField // ErrUnsupportedFieldType indicates the type of a field in the provided // command struct is not one of the supported types. ErrUnsupportedFieldType // ErrNonOptionalField indicates a non-optional field was specified // after an optional field. ErrNonOptionalField // ErrNonOptionalDefault indicates a 'jsonrpcdefault' struct tag was // specified for a non-optional field. ErrNonOptionalDefault // ErrMismatchedDefault indicates a 'jsonrpcdefault' struct tag contains // a value that doesn't match the type of the field. ErrMismatchedDefault // ErrUnregisteredMethod indicates a method was specified that has not // been registered. ErrUnregisteredMethod // ErrMissingDescription indicates a description required to generate // help is missing. ErrMissingDescription // ErrNumParams inidcates the number of params supplied do not // match the requirements of the associated command. ErrNumParams )
These constants are used to identify a specific RuleError.
type 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 EstimatePriorityCmd ¶
type EstimatePriorityCmd struct {
NumBlocks int64
}
EstimatePriorityCmd defines the estimatepriority JSON-RPC command.
func NewEstimatePriorityCmd ¶
func NewEstimatePriorityCmd(numBlocks int64) *EstimatePriorityCmd
NewEstimatePriorityCmd returns a new instance which can be used to issue a estimatepriority JSON-RPC command.
type EstimateSmartFeeCmd ¶
type EstimateSmartFeeCmd struct { ConfTarget int64 EstimateMode *EstimateSmartFeeMode `jsonrpcdefault:"\"CONSERVATIVE\""` }
EstimateSmartFeeCmd defines the estimatesmartfee JSON-RPC command.
func NewEstimateSmartFeeCmd ¶
func NewEstimateSmartFeeCmd(confTarget int64, mode *EstimateSmartFeeMode) *EstimateSmartFeeCmd
NewEstimateSmartFeeCmd returns a new instance which can be used to issue a 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 FilterTypeName ¶
type FilterTypeName string
FilterTypeName defines the type used in the getblockfilter JSON-RPC command for the filter type field.
const ( // FilterTypeBasic is the basic filter type defined in BIP0158. FilterTypeBasic FilterTypeName = "basic" )
func NewFilterTypeName ¶
func NewFilterTypeName(v FilterTypeName) *FilterTypeName
NewFilterTypeName is a helper routine that allocates a new FilterTypeName value to store v and returns a pointer to it. This is useful when assigning optional parameters.
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 FundRawTransactionCmd ¶
type FundRawTransactionCmd struct { HexTx string Options FundRawTransactionOpts IsWitness *bool }
FundRawTransactionCmd defines the fundrawtransaction JSON-RPC command
func NewFundRawTransactionCmd ¶
func NewFundRawTransactionCmd(serializedTx []byte, opts FundRawTransactionOpts, isWitness *bool) *FundRawTransactionCmd
NewFundRawTransactionCmd returns a new instance which can be used to issue a fundrawtransaction JSON-RPC command
type FundRawTransactionOpts ¶
type FundRawTransactionOpts struct { ChangeAddress *string `json:"changeAddress,omitempty"` ChangePosition *int `json:"changePosition,omitempty"` ChangeType *ChangeType `json:"change_type,omitempty"` IncludeWatching *bool `json:"includeWatching,omitempty"` LockUnspents *bool `json:"lockUnspents,omitempty"` FeeRate *float64 `json:"feeRate,omitempty"` // BTC/kB SubtractFeeFromOutputs []int `json:"subtractFeeFromOutputs,omitempty"` Replaceable *bool `json:"replaceable,omitempty"` ConfTarget *int `json:"conf_target,omitempty"` EstimateMode *EstimateSmartFeeMode `json:"estimate_mode,omitempty"` }
FundRawTransactionOpts are the different options that can be passed to rawtransaction
type FundRawTransactionResult ¶
type FundRawTransactionResult struct { Transaction *wire.MsgTx Fee btcutil.Amount ChangePosition int // the position of the added change output, or -1 }
FundRawTransactionResult is the result of the fundrawtransaction JSON-RPC call
func (*FundRawTransactionResult) UnmarshalJSON ¶
func (f *FundRawTransactionResult) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the result of the fundrawtransaction JSON-RPC call
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 GenerateToAddressCmd ¶
type GenerateToAddressCmd struct { NumBlocks int64 Address string MaxTries *int64 `jsonrpcdefault:"1000000"` }
GenerateToAddressCmd defines the generatetoaddress JSON-RPC command.
func NewGenerateToAddressCmd ¶
func NewGenerateToAddressCmd(numBlocks int64, address string, maxTries *int64) *GenerateToAddressCmd
NewGenerateToAddressCmd returns a new instance which can be used to issue a generatetoaddress JSON-RPC command.
type GetAccountAddressCmd ¶
type GetAccountAddressCmd struct {
Account string
}
GetAccountAddressCmd defines the getaccountaddress JSON-RPC command.
func NewGetAccountAddressCmd ¶
func NewGetAccountAddressCmd(account string) *GetAccountAddressCmd
NewGetAccountAddressCmd returns a new instance which can be used to issue a getaccountaddress JSON-RPC command.
type GetAccountCmd ¶
type GetAccountCmd struct {
Address string
}
GetAccountCmd defines the getaccount JSON-RPC command.
func NewGetAccountCmd ¶
func NewGetAccountCmd(address string) *GetAccountCmd
NewGetAccountCmd returns a new instance which can be used to issue a getaccount 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 GetAddressInfoCmd ¶
type GetAddressInfoCmd struct {
Address string
}
GetAddressInfoCmd defines the getaddressinfo JSON-RPC command.
func NewGetAddressInfoCmd ¶
func NewGetAddressInfoCmd(address string) *GetAddressInfoCmd
NewGetAddressInfoCmd returns a new instance which can be used to issue a getaddressinfo JSON-RPC command.
type GetAddressInfoResult ¶
type GetAddressInfoResult struct { IsMine bool `json:"ismine"` IsWatchOnly bool `json:"iswatchonly"` Timestamp *int `json:"timestamp,omitempty"` HDKeyPath *string `json:"hdkeypath,omitempty"` HDSeedID *string `json:"hdseedid,omitempty"` Embedded *embeddedAddressInfo `json:"embedded,omitempty"` // contains filtered or unexported fields }
GetAddressInfoResult models the result of the getaddressinfo command. It contains information about a bitcoin address.
Reference: https://bitcoincore.org/en/doc/0.20.0/rpc/wallet/getaddressinfo
The GetAddressInfoResult has three segments:
- General information about the address.
- Metadata (Timestamp, HDKeyPath, HDSeedID) and wallet fields (IsMine, IsWatchOnly).
- Information about the embedded address in case of P2SH or P2WSH. Same structure as (1).
func (*GetAddressInfoResult) UnmarshalJSON ¶
func (e *GetAddressInfoResult) UnmarshalJSON(data []byte) error
UnmarshalJSON provides a custom unmarshaller for GetAddressInfoResult. It is adapted to avoid creating a duplicate raw struct for unmarshalling the JSON bytes into.
Reference: http://choly.ca/post/go-json-marshalling
type GetAddressesByAccountCmd ¶
type GetAddressesByAccountCmd struct {
Account string
}
GetAddressesByAccountCmd defines the getaddressesbyaccount JSON-RPC command.
func NewGetAddressesByAccountCmd ¶
func NewGetAddressesByAccountCmd(account string) *GetAddressesByAccountCmd
NewGetAddressesByAccountCmd returns a new instance which can be used to issue a getaddressesbyaccount JSON-RPC command.
type GetBalanceCmd ¶
GetBalanceCmd defines the getbalance JSON-RPC command.
func NewGetBalanceCmd ¶
func NewGetBalanceCmd(account *string, minConf *int) *GetBalanceCmd
NewGetBalanceCmd returns a new instance which can be used to issue a getbalance JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetBalancesCmd ¶
type GetBalancesCmd struct{}
GetBalancesCmd defines the getbalances JSON-RPC command.
func NewGetBalancesCmd ¶
func NewGetBalancesCmd() *GetBalancesCmd
NewGetBalancesCmd returns a new instance which can be used to issue a getbalances JSON-RPC command.
type GetBalancesResult ¶
type GetBalancesResult struct { Mine BalanceDetailsResult `json:"mine"` WatchOnly *BalanceDetailsResult `json:"watchonly"` }
GetBalancesResult models the data returned from the getbalances 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"` Difficulty float64 `json:"difficulty"` MedianTime int64 `json:"mediantime"` VerificationProgress float64 `json:"verificationprogress,omitempty"` InitialBlockDownload bool `json:"initialblockdownload,omitempty"` Pruned bool `json:"pruned"` PruneHeight int32 `json:"pruneheight,omitempty"` ChainWork string `json:"chainwork,omitempty"` SizeOnDisk int64 `json:"size_on_disk,omitempty"` *SoftForks *UnifiedSoftForks }
GetBlockChainInfoResult models the data returned from the getblockchaininfo command.
type GetBlockCmd ¶
GetBlockCmd defines the getblock JSON-RPC command.
func NewGetBlockCmd ¶
func NewGetBlockCmd(hash string, verbosity *int) *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 GetBlockFilterCmd ¶
type GetBlockFilterCmd struct { BlockHash string // The hash of the block FilterType *FilterTypeName // The type name of the filter, default=basic }
GetBlockFilterCmd defines the getblockfilter JSON-RPC command.
func NewGetBlockFilterCmd ¶
func NewGetBlockFilterCmd(blockHash string, filterType *FilterTypeName) *GetBlockFilterCmd
NewGetBlockFilterCmd returns a new instance which can be used to issue a getblockfilter JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetBlockFilterResult ¶
type GetBlockFilterResult struct { Filter string `json:"filter"` // the hex-encoded filter data Header string `json:"header"` // the hex-encoded filter header }
GetBlockFilterResult models the data returned from the getblockfilter 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"` Chainlock bool `json:"chainlock"` }
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 GetBlockStatsCmd ¶
type GetBlockStatsCmd struct { HashOrHeight HashOrHeight Stats *[]string }
GetBlockStatsCmd defines the getblockstats JSON-RPC command.
func NewGetBlockStatsCmd ¶
func NewGetBlockStatsCmd(hashOrHeight HashOrHeight, stats *[]string) *GetBlockStatsCmd
NewGetBlockStatsCmd returns a new instance which can be used to issue a getblockstats JSON-RPC command. Either height or hash must be specified.
type GetBlockStatsResult ¶
type GetBlockStatsResult struct { AverageFee int64 `json:"avgfee"` AverageFeeRate int64 `json:"avgfeerate"` AverageTxSize int64 `json:"avgtxsize"` FeeratePercentiles []int64 `json:"feerate_percentiles"` Hash string `json:"blockhash"` Height int64 `json:"height"` Ins int64 `json:"ins"` MaxFee int64 `json:"maxfee"` MaxFeeRate int64 `json:"maxfeerate"` MaxTxSize int64 `json:"maxtxsize"` MedianFee int64 `json:"medianfee"` MedianTime int64 `json:"mediantime"` MedianTxSize int64 `json:"mediantxsize"` MinFee int64 `json:"minfee"` MinFeeRate int64 `json:"minfeerate"` MinTxSize int64 `json:"mintxsize"` Outs int64 `json:"outs"` SegWitTotalSize int64 `json:"swtotal_size"` SegWitTotalWeight int64 `json:"swtotal_weight"` SegWitTxs int64 `json:"swtxs"` Subsidy int64 `json:"subsidy"` Time int64 `json:"time"` TotalOut int64 `json:"total_out"` TotalSize int64 `json:"total_size"` TotalWeight int64 `json:"total_weight"` Txs int64 `json:"txs"` UTXOIncrease int64 `json:"utxo_increase"` UTXOSizeIncrease int64 `json:"utxo_size_inc"` }
GetBlockStatsResult models the data from the getblockstats command.
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"` TxID string `json:"txid"` 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"` // Note: this field is always empty when verbose != 2. 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"` Chainlock bool `json:"chainlock"` }
GetBlockVerboseResult models the data from the getblock command when the verbose flag is set to 1. When the verbose flag is set to 0, getblock returns a hex-encoded string. When the verbose flag is set to 1, getblock returns an object whose tx field is an array of transaction hashes. When the verbose flag is set to 2, getblock returns an object whose tx field is an array of raw transactions. Use GetBlockVerboseTxResult to unmarshal data received from passing verbose=2 to getblock.
type GetBlockVerboseTxResult ¶
type GetBlockVerboseTxResult 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 []TxRawResult `json:"tx,omitempty"` RawTx []TxRawResult `json:"rawtx,omitempty"` // Deprecated: removed in Bitcoin Core 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"` Chainlock bool `json:"chainlock"` }
GetBlockVerboseTxResult models the data from the getblock command when the verbose flag is set to 2. When the verbose flag is set to 0, getblock returns a hex-encoded string. When the verbose flag is set to 1, getblock returns an object whose tx field is an array of transaction hashes. When the verbose flag is set to 2, getblock returns an object whose tx field is an array of raw transactions. Use GetBlockVerboseResult to unmarshal data received from passing verbose=1 to getblock.
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 GetChainTxStatsCmd ¶
GetChainTxStatsCmd defines the getchaintxstats JSON-RPC command.
func NewGetChainTxStatsCmd ¶
func NewGetChainTxStatsCmd(nBlocks *int32, blockHash *string) *GetChainTxStatsCmd
NewGetChainTxStatsCmd returns a new instance which can be used to issue a getchaintxstats JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetChainTxStatsResult ¶
type GetChainTxStatsResult struct { Time int64 `json:"time"` TxCount int64 `json:"txcount"` WindowFinalBlockHash string `json:"window_final_block_hash"` WindowFinalBlockHeight int32 `json:"window_final_block_height"` WindowBlockCount int32 `json:"window_block_count"` WindowTxCount int32 `json:"window_tx_count"` WindowInterval int32 `json:"window_interval"` TxRate float64 `json:"txrate"` }
GetChainTxStatsResult models the data from the getchaintxstats 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 GetDescriptorInfoCmd ¶
type GetDescriptorInfoCmd struct {
Descriptor string
}
GetDescriptorInfoCmd defines the getdescriptorinfo JSON-RPC command.
func NewGetDescriptorInfoCmd ¶
func NewGetDescriptorInfoCmd(descriptor string) *GetDescriptorInfoCmd
NewGetDescriptorInfoCmd returns a new instance which can be used to issue a getdescriptorinfo JSON-RPC command.
type GetDescriptorInfoResult ¶
type GetDescriptorInfoResult struct { Descriptor string `json:"descriptor"` // descriptor in canonical form, without private keys Checksum string `json:"checksum"` // checksum for the input descriptor IsRange bool `json:"isrange"` // whether the descriptor is ranged IsSolvable bool `json:"issolvable"` // whether the descriptor is solvable HasPrivateKeys bool `json:"hasprivatekeys"` // whether the descriptor has at least one private key }
GetDescriptorInfoResult models the data from the getdescriptorinfo 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 GetMempoolEntryResult ¶
type GetMempoolEntryResult struct { VSize int32 `json:"vsize"` Size int32 `json:"size"` Weight int64 `json:"weight"` Fee float64 `json:"fee"` ModifiedFee float64 `json:"modifiedfee"` Time int64 `json:"time"` Height int64 `json:"height"` DescendantCount int64 `json:"descendantcount"` DescendantSize int64 `json:"descendantsize"` DescendantFees float64 `json:"descendantfees"` AncestorCount int64 `json:"ancestorcount"` AncestorSize int64 `json:"ancestorsize"` AncestorFees float64 `json:"ancestorfees"` WTxId string `json:"wtxid"` Fees MempoolFees `json:"fees"` Depends []string `json:"depends"` }
GetMempoolEntryResult models the data returned from the getmempoolentry 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 float64 `json:"hashespersec"` NetworkHashPS float64 `json:"networkhashps"` PooledTx uint64 `json:"pooledtx"` TestNet bool `json:"testnet"` }
GetMiningInfoResult models the data from the getmininginfo command.
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 GetNetworkInfoResult ¶
type GetNetworkInfoResult struct { Version int32 `json:"version"` SubVersion string `json:"subversion"` ProtocolVersion int32 `json:"protocolversion"` LocalServices string `json:"localservices"` LocalRelay bool `json:"localrelay"` TimeOffset int64 `json:"timeoffset"` Connections int32 `json:"connections"` NetworkActive bool `json:"networkactive"` Networks []NetworksResult `json:"networks"` RelayFee float64 `json:"relayfee"` IncrementalFee float64 `json:"incrementalfee"` LocalAddresses []LocalAddressesResult `json:"localaddresses"` Warnings string `json:"warnings"` }
GetNetworkInfoResult models the data returned from the getnetworkinfo command.
type GetNewAddressCmd ¶
type GetNewAddressCmd struct {
Account *string
}
GetNewAddressCmd defines the getnewaddress JSON-RPC command.
func NewGetNewAddressCmd ¶
func NewGetNewAddressCmd(account *string) *GetNewAddressCmd
NewGetNewAddressCmd returns a new instance which can be used to issue a getnewaddress JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetNodeAddressesCmd ¶
type GetNodeAddressesCmd struct {
Count *int32 `jsonrpcdefault:"1"`
}
GetNodeAddressesCmd defines the getnodeaddresses JSON-RPC command.
func NewGetNodeAddressesCmd ¶
func NewGetNodeAddressesCmd(count *int32) *GetNodeAddressesCmd
NewGetNodeAddressesCmd returns a new instance which can be used to issue a getnodeaddresses JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type GetNodeAddressesResult ¶
type GetNodeAddressesResult struct { // Timestamp in seconds since epoch (Jan 1 1970 GMT) keeping track of when the node was last seen Time int64 `json:"time"` Services uint64 `json:"services"` // The services offered Address string `json:"address"` // The address of the node Port uint16 `json:"port"` // The port of the node }
GetNodeAddressesResult models the data returned from the getnodeaddresses 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 GetRawChangeAddressCmd ¶
type GetRawChangeAddressCmd struct {
Account *string
}
GetRawChangeAddressCmd defines the getrawchangeaddress JSON-RPC command.
func NewGetRawChangeAddressCmd ¶
func NewGetRawChangeAddressCmd(account *string) *GetRawChangeAddressCmd
NewGetRawChangeAddressCmd returns a new instance which can be used to issue a getrawchangeaddress JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
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"` Weight int32 `json:"weight"` 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 *int) *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 GetReceivedByAccountCmd ¶
GetReceivedByAccountCmd defines the getreceivedbyaccount JSON-RPC command.
func NewGetReceivedByAccountCmd ¶
func NewGetReceivedByAccountCmd(account string, minConf *int) *GetReceivedByAccountCmd
NewGetReceivedByAccountCmd returns a new instance which can be used to issue a getreceivedbyaccount 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 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"` Value float64 `json:"value"` ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"` 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 GetTxOutSetInfoResult ¶
type GetTxOutSetInfoResult struct { Height int64 `json:"height"` BestBlock chainhash.Hash `json:"bestblock"` Transactions int64 `json:"transactions"` TxOuts int64 `json:"txouts"` BogoSize int64 `json:"bogosize"` HashSerialized chainhash.Hash `json:"hash_serialized_2"` DiskSize int64 `json:"disk_size"` TotalAmount btcutil.Amount `json:"total_amount"` }
GetTxOutSetInfoResult models the data from the gettxoutsetinfo command.
func (*GetTxOutSetInfoResult) UnmarshalJSON ¶
func (g *GetTxOutSetInfoResult) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the result of the gettxoutsetinfo JSON-RPC call
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 GetWalletInfoCmd ¶
type GetWalletInfoCmd struct{}
GetWalletInfoCmd defines the getwalletinfo JSON-RPC command.
func NewGetWalletInfoCmd ¶
func NewGetWalletInfoCmd() *GetWalletInfoCmd
NewGetWalletInfoCmd returns a new instance which can be used to issue a getwalletinfo JSON-RPC command.
type GetWalletInfoResult ¶
type GetWalletInfoResult struct { WalletName string `json:"walletname"` WalletVersion int `json:"walletversion"` TransactionCount int `json:"txcount"` KeyPoolOldest int `json:"keypoololdest"` KeyPoolSize int `json:"keypoolsize"` KeyPoolSizeHDInternal *int `json:"keypoolsize_hd_internal,omitempty"` UnlockedUntil *int `json:"unlocked_until,omitempty"` PayTransactionFee float64 `json:"paytxfee"` HDSeedID *string `json:"hdseedid,omitempty"` PrivateKeysEnabled bool `json:"private_keys_enabled"` AvoidReuse bool `json:"avoid_reuse"` Scanning ScanningOrFalse `json:"scanning"` }
GetWalletInfoResult models the result of the getwalletinfo command.
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 GetWorkResult ¶
type GetWorkResult struct { Data string `json:"data"` Hash1 string `json:"hash1"` Midstate string `json:"midstate"` Target string `json:"target"` }
GetWorkResult models the data from the getwork command.
type HashOrHeight ¶
type HashOrHeight struct {
Value interface{}
}
HashOrHeight defines a type that can be used as hash_or_height value in JSON-RPC commands.
func (HashOrHeight) MarshalJSON ¶
func (h HashOrHeight) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface
func (*HashOrHeight) UnmarshalJSON ¶
func (h *HashOrHeight) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
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 ImportAddressCmd ¶
ImportAddressCmd defines the importaddress JSON-RPC command.
func NewImportAddressCmd ¶
func NewImportAddressCmd(address string, account string, rescan *bool) *ImportAddressCmd
NewImportAddressCmd returns a new instance which can be used to issue an importaddress JSON-RPC command.
type ImportMultiCmd ¶
type ImportMultiCmd struct { Requests []ImportMultiRequest Options *ImportMultiOptions }
ImportMultiCmd defines the importmulti JSON-RPC command.
func NewImportMultiCmd ¶
func NewImportMultiCmd(requests []ImportMultiRequest, options *ImportMultiOptions) *ImportMultiCmd
NewImportMultiCmd returns a new instance which can be used to issue an importmulti JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ImportMultiOptions ¶
type ImportMultiOptions struct {
Rescan bool `json:"rescan"` // Rescan the blockchain after all imports
}
ImportMultiRequest defines the options struct, provided to the ImportMultiCmd as a pointer argument.
type ImportMultiRequest ¶
type ImportMultiRequest struct { // Descriptor to import, in canonical form. If using Descriptor, do not // also provide ScriptPubKey, RedeemScript, WitnessScript, PubKeys, or Keys. Descriptor *string `json:"desc,omitempty"` // Script/address to import. Should not be provided if using Descriptor. ScriptPubKey *ScriptPubKey `json:"scriptPubKey,omitempty"` // Creation time of the key in seconds since epoch (Jan 1 1970 GMT), or // the string "now" to substitute the current synced blockchain time. // // The timestamp of the oldest key will determine how far back blockchain // rescans need to begin for missing wallet transactions. // // Specifying "now" bypasses scanning. Useful for keys that are known to // never have been used. // // Specifying 0 scans the entire blockchain. Timestamp TimestampOrNow `json:"timestamp"` // Allowed only if the ScriptPubKey is a P2SH or P2SH-P2WSH // address/scriptPubKey. RedeemScript *string `json:"redeemscript,omitempty"` // Allowed only if the ScriptPubKey is a P2SH-P2WSH or P2WSH // address/scriptPubKey. WitnessScript *string `json:"witnessscript,omitempty"` // Array of strings giving pubkeys to import. They must occur in P2PKH or // P2WPKH scripts. They are not required when the private key is also // provided (see Keys). PubKeys *[]string `json:"pubkeys,omitempty"` // Array of strings giving private keys to import. The corresponding // public keys must occur in the output or RedeemScript. Keys *[]string `json:"keys,omitempty"` // If the provided Descriptor is ranged, this specifies the end // (as an int) or the range (as []int{begin, end}) to import. Range *DescriptorRange `json:"range,omitempty"` // States whether matching outputs should be treated as not incoming // payments (also known as change). Internal *bool `json:"internal,omitempty"` // States whether matching outputs should be considered watchonly. // // If an address/script is imported without all of the private keys // required to spend from that address, set this field to true. // // If all the private keys are provided and the address/script is // spendable, set this field to false. WatchOnly *bool `json:"watchonly,omitempty"` // Label to assign to the address. Only allowed when Internal is false. Label *string `json:"label,omitempty"` // States whether imported public keys should be added to the keypool for // when users request new addresses. Only allowed when wallet private keys // are disabled. KeyPool *bool `json:"keypool,omitempty"` }
ImportMultiRequest defines the request struct to be passed to the ImportMultiCmd, as an array.
type ImportMultiResults ¶
type ImportMultiResults []struct { Success bool `json:"success"` Error *RPCError `json:"error,omitempty"` Warnings *[]string `json:"warnings,omitempty"` }
ImportMultiResults is a slice that models the result of the importmulti command.
Each item in the slice contains the execution result corresponding to the input requests of type btcjson.ImportMultiRequest, passed to the ImportMulti[Async] function.
type ImportPrivKeyCmd ¶
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 ImportPubKeyCmd ¶
ImportPubKeyCmd defines the importpubkey JSON-RPC command.
func NewImportPubKeyCmd ¶
func NewImportPubKeyCmd(pubKey string, rescan *bool) *ImportPubKeyCmd
NewImportPubKeyCmd returns a new instance which can be used to issue an importpubkey JSON-RPC command.
type ImportWalletCmd ¶
type ImportWalletCmd struct {
Filename string
}
ImportWalletCmd defines the importwallet JSON-RPC command.
func NewImportWalletCmd ¶
func NewImportWalletCmd(filename string) *ImportWalletCmd
NewImportWalletCmd returns a new instance which can be used to issue a importwallet JSON-RPC command.
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"` Proxy string `json:"proxy"` 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"` Proxy string `json:"proxy"` 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 KeyPoolRefillCmd ¶
type KeyPoolRefillCmd struct {
NewSize *uint `jsonrpcdefault:"100"`
}
KeyPoolRefillCmd defines the keypoolrefill JSON-RPC command.
func NewKeyPoolRefillCmd ¶
func NewKeyPoolRefillCmd(newSize *uint) *KeyPoolRefillCmd
NewKeyPoolRefillCmd returns a new instance which can be used to issue a keypoolrefill JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type LLMQType ¶
type LLMQType int
LLMQType is the type of quorum
const ( LLMQType_50_60 LLMQType = 1 // 50 members, 30 (60%) threshold, one per hour LLMQType_400_60 LLMQType = 2 // 400 members, 240 (60%) threshold, one every 12 hours LLMQType_400_85 LLMQType = 3 // 400 members, 340 (85%) threshold, one every 24 hours LLMQType_100_67 LLMQType = 4 // 100 members, 67 (67%) threshold, one per hour LLMQType_60_75 LLMQType = 5 // 60 members, 45 (75%) threshold, one every 12 hours LLMQType_25_67 LLMQType = 6 // 25 members, 17 (67%) threshold, one per hour LLMQType_TEST LLMQType = 100 // 3 members, 2 (66%) threshold, one per hour LLMQType_DEVNET LLMQType = 101 // 12 members, 6 (50%) threshold, one per hour LLMQType_TEST_V17 LLMQType = 102 // 3 members, 2 (66%) threshold, one per hour LLMQType_TEST_DIP0024 LLMQType = 103 // 4 members, 2 (66%) threshold, one per hour LLMQType_TEST_INSTANTSEND LLMQType = 104 // 3 members, 2 (66%) threshold, one per hour LLMQType_DEVNET_DIP0024 LLMQType = 105 // 8 members, 4 (50%) threshold, one per hour LLMQType_TEST_PLATFORM LLMQType = 106 // 3 members, 2 (66%) threshold, one per hour LLMQType_DEVNET_PLATFORM LLMQType = 107 // 12 members, 8 (67%) threshold, one per hour // LLMQType_5_60 is replaced with LLMQType_TEST to adhere to DIP-0006 naming LLMQType_5_60 LLMQType = LLMQType_TEST )
Enum of LLMQTypes See https://github.com/dashpay/dips/blob/master/dip-0006.md#current-llmq-types and https://github.com/dashpay/dash/blob/master/src/llmq/params.h
func GetLLMQType ¶
GetLLMQType returns LLMQ type for the given name. Returns 0 when the name is not supported.
func (LLMQType) Name ¶
Name returns name of the LLMQType. Returns empty string when the type is invalid. See https://github.com/dashpay/dash/blob/master/src/llmq/params.h
func (LLMQType) Validate ¶
Validate checks if provided LLMQ type is valid, eg. if it's one of LLMQ types defined in accordance with DIP-0006. See https://github.com/dashpay/dips/blob/master/dip-0006/llmq-types.md
type ListAccountsCmd ¶
type ListAccountsCmd struct {
MinConf *int `jsonrpcdefault:"1"`
}
ListAccountsCmd defines the listaccounts JSON-RPC command.
func NewListAccountsCmd ¶
func NewListAccountsCmd(minConf *int) *ListAccountsCmd
NewListAccountsCmd returns a new instance which can be used to issue a listaccounts JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ListAddressGroupingsCmd ¶
type ListAddressGroupingsCmd struct{}
ListAddressGroupingsCmd defines the listaddressgroupings JSON-RPC command.
func NewListAddressGroupingsCmd ¶
func NewListAddressGroupingsCmd() *ListAddressGroupingsCmd
NewListAddressGroupingsCmd returns a new instance which can be used to issue a listaddressgroupoings 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 ListReceivedByAccountCmd ¶
type ListReceivedByAccountCmd struct { MinConf *int `jsonrpcdefault:"1"` IncludeEmpty *bool `jsonrpcdefault:"false"` IncludeWatchOnly *bool `jsonrpcdefault:"false"` }
ListReceivedByAccountCmd defines the listreceivedbyaccount JSON-RPC command.
func NewListReceivedByAccountCmd ¶
func NewListReceivedByAccountCmd(minConf *int, includeEmpty, includeWatchOnly *bool) *ListReceivedByAccountCmd
NewListReceivedByAccountCmd returns a new instance which can be used to issue a listreceivedbyaccount JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type ListReceivedByAccountResult ¶
type ListReceivedByAccountResult struct { Account string `json:"account"` Amount float64 `json:"amount"` Confirmations uint64 `json:"confirmations"` }
ListReceivedByAccountResult models the data from the listreceivedbyaccount 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 ¶
type ListTransactionsCmd struct { Account *string Count *int `jsonrpcdefault:"10"` From *int `jsonrpcdefault:"0"` IncludeWatchOnly *bool `jsonrpcdefault:"false"` }
ListTransactionsCmd defines the listtransactions JSON-RPC command.
func NewListTransactionsCmd ¶
func NewListTransactionsCmd(account *string, count, from *int, includeWatchOnly *bool) *ListTransactionsCmd
NewListTransactionsCmd returns a new instance which can be used to issue a listtransactions JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
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"` BlockHeight *int32 `json:"blockheight,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"` Label *string `json:"label,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"` Account string `json:"account"` ScriptPubKey string `json:"scriptPubKey"` RedeemScript string `json:"redeemScript,omitempty"` Amount float64 `json:"amount"` Confirmations int64 `json:"confirmations"` 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 btcd 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 btcd extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
type LoadWalletCmd ¶
type LoadWalletCmd struct {
WalletName string
}
LoadWalletCmd defines the loadwallet JSON-RPC command
func NewLoadWalletCmd ¶
func NewLoadWalletCmd(walletName string) *LoadWalletCmd
NewLoadWalletCmd returns a new instance which can be used to issue a loadwallet JSON-RPC command
type LoadWalletResult ¶
LoadWalletResult models the data from the loadwallet command
type LocalAddressesResult ¶
type LocalAddressesResult struct { Address string `json:"address"` Port uint16 `json:"port"` Score int32 `json:"score"` }
LocalAddressesResult models the localaddresses data from the getnetworkinfo command.
type LockUnspentCmd ¶
type LockUnspentCmd struct { Unlock bool Transactions []TransactionInput }
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 MNStatusState ¶ added in v0.24.1
type MNStatusState string
MNStatusState masternode status state
const ( MNStatusStateWaitingForProtx MNStatusState = "WAITING_FOR_PROTX" MNStatusStatePoseBanned MNStatusState = "POSE_BANNED" MNStatusStateRemoved MNStatusState = "REMOVED" MNStatusStateOperatorKeyChanged MNStatusState = "OPERATOR_KEY_CHANGED" MNStatusStateProtxIpChanged MNStatusState = "PROTX_IP_CHANGED" MNStatusStateReady MNStatusState = "READY" MNStatusStateError MNStatusState = "ERROR" MNStatusStateUnknown MNStatusState = "UNKNOWN" )
The list of all possible masternode status states
type MasternodeCmd ¶
type MasternodeCmd struct { SubCmd MasternodeSubCmd `jsonrpcusage:"\"count|current|outputs|status|winner|winners\""` Count *string `json:",omitempty"` Filter *string `json:",omitempty"` }
MasternodeCmd defines the quorum JSON-RPC command.
func NewMasternodeCmd ¶
func NewMasternodeCmd(sub MasternodeSubCmd) *MasternodeCmd
NewMasternodeCmd returns a new instance which can be used to issue a quorum JSON-RPC command.
func NewMasternodeWinnersCmd ¶
func NewMasternodeWinnersCmd(count int, filter string) *MasternodeCmd
NewMasternodeWinnersCmd returns a new instance which can be used to issue a quorum JSON-RPC command.
type MasternodeCountResult ¶
MasternodeCountResult models the data from the masternode count command. https://dashcore.readme.io/docs/core-api-ref-remote-procedure-calls-dash#masternode-count
type MasternodeResult ¶
type MasternodeStatusResult ¶
type MasternodeStatusResult struct { Outpoint string `json:"outpoint"` Service string `json:"service"` ProTxHash string `json:"proTxHash"` CollateralHash string `json:"collateralHash"` CollateralIndex int `json:"collateralIndex"` DMNState DMNState `json:"dmnState"` State MNStatusState `json:"state"` Status string `json:"status"` }
MasternodeStatusResult models the data from the quorum sign command. returns a hex-encoded string.
type MasternodeSubCmd ¶
type MasternodeSubCmd string
MasternodeSubCmd defines the sub command used in the quorum JSON-RPC command.
const ( MasternodeCount MasternodeSubCmd = "count" MasternodeCurrent MasternodeSubCmd = "current" MasternodeOutputs MasternodeSubCmd = "outputs" MasternodeStatus MasternodeSubCmd = "status" // MasternodeList MasternodeSubCmd = "list" // same as masternodelist MasternodeWinner MasternodeSubCmd = "winner" MasternodeWinners MasternodeSubCmd = "winners" )
Masternode subcommands
type MasternodelistCmd ¶
MasternodelistCmd defines the quorum JSON-RPC command.
func NewMasternodeListCmd ¶
func NewMasternodeListCmd(mode, filter string) *MasternodelistCmd
NewMasternodeListCmd returns a new instance which can be used to issue a quorum JSON-RPC command.
type MasternodelistResultJSON ¶
type MasternodelistResultJSON struct { Address string `json:"address"` Collateraladdress string `json:"collateraladdress"` Lastpaidblock int `json:"lastpaidblock"` Lastpaidtime int `json:"lastpaidtime"` Owneraddress string `json:"owneraddress"` Payee string `json:"payee"` ProTxHash string `json:"proTxHash"` Pubkeyoperator string `json:"pubkeyoperator"` Status string `json:"status"` Votingaddress string `json:"votingaddress"` }
type MempoolFees ¶
type MinableCommitment ¶
type MinableCommitment struct { Version int `json:"version"` LLMQType int `json:"llmqType"` QuorumHash string `json:"quorumHash"` SignersCount int `json:"signersCount"` ValidMembersCount int `json:"validMembersCount"` QuorumPublicKey string `json:"quorumPublicKey"` }
MinableCommitment are the minableCommitments from dkgstatus
type MoveCmd ¶
type MoveCmd struct { FromAccount string ToAccount string Amount float64 // In BTC MinConf *int `jsonrpcdefault:"1"` Comment *string }
MoveCmd defines the move JSON-RPC command.
func NewMoveCmd ¶
func NewMoveCmd(fromAccount, toAccount string, amount float64, minConf *int, comment *string) *MoveCmd
NewMoveCmd returns a new instance which can be used to issue a move JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type NetworksResult ¶
type NetworksResult struct { Name string `json:"name"` Limited bool `json:"limited"` Reachable bool `json:"reachable"` Proxy string `json:"proxy"` ProxyRandomizeCredentials bool `json:"proxy_randomize_credentials"` }
NetworksResult models the networks data from the getnetworkinfo command.
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
deprecated
type NotifyReceivedCmd struct {
Addresses []string
}
NotifyReceivedCmd defines the notifyreceived JSON-RPC command.
Deprecated: Use LoadTxFilterCmd instead.
func NewNotifyReceivedCmd
deprecated
func NewNotifyReceivedCmd(addresses []string) *NotifyReceivedCmd
NewNotifyReceivedCmd returns a new instance which can be used to issue a notifyreceived JSON-RPC command.
Deprecated: Use NewLoadTxFilterCmd instead.
type NotifySpentCmd
deprecated
type NotifySpentCmd struct {
OutPoints []OutPoint
}
NotifySpentCmd defines the notifyspent JSON-RPC command.
Deprecated: Use LoadTxFilterCmd instead.
func NewNotifySpentCmd
deprecated
func NewNotifySpentCmd(outPoints []OutPoint) *NotifySpentCmd
NewNotifySpentCmd returns a new instance which can be used to issue a notifyspent JSON-RPC command.
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 { Addresses []string `json:"addresses,omitempty"` Value float64 `json:"value"` }
PrevOut represents previous output for an input Vin.
type ProTxCmd ¶
type ProTxCmd struct { SubCmd ProTxSubCmd `` /* 128-byte string literal not displayed */ ProTxHash *string `json:",omitempty"` Type *ProTxListType `json:",omitempty"` Detailed *bool `json:",omitempty"` Height *int `json:",omitempty"` BaseBlock *int `json:",omitempty"` Block *int `json:",omitempty"` CollateralHash *string `json:",omitempty"` CollateralIndex *int `json:",omitempty"` CollateralAddress *string `json:",omitempty"` IPAndPort *string `json:",omitempty"` OwnerAddress *string `json:",omitempty"` OperatorPubKey *string `json:",omitempty"` OperatorPrivateKey *string `json:",omitempty"` OperatorPayoutAddress *string `json:",omitempty"` VotingAddress *string `json:",omitempty"` OperatorReward *float64 `json:",omitempty"` PayoutAddress *string `json:",omitempty"` FundAddress *string `json:",omitempty"` Reason *int `json:",omitempty"` FeeSourceAddress *string `json:",omitempty"` Submit *bool `json:",omitempty"` Tx *string `json:",omitempty"` Sig *string `json:",omitempty"` }
func NewProTxDiffCmd ¶
NewProTxDiffCmd returns a new instance which can be used to issue a protx diff JSON-RPC command.
func NewProTxInfoCmd ¶
NewProTxInfoCmd returns a new instance which can be used to issue a protx info JSON-RPC command.
func NewProTxListCmd ¶
func NewProTxListCmd(cmdType ProTxListType, detailed bool, height int) *ProTxCmd
NewProTxListCmd returns a new instance which can be used to issue a protx list JSON-RPC command.
func NewProTxRegisterCmd ¶
func NewProTxRegisterCmd(collateralHash string, collateralIndex int, ipAndPort, ownerAddress, operatorPubKey, votingAddress string, operatorReward float64, payoutAddress, feeSourceAddress string, submit bool) *ProTxCmd
NewProTxRegisterCmd returns a new instance which can be used to issue a protx register JSON-RPC command.
func NewProTxRegisterFundCmd ¶
func NewProTxRegisterFundCmd(collateralAddress, ipAndPort, ownerAddress, operatorPubKey, votingAddress string, operatorReward float64, payoutAddress, fundAddress string, submit bool) *ProTxCmd
NewProTxRegisterFundCmd returns a new instance which can be used to issue a protx register_fund JSON-RPC command.
func NewProTxRegisterPrepareCmd ¶
func NewProTxRegisterPrepareCmd(collateralHash string, collateralIndex int, ipAndPort, ownerAddress, operatorPubKey, votingAddress string, operatorReward float64, payoutAddress, feeSourceAddress string) *ProTxCmd
NewProTxRegisterPrepareCmd returns a new instance which can be used to issue a protx register_prepare JSON-RPC command.
func NewProTxRegisterSubmitCmd ¶
NewProTxRegisterSubmitCmd returns a new instance which can be used to issue a protx register_submit JSON-RPC command.
func NewProTxRevokeCmd ¶
func NewProTxRevokeCmd(proTxHash, operatorPrivateKey string, reason int, feeSourceAddress string) *ProTxCmd
NewProTxRevokeCmd returns a new instance which can be used to issue a protx revoke JSON-RPC command.
func NewProTxUpdateRegistrarCmd ¶
func NewProTxUpdateRegistrarCmd(proTxHash, operatorPubKey, votingAddress, payoutAddress, feeSourceAddress string) *ProTxCmd
NewProTxUpdateRegistrarCmd returns a new instance which can be used to issue a protx update_registrar JSON-RPC command.
func NewProTxUpdateServiceCmd ¶
func NewProTxUpdateServiceCmd(proTxHash, ipAndPort, operatorPubKey, operatorPayoutAddress, feeSourceAddress string) *ProTxCmd
NewProTxUpdateServiceCmd returns a new instance which can be used to issue a protx update_service JSON-RPC command.
type ProTxDiffDeletedQuorum ¶
type ProTxDiffMN ¶
type ProTxDiffNewQuorum ¶
type ProTxDiffNewQuorum struct { Version int `json:"version"` LlmqType int `json:"llmqType"` QuorumHash string `json:"quorumHash"` SignersCount int `json:"signersCount"` Signers string `json:"signers"` ValidMembersCount int `json:"validMembersCount"` ValidMembers string `json:"validMembers"` QuorumPublicKey string `json:"quorumPublicKey"` QuorumVvecHash string `json:"quorumVvecHash"` QuorumSig string `json:"quorumSig"` MembersSig string `json:"membersSig"` }
type ProTxDiffResult ¶
type ProTxDiffResult struct { BaseBlockHash string `json:"baseBlockHash"` BlockHash string `json:"blockHash"` CbTxMerkleTree string `json:"cbTxMerkleTree"` CbTx string `json:"cbTx"` DeletedMNs []string `json:"deletedMNs"` MnList []ProTxDiffMN `json:"mnList"` DeletedQuorums []ProTxDiffDeletedQuorum `json:"deletedQuorums"` NewQuorums []ProTxDiffNewQuorum `json:"newQuorums"` MerkleRootMNList string `json:"merkleRootMNList"` }
type ProTxInfoResult ¶
type ProTxInfoResult struct { ProTxHash string `json:"proTxHash"` CollateralHash string `json:"collateralHash"` CollateralIndex int `json:"collateralIndex"` CollateralAddress string `json:"collateralAddress"` OperatorReward float64 `json:"operatorReward"` State ProTxState `json:"state"` Confirmations int `json:"confirmations"` Wallet ProTxWallet `json:"wallet"` MetaInfo ProTxMetaInfo `json:"metaInfo"` }
ProTxInfoResult models the data from the protx info command.
type ProTxListType ¶
type ProTxListType string
const ( ProTxListTypeRegistered ProTxListType = "registered" ProTxListTypeValid ProTxListType = "valid" ProTxListTypeWallet ProTxListType = "wallet" )
type ProTxMetaInfo ¶
type ProTxMetaInfo struct { LastDSQ int `json:"lastDSQ"` MixingTxCount int `json:"mixingTxCount"` LastOutboundAttempt int `json:"lastOutboundAttempt"` LastOutboundAttemptElapsed int `json:"lastOutboundAttemptElapsed"` LastOutboundSuccess int `json:"lastOutboundSuccess"` LastOutboundSuccessElapsed int `json:"lastOutboundSuccessElapsed"` }
type ProTxState ¶
type ProTxState struct { Service string `json:"service"` RegisteredHeight int `json:"registeredHeight"` LastPaidHeight int `json:"lastPaidHeight"` PoSePenalty int `json:"PoSePenalty"` PoSeRevivedHeight int `json:"PoSeRevivedHeight"` PoSeBanHeight int `json:"PoSeBanHeight"` RevocationReason int `json:"revocationReason"` OwnerAddress string `json:"ownerAddress"` VotingAddress string `json:"votingAddress"` PayoutAddress string `json:"payoutAddress"` PubKeyOperator string `json:"pubKeyOperator"` OperatorPayoutAddress string `json:"operatorPayoutAddress"` }
type ProTxSubCmd ¶
type ProTxSubCmd string
const ( ProTxRegister ProTxSubCmd = "register" ProTxRegisterFund ProTxSubCmd = "register_fund" ProTxRegisterPrepare ProTxSubCmd = "register_prepare" ProTxRegisterSubmit ProTxSubCmd = "register_submit" ProTxList ProTxSubCmd = "list" ProTxInfo ProTxSubCmd = "info" ProTxUpdateService ProTxSubCmd = "update_service" ProTxUpdateRegistrar ProTxSubCmd = "update_registrar" ProTxRevoke ProTxSubCmd = "revoke" ProTxDiff ProTxSubCmd = "diff" )
type ProTxWallet ¶
type ProTxWallet struct { HasOwnerKey bool `json:"hasOwnerKey"` HasOperatorKey bool `json:"hasOperatorKey"` HasVotingKey bool `json:"hasVotingKey"` OwnsCollateral bool `json:"ownsCollateral"` OwnsPayeeScript bool `json:"ownsPayeeScript"` OwnsOperatorRewardScript bool `json:"ownsOperatorRewardScript"` }
type PsbtInput ¶
type PsbtInput struct { Txid string `json:"txid"` Vout uint32 `json:"vout"` Sequence uint32 `json:"sequence"` }
PsbtInput represents an input to include in the PSBT created by the WalletCreateFundedPsbtCmd command.
type PsbtOutput ¶
type PsbtOutput map[string]interface{}
PsbtOutput represents an output to include in the PSBT created by the WalletCreateFundedPsbtCmd command.
func NewPsbtDataOutput ¶
func NewPsbtDataOutput(data []byte) PsbtOutput
NewPsbtDataOutput returns a new instance of a PSBT data output to use with the WalletCreateFundedPsbtCmd command.
func NewPsbtOutput ¶
func NewPsbtOutput(address string, amount btcutil.Amount) PsbtOutput
NewPsbtOutput returns a new instance of a PSBT output to use with the WalletCreateFundedPsbtCmd command.
type QuorumCmd ¶
type QuorumCmd struct { SubCmd QuorumCmdSubCmd `jsonrpcusage:"\"list|info|dkgstatus|sign|platformsign|getrecsig|hasrecsig|isconflicting|memberof|selectquorum\""` LLMQType *LLMQType `json:",omitempty"` RequestID *string `json:",omitempty"` MessageHash *string `json:",omitempty"` QuorumHash *string `json:",omitempty"` Signature *string `json:",omitempty"` Submit *bool `json:",omitempty"` DKGStatusDetailLevel *DetailLevel `json:",omitempty"` ProTxHash *string `json:",omitempty"` ScanQuorumsCount *int `json:",omitempty"` }
QuorumCmd defines the quorum JSON-RPC command.
func NewQuorumDKGStatusCmd ¶
func NewQuorumDKGStatusCmd(detailLevel DetailLevel) *QuorumCmd
NewQuorumDKGStatusCmd returns the result from quorum dkgstatus
func NewQuorumGetRecSig ¶
NewQuorumGetRecSig returns the result from quorum getrecsig
func NewQuorumHasRecSig ¶
NewQuorumHasRecSig returns the result from quorum hasrecsig
func NewQuorumInfoCmd ¶
NewQuorumInfoCmd returns a new instance which can be used to issue a quorum JSON-RPC command.
func NewQuorumIsConflicting ¶
NewQuorumIsConflicting returns the result from quorum isconflicting
func NewQuorumListCmd ¶
func NewQuorumListCmd() *QuorumCmd
NewQuorumListCmd returns a list of quorums JSON-RPC command.
func NewQuorumMemberOfCmd ¶
NewQuorumMemberOfCmd returns the result from quorum memberof
func NewQuorumPlatformSignCmd ¶ added in v0.25.0
NewQuorumPlatformSignCmd returns a new instance which can be used to issue a quorum JSON-RPC command.
func NewQuorumSelectQuorumCmd ¶
NewQuorumSelectQuorumCmd returns the selected quorum
func NewQuorumSignCmd ¶
func NewQuorumSignCmd(quorumType LLMQType, requestID, messageHash, quorumHash string, submit bool) *QuorumCmd
NewQuorumSignCmd returns a new instance which can be used to issue a quorum JSON-RPC command.
func NewQuorumVerifyCmd ¶
func NewQuorumVerifyCmd(quorumType LLMQType, requestID string, messageHash string, signature string, quorumHash string) *QuorumCmd
NewQuorumVerifyCmd returns a new instance which can be used to issue a quorum JSON-RPC command.
func (*QuorumCmd) UnmarshalArgs ¶
UnmarshalArgs maps a list of arguments to quorum struct
type QuorumCmdSubCmd ¶
type QuorumCmdSubCmd string
QuorumCmdSubCmd defines the sub command used in the quorum JSON-RPC command.
const ( QuorumSign QuorumCmdSubCmd = "sign" QuorumSignPlatform QuorumCmdSubCmd = "platformsign" QuorumVerify QuorumCmdSubCmd = "verify" QuorumInfo QuorumCmdSubCmd = "info" // QuorumList lists all quorums QuorumList QuorumCmdSubCmd = "list" QuorumSelectQuorum QuorumCmdSubCmd = "selectquorum" QuorumDKGStatus QuorumCmdSubCmd = "dkgstatus" QuorumMemberOf QuorumCmdSubCmd = "memberof" QuorumGetRecSig QuorumCmdSubCmd = "getrecsig" QuorumHasRecSig QuorumCmdSubCmd = "hasrecsig" QuorumIsConflicting QuorumCmdSubCmd = "isconflicting" )
Quorum commands https://dashcore.readme.io/docs/core-api-ref-remote-procedure-calls-evo#quorum
type QuorumConnection ¶
type QuorumConnection struct { ProTxHash string `json:"proTxHash"` Connected bool `json:"connected"` Address string `json:"address,omitempty"` Outbound bool `json:"outbound"` }
QuorumConnection are the quorumConnections from dkgstatus
type QuorumDKGStatusCountsResult ¶
type QuorumDKGStatusCountsResult struct { Session struct { Llmq50_60 DKGSessionCounts `json:"llmq_50_60"` Llmq400_60 DKGSessionCounts `json:"llmq_400_60"` Llmq400_85 DKGSessionCounts `json:"llmq_400_85"` Llmq100_67 DKGSessionCounts `json:"llmq_100_67"` } `json:"session"` }
QuorumDKGStatusCountsResult models the data from quorum dkgstatus command.
type QuorumDKGStatusIndexesResult ¶
type QuorumDKGStatusIndexesResult struct { Session struct { Llmq50_60 DKGSessionIndexes `json:"llmq_50_60"` Llmq400_60 DKGSessionIndexes `json:"llmq_400_60"` Llmq400_85 DKGSessionIndexes `json:"llmq_400_85"` Llmq100_67 DKGSessionIndexes `json:"llmq_100_67"` } `json:"session"` }
QuorumDKGStatusIndexesResult models the data from quorum dkgstatus command.
type QuorumDKGStatusMembersProTxHashesResult ¶
type QuorumDKGStatusMembersProTxHashesResult struct { Session struct { Llmq50_60 DKGSessionMembersProTxHashes `json:"llmq_50_60"` Llmq400_60 DKGSessionMembersProTxHashes `json:"llmq_400_60"` Llmq400_85 DKGSessionMembersProTxHashes `json:"llmq_400_85"` Llmq100_67 DKGSessionMembersProTxHashes `json:"llmq_100_67"` } `json:"session"` }
QuorumDKGStatusMembersProTxHashesResult models the data from quorum dkgstatus command.
type QuorumDKGStatusResultShared ¶
type QuorumDKGStatusResultShared struct { MinableCommitment `json:"llmq_50_60"` Llmq400_60 MinableCommitment `json:"llmq_400_60"` Llmq400_85 MinableCommitment `json:"llmq_400_85"` Llmq100_67 MinableCommitment `json:"llmq_100_67"` } `json:"minableCommitments"` Llmq50_60 []QuorumConnection `json:"llmq_50_60"` Llmq400_60 []QuorumConnection `json:"llmq_400_60"` Llmq400_85 []QuorumConnection `json:"llmq_400_85"` Llmq100_67 []QuorumConnection `json:"llmq_100_67"` } `json:"quorumConnections"` }Llmq50_60
QuorumDKGStatusResultShared models shared data between different levels of dkgstatus
type QuorumInfoResult ¶
type QuorumInfoResult struct { Height uint32 `json:"height"` Type string `json:"type"` QuorumHash string `json:"quorumHash"` MinedBlock string `json:"minedBlock"` Members []QuorumMember `json:"members"` QuorumPublicKey string `json:"quorumPublicKey"` }
QuorumInfoResult models the data from the quorum info command. returns a hex-encoded string.
type QuorumListResult ¶
type QuorumListResult struct { Llmq50_60 []string `json:"llmq_50_60"` Llmq400_60 []string `json:"llmq_400_60"` Llmq400_85 []string `json:"llmq_400_85"` Llmq100_67 []string `json:"llmq_100_67"` }
QuorumListResult models the data from the quorum list command.
type QuorumMember ¶
type QuorumMemberOfResult ¶
type QuorumMemberOfResult struct { Height int `json:"height"` Type string `json:"type"` QuorumHash string `json:"quorumHash"` MinedBlock string `json:"minedBlock"` QuorumPublicKey string `json:"quorumPublicKey"` IsValidMember bool `json:"isValidMember"` MemberIndex int `json:"memberIndex"` }
QuorumMemberOfResult data return by quorum memberof
type QuorumSelectQuorumResult ¶
type QuorumSelectQuorumResult struct { QuorumHash string `json:"quorumHash"` RecoveryMembers []string `json:"recoveryMembers"` }
QuorumSelectQuorumResult models the data from the quorum selectquorum command.
type QuorumSignResult ¶
type QuorumSignResult struct { LLMQType int `json:"llmqType,omitempty"` QuorumHash string `json:"quorumHash,omitempty"` QuorumMember int `json:"quorumMember,omitempty"` ID string `json:"id,omitempty"` MsgHash string `json:"msgHash,omitempty"` SignHash string `json:"signHash,omitempty"` Signature string `json:"signature,omitempty"` }
QuorumSignResult models the data from the quorum sign command. returns a hex-encoded string.
type QuorumSignResultWithBool ¶
type QuorumSignResultWithBool struct { QuorumSignResult // Result is the output if submit was true Result bool `json:"result,omitempty"` }
func (*QuorumSignResultWithBool) UnmarshalJSON ¶
func (qsr *QuorumSignResultWithBool) UnmarshalJSON(data []byte) error
UnmarshalJSON is a custom unmarshal because the result can be just a boolean
type QuorumVerifyResult ¶
type QuorumVerifyResult struct { // Result is the output if submit was true Result bool `json:"result,omitempty"` }
QuorumVerifyResult models the data from the quorum verify command. returns a boolean.
type RPCError ¶
type RPCError struct { Code RPCErrorCode `json:"code,omitempty"` Message string `json:"message,omitempty"` }
RPCError represents an error that is used as a part of a JSON-RPC Response object.
func NewRPCError ¶
func NewRPCError(code RPCErrorCode, message string) *RPCError
NewRPCError constructs and returns a new JSON-RPC error that is suitable for use in a JSON-RPC Response object.
type RPCErrorCode ¶
type RPCErrorCode int
RPCErrorCode represents an error code to be used as a part of an RPCError which is in turn used in a JSON-RPC Response object.
A specific type is used to help ensure the wrong errors aren't used.
const ( // ErrRPCMisc indicates an exception thrown during command handling. ErrRPCMisc RPCErrorCode = -1 // ErrRPCForbiddenBySafeMode indicates that server is in safe mode, and // command is not allowed in safe mode. ErrRPCForbiddenBySafeMode RPCErrorCode = -2 // ErrRPCType indicates that an unexpected type was passed as parameter. ErrRPCType RPCErrorCode = -3 // ErrRPCInvalidAddressOrKey indicates an invalid address or key. ErrRPCInvalidAddressOrKey RPCErrorCode = -5 // ErrRPCOutOfMemory indicates that the server ran out of memory during // operation. ErrRPCOutOfMemory RPCErrorCode = -7 // ErrRPCInvalidParameter indicates an invalid, missing, or duplicate // parameter. ErrRPCInvalidParameter RPCErrorCode = -8 // ErrRPCDatabase indicates a database error. ErrRPCDatabase RPCErrorCode = -20 // ErrRPCDeserialization indicates an error parsing or validating structure // in raw format. ErrRPCDeserialization RPCErrorCode = -22 // ErrRPCVerify indicates a general error during transaction or block // submission. ErrRPCVerify RPCErrorCode = -25 // ErrRPCVerifyRejected indicates that transaction or block was rejected by // network rules. ErrRPCVerifyRejected RPCErrorCode = -26 // ErrRPCVerifyAlreadyInChain indicates that submitted transaction is // already in chain. ErrRPCVerifyAlreadyInChain RPCErrorCode = -27 // ErrRPCInWarmup indicates that client is still warming up. ErrRPCInWarmup RPCErrorCode = -28 // ErrRPCInWarmup indicates that the RPC error is deprecated. ErrRPCMethodDeprecated RPCErrorCode = -32 )
General application defined JSON errors.
const ( // ErrRPCClientNotConnected indicates that Bitcoin is not connected. ErrRPCClientNotConnected RPCErrorCode = -9 // ErrRPCClientInInitialDownload indicates that client is still downloading // initial blocks. ErrRPCClientInInitialDownload RPCErrorCode = -10 // ErrRPCClientNodeAlreadyAdded indicates that node is already added. ErrRPCClientNodeAlreadyAdded RPCErrorCode = -23 // ErrRPCClientNodeNotAdded indicates that node has not been added before. ErrRPCClientNodeNotAdded RPCErrorCode = -24 // ErrRPCClientNodeNotConnected indicates that node to disconnect was not // found in connected nodes. ErrRPCClientNodeNotConnected RPCErrorCode = -29 // ErrRPCClientInvalidIPOrSubnet indicates an invalid IP/Subnet. ErrRPCClientInvalidIPOrSubnet RPCErrorCode = -30 // ErrRPCClientP2PDisabled indicates that no valid connection manager // instance was found. ErrRPCClientP2PDisabled RPCErrorCode = -31 )
Peer-to-peer client errors.
const ( // ErrRPCWallet indicates an unspecified problem with wallet, for // example, key not found, etc. ErrRPCWallet RPCErrorCode = -4 // ErrRPCWalletInsufficientFunds indicates that there are not enough // funds in wallet or account. ErrRPCWalletInsufficientFunds RPCErrorCode = -6 // ErrRPCWalletInvalidAccountName indicates an invalid label name. ErrRPCWalletInvalidAccountName RPCErrorCode = -11 // ErrRPCWalletKeypoolRanOut indicates that the keypool ran out, and that // keypoolrefill must be called first. ErrRPCWalletKeypoolRanOut RPCErrorCode = -12 // ErrRPCWalletUnlockNeeded indicates that the wallet passphrase must be // entered first with the walletpassphrase RPC. ErrRPCWalletUnlockNeeded RPCErrorCode = -13 // ErrRPCWalletPassphraseIncorrect indicates that the wallet passphrase // that was entered was incorrect. ErrRPCWalletPassphraseIncorrect RPCErrorCode = -14 // ErrRPCWalletWrongEncState indicates that a command was given in wrong // wallet encryption state, for example, encrypting an encrypted wallet. ErrRPCWalletWrongEncState RPCErrorCode = -15 // ErrRPCWalletEncryptionFailed indicates a failure to encrypt the wallet. ErrRPCWalletEncryptionFailed RPCErrorCode = -16 // ErrRPCWalletAlreadyUnlocked indicates an attempt to unlock a wallet // that was already unlocked. ErrRPCWalletAlreadyUnlocked RPCErrorCode = -17 // ErrRPCWalletNotFound indicates that an invalid wallet was specified, // which does not exist. It can also indicate an attempt to unload a // wallet that was not previously loaded. // // Not to be confused with ErrRPCNoWallet, which is specific to btcd. ErrRPCWalletNotFound RPCErrorCode = -18 // ErrRPCWalletNotSpecified indicates that no wallet was specified, for // example, when there are multiple wallets loaded. ErrRPCWalletNotSpecified RPCErrorCode = -19 )
Wallet JSON errors
const ( ErrRPCBlockNotFound RPCErrorCode = -5 ErrRPCBlockCount RPCErrorCode = -5 ErrRPCBestBlockHash RPCErrorCode = -5 ErrRPCDifficulty RPCErrorCode = -5 ErrRPCOutOfRange RPCErrorCode = -1 ErrRPCNoTxInfo RPCErrorCode = -5 ErrRPCNoCFIndex RPCErrorCode = -5 ErrRPCNoNewestBlockInfo RPCErrorCode = -5 ErrRPCInvalidTxVout RPCErrorCode = -5 ErrRPCRawTxString RPCErrorCode = -32602 ErrRPCDecodeHexString RPCErrorCode = -22 ErrRPCTxError RPCErrorCode = -25 ErrRPCTxRejected RPCErrorCode = -26 ErrRPCTxAlreadyInChain RPCErrorCode = -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.
const ( ErrRPCNoWallet RPCErrorCode = -1 ErrRPCUnimplemented RPCErrorCode = -1 )
Errors that are specific to btcd.
const ( // ErrRPCClientMempoolDisabled indicates that no mempool instance was // found. ErrRPCClientMempoolDisabled RPCErrorCode = -33 )
Chain errors
type RPCVersion ¶
type RPCVersion string
RPCVersion is a type to indicate RPC versions.
const ( // version 1 of rpc RpcVersion1 RPCVersion = RPCVersion("1.0") // version 2 of rpc RpcVersion2 RPCVersion = RPCVersion("2.0") )
func (RPCVersion) IsValid ¶
func (r RPCVersion) IsValid() bool
check if the rpc version is a valid version
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 RawTxWitnessInput ¶
type RawTxWitnessInput struct { Txid string `json:"txid"` Vout uint32 `json:"vout"` ScriptPubKey string `json:"scriptPubKey"` RedeemScript *string `json:"redeemScript,omitempty"` WitnessScript *string `json:"witnessScript,omitempty"` Amount *float64 `json:"amount,omitempty"` // In BTC }
RawTxWitnessInput models the data needed for raw transaction input that is used in the SignRawTransactionWithWalletCmd struct. The RedeemScript is required for P2SH inputs, the WitnessScript is required for P2WSH or P2SH-P2WSH witness scripts, and the Amount is required for Segwit inputs. Otherwise, those fields can be left blank.
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
deprecated
type RecvTxNtfn struct { HexTx string Block *BlockDetails }
RecvTxNtfn defines the recvtx JSON-RPC notification.
Deprecated: Use RelevantTxAcceptedNtfn and FilteredBlockConnectedNtfn instead.
func NewRecvTxNtfn
deprecated
func NewRecvTxNtfn(hexTx string, block *BlockDetails) *RecvTxNtfn
NewRecvTxNtfn returns a new instance which can be used to issue a recvtx JSON-RPC notification.
Deprecated: Use NewRelevantTxAcceptedNtfn and NewFilteredBlockConnectedNtfn instead.
type RedeemingTxNtfn
deprecated
type RedeemingTxNtfn struct { HexTx string Block *BlockDetails }
RedeemingTxNtfn defines the redeemingtx JSON-RPC notification.
Deprecated: Use RelevantTxAcceptedNtfn and FilteredBlockConnectedNtfn instead.
func NewRedeemingTxNtfn
deprecated
func NewRedeemingTxNtfn(hexTx string, block *BlockDetails) *RedeemingTxNtfn
NewRedeemingTxNtfn returns a new instance which can be used to issue a redeemingtx JSON-RPC notification.
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 RenameAccountCmd ¶
RenameAccountCmd defines the renameaccount JSON-RPC command.
func NewRenameAccountCmd ¶
func NewRenameAccountCmd(oldAccount, newAccount string) *RenameAccountCmd
NewRenameAccountCmd returns a new instance which can be used to issue a renameaccount JSON-RPC command.
type Request ¶
type Request struct { Jsonrpc RPCVersion `json:"jsonrpc"` Method string `json:"method"` Params []json.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 ¶
func NewRequest(rpcVersion RPCVersion, id interface{}, method string, params []interface{}) (*Request, error)
NewRequest returns a new JSON-RPC request object given the provided rpc version, id, method, and parameters. The parameters are marshalled into a json.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.
func (*Request) UnmarshalJSON ¶
UnmarshalJSON is a custom unmarshal func for the Request struct. The param field defaults to an empty json.RawMessage array it is omitted by the request or nil if the supplied value is invalid.
type RescanBlocksCmd ¶
type RescanBlocksCmd struct { // Block hashes as a string array. BlockHashes []string }
RescanBlocksCmd defines the rescan JSON-RPC command.
NOTE: This is a btcd 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 btcd extension ported from github.com/decred/dcrd/dcrjson and requires a websocket connection.
type RescanCmd
deprecated
type RescanCmd struct { BeginBlock string Addresses []string OutPoints []OutPoint EndBlock *string }
RescanCmd defines the rescan JSON-RPC command.
Deprecated: Use RescanBlocksCmd instead.
func NewRescanCmd
deprecated
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.
Deprecated: Use NewRescanBlocksCmd instead.
type RescanFinishedNtfn
deprecated
RescanFinishedNtfn defines the rescanfinished JSON-RPC notification.
Deprecated: Not used with rescanblocks command.
func NewRescanFinishedNtfn
deprecated
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.
Deprecated: Not used with rescanblocks command.
type RescanProgressNtfn
deprecated
RescanProgressNtfn defines the rescanprogress JSON-RPC notification.
Deprecated: Not used with rescanblocks command.
func NewRescanProgressNtfn
deprecated
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.
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 { Jsonrpc RPCVersion `json:"jsonrpc"` Result json.RawMessage `json:"result"` Error *RPCError `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 to allow for a nil value when empty.
func NewResponse ¶
func NewResponse(rpcVersion RPCVersion, id interface{}, marshalledResult []byte, rpcErr *RPCError) (*Response, error)
NewResponse returns a new JSON-RPC response object given the provided rpc version, 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 ScanProgress ¶
type ScanningOrFalse ¶
type ScanningOrFalse struct {
Value interface{}
}
func (ScanningOrFalse) MarshalJSON ¶
func (h ScanningOrFalse) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface
func (*ScanningOrFalse) UnmarshalJSON ¶
func (h *ScanningOrFalse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
type ScriptPubKey ¶
type ScriptPubKey struct {
Value interface{}
}
ScriptPubKey represents a script (as a string) or an address (as a ScriptPubKeyAddress).
func (ScriptPubKey) MarshalJSON ¶
func (s ScriptPubKey) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for ScriptPubKey
func (*ScriptPubKey) UnmarshalJSON ¶
func (s *ScriptPubKey) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for ScriptPubKey
type ScriptPubKeyAddress ¶
type ScriptPubKeyAddress struct {
Address string `json:"address"`
}
ScriptPubKeyAddress represents an address, to be used in conjunction with ScriptPubKey.
type ScriptPubKeyResult ¶
type ScriptPubKeyResult struct { Asm string `json:"asm"` Hex string `json:"hex,omitempty"` ReqSigs int32 `json:"reqSigs,omitempty"` Type string `json:"type"` Addresses []string `json:"addresses,omitempty"` }
ScriptPubKeyResult models the scriptPubKey data of a tx script. It is defined separately since it is used by multiple commands.
type ScriptSig ¶
ScriptSig models a signature script. It is defined separately since it only applies to non-coinbase. Therefore the field in the Vin structure needs to be a pointer.
type 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 SearchRawTransactionsResult ¶
type SearchRawTransactionsResult struct { Hex string `json:"hex,omitempty"` Txid string `json:"txid"` Hash string `json:"hash"` Size string `json:"size"` Vsize string `json:"vsize"` Weight string `json:"weight"` 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"` }
SearchRawTransactionsResult models the data from the searchrawtransaction command.
type SendFromCmd ¶
type SendFromCmd struct { FromAccount string ToAddress string Amount float64 // In BTC MinConf *int `jsonrpcdefault:"1"` Comment *string CommentTo *string }
SendFromCmd defines the sendfrom JSON-RPC command.
func NewSendFromCmd ¶
func NewSendFromCmd(fromAccount, 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 { FromAccount string Amounts map[string]float64 `jsonrpcusage:"{\"address\":amount,...}"` // In BTC MinConf *int `jsonrpcdefault:"1"` Comment *string }
SendManyCmd defines the sendmany JSON-RPC command.
func NewSendManyCmd ¶
func NewSendManyCmd(fromAccount 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 ¶
type SendRawTransactionCmd struct { HexTx string FeeSetting *AllowHighFeesOrMaxFeeRate `jsonrpcdefault:"false"` }
SendRawTransactionCmd defines the sendrawtransaction JSON-RPC command.
func NewBitcoindSendRawTransactionCmd ¶
func NewBitcoindSendRawTransactionCmd(hexTx string, maxFeeRate int32) *SendRawTransactionCmd
NewSendRawTransactionCmd returns a new instance which can be used to issue a sendrawtransaction JSON-RPC command to a bitcoind node.
A 0 maxFeeRate indicates that a maximum fee rate won't be enforced.
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 SessionCmd ¶
type SessionCmd struct{}
SessionCmd defines the session JSON-RPC command.
func NewSessionCmd ¶
func NewSessionCmd() *SessionCmd
NewSessionCmd returns a new instance which can be used to issue a session JSON-RPC command.
type SessionResult ¶
type SessionResult struct {
SessionID uint64 `json:"sessionid"`
}
SessionResult models the data from the session command.
type SetAccountCmd ¶
SetAccountCmd defines the setaccount JSON-RPC command.
func NewSetAccountCmd ¶
func NewSetAccountCmd(address, account string) *SetAccountCmd
NewSetAccountCmd returns a new instance which can be used to issue a setaccount JSON-RPC 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 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 SignMessageWithPrivKeyCmd ¶
type SignMessageWithPrivKeyCmd struct { PrivKey string // base 58 Wallet Import format private key Message string // Message to sign }
SignMessageWithPrivKeyCmd defines the signmessagewithprivkey JSON-RPC command.
func NewSignMessageWithPrivKey ¶
func NewSignMessageWithPrivKey(privKey, message string) *SignMessageWithPrivKeyCmd
NewSignMessageWithPrivKey returns a new instance which can be used to issue a signmessagewithprivkey JSON-RPC command.
The first parameter is a private key in base 58 Wallet Import format. The second parameter is the message to sign.
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 SignRawTransactionWithWalletCmd ¶
type SignRawTransactionWithWalletCmd struct { RawTx string Inputs *[]RawTxWitnessInput SigHashType *string `jsonrpcdefault:"\"ALL\""` }
SignRawTransactionWithWalletCmd defines the signrawtransactionwithwallet JSON-RPC command.
func NewSignRawTransactionWithWalletCmd ¶
func NewSignRawTransactionWithWalletCmd(hexEncodedTx string, inputs *[]RawTxWitnessInput, sigHashType *string) *SignRawTransactionWithWalletCmd
NewSignRawTransactionWithWalletCmd returns a new instance which can be used to issue a signrawtransactionwithwallet JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SignRawTransactionWithWalletResult ¶
type SignRawTransactionWithWalletResult struct { Hex string `json:"hex"` Complete bool `json:"complete"` Errors []SignRawTransactionError `json:"errors,omitempty"` }
SignRawTransactionWithWalletResult models the data from the signrawtransactionwithwallet 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 signalling.
type SoftForks ¶
type SoftForks struct { SoftForks []*SoftForkDescription `json:"softforks"` Bip9SoftForks map[string]*Bip9SoftForkDescription `json:"bip9_softforks"` }
SoftForks describes the current softforks enabled by the backend. Softforks activated through BIP9 are grouped together separate from any other softforks with different activation types.
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
deprecated
type StopNotifyReceivedCmd struct {
Addresses []string
}
StopNotifyReceivedCmd defines the stopnotifyreceived JSON-RPC command.
Deprecated: Use LoadTxFilterCmd instead.
func NewStopNotifyReceivedCmd
deprecated
func NewStopNotifyReceivedCmd(addresses []string) *StopNotifyReceivedCmd
NewStopNotifyReceivedCmd returns a new instance which can be used to issue a stopnotifyreceived JSON-RPC command.
Deprecated: Use NewLoadTxFilterCmd instead.
type StopNotifySpentCmd
deprecated
type StopNotifySpentCmd struct {
OutPoints []OutPoint
}
StopNotifySpentCmd defines the stopnotifyspent JSON-RPC command.
Deprecated: Use LoadTxFilterCmd instead.
func NewStopNotifySpentCmd
deprecated
func NewStopNotifySpentCmd(outPoints []OutPoint) *StopNotifySpentCmd
NewStopNotifySpentCmd returns a new instance which can be used to issue a stopnotifyspent JSON-RPC command.
Deprecated: Use NewLoadTxFilterCmd instead.
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"` // list of supported softfork deployments, by name // Ref: https://en.bitcoin.it/wiki/BIP_0009#getblocktemplate_changes. Rules []string `json:"rules,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 TimestampOrNow ¶
type TimestampOrNow struct {
Value interface{}
}
TimestampOrNow defines a type to represent a timestamp value in seconds, since epoch.
The value can either be a integer, or the string "now".
NOTE: Interpretation of the timestamp value depends upon the specific JSON-RPC command, where it is used.
func (TimestampOrNow) MarshalJSON ¶
func (t TimestampOrNow) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for TimestampOrNow
func (*TimestampOrNow) UnmarshalJSON ¶
func (t *TimestampOrNow) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for TimestampOrNow
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"` Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` }
TxRawDecodeResult models the data from the decoderawtransaction command.
type TxRawResult ¶
type TxRawResult struct { Hex string `json:"hex"` Txid string `json:"txid"` Hash string `json:"hash,omitempty"` Size int32 `json:"size,omitempty"` Vsize int32 `json:"vsize,omitempty"` Weight int32 `json:"weight,omitempty"` Version uint32 `json:"version"` LockTime uint32 `json:"locktime"` Vin []Vin `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"` InstantLock bool `json:"instantlock,omitempty"` InstantLockInternal bool `json:"instantlock_internal,omitempty"` ChainLock bool `json:"chainlock,omitempty"` }
TxRawResult models the data from the getrawtransaction command.
type UnifiedSoftFork ¶
type UnifiedSoftFork struct { Type string `json:"type"` BIP9SoftForkDescription *Bip9SoftForkDescription `json:"bip9"` Height int32 `json:"height"` Active bool `json:"active"` }
UnifiedSoftForks describes a softforks in a general manner, irrespective of its activation type. This was a format introduced by bitcoind v0.19.0
type UnifiedSoftForks ¶
type UnifiedSoftForks struct {
SoftForks map[string]*UnifiedSoftFork `json:"softforks"`
}
UnifiedSoftForks describes the current softforks enabled the by the backend in a unified manner, i.e, softforks with different activation types are grouped together. This was a format introduced by bitcoind v0.19.0
type UnloadWalletCmd ¶
type UnloadWalletCmd struct {
WalletName *string
}
UnloadWalletCmd defines the unloadwallet JSON-RPC command
func NewUnloadWalletCmd ¶
func NewUnloadWalletCmd(walletName *string) *UnloadWalletCmd
NewUnloadWalletCmd returns a new instance which can be used to issue a unloadwallet JSON-RPC command.
type Unmarshaler ¶
type Unmarshaler interface {
UnmarshalArgs(args []interface{}) error
}
Unmarshaler is an interface for a specific unmarshal function of arguments
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"` IsScript *bool `json:"isscript,omitempty"` IsWitness *bool `json:"iswitness,omitempty"` WitnessVersion *int32 `json:"witness_version,omitempty"` WitnessProgram *string `json:"witness_program,omitempty"` }
ValidateAddressChainResult models the data returned by the chain server validateaddress command.
Compared to the Bitcoin Core version, this struct lacks the scriptPubKey field since it requires wallet access, which is outside the scope of btcd. Ref: https://bitcoincore.org/en/doc/0.20.0/rpc/util/validateaddress/
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 { Value float64 `json:"value"` N uint32 `json:"n"` ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"` }
Vout models parts of the tx data. It is defined separately since both getrawtransaction and decoderawtransaction use the same structure.
type WalletCreateFundedPsbtCmd ¶
type WalletCreateFundedPsbtCmd struct { Inputs []PsbtInput Outputs []PsbtOutput Locktime *uint32 Options *WalletCreateFundedPsbtOpts Bip32Derivs *bool }
WalletCreateFundedPsbtCmd defines the walletcreatefundedpsbt JSON-RPC command.
func NewWalletCreateFundedPsbtCmd ¶
func NewWalletCreateFundedPsbtCmd( inputs []PsbtInput, outputs []PsbtOutput, locktime *uint32, options *WalletCreateFundedPsbtOpts, bip32Derivs *bool, ) *WalletCreateFundedPsbtCmd
NewWalletCreateFundedPsbtCmd returns a new instance which can be used to issue a walletcreatefundedpsbt JSON-RPC command.
type WalletCreateFundedPsbtOpts ¶
type WalletCreateFundedPsbtOpts struct { ChangeAddress *string `json:"changeAddress,omitempty"` ChangePosition *int64 `json:"changePosition,omitempty"` ChangeType *ChangeType `json:"change_type,omitempty"` IncludeWatching *bool `json:"includeWatching,omitempty"` LockUnspents *bool `json:"lockUnspents,omitempty"` FeeRate *float64 `json:"feeRate,omitempty"` SubtractFeeFromOutputs *[]int64 `json:"subtractFeeFromOutputs,omitempty"` Replaceable *bool `json:"replaceable,omitempty"` ConfTarget *int64 `json:"conf_target,omitempty"` EstimateMode *string `json:"estimate_mode,omitempty"` }
WalletCreateFundedPsbtOpts represents the optional options struct provided with a WalletCreateFundedPsbtCmd command.
type WalletCreateFundedPsbtResult ¶
type WalletCreateFundedPsbtResult struct { Psbt string `json:"psbt"` Fee float64 `json:"fee"` ChangePos int64 `json:"changepos"` }
WalletCreateFundedPsbtResult models the data returned from the walletcreatefundedpsbtresult command.
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 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 WalletProcessPsbtCmd ¶
type WalletProcessPsbtCmd struct { Psbt string Sign *bool `jsonrpcdefault:"true"` SighashType *string `jsonrpcdefault:"\"ALL\""` Bip32Derivs *bool }
WalletProcessPsbtCmd defines the walletprocesspsbt JSON-RPC command.
func NewWalletProcessPsbtCmd ¶
func NewWalletProcessPsbtCmd(psbt string, sign *bool, sighashType *string, bip32Derivs *bool) *WalletProcessPsbtCmd
NewWalletProcessPsbtCmd returns a new instance which can be used to issue a walletprocesspsbt JSON-RPC command.
type WalletProcessPsbtResult ¶
WalletProcessPsbtResult models the data returned from the walletprocesspsbtresult command.
Source Files ¶
- btcdextcmds.go
- btcdextresults.go
- btcwalletextcmds.go
- chainsvrcmds.go
- chainsvrresults.go
- chainsvrwscmds.go
- chainsvrwsntfns.go
- chainsvrwsresults.go
- cmdinfo.go
- cmdparse.go
- dashevocmds.go
- dashevoresults.go
- dashmasternodecmds.go
- dashmasternoderesults.go
- doc.go
- error.go
- help.go
- helpers.go
- jsonrpc.go
- jsonrpcerr.go
- register.go
- util.go
- walletsvrcmds.go
- walletsvrresults.go
- walletsvrwscmds.go
- walletsvrwsntfns.go