Documentation ¶
Index ¶
- Constants
- type Caller
- type DcrdConnect
- type DcrdRPC
- func (c *DcrdRPC) DecodeRawTransaction(txHex string) (*dcrdtypes.TxRawDecodeResult, error)
- func (c *DcrdRPC) ExistsLiveTicket(ticketHash string) (bool, error)
- func (c *DcrdRPC) GetBestBlockHeader() (*wire.BlockHeader, error)
- func (c *DcrdRPC) GetBlock(hash string) (*wire.MsgBlock, error)
- func (c *DcrdRPC) GetBlockCount() (int64, error)
- func (c *DcrdRPC) GetBlockHash(height int64) (string, error)
- func (c *DcrdRPC) GetBlockHeader(blockHash string) (*wire.BlockHeader, error)
- func (c *DcrdRPC) GetCFilterV2(header *wire.BlockHeader, verifyProof bool) ([gcs.KeySize]byte, *gcs.FilterV2, error)
- func (c *DcrdRPC) GetRawTransaction(txHash string) (*dcrdtypes.TxRawResult, error)
- func (c *DcrdRPC) NotifyBlocks() error
- func (c *DcrdRPC) SendRawTransaction(txHex string) error
- type WalletConnect
- type WalletRPC
- func (c *WalletRPC) AddTicketForVoting(votingWIF, blockHash, txHex string) error
- func (c *WalletRPC) GetBestBlockHeight() (int64, error)
- func (c *WalletRPC) RescanFrom(fromHeight int64) error
- func (c *WalletRPC) SetTSpendPolicy(tSpend, policy, ticket string) error
- func (c *WalletRPC) SetTreasuryPolicy(key, policy, ticket string) error
- func (c *WalletRPC) SetVoteChoice(agenda, choice, ticketHash string) error
- func (c *WalletRPC) TicketInfo(startHeight int64) (map[string]*wallettypes.TicketInfoResult, error)
- func (c *WalletRPC) WalletInfo() (*wallettypes.WalletInfoResult, error)
Constants ¶
const ( // These numerical error codes are defined in dcrd/dcrjson. Copied here so // we dont need to import the whole package. ErrRPCDuplicateTx = -40 ErrNoTxInfo = -5 // This error string is defined in dcrd/internal/mempool. Copied here // because it is not exported. ErrUnknownOutputs = "references outputs of unknown or fully-spent transaction" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Caller ¶
type Caller interface { // String returns the dialed URL. String() string // Call performs the remote procedure call defined by method and // waits for a response or a broken client connection. // Args provides positional parameters for the call. // Res must be a pointer to a struct, slice, or map type to unmarshal // a result (if any), or nil if no result is needed. Call(ctx context.Context, method string, res any, args ...any) error }
Caller provides a client interface to perform JSON-RPC remote procedure calls.
type DcrdConnect ¶
type DcrdConnect struct {
// contains filtered or unexported fields
}
func SetupDcrd ¶
func SetupDcrd(user, pass, addr string, cert []byte, params *chaincfg.Params, log slog.Logger, blockConnectedChan chan *wire.BlockHeader) DcrdConnect
func (*DcrdConnect) Client ¶
func (d *DcrdConnect) Client() (*DcrdRPC, string, error)
Client creates a new DcrdRPC client instance. Returns an error if dialing dcrd fails or if dcrd is misconfigured.
func (*DcrdConnect) Close ¶
func (d *DcrdConnect) Close()
type DcrdRPC ¶
type DcrdRPC struct {
Caller
}
DcrdRPC provides methods for calling dcrd JSON-RPCs without exposing the details of JSON encoding.
func (*DcrdRPC) DecodeRawTransaction ¶
func (c *DcrdRPC) DecodeRawTransaction(txHex string) (*dcrdtypes.TxRawDecodeResult, error)
DecodeRawTransaction uses decoderawtransaction RPC to decode raw transaction bytes.
func (*DcrdRPC) ExistsLiveTicket ¶
ExistsLiveTicket uses existslivetickets RPC to check if the provided ticket hash is a live ticket known to the dcrd instance.
func (*DcrdRPC) GetBestBlockHeader ¶
func (c *DcrdRPC) GetBestBlockHeader() (*wire.BlockHeader, error)
GetBestBlockHeader uses getbestblockhash RPC, followed by getblockheader RPC, to retrieve the header of the best block known to the dcrd instance.
func (*DcrdRPC) GetBlockCount ¶
func (*DcrdRPC) GetBlockHeader ¶
func (c *DcrdRPC) GetBlockHeader(blockHash string) (*wire.BlockHeader, error)
GetBlockHeader uses getblockheader RPC with verbose=false to retrieve the header of the requested block.
func (*DcrdRPC) GetCFilterV2 ¶
func (c *DcrdRPC) GetCFilterV2(header *wire.BlockHeader, verifyProof bool) ([gcs.KeySize]byte, *gcs.FilterV2, error)
GetCFilterV2 retrieves the GCS filter for the provided block header, optionally verifies the inclusion proof, then returns the filter along with its key.
func (*DcrdRPC) GetRawTransaction ¶
func (c *DcrdRPC) GetRawTransaction(txHash string) (*dcrdtypes.TxRawResult, error)
GetRawTransaction uses getrawtransaction RPC to retrieve details about the transaction with the provided hash.
func (*DcrdRPC) NotifyBlocks ¶
NotifyBlocks uses notifyblocks RPC to request new block notifications from dcrd.
func (*DcrdRPC) SendRawTransaction ¶
SendRawTransaction uses sendrawtransaction RPC to broadcast a transaction to the network. It ignores errors caused by duplicate transactions.
type WalletConnect ¶
type WalletConnect struct {
// contains filtered or unexported fields
}
func SetupWallet ¶
func SetupWallet(user, pass, addrs []string, cert [][]byte, params *chaincfg.Params, log slog.Logger) WalletConnect
func (*WalletConnect) Clients ¶
func (w *WalletConnect) Clients() ([]*WalletRPC, []string)
Clients loops over each wallet and tries to establish a connection. It increments a count of failed connections if a connection cannot be established, or if the wallet is misconfigured.
func (*WalletConnect) Close ¶
func (w *WalletConnect) Close()
type WalletRPC ¶
type WalletRPC struct {
Caller
}
WalletRPC provides methods for calling dcrwallet JSON-RPCs without exposing the details of JSON encoding.
func (*WalletRPC) AddTicketForVoting ¶
AddTicketForVoting uses importprivkey RPC, followed by addtransaction RPC, to add a new ticket to a voting wallet.
func (*WalletRPC) GetBestBlockHeight ¶
GetBestBlockHeight uses getblockcount RPC to query the height of the best block known by the dcrwallet instance.
func (*WalletRPC) RescanFrom ¶
RescanFrom uses rescanwallet RPC to trigger the wallet to perform a rescan from the specified block height.
func (*WalletRPC) SetTSpendPolicy ¶
SetTSpendPolicy sets the specified tickets voting policy for a single tspend identified by its hash.
func (*WalletRPC) SetTreasuryPolicy ¶
SetTreasuryPolicy sets the specified tickets voting policy for all tspends published by the given treasury key.
func (*WalletRPC) SetVoteChoice ¶
SetVoteChoice uses setvotechoice RPC to set the vote choice on the given agenda, for the given ticket.
func (*WalletRPC) TicketInfo ¶
func (c *WalletRPC) TicketInfo(startHeight int64) (map[string]*wallettypes.TicketInfoResult, error)
TicketInfo uses ticketinfo RPC to retrieve a detailed list of all tickets known by this dcrwallet instance.
func (*WalletRPC) WalletInfo ¶
func (c *WalletRPC) WalletInfo() (*wallettypes.WalletInfoResult, error)
WalletInfo uses walletinfo RPC to retrieve information about how the dcrwallet instance is configured.