Documentation ¶
Index ¶
- Constants
- Variables
- func BuySplitTicket(ctx context.Context, cfg *Config) error
- func DefaultConfigFileExists() bool
- func InitConfigFromDcrwallet() error
- func InitConfigFromDecrediton(walletName, poolHost string) error
- func InitDefaultConfig() error
- func ListDecreditonWalletStakepools(walletName string) []string
- func ListDecreditonWallets() []string
- func WatchMatcherWaitingList(ctx context.Context, matcherHost string, certFile string, ...) error
- type Config
- type LoggerMiddleware
- type MatcherClientConn
- type NullReporter
- type Reporter
- type Session
- type SessionWriter
- type Stage
- type WalletClientConn
- type WriterReporter
Constants ¶
const (
// ReporterCtxKey is the key to use when passing a reporter via context
ReporterCtxKey = reporterCtxKey(1)
)
Variables ¶
var ( // ErrHelpRequested is the error returned when the help command line option // was requested ErrHelpRequested = fmt.Errorf("help requested") // ErrVersionRequested is the error returned when the version command line // option was requested ErrVersionRequested = fmt.Errorf("version requested") // ErrEmptyPassword is the error returned when an empty password has been // provided in the config ErrEmptyPassword = fmt.Errorf("empty password") )
Functions ¶
func BuySplitTicket ¶
BuySplitTicket performs the whole split ticket purchase process, given the config provided. The context may be canceled at any time to abort the session.
func DefaultConfigFileExists ¶ added in v0.4.6
func DefaultConfigFileExists() bool
DefaultConfigFileExists checks whether the default config file for the buyer exists for the current user
func InitConfigFromDcrwallet ¶ added in v0.4.6
func InitConfigFromDcrwallet() error
InitConfigFromDcrwallet inits a config based on whatever is stored in the dcrwallet.conf file. This replaces any existing configuration.
func InitConfigFromDecrediton ¶ added in v0.4.6
InitConfigFromDecrediton replaces the config with the default one plus all available entries read from an installed decrediton. Requires a decrediton version >= 1.2.0.
The data for the given walletName (of the currently selected network) will be used.
func InitDefaultConfig ¶ added in v0.4.6
func InitDefaultConfig() error
InitDefaultConfig replaces the current config (if it exists) with the factory default config.
func ListDecreditonWalletStakepools ¶ added in v0.5.1
ListDecreditonWalletStakepools lists the stakepools configured for the given decrediton wallet.
func ListDecreditonWallets ¶ added in v0.4.6
func ListDecreditonWallets() []string
ListDecreditonWallets returns the names of the available decrediton wallets. Returns nil if decrediton isn't installed or not initialized.
func WatchMatcherWaitingList ¶ added in v0.4.6
func WatchMatcherWaitingList(ctx context.Context, matcherHost string, certFile string, watcher waitingListWatcher) error
WatchMatcherWaitingList will watch the waiting list queues of the matcher given by the arguments, until the context is Done or the matcher sends an error. Whenever the waiting list changes, the changesChan receives a list with the current queues.
Types ¶
type Config ¶ added in v0.5.1
type Config struct { ConfigFile string `short:"C" long:"configfile" description:"Path to config file"` WalletCertFile string `long:"wallet.certfile" description:"Path Wallet rpc.cert file"` WalletHost string `` /* 136-byte string literal not displayed */ Pass string `short:"P" long:"pass" description:"Passphrase to unlock the wallet"` MatcherHost string `long:"matcher.host" description:"Address of the matcher host"` MaxAmount float64 `long:"maxamount" description:"Maximum participation amount"` SourceAccount uint32 `long:"sourceaccount" description:"Source account of funds for purchase"` SStxFeeLimits uint16 `long:"sstxfeelimits" description:"Fee limit allowance for sstx purchases"` VoteAddress string `long:"voteaddress" description:"Voting address of the stakepool"` PoolAddress string `long:"pooladdress" description:"Pool fee address of the stakepool"` PoolFeeRate float64 `long:"poolfeerate" description:"Pool fee rate (percentage) that the given pool has advertised as using"` TestNet bool `long:"testnet" description:"Whether this is connecting to a testnet wallet/matcher service"` SimNet bool `long:"simnet" description:"Whether this is connecting to a simnet wallet/matcher service"` MaxTime int `long:"maxtime" description:"Maximum amount of time (in seconds) to wait for the completion of the split buy"` MaxWaitTime int `long:"maxwaittime" description:"Maximum amount of time (in seconds) to wait until a new split ticket session is initiated"` DataDir string `long:"datadir" description:"Directory where session data files are stored"` MatcherCertFile string `long:"matchercertfile" description:"Location of the certificate file for connecting to the grpc matcher service"` SessionName string `long:"sessionname" description:"Name of the session to connect to. Leave blank to connect to the public matching session."` DcrdHost string `long:"dcrdhost" description:"Host of the dcrd daemon"` DcrdUser string `long:"dcrduser" description:"Username of the dcrd daemon"` DcrdPass string `long:"dcrpass" description:"Password of the dcrd daemon"` DcrdCert string `long:"dcrdcert" description:"Location of the certificate for the dcrd daemon"` SkipWaitPublishedTxs bool `` /* 166-byte string literal not displayed */ ShowVersion bool `long:"version" description:"Show version and quit"` SkipReportErrorsToSvc bool `long:"skipreporterrorstosvc" description:"Skip sending buyer errors that happen during the session to the service"` UtxosFromDcrdata bool `long:"utxosfromdcrdata" description:"Fetch utxo information of other participants from dcrdata instead of dcrd"` DcrdataURL string `` /* 135-byte string literal not displayed */ Passphrase []byte ChainParams *chaincfg.Params // WalletConn is an alternative way of issuing wallet commands. When // specified, instead of opening a direct grpc connection to the wallet, the // buyer will relay all network-related calls to this object. WalletConn WalletClientConn // MatcherConn is an alternative way of issuing matcher commands. When // specified, instead of opening a direct grpc connection to the matcher, // the buyer will relay all network-related calls to this object. MatcherConn MatcherClientConn // SaveSessionWriter is an alternative way of saving session data of // completed sessions. If specified, it will be used instead of directly // saving to a file. SaveSessionWriter SessionWriter }
Config stores the configuration needed to perform a single ticket split session as a buyer.
func LoadConfig ¶
LoadConfig parses command line arguments, the config file (either the default one or the one specificed with the -C option), merges the settings and returns a new BuyerConfig object for use in a split ticket buying session
func (*Config) ReadPassphrase ¶ added in v0.5.1
ReadPassphrase reads the passphrase from stdin (if needed), fills the PassPhrase field and clears the Pass field
type LoggerMiddleware ¶ added in v0.5.2
type LoggerMiddleware struct {
// contains filtered or unexported fields
}
LoggerMiddleware allows to log both to a file and standard output
func NewLoggerMiddleware ¶ added in v0.5.2
func NewLoggerMiddleware(w io.Writer, logDir string) *LoggerMiddleware
NewLoggerMiddleware returns a new middleware to write to both a log file and the standard log reporing output
type MatcherClientConn ¶ added in v0.7.5
type MatcherClientConn interface { pb.SplitTicketMatcherServiceClient Close() // FetchSpentUtxos should fetch the utxos being spent by the provided // transaction (ie. the outpoints for every input of the argument) and // return the utxo map. FetchSpentUtxos(*wire.MsgTx) (splitticket.UtxoMap, error) }
MatcherClientConn is an interface defining the functions needed on a remote matcher service.
type NullReporter ¶
type NullReporter struct{}
NullReporter is a dummy reporter that never outputs anything.
type Reporter ¶
type Reporter interface {
// contains filtered or unexported methods
}
Reporter is an interface that must be implemented to report status of a buyer session during its progress.
type Session ¶ added in v0.5.1
type Session struct { ID matcher.ParticipantID Amount dcrutil.Amount Fee dcrutil.Amount PoolFee dcrutil.Amount TicketPrice dcrutil.Amount // contains filtered or unexported fields }
Session is the structure that stores data for a single split ticket session in progress.
type SessionWriter ¶ added in v0.7.5
type SessionWriter interface { io.Writer StartWritingSession(ticketHash string) SessionWritingFinished() }
SessionWriter is an interface defining the methods needed for writing information of a successful ticket session to disk.
type Stage ¶ added in v0.5.1
type Stage int32
Stage represents a single stage of the full ticket buying process.
const ( StageUnknown Stage = iota StageStarting StageConnectingToMatcher StageConnectingToDcrd StageConnectingToDcrdata StageConnectingToWallet StageFindingMatches StageMatchesFound StageGeneratingOutputs StageGenerateSplitOutputAddr StageGenerateTicketCommitmentAddr StageGenerateSplitInputs StageOutputsGenerated StageGeneratingTicket StageTicketGenerated StageSigningTicket StageTicketSigned StageSigningRevocation StageRevocationSigned StageFundingTicket StageTicketFunded StageSigningSplitTx StageSplitTxSigned StageFundingSplitTx StageSplitTxFunded StageSkippedWaiting StageWaitingPublishedTxs StageSessionEndedSuccessfully )
Following are the various stages the buyer can be in. They may not necessarily pass through all of these stages.
type WalletClientConn ¶ added in v0.7.5
type WalletClientConn interface { Ping(ctx context.Context, in *pb.PingRequest, opts ...grpc.CallOption) (*pb.PingResponse, error) Network(ctx context.Context, in *pb.NetworkRequest, opts ...grpc.CallOption) (*pb.NetworkResponse, error) NextAddress(ctx context.Context, in *pb.NextAddressRequest, opts ...grpc.CallOption) (*pb.NextAddressResponse, error) ConstructTransaction(ctx context.Context, in *pb.ConstructTransactionRequest, opts ...grpc.CallOption) (*pb.ConstructTransactionResponse, error) SignTransactions(ctx context.Context, in *pb.SignTransactionsRequest, opts ...grpc.CallOption) (*pb.SignTransactionsResponse, error) ValidateAddress(ctx context.Context, in *pb.ValidateAddressRequest, opts ...grpc.CallOption) (*pb.ValidateAddressResponse, error) SignMessage(ctx context.Context, in *pb.SignMessageRequest, opts ...grpc.CallOption) (*pb.SignMessageResponse, error) BestBlock(ctx context.Context, in *pb.BestBlockRequest, opts ...grpc.CallOption) (*pb.BestBlockResponse, error) TicketPrice(ctx context.Context, in *pb.TicketPriceRequest, opts ...grpc.CallOption) (*pb.TicketPriceResponse, error) MonitorForSessionTransactions(ctx context.Context, splitTxHash *chainhash.Hash, ticketsHashes []*chainhash.Hash) error PublishedSplitTx() bool PublishedTicketTx() *chainhash.Hash Close() error }
WalletClientConn is an interface defining the functions needed by the buyer by a remote wallet.
type WriterReporter ¶ added in v0.5.1
type WriterReporter struct {
// contains filtered or unexported fields
}
WriterReporter implements the BuyerReporter interface by generating descriptive messages to a writer
func NewWriterReporter ¶ added in v0.4.6
func NewWriterReporter(w io.Writer, sessionName string) *WriterReporter
NewWriterReporter returns a reporter that writes into stdout
func (*WriterReporter) WaitingListChanged ¶ added in v0.5.1
func (rep *WriterReporter) WaitingListChanged(queues []matcher.WaitingQueue)
WaitingListChanged fulfills waitingListWatcher by outputting the changes