dcr

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: ISC Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShuffleServer      = "mix.decred.org"
	MainnetShufflePort = "5760"
	TestnetShufflePort = "15760"
	MixedAccountBranch = int32(udb.ExternalBranch)
)
View Source
const (
	InvalidSyncStage          = utils.InvalidSyncStage
	CFiltersFetchSyncStage    = utils.CFiltersFetchSyncStage
	HeadersFetchSyncStage     = utils.HeadersFetchSyncStage
	AddressDiscoverySyncStage = utils.AddressDiscoverySyncStage
	HeadersRescanSyncStage    = utils.HeadersRescanSyncStage
)
View Source
const (
	// Export constants for use in mobile apps
	// since gomobile excludes fields from sub packages.
	TxFilterAll         = utils.TxFilterAll
	TxFilterSent        = utils.TxFilterSent
	TxFilterReceived    = utils.TxFilterReceived
	TxFilterTransferred = utils.TxFilterTransferred
	TxFilterStaking     = utils.TxFilterStaking
	TxFilterCoinBase    = utils.TxFilterCoinBase
	TxFilterRegular     = utils.TxFilterRegular
	TxFilterMixed       = utils.TxFilterMixed
	TxFilterVoted       = utils.TxFilterVoted
	TxFilterRevoked     = utils.TxFilterRevoked
	TxFilterImmature    = utils.TxFilterImmature
	TxFilterLive        = utils.TxFilterLive
	TxFilterUnmined     = utils.TxFilterUnmined
	TxFilterExpired     = utils.TxFilterExpired
	TxFilterTickets     = utils.TxFilterTickets

	TxDirectionInvalid     = txhelper.TxDirectionInvalid
	TxDirectionSent        = txhelper.TxDirectionSent
	TxDirectionReceived    = txhelper.TxDirectionReceived
	TxDirectionTransferred = txhelper.TxDirectionTransferred

	TxTypeRegular        = txhelper.TxTypeRegular
	TxTypeCoinBase       = txhelper.TxTypeCoinBase
	TxTypeTicketPurchase = txhelper.TxTypeTicketPurchase
	TxTypeVote           = txhelper.TxTypeVote
	TxTypeRevocation     = txhelper.TxTypeRevocation
	TxTypeMixed          = txhelper.TxTypeMixed

	TicketStatusUnmined        = "unmined"
	TicketStatusImmature       = "immature"
	TicketStatusLive           = "live"
	TicketStatusVotedOrRevoked = "votedrevoked"
	TicketStatusExpired        = "expired"
)
View Source
const (
	AddressGapLimit       uint32 = 20
	ImportedAccountNumber        = udb.ImportedAddrAccount
	DefaultAccountNum            = udb.DefaultAccountNum
)
View Source
const (
	TestnetHDPath       = "m / 44' / 1' / "
	LegacyTestnetHDPath = "m / 44’ / 11’ / "
	MainnetHDPath       = "m / 44' / 42' / "
	LegacyMainnetHDPath = "m / 44’ / 20’ / "
)
View Source
const AlternatingWords = `` /* 4430-byte string literal not displayed */
View Source
const BlockValid = 1 << 0

Variables

This section is empty.

Functions

func AmountAtom

func AmountAtom(f float64) int64

func Confirmations

func Confirmations(bestBlock int32, tx *sharedW.Transaction) int32

func CreateNewWallet

func CreateNewWallet(pass *sharedW.AuthInfo, params *sharedW.InitParams) (sharedW.Asset, error)

CreateNewWallet accepts the wallet pass information and the init parameters. It validates the network type passed by fetching the chain parameters associated with it for the DCR asset. It then generates the DCR loader interface that is passed to be used upstream while creating a new wallet in the shared wallet implementation. Immediately a new wallet is created, the function to safely cancel network sync is set. There after returning the new wallet's interface.

func CreateWatchOnlyWallet

func CreateWatchOnlyWallet(walletName, extendedPublicKey string, params *sharedW.InitParams) (sharedW.Asset, error)

CreateWatchOnlyWallet accepts the wallet name, extended public key and the init parameters to create a watch only wallet for the DCR asset. It validates the network type passed by fetching the chain parameters associated with it for the DCR asset. It then generates the DCR loader interface that is passed to be used upstream while creating the watch only wallet in the shared wallet implementation. Immediately a watch only wallet is created, the function to safely cancel network sync is set. There after returning the watch only wallet's interface.

func LoadExisting

func LoadExisting(w *sharedW.Wallet, params *sharedW.InitParams) (sharedW.Asset, error)

LoadExisting accepts the stored shared wallet information and the init parameters. It validates the network type passed by fetching the chain parameters associated with it for the DCR asset. It then generates the DCR loader interface that is passed to be used upstream while loading the existing the wallet in the shared wallet implementation. Immediately loading the existing wallet is complete, the function to safely cancel network sync is set. There after returning the loaded wallet's interface.

func Log

func Log(m string)

Log writes a message to the log using LevelInfo.

func LogT

func LogT(tag, m string)

LogT writes a tagged message to the log using LevelInfo.

func PGPWordList

func PGPWordList() []string

func RestoreWallet

func RestoreWallet(seedMnemonic string, pass *sharedW.AuthInfo, params *sharedW.InitParams) (sharedW.Asset, error)

RestoreWallet accepts the seed, wallet pass information and the init parameters. It validates the network type passed by fetching the chain parameters associated with it for the DCR asset. It then generates the DCR loader interface that is passed to be used upstream while restoring the wallet in the shared wallet implementation. Immediately wallet restore is complete, the function to safely cancel network sync is set. There after returning the restored wallet's interface.

func TicketStatus

func TicketStatus(ticketMaturity, ticketExpiry, bestBlock int32, tx *sharedW.Transaction) string

func UseLogger

func UseLogger(logger slog.Logger)

UseLoggers sets the subsystem logs to use the provided loggers.

Types

type AccountMixerNotificationListener

type AccountMixerNotificationListener struct {
	OnAccountMixerStarted func(walletID int)
	OnAccountMixerEnded   func(walletID int)
}

type AccountsIterator

type AccountsIterator struct {
	// contains filtered or unexported fields
}

func (*AccountsIterator) Next

func (accountsInterator *AccountsIterator) Next() *sharedW.Account

func (*AccountsIterator) Reset

func (accountsInterator *AccountsIterator) Reset()

type AddressInfo

type AddressInfo struct {
	Address       string
	IsMine        bool
	AccountNumber uint32
	AccountName   string
}

AddressInfo holds information about an address If the address belongs to the querying wallet, IsMine will be true and the AccountNumber and AccountName values will be populated

type Agenda

type Agenda struct {
	AgendaID         string            `json:"agenda_id"`
	Description      string            `json:"description"`
	Mask             uint32            `json:"mask"`
	Choices          []chaincfg.Choice `json:"choices"`
	VotingPreference string            `json:"voting_preference"`
	StartTime        int64             `json:"start_time"`
	ExpireTime       int64             `json:"expire_time"`
	Status           string            `json:"status"`
}

Agenda contains information about a consensus deployment

func AllVoteAgendas added in v1.1.0

func AllVoteAgendas(chainParams *chaincfg.Params, newestFirst bool) ([]*Agenda, error)

AllVoteAgendas returns all agendas of all stake versions for the active network and this version of the software.

type AgendaStatusType

type AgendaStatusType string

AgendaStatusType defines the various agenda statuses.

const (

	// AgendaStatusUpcoming used to define an agenda yet to vote.
	AgendaStatusUpcoming AgendaStatusType = "upcoming"

	// AgendaStatusInProgress used to define an agenda with voting ongoing.
	AgendaStatusInProgress AgendaStatusType = "in progress"

	// AgendaStatusFailed used to define an agenda when the votes tally does not
	// attain the minimum threshold set. Activation height is not set for such an
	// agenda.
	AgendaStatusFailed AgendaStatusType = "failed"

	// AgendaStatusLockedIn used to define an agenda that has passed after attaining
	// the minimum set threshold.
	AgendaStatusLockedIn AgendaStatusType = "locked in"

	// AgendaStatusFinished used to define an agenda that has finished voting.
	AgendaStatusFinished AgendaStatusType = "finished"

	// UnknownStatus is used when a status string is not recognized.
	UnknownStatus AgendaStatusType = "unknown"
)

func AgendaStatusFromStr

func AgendaStatusFromStr(status string) AgendaStatusType

AgendaStatusFromStr creates an agenda status from a string. If "UnknownStatus" is returned then an invalid status string has been passed.

func (AgendaStatusType) String

func (a AgendaStatusType) String() string

type Amount

type Amount dcrutil.Amount

Amount implements the Asset amount interface for the DCR asset

func (Amount) MulF64

func (a Amount) MulF64(f float64) sharedW.AssetAmount

MulF64 multiplys the Amount with the provided float64 value.

func (Amount) String

func (a Amount) String() string

String returns the string version of the DCR formatted asset amount.

func (Amount) ToCoin

func (a Amount) ToCoin() float64

ToCoin returns the float64 version of the DCR formatted asset amount.

func (Amount) ToInt

func (a Amount) ToInt() int64

ToInt return the original unformatted amount DCRs

type Asset

type Asset struct {
	*sharedW.Wallet

	TxAuthoredInfo *TxAuthor
	// contains filtered or unexported fields
}

func (*Asset) AccountMixerConfigIsSet

func (asset *Asset) AccountMixerConfigIsSet() bool

func (*Asset) AccountMixerMixChange

func (asset *Asset) AccountMixerMixChange() bool

func (*Asset) AccountName

func (asset *Asset) AccountName(accountNumber int32) (string, error)

func (*Asset) AccountNameRaw

func (asset *Asset) AccountNameRaw(accountNumber uint32) (string, error)

func (*Asset) AccountNumber

func (asset *Asset) AccountNumber(accountName string) (int32, error)

func (*Asset) AccountOfAddress

func (asset *Asset) AccountOfAddress(address string) (string, error)

func (*Asset) AccountXPubMatches

func (asset *Asset) AccountXPubMatches(account uint32, legacyXPub, slip044XPub string) (bool, error)

AccountXPubMatches checks if the xpub of the provided account matches the provided legacy or SLIP0044 xpub. While both the legacy and SLIP0044 xpubs will be checked for watch-only wallets, other wallets will only check the xpub that matches the coin type key used by the asset.

func (*Asset) AccountsIterator

func (asset *Asset) AccountsIterator() (*AccountsIterator, error)

func (*Asset) AddAccountMixerNotificationListener

func (asset *Asset) AddAccountMixerNotificationListener(accountMixerNotificationListener *AccountMixerNotificationListener, uniqueIdentifier string) error

func (*Asset) AddSendDestination

func (asset *Asset) AddSendDestination(id int, address string, atomAmount int64, sendMax bool) error

func (*Asset) AddSyncProgressListener

func (asset *Asset) AddSyncProgressListener(syncProgressListener *sharedW.SyncProgressListener, uniqueIdentifier string) error

func (*Asset) AddTxAndBlockNotificationListener

func (asset *Asset) AddTxAndBlockNotificationListener(txAndBlockNotificationListener *sharedW.TxAndBlockNotificationListener, uniqueIdentifier string) error

AddTxAndBlockNotificationListener registers a set of functions to be invoked when a transaction or block update is processed by the asset. If async is true, the provided callback methods will be called from separate goroutines, allowing notification senders to continue their operation without waiting for the listener to complete processing the notification. This asyncrhonous handling is especially important for cases where the wallet process that sends the notification temporarily prevents access to other wallet features until all notification handlers finish processing the notification. If a notification handler were to try to access such features, it would result in a deadlock.

func (*Asset) AddressInfo

func (asset *Asset) AddressInfo(address string) (*AddressInfo, error)

func (*Asset) AddressPubKey

func (asset *Asset) AddressPubKey(address string) (string, error)

func (*Asset) AgendaChoices added in v1.1.0

func (asset *Asset) AgendaChoices(txHash string) (map[string]string, error)

AgendaChoices returns saved vote preferences for the agendas of the current stake version. If a txHash is provided, the vote preferences saved for that specific tx will be returned. Vote preferences for older agendas cannot currently be retrieved.

func (*Asset) AutoTicketsBuyerConfig

func (asset *Asset) AutoTicketsBuyerConfig() *TicketBuyerConfig

AutoTicketsBuyerConfig returns the previously set ticket buyer config for the asset.

func (*Asset) Broadcast

func (asset *Asset) Broadcast(privatePassphrase, transactionLabel string) ([]byte, error)

func (*Asset) CancelRescan

func (asset *Asset) CancelRescan()

func (*Asset) CancelSync

func (asset *Asset) CancelSync()

func (*Asset) ClearMixerConfig

func (asset *Asset) ClearMixerConfig()

func (*Asset) ClearTicketBuyerConfig

func (asset *Asset) ClearTicketBuyerConfig(_ int) error

ClearTicketBuyerConfig clears the wallet's ticket buyer config.

func (*Asset) ComputeTxSizeEstimation

func (asset *Asset) ComputeTxSizeEstimation(dstnAddress string, utxos []*sharedW.UnspentOutput) (int, error)

ComputeTxSizeEstimation computes the estimated size of the final raw transaction.

func (*Asset) ConnectedPeers

func (asset *Asset) ConnectedPeers() int32

func (*Asset) CountTransactions

func (asset *Asset) CountTransactions(txFilter int32) (int, error)

func (*Asset) CreateMixerAccounts

func (asset *Asset) CreateMixerAccounts(mixedAccount, unmixedAccount, privPass string) error

CreateMixerAccounts creates the two accounts needed for the account mixer. This function is added to ease unlocking the wallet before creating accounts. This function should be used with auto cspp mixer setup.

func (*Asset) CreateNewAccount

func (asset *Asset) CreateNewAccount(accountName, privPass string) (int32, error)

func (*Asset) CurrentAddress

func (asset *Asset) CurrentAddress(account int32) (string, error)

CurrentAddress gets the most recently requested payment address from the asset. If that address has already been used to receive funds, the next chained address is returned.

func (*Asset) CurrentSyncStage

func (asset *Asset) CurrentSyncStage() utils.SyncStage

func (*Asset) DecodeTransaction

func (asset *Asset) DecodeTransaction(walletTx *sharedW.TxInfoFromWallet, netParams *chaincfg.Params) (*sharedW.Transaction, error)

DecodeTransaction uses `walletTx.Hex` to retrieve detailed information for a transaction.

func (*Asset) DiscoverUsage

func (asset *Asset) DiscoverUsage(gapLimit uint32) error

func (*Asset) EnableSyncLogs

func (asset *Asset) EnableSyncLogs()

func (*Asset) EstimateFeeAndSize

func (asset *Asset) EstimateFeeAndSize() (*sharedW.TxFeeAndSize, error)

func (*Asset) EstimateMaxSendAmount

func (asset *Asset) EstimateMaxSendAmount() (*sharedW.Amount, error)

func (*Asset) GeneralSyncProgress

func (asset *Asset) GeneralSyncProgress() *sharedW.GeneralSyncProgress

func (*Asset) GetAccount

func (asset *Asset) GetAccount(accountNumber int32) (*sharedW.Account, error)

func (*Asset) GetAccountBalance

func (asset *Asset) GetAccountBalance(accountNumber int32) (*sharedW.Balance, error)

func (*Asset) GetAccounts

func (asset *Asset) GetAccounts() (string, error)

func (*Asset) GetAccountsRaw

func (asset *Asset) GetAccountsRaw() (*sharedW.Accounts, error)

func (*Asset) GetBestBlock

func (asset *Asset) GetBestBlock() *sharedW.BlockInfo

func (*Asset) GetBestBlockHeight

func (asset *Asset) GetBestBlockHeight() int32

func (*Asset) GetBestBlockTimeStamp

func (asset *Asset) GetBestBlockTimeStamp() int64

func (*Asset) GetExtendedPubKey

func (asset *Asset) GetExtendedPubKey(account int32) (string, error)

func (*Asset) GetTransaction

func (asset *Asset) GetTransaction(txHash string) (string, error)

func (*Asset) GetTransactionRaw

func (asset *Asset) GetTransactionRaw(txHash string) (*sharedW.Transaction, error)

func (*Asset) GetTransactions

func (asset *Asset) GetTransactions(offset, limit, txFilter int32, newestFirst bool) (string, error)

func (*Asset) GetTransactionsRaw

func (asset *Asset) GetTransactionsRaw(offset, limit, txFilter int32, newestFirst bool, txHashSearch string) (transactions []*sharedW.Transaction, err error)

func (*Asset) GetUnsignedTx

func (asset *Asset) GetUnsignedTx() *TxAuthor

func (*Asset) GetWalletBalance added in v1.1.0

func (asset *Asset) GetWalletBalance() (*sharedW.Balance, error)

GetWalletBalance returns the total balance across all accounts.

func (*Asset) GetvspPolicy added in v1.0.1

func (asset *Asset) GetvspPolicy(account int32) vsp.Policy

GetvspPolicy creates the VSP policy using the account number provided. Uses the user-specified instructions for processing fee payments on a ticket, rather than some default policy.

func (*Asset) HDPathForAccount

func (asset *Asset) HDPathForAccount(accountNumber int32) (string, error)

func (*Asset) HasAccount

func (asset *Asset) HasAccount(accountName string) bool

func (*Asset) HaveAddress

func (asset *Asset) HaveAddress(address string) bool

func (*Asset) IndexTransactions

func (asset *Asset) IndexTransactions() error

func (*Asset) IsAccountMixerActive

func (asset *Asset) IsAccountMixerActive() bool

IsAccountMixerActive returns true if account mixer is active

func (*Asset) IsAddressDiscovering added in v1.1.2

func (asset *Asset) IsAddressDiscovering() bool

func (*Asset) IsAddressValid

func (asset *Asset) IsAddressValid(address string) bool

func (*Asset) IsAutoTicketsPurchaseActive

func (asset *Asset) IsAutoTicketsPurchaseActive() bool

IsAutoTicketsPurchaseActive returns true if ticket buyer is active.

func (*Asset) IsConnectedToDecredNetwork

func (asset *Asset) IsConnectedToDecredNetwork() bool

func (*Asset) IsConnectedToNetwork

func (asset *Asset) IsConnectedToNetwork() bool

func (*Asset) IsRescanning

func (asset *Asset) IsRescanning() bool

func (*Asset) IsSycnRescanning added in v1.1.2

func (asset *Asset) IsSycnRescanning() bool

func (*Asset) IsSyncProgressListenerRegisteredFor

func (asset *Asset) IsSyncProgressListenerRegisteredFor(uniqueIdentifier string) bool

func (*Asset) IsSyncShuttingDown

func (asset *Asset) IsSyncShuttingDown() bool

func (*Asset) IsSynced

func (asset *Asset) IsSynced() bool

func (*Asset) IsSyncing

func (asset *Asset) IsSyncing() bool

func (*Asset) IsUnsignedTxExist

func (asset *Asset) IsUnsignedTxExist() bool

func (*Asset) IsWaiting

func (asset *Asset) IsWaiting() bool

func (*Asset) KnownVSPs

func (asset *Asset) KnownVSPs() []*VSP

KnownVSPs returns a list of known VSPs. This list may be updated by calling ReloadVSPList. This method is safe for concurrent access.

func (*Asset) LastUsedVSP

func (asset *Asset) LastUsedVSP() string

LastUsedVSP returns the host of the last used VSP, as saved by the SaveLastUsedVSP() method.

func (*Asset) MixedAccountNumber

func (asset *Asset) MixedAccountNumber() int32

func (*Asset) NewUnsignedTx

func (asset *Asset) NewUnsignedTx(sourceAccountNumber int32, utxos []*sharedW.UnspentOutput) error

func (*Asset) NextAccount

func (asset *Asset) NextAccount(accountName string) (int32, error)

func (*Asset) NextAddress

func (asset *Asset) NextAddress(account int32) (string, error)

NextAddress returns the address immediately following the last requested payment address. If that address has already been used to receive funds, the next chained address is returned.

func (*Asset) NextTicketPriceRemaining

func (asset *Asset) NextTicketPriceRemaining() (secs int64, err error)

NextTicketPriceRemaining returns the remaning time in seconds of a ticket for the next block, if secs equal 0 is imminent

func (*Asset) PeerInfo

func (asset *Asset) PeerInfo() (string, error)

func (*Asset) PeerInfoRaw

func (asset *Asset) PeerInfoRaw() ([]sharedW.PeerInfo, error)

func (*Asset) PublishLastSyncProgress

func (asset *Asset) PublishLastSyncProgress(uniqueIdentifier string) error

func (*Asset) PublishUnminedTransactions

func (asset *Asset) PublishUnminedTransactions() error

func (*Asset) PurchaseTickets

func (asset *Asset) PurchaseTickets(account, numTickets int32, vspHost, passphrase string, vspPubKey []byte) ([]*chainhash.Hash, error)

PurchaseTickets purchases tickets from the asset. Returns a slice of hashes for tickets purchased.

func (*Asset) ReadyToMix

func (asset *Asset) ReadyToMix(_ int) (bool, error)

func (*Asset) ReloadVSPList

func (asset *Asset) ReloadVSPList(ctx context.Context)

ReloadVSPList reloads the list of known VSPs. This method makes multiple network calls; should be called in a goroutine to prevent blocking the UI thread.

func (*Asset) RemoveAccountMixerNotificationListener

func (asset *Asset) RemoveAccountMixerNotificationListener(uniqueIdentifier string)

func (*Asset) RemoveChangeDestination

func (asset *Asset) RemoveChangeDestination()

func (*Asset) RemovePeers

func (asset *Asset) RemovePeers()

func (*Asset) RemoveSendDestination

func (asset *Asset) RemoveSendDestination(id int)

func (*Asset) RemoveSyncProgressListener

func (asset *Asset) RemoveSyncProgressListener(uniqueIdentifier string)

func (*Asset) RemoveTxAndBlockNotificationListener

func (asset *Asset) RemoveTxAndBlockNotificationListener(uniqueIdentifier string)

func (*Asset) RenameAccount

func (asset *Asset) RenameAccount(accountNumber int32, newName string) error

func (*Asset) RescanBlocks

func (asset *Asset) RescanBlocks() error

func (*Asset) RescanBlocksFromHeight

func (asset *Asset) RescanBlocksFromHeight(startHeight int32) error

func (*Asset) RestartSpvSync

func (asset *Asset) RestartSpvSync() error

func (*Asset) SafelyCancelSync

func (asset *Asset) SafelyCancelSync()

SafelyCancelSync is used to controllably disable network activity.

func (*Asset) SaveLastUsedVSP

func (asset *Asset) SaveLastUsedVSP(host string)

SaveLastUsedVSP saves the host of the last used VSP.

func (*Asset) SaveVSP

func (asset *Asset) SaveVSP(host string) (err error)

SaveVSP marks a VSP as known and will be susbequently included as part of known VSPs.

func (*Asset) SendDestination

func (asset *Asset) SendDestination(id int) *sharedW.TransactionDestination

func (*Asset) SetAccountMixerConfig

func (asset *Asset) SetAccountMixerConfig(mixedAccount, unmixedAccount int32, privPass string) error

SetAccountMixerConfig sets the config for mixed and unmixed account. Private passphrase is verifed for security even if not used. This function should be used with manual cspp mixer setup.

func (*Asset) SetAutoTicketsBuyerConfig

func (asset *Asset) SetAutoTicketsBuyerConfig(vspHost string, purchaseAccount int32, amountToMaintain int64)

SetAutoTicketsBuyerConfig sets ticket buyer config for the asset.

func (*Asset) SetBlocksRescanProgressListener

func (asset *Asset) SetBlocksRescanProgressListener(blocksRescanProgressListener *sharedW.BlocksRescanProgressListener)

func (*Asset) SetChangeDestination

func (asset *Asset) SetChangeDestination(address string)

func (*Asset) SetSpecificPeer

func (asset *Asset) SetSpecificPeer(addresses string)

func (*Asset) SetTreasuryPolicy

func (asset *Asset) SetTreasuryPolicy(PiKey, newVotingPolicy, tixHash string, passphrase string) error

SetTreasuryPolicy saves the voting policy for treasury spends by a particular PI key. If a ticket hash is provided, the voting policy is also updated with the VSP controlling the ticket. If a ticket hash isn't provided, the vote choice is saved to the local wallet database and the VSPs controlling all unspent, unexpired tickets are updated to use the specified vote policy.

func (*Asset) SetVoteChoice

func (asset *Asset) SetVoteChoice(agendaID, choiceID, hash, passphrase string) error

SetVoteChoice sets a voting choice for the specified agenda. If a ticket hash is provided, the voting choice is also updated with the VSP controlling the ticket. If a ticket hash isn't provided, the vote choice is saved to the local wallet database and the VSPs controlling all unspent, unexpired tickets are updated to use the specified vote choice.

func (*Asset) SignMessage

func (asset *Asset) SignMessage(passphrase, address, message string) ([]byte, error)

func (*Asset) SpendableForAccount

func (asset *Asset) SpendableForAccount(account int32) (int64, error)

func (*Asset) SpvSync

func (asset *Asset) SpvSync() error

func (*Asset) StakingOverview

func (asset *Asset) StakingOverview() (stOverview *StakingOverview, err error)

func (*Asset) StartAccountMixer

func (asset *Asset) StartAccountMixer(walletPassphrase string) error

StartAccountMixer starts the automatic account mixer

func (*Asset) StartTicketBuyer

func (asset *Asset) StartTicketBuyer(passphrase string) error

StartTicketBuyer starts the automatic ticket buyer. The wallet should already be configured with the required parameters using asset.SetAutoTicketsBuyerConfig().

func (*Asset) StopAccountMixer

func (asset *Asset) StopAccountMixer() error

StopAccountMixer stops the active account mixer

func (*Asset) StopAutoTicketsPurchase

func (asset *Asset) StopAutoTicketsPurchase() error

StopAutoTicketsPurchase stops the automatic ticket buyer.

func (*Asset) SyncData added in v1.1.0

func (asset *Asset) SyncData() *SyncData

func (*Asset) SyncInactiveForPeriod

func (asset *Asset) SyncInactiveForPeriod(totalInactiveSeconds int64)

func (*Asset) Synced

func (asset *Asset) Synced() bool

func (*Asset) TicketBuyerConfigIsSet

func (asset *Asset) TicketBuyerConfigIsSet() bool

TicketBuyerConfigIsSet checks if ticket buyer config is set for the asset.

func (*Asset) TicketExpiry

func (asset *Asset) TicketExpiry() int32

func (*Asset) TicketHasVotedOrRevoked

func (asset *Asset) TicketHasVotedOrRevoked(ticketHash string) (bool, error)

func (*Asset) TicketMaturity

func (asset *Asset) TicketMaturity() int32

func (*Asset) TicketPrice

func (asset *Asset) TicketPrice() (*TicketPriceResponse, error)

TicketPrice returns the price of a ticket for the next block, also known as the stake difficulty. May be incorrect if blockchain sync is ongoing or if blockchain is not up-to-date.

func (*Asset) TicketSpender

func (asset *Asset) TicketSpender(ticketHash string) (*sharedW.Transaction, error)

func (*Asset) ToAmount

func (asset *Asset) ToAmount(v int64) sharedW.AssetAmount

Returns a DCR amount that implements the asset amount interface.

func (*Asset) TotalSendAmount

func (asset *Asset) TotalSendAmount() *sharedW.Amount

func (*Asset) TotalStakingRewards

func (asset *Asset) TotalStakingRewards() (int64, error)

func (*Asset) TransactionOverview

func (asset *Asset) TransactionOverview() (txOverview *sharedW.TransactionOverview, err error)

func (*Asset) TreasuryPolicies

func (asset *Asset) TreasuryPolicies(PiKey, tixHash string) ([]*TreasuryKeyPolicy, error)

TreasuryPolicies returns saved voting policies for treasury spends per pi key. If a pi key is specified, the policy for that pi key is returned; otherwise the policies for all pi keys are returned. If a ticket hash is provided, the policy(ies) for that ticket is/are returned.

func (*Asset) TxMatchesFilter

func (asset *Asset) TxMatchesFilter(tx *sharedW.Transaction, txFilter int32) bool

func (*Asset) TxMatchesFilter2

func (asset *Asset) TxMatchesFilter2(direction, blockHeight int32, txType, ticketSpender string, txFilter int32) bool

func (*Asset) UnmixedAccountNumber

func (asset *Asset) UnmixedAccountNumber() int32

func (*Asset) UnspentOutputs

func (asset *Asset) UnspentOutputs(account int32) ([]*sharedW.UnspentOutput, error)

UnspentOutputs returns unspent outputs that can be used for transactions. Unspent outputs that are locked by the wallet are not returned as valid unspent utxos.

func (*Asset) UnspentUnexpiredTickets

func (asset *Asset) UnspentUnexpiredTickets() ([]*sharedW.Transaction, error)

UnspentUnexpiredTickets returns all Unmined, Immature and Live tickets.

func (*Asset) UpdateSendDestination

func (asset *Asset) UpdateSendDestination(id int, address string, atomAmount int64, sendMax bool) error

func (*Asset) VSPClient

func (asset *Asset) VSPClient(host string, pubKey []byte) (*vsp.Client, error)

VSPClient loads or creates a VSP client instance for the specified host.

func (*Asset) VSPTicketInfo

func (asset *Asset) VSPTicketInfo(hash string) (*VSPTicketInfo, error)

VSPTicketInfo returns vsp-related info for a given ticket. Returns an error if the ticket is not yet assigned to a VSP.

func (*Asset) VerifyMessage

func (asset *Asset) VerifyMessage(address, message, signatureBase64 string) (bool, error)

type CSPPConfig

type CSPPConfig struct {
	CSPPServer         string
	DialCSPPServer     func(ctx context.Context, network, addr string) (net.Conn, error)
	MixedAccount       uint32
	MixedAccountBranch uint32
	TicketSplitAccount uint32
	ChangeAccount      uint32
}

type DEXWallet added in v1.1.0

type DEXWallet struct {
	// contains filtered or unexported fields
}

DEXWallet wraps *Asset and implements dexdcr.Wallet.

func NewDEXWallet added in v1.1.0

func NewDEXWallet(w *dcrwallet.Wallet, helper WalletHelper, tradingAccountNumber int32, syncData *SyncData) *DEXWallet

NewDEXWallet returns a new *DEXWallet.

func (*DEXWallet) AccountBalance added in v1.1.0

func (dw *DEXWallet) AccountBalance(ctx context.Context, confirms int32, accountName string) (*walletjson.GetAccountBalanceResult, error)

AccountBalance returns the balance breakdown for the specified account. Part of the Wallet interface.

func (*DEXWallet) AccountOwnsAddress added in v1.1.0

func (dw *DEXWallet) AccountOwnsAddress(ctx context.Context, addr stdaddr.Address, acctName string) (bool, error)

AccountOwnsAddress checks if the provided address belongs to the specified account. Part of the Wallet interface.

func (*DEXWallet) AccountUnlocked added in v1.1.0

func (dw *DEXWallet) AccountUnlocked(_ context.Context, _ string) (bool, error)

AccountUnlocked returns true if the account is unlocked. Part of the Wallet interface.

func (*DEXWallet) Accounts added in v1.1.0

func (dw *DEXWallet) Accounts() dexdcr.XCWalletAccounts

Accounts returns the names of the accounts for use by the exchange wallet.

func (*DEXWallet) AddressInfo added in v1.1.0

func (dw *DEXWallet) AddressInfo(ctx context.Context, address string) (*dexdcr.AddressInfo, error)

AddressInfo returns information for the provided address. It is an error if the address is not owned by the wallet. Part of the Wallet interface.

func (*DEXWallet) AddressPrivKey added in v1.1.0

func (dw *DEXWallet) AddressPrivKey(ctx context.Context, addr stdaddr.Address) (*secp256k1.PrivateKey, error)

AddressPrivKey fetches the privkey for the specified address. Part of the Wallet interface.

func (*DEXWallet) Connect added in v1.1.0

func (dw *DEXWallet) Connect(_ context.Context) error

Connect establishes a connection to the wallet. Part of the Wallet interface.

func (*DEXWallet) Disconnect added in v1.1.0

func (dw *DEXWallet) Disconnect()

Disconnect shuts down access to the wallet. Part of the Wallet interface.

func (*DEXWallet) ExternalAddress added in v1.1.0

func (dw *DEXWallet) ExternalAddress(ctx context.Context, accountName string) (stdaddr.Address, error)

ExternalAddress returns an external address using GapPolicyIgnore. Part of the Wallet interface. Using GapPolicyWrap here, introducing a relatively small risk of address reuse, but improving wallet recoverability.

func (*DEXWallet) GetBestBlock added in v1.1.0

func (dw *DEXWallet) GetBestBlock(ctx context.Context) (*chainhash.Hash, int64, error)

GetBestBlock returns the hash and height of the wallet's best block. Part of the Wallet interface.

func (*DEXWallet) GetBlock added in v1.1.0

func (dw *DEXWallet) GetBlock(ctx context.Context, blockHash *chainhash.Hash) (*wire.MsgBlock, error)

GetBlock returns the *wire.MsgBlock. Part of the Wallet interface.

func (*DEXWallet) GetBlockHash added in v1.1.0

func (dw *DEXWallet) GetBlockHash(ctx context.Context, blockHeight int64) (*chainhash.Hash, error)

GetBlockHash returns the hash of the mainchain block at the specified height. Part of the Wallet interface.

func (*DEXWallet) GetBlockHeader added in v1.1.0

func (dw *DEXWallet) GetBlockHeader(ctx context.Context, blockHash *chainhash.Hash) (*dexdcr.BlockHeader, error)

GetBlockHeader generates a *BlockHeader for the specified block hash. The returned block header is a wire.BlockHeader with the addition of the block's median time. Part of the Wallet interface.

func (*DEXWallet) GetRawTransaction added in v1.1.0

func (dw *DEXWallet) GetRawTransaction(ctx context.Context, txHash *chainhash.Hash) (*wire.MsgTx, error)

GetRawTransaction returns details of the tx with the provided hash. Returns dw.wallet. CoinNotFoundError if the tx is not found. Part of the Wallet interface.

func (*DEXWallet) GetTransaction added in v1.1.0

func (dw *DEXWallet) GetTransaction(ctx context.Context, txHash *chainhash.Hash) (*dexdcr.WalletTransaction, error)

GetTransaction returns the details of a wallet tx, if the wallet contains a tx with the provided hash. Returns dw.wallet. CoinNotFoundError if the tx is not found in the wallet.

func (*DEXWallet) InternalAddress added in v1.1.0

func (dw *DEXWallet) InternalAddress(ctx context.Context, accountName string) (stdaddr.Address, error)

InternalAddress returns an internal address using GapPolicyIgnore. Part of the Wallet interface.

func (*DEXWallet) ListSinceBlock added in v1.1.2

func (dw *DEXWallet) ListSinceBlock(ctx context.Context, start, end, syncHeight int32) ([]walletjson.ListTransactionsResult, error)

func (*DEXWallet) LockAccount added in v1.1.0

func (dw *DEXWallet) LockAccount(_ context.Context, _ string) error

LockAccount locks the specified account. Part of the Wallet interface.

func (*DEXWallet) LockUnspent added in v1.1.0

func (dw *DEXWallet) LockUnspent(_ context.Context, unlock bool, ops []*wire.OutPoint) error

LockUnspent locks or unlocks the specified outpoint. Part of the Wallet interface.

func (*DEXWallet) LockedOutputs added in v1.1.0

func (dw *DEXWallet) LockedOutputs(ctx context.Context, accountName string) ([]chainjson.TransactionInput, error)

LockedOutputs fetches locked outputs for the Wallet. Part of the Wallet interface.

func (*DEXWallet) MatchAnyScript added in v1.1.0

func (dw *DEXWallet) MatchAnyScript(ctx context.Context, blockHash *chainhash.Hash, scripts [][]byte) (bool, error)

MatchAnyScript looks for any of the provided scripts in the block specified. Part of the Wallet interface.

func (*DEXWallet) NotifyOnTipChange added in v1.1.0

func (dw *DEXWallet) NotifyOnTipChange(_ context.Context, _ dexdcr.TipChangeCallback) bool

NotifyOnTipChange is not used, in favor of the tipNotifier pattern. See: https://github.com/decred/dcrdex/blob/master/client/asset/dcr/spv.go#513. Part of the Wallet interface.

func (*DEXWallet) PeerCount added in v1.1.0

func (dw *DEXWallet) PeerCount(_ context.Context) (uint32, error)

PeerCount returns the number of network peers to which the wallet or its backing node are connected. Part of the Wallet interface.

func (*DEXWallet) PurchaseTickets added in v1.1.0

func (dw *DEXWallet) PurchaseTickets(_ context.Context, _ int, _, _ string) ([]*dexasset.Ticket, error)

PurchaseTickets purchases n tickets. vspHost and vspPubKey only needed for internal wallets.

func (*DEXWallet) Reconfigure added in v1.1.0

func (dw *DEXWallet) Reconfigure(_ context.Context, _ *dexasset.WalletConfig, _ dex.Network, _ string) (restart bool, err error)

Part of the Wallet interface.

func (*DEXWallet) SendRawTransaction added in v1.1.0

func (dw *DEXWallet) SendRawTransaction(ctx context.Context, tx *wire.MsgTx, _ bool) (*chainhash.Hash, error)

SendRawTransaction broadcasts the provided transaction to the Decred network. Part of the Wallet interface.

func (*DEXWallet) SetTxFee added in v1.1.0

func (dw *DEXWallet) SetTxFee(_ context.Context, _ dcrutil.Amount) error

func (*DEXWallet) SetVotingPreferences added in v1.1.0

func (dw *DEXWallet) SetVotingPreferences(_ context.Context, _, _, _ map[string]string) error

SetVotingPreferences sets preferences used when a ticket is chosen to be voted on.

func (*DEXWallet) SignRawTransaction added in v1.1.0

func (dw *DEXWallet) SignRawTransaction(ctx context.Context, baseTx *wire.MsgTx) (*wire.MsgTx, error)

SignRawTransaction signs the provided transaction. SignRawTransaction is not used for redemptions, so previous outpoints and scripts should be known by the wallet. SignRawTransaction should not mutate the input transaction. Part of the Wallet interface.

func (*DEXWallet) SpvMode added in v1.1.0

func (dw *DEXWallet) SpvMode() bool

SpvMode returns true if the wallet is connected to the Decred network via SPV peers. Part of the Wallet interface.

func (*DEXWallet) StakeInfo added in v1.1.0

func (dw *DEXWallet) StakeInfo(_ context.Context) (*dcrwallet.StakeInfoData, error)

func (*DEXWallet) SyncStatus added in v1.1.0

func (dw *DEXWallet) SyncStatus(_ context.Context) (synced bool, progress float32, err error)

SyncStatus returns the wallet's sync status. Part of the Wallet interface.

func (*DEXWallet) Tickets added in v1.1.0

func (dw *DEXWallet) Tickets(_ context.Context) ([]*dexasset.Ticket, error)

Tickets returns current active ticket hashes up until they are voted or revoked. Includes unconfirmed tickets.

func (*DEXWallet) UnlockAccount added in v1.1.0

func (dw *DEXWallet) UnlockAccount(ctx context.Context, pass []byte, _ string) error

UnlockAccount unlocks the specified account or the wallet if account is not encrypted. Part of the Wallet interface.

func (*DEXWallet) UnspentOutput added in v1.1.0

func (dw *DEXWallet) UnspentOutput(ctx context.Context, txHash *chainhash.Hash, index uint32, _ int8) (*dexdcr.TxOutput, error)

UnspentOutput returns information about an unspent tx output, if found and unspent. Use wire.TxTreeUnknown if the output tree is unknown, the correct tree will be returned if the unspent output is found. This method is only guaranteed to return results for outputs that pay to the wallet, although wallets connected to a full node may return results for non-wallet outputs. Returns dw.wallet.CoinNotFoundError if the unspent output cannot be located. Part of the Wallet interface.

func (*DEXWallet) Unspents added in v1.1.0

func (dw *DEXWallet) Unspents(ctx context.Context, accountName string) ([]*walletjson.ListUnspentResult, error)

Unspents fetches unspent outputs for the Wallet. Part of the Wallet interface.

func (*DEXWallet) VotingPreferences added in v1.1.0

VotingPreferences returns current voting preferences.

type DcrdataAgenda

type DcrdataAgenda struct {
	Name          string `json:"name"`
	Description   string `json:"-"`
	Status        string `json:"status"`
	VotingStarted int64  `json:"-"`
	VotingDone    int64  `json:"-"`
	Activated     int64  `json:"-"`
	HardForked    int64  `json:"-"`
	StartTime     string `json:"-"`
	ExpireTime    string `json:"-"`
	VoteVersion   uint32 `json:"-"`
	Mask          uint16 `json:"-"`
}

DcrdataAgenda models agenda information for the active network from the dcrdata api https://dcrdata.decred.org/api/agendas for mainnet or https://testnet.decred.org/api/agendas for testnet.

type StakingOverview

type StakingOverview struct {
	All      int
	Unmined  int
	Immature int
	Live     int
	Voted    int
	Revoked  int
	Expired  int
}

type SyncData

type SyncData struct {
	// contains filtered or unexported fields
}

reading/writing of properties of this struct are protected by mutex.x

type TicketBuyerConfig

type TicketBuyerConfig struct {
	VspHost           string
	PurchaseAccount   int32
	BalanceToMaintain int64

	VspClient *vsp.Client
}

TicketBuyerConfig defines configuration parameters for running an automated ticket buyer.

type TicketPriceResponse

type TicketPriceResponse struct {
	TicketPrice int64
	Height      int32
}

type TreasuryKeyPolicy

type TreasuryKeyPolicy struct {
	PiKey      string `json:"pi_key"`
	TicketHash string `json:"ticket_hash"` // nil unless for per-ticket VSP policies
	Policy     string `json:"policy"`
}

TreasuryKeyPolicy records the voting policy for treasury spend transactions by a particular key, and possibly for a particular ticket being voted on by a VSP.

type TxAuthor

type TxAuthor struct {
	// contains filtered or unexported fields
}

type VSP

type VSP struct {
	Host string
	*VspInfoResponse
}

type VSPFeeStatus

type VSPFeeStatus uint8

VSPFeeStatus represents the current fee status of a ticket.

const (
	// VSPFeeProcessStarted represents the state which process has being
	// called but fee still not paid.
	VSPFeeProcessStarted VSPFeeStatus = iota
	// VSPFeeProcessPaid represents the state where the process has being
	// paid, but not published.
	VSPFeeProcessPaid
	VSPFeeProcessErrored
	// VSPFeeProcessConfirmed represents the state where the fee has been
	// confirmed by the VSP.
	VSPFeeProcessConfirmed
)

func (VSPFeeStatus) String

func (status VSPFeeStatus) String() string

String returns a human-readable interpretation of the vsp fee status.

type VSPTicketInfo

type VSPTicketInfo struct {
	VSP         string
	FeeTxHash   string
	FeeTxStatus VSPFeeStatus
	// Client defines the vsp client needed to process more tickets requests.
	Client *vsp.Client
	// ConfirmedByVSP is nil if the ticket status could not be obtained
	// from the VSP, false if the VSP hasn't confirmed the fee and true
	// if the VSP has fully registered the ticket.
	ConfirmedByVSP bool
	// VoteChoices is only set if the ticket status was obtained from the
	// VSP.
	VoteChoices map[string]string
}

VSPTicketInfo is information about a ticket that is assigned to a VSP.

type VspInfoResponse

type VspInfoResponse struct {
	APIVersions   []int64 `json:"apiversions"`
	Timestamp     int64   `json:"timestamp"`
	PubKey        []byte  `json:"pubkey"`
	FeePercentage float64 `json:"feepercentage"`
	VspClosed     bool    `json:"vspclosed"`
	Network       string  `json:"network"`
	VspdVersion   string  `json:"vspdversion"`
	Voting        int64   `json:"voting"`
	Voted         int64   `json:"voted"`
	Revoked       int64   `json:"revoked"`
}

* begin vspd-related types

type WalletHelper added in v1.1.2

type WalletHelper interface {
	IsAccountMixerActive() bool
	UnmixedAccountNumber() int32
	MixedAccountNumber() int32
}

type WalletsIterator

type WalletsIterator struct {
	CurrentIndex int
	Wallets      []*Asset
}

func (*WalletsIterator) Next

func (walletsIterator *WalletsIterator) Next() *Asset

func (*WalletsIterator) Reset

func (walletsIterator *WalletsIterator) Reset()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL