Comment exported methods

This commit is contained in:
jholdstock 2020-08-07 15:40:48 +01:00 committed by David Hill
parent bcb6fd5ec3
commit ba77d39f35
4 changed files with 30 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import (
bolt "go.etcd.io/bbolt"
)
// GetLastAddressIndex retrieves the last index used to derive a new fee
// address from the fee xpub key.
func (vdb *VspDatabase) GetLastAddressIndex() (uint32, error) {
var idx uint32
err := vdb.db.View(func(tx *bolt.Tx) error {
@ -24,6 +26,8 @@ func (vdb *VspDatabase) GetLastAddressIndex() (uint32, error) {
return idx, err
}
// SetLastAddressIndex updates the last index used to derive a new fee address
// from the fee xpub key.
func (vdb *VspDatabase) SetLastAddressIndex(idx uint32) error {
err := vdb.db.Update(func(tx *bolt.Tx) error {
vspBkt := tx.Bucket(vspBktK)

View File

@ -193,6 +193,7 @@ func (vdb *VspDatabase) Close() {
}
}
// KeyPair retrieves the keypair used to sign API responses from the database.
func (vdb *VspDatabase) KeyPair() (ed25519.PrivateKey, ed25519.PublicKey, error) {
var seed []byte
err := vdb.db.View(func(tx *bolt.Tx) error {
@ -227,6 +228,8 @@ func (vdb *VspDatabase) KeyPair() (ed25519.PrivateKey, ed25519.PublicKey, error)
return signKey, pubKey, err
}
// GetFeeXPub retrieves the extended pubkey used for generating fee addresses
// from the database.
func (vdb *VspDatabase) GetFeeXPub() (string, error) {
var feeXPub string
err := vdb.db.View(func(tx *bolt.Tx) error {
@ -245,6 +248,8 @@ func (vdb *VspDatabase) GetFeeXPub() (string, error) {
return feeXPub, err
}
// GetCookieSecret retrieves the generated cookie store secret key from the
// database.
func (vdb *VspDatabase) GetCookieSecret() ([]byte, error) {
var cookieSecret []byte
err := vdb.db.View(func(tx *bolt.Tx) error {

View File

@ -102,6 +102,8 @@ func (d *DcrdConnect) Client(ctx context.Context, netParams *chaincfg.Params) (*
return &DcrdRPC{c, ctx}, nil
}
// GetRawTransaction uses getrawtransaction RPC to retrieve details about the
// transaction with the provided hash.
func (c *DcrdRPC) GetRawTransaction(txHash string) (*dcrdtypes.TxRawResult, error) {
verbose := 1
var resp dcrdtypes.TxRawResult
@ -112,6 +114,8 @@ func (c *DcrdRPC) GetRawTransaction(txHash string) (*dcrdtypes.TxRawResult, erro
return &resp, nil
}
// SendRawTransaction uses sendrawtransaction RPC to broadcast a transaction to
// the network. It ignores errors caused by duplicate transactions.
func (c *DcrdRPC) SendRawTransaction(txHex string) error {
allowHighFees := false
err := c.Call(c.ctx, "sendrawtransaction", nil, txHex, allowHighFees)
@ -149,10 +153,13 @@ func (c *DcrdRPC) SendRawTransaction(txHex string) error {
return nil
}
// NotifyBlocks uses notifyblocks RPC to request new block notifications from dcrd.
func (c *DcrdRPC) NotifyBlocks() error {
return c.Call(c.ctx, "notifyblocks", nil)
}
// GetBestBlockHeader uses getbestblockhash RPC, followed by getblockheader RPC,
// to retrieve the header of the best block known to the dcrd instance.
func (c *DcrdRPC) GetBestBlockHeader() (*dcrdtypes.GetBlockHeaderVerboseResult, error) {
var bestBlockHash string
err := c.Call(c.ctx, "getbestblockhash", &bestBlockHash)
@ -169,6 +176,8 @@ func (c *DcrdRPC) GetBestBlockHeader() (*dcrdtypes.GetBlockHeaderVerboseResult,
return &blockHeader, nil
}
// ExistsLiveTicket uses existslivetickets RPC to check if the provided ticket
// hash is a live ticket known to the dcrd instance.
func (c *DcrdRPC) ExistsLiveTicket(ticketHash string) (bool, error) {
var exists string
err := c.Call(c.ctx, "existslivetickets", &exists, []string{ticketHash})

View File

@ -135,6 +135,8 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params)
return walletClients, failedConnections
}
// WalletInfo uses walletinfo RPC to retrieve information about how the
// dcrwallet instance is configured.
func (c *WalletRPC) WalletInfo() (*wallettypes.WalletInfoResult, error) {
var walletInfo wallettypes.WalletInfoResult
err := c.Call(c.ctx, "walletinfo", &walletInfo)
@ -144,6 +146,8 @@ func (c *WalletRPC) WalletInfo() (*wallettypes.WalletInfoResult, error) {
return &walletInfo, nil
}
// AddTicketForVoting uses importprivkey RPC, followed by addtransaction RPC, to
// add a new ticket to a voting wallet.
func (c *WalletRPC) AddTicketForVoting(votingWIF, blockHash, txHex string) error {
label := "imported"
rescan := false
@ -161,10 +165,14 @@ func (c *WalletRPC) AddTicketForVoting(votingWIF, blockHash, txHex string) error
return nil
}
// SetVoteChoice uses setvotechoice RPC to set the vote choice on the given
// agenda, for the given ticket.
func (c *WalletRPC) SetVoteChoice(agenda, choice, ticketHash string) error {
return c.Call(c.ctx, "setvotechoice", nil, agenda, choice, ticketHash)
}
// GetBestBlockHeight uses getbestblock RPC to query the height of the best
// block known by the dcrwallet instance.
func (c *WalletRPC) GetBestBlockHeight() (int64, error) {
var block dcrdtypes.GetBestBlockResult
err := c.Call(c.ctx, "getbestblock", &block)
@ -174,6 +182,8 @@ func (c *WalletRPC) GetBestBlockHeight() (int64, error) {
return block.Height, nil
}
// TicketInfo uses ticketinfo RPC to retrieve a detailed list of all tickets
// known by this dcrwallet instance.
func (c *WalletRPC) TicketInfo() (map[string]*wallettypes.TicketInfoResult, error) {
var result []*wallettypes.TicketInfoResult
err := c.Call(c.ctx, "ticketinfo", &result)
@ -191,6 +201,8 @@ func (c *WalletRPC) TicketInfo() (map[string]*wallettypes.TicketInfoResult, erro
return tickets, err
}
// RescanFrom uses rescanwallet RPC to trigger the wallet to perform a rescan
// from the specified block height.
func (c *WalletRPC) RescanFrom(fromHeight int64) error {
return c.Call(c.ctx, "rescanwallet", nil, fromHeight)
}