Documentation ¶
Index ¶
- Constants
- Variables
- func BTCChainParams(netType NetworkType) (*btccfg.Params, error)
- func DCRChainParams(netType NetworkType) (*dcrcfg.Params, error)
- func DecodeBase64(base64Text string) ([]byte, error)
- func EncodeBase64(text []byte) string
- func EncodeHex(hexBytes []byte) string
- func ErrBTCMethodNotImplemented(method string) error
- func ErrDCRMethodNotImplemented(method string) error
- func ErrLTCMethodNotImplemented(method string) error
- func ExtractDateOrTime(timestamp int64) string
- func FormatUTCShortTime(timestamp int64) string
- func FormatUTCTime(timestamp int64) string
- func GradientColorSchemes() map[AssetType]GradientColorScheme
- func HTTPRequest(reqConfig *ReqConfig, respObj interface{}) (*http.Response, error)
- func IsOnline() bool
- func LTCChainParams(netType NetworkType) (*ltccfg.Params, error)
- func NetDir(assetType AssetType, netType NetworkType) string
- func NormalizeAddress(addr string, defaultPort string) (string, error)
- func ShannonEntropy(text string) (entropy float64)
- func ShutdownHTTPClients()
- func TranslateError(err error) error
- func TranslateNetworkError(host string, errMsg error) error
- func TrimNonAphaNumeric(text string) string
- type AssetType
- type ChainsParams
- type Client
- type ColorScheme
- type Dailer
- type GradientColorScheme
- type HTTPAPIType
- type NetworkType
- type ProposalStatus
- type ReqConfig
- type SyncStage
Constants ¶
const ( LogFileName = "libwallet.log" NilAsset AssetType = "" BTCWalletAsset AssetType = "BTC" DCRWalletAsset AssetType = "DCR" LTCWalletAsset AssetType = "LTC" InvalidSyncStage SyncStage = -1 CFiltersFetchSyncStage SyncStage = 0 HeadersFetchSyncStage SyncStage = 1 AddressDiscoverySyncStage SyncStage = 2 HeadersRescanSyncStage SyncStage = 3 TxFilterAll int32 = 0 TxFilterSent int32 = 1 TxFilterReceived int32 = 2 TxFilterTransferred int32 = 3 TxFilterStaking int32 = 4 TxFilterCoinBase int32 = 5 TxFilterRegular int32 = 6 TxFilterMixed int32 = 7 TxFilterVoted int32 = 8 TxFilterRevoked int32 = 9 TxFilterImmature int32 = 10 TxFilterLive int32 = 11 TxFilterUnmined int32 = 12 TxFilterExpired int32 = 13 TxFilterTickets int32 = 14 TypeFilter = "Type" DirectionFilter = "Direction" HeightFilter = "BlockHeight" TicketSpenderFilter = "TicketSpender" LogLevelOff = "off" LogLevelTrace = "trace" LogLevelDebug = "debug" LogLevelInfo = "info" LogLevelWarn = "warn" LogLevelError = "error" LogLevelCritical = "critical" DefaultLogLevel = LogLevelInfo // UserFilePerm contains permissions for the user only. Attempting to modify // more permissions require a super user permission that isn't readily available. UserFilePerm = fs.FileMode(0o700) )
const ( // Error Codes ErrInsufficientBalance = "insufficient_balance" ErrInvalid = "invalid" ErrWalletLocked = "wallet_locked" ErrWalletDatabaseInUse = "wallet_db_in_use" ErrWalletNotLoaded = "wallet_not_loaded" ErrWalletNotFound = "wallet_not_found" ErrWalletNameExist = "wallet_name_exists" ErrReservedWalletName = "wallet_name_reserved" ErrWalletIsRestored = "wallet_is_restored" ErrWalletIsWatchOnly = "watch_only_wallet" ErrUnusableSeed = "unusable_seed" ErrPassphraseRequired = "passphrase_required" ErrInvalidPassphrase = "invalid_passphrase" ErrNotConnected = "not_connected" ErrExist = "exists" ErrNotExist = "not_exists" ErrEmptySeed = "empty_seed" ErrInvalidAddress = "invalid_address" ErrInvalidAuth = "invalid_auth" ErrContextCanceled = "context_canceled" ErrFailedPrecondition = "failed_precondition" ErrSyncAlreadyInProgress = "sync_already_in_progress" ErrNoPeers = "no_peers" ErrInvalidPeers = "invalid_peers" ErrListenerAlreadyExist = "listener_already_exist" ErrLoggerAlreadyRegistered = "logger_already_registered" ErrLogRotatorAlreadyInitialized = "log_rotator_already_initialized" ErrAddressDiscoveryNotDone = "address_discovery_not_done" ErrChangingPassphrase = "err_changing_passphrase" ErrSavingWallet = "err_saving_wallet" ErrIndexOutOfRange = "err_index_out_of_range" ErrNoMixableOutput = "err_no_mixable_output" ErrInvalidVoteBit = "err_invalid_vote_bit" ErrNotSynced = "err_not_synced" ErrNoSeed = "no_seed" )
Variables ¶
var ( ErrInvalidNet = errors.New("invalid network type found") ErrAssetUnknown = errors.New("unknown asset found") ErrBTCNotInitialized = errors.New("btc asset not initialized") ErrDCRNotInitialized = errors.New("dcr asset not initialized") ErrLTCNotInitialized = errors.New("ltc asset not initialized") ErrUnsupporttedIPV6Address = errors.New("IPv6 addresses unsupportted by the current network") ErrNetConnectionTimeout = errors.New("Timeout on network connection") ErrPeerConnectionRejected = errors.New("Peer connection rejected") )
var ( DCRmainnetParams = dcrcfg.MainNetParams() DCRtestnetParams = dcrcfg.TestNet3Params() DCRSimnetParams = dcrcfg.SimNetParams() DCRRegnetParams = dcrcfg.RegNetParams() BTCmainnetParams = &btccfg.MainNetParams BTCtestnetParams = &btccfg.TestNet3Params BTCSimnetParams = &btccfg.SimNetParams BTCRegnetParamsVal = btccfg.RegressionNetParams LTCmainnetParams = <ccfg.MainNetParams LTCtestnetParams = <ccfg.TestNet4Params LTCSimnetParams = <ccfg.SimNetParams LTCRegnetParamsVal = ltccfg.RegressionNetParams DCRDEXSimnetParams = dcrcfg.SimNetParams() BTCDEXRegnetParamsVal = btccfg.RegressionNetParams LTCDEXRegnetParamsVal = ltccfg.RegressionNetParams )
Functions ¶
func BTCChainParams ¶
func BTCChainParams(netType NetworkType) (*btccfg.Params, error)
BTCChainParams returns the network parameters from the BTC chain provided a given network.
func DCRChainParams ¶
func DCRChainParams(netType NetworkType) (*dcrcfg.Params, error)
DCRChainParams returns the network parameters from the DCR chain provided a given network.
func DecodeBase64 ¶
func EncodeBase64 ¶
func ExtractDateOrTime ¶
ExtractDateOrTime returns the date represented by the timestamp as a date string if the timestamp is over 24 hours ago. Otherwise, the time alone is returned as a string.
func FormatUTCShortTime ¶
func FormatUTCTime ¶
func GradientColorSchemes ¶
func GradientColorSchemes() map[AssetType]GradientColorScheme
func HTTPRequest ¶
HTTPRequest queries the API provided in the ReqConfig object and converts the returned json(Byte data) into an respObj interface. Returned http response body is usually empty because the http stream cannot be read twice.
func IsOnline ¶
func IsOnline() bool
IsOnline is a function to check whether an internet connection can be established. If established, IsOnline should return true otherwise IsOnline returns false.
func LTCChainParams ¶
func LTCChainParams(netType NetworkType) (*ltccfg.Params, error)
LTCChainParams returns the network parameters from the LTC chain provided a network type is given.
func NetDir ¶
func NetDir(assetType AssetType, netType NetworkType) string
NetDir returns data directory name for a given asset's type and network connected. If "unknown" is returned, unsupported asset type or network was detected.
func ShannonEntropy ¶
func ShutdownHTTPClients ¶
func ShutdownHTTPClients()
ShutdownHTTPClients shutdowns any active connection by cancelling the context.
func TranslateError ¶
todo, should update this method to translate more error kinds.
func TranslateNetworkError ¶
func TrimNonAphaNumeric ¶
TrimNonAphanumeric removes all the characters that don't include the following: `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-`
Types ¶
type AssetType ¶
type AssetType string
AssetType is the capitalized version of an asset's symbol (e.g BTC, DCR, LTC) that serves as the asset's unique identity.
func (AssetType) ToStringLower ¶
Stringer used in generating the directory path where the lowercase of the asset type is required. The uppercase defined by default is required to asset previously created using the uppercase.
type ChainsParams ¶
ChainsParams collectively defines the chain parameters of all assets supported.
func GetChainParams ¶
func GetChainParams(assetType AssetType, netType NetworkType) (*ChainsParams, error)
GetChainParams returns the network parameters of a chain provided its asset type and network type.
type ColorScheme ¶
type ColorScheme struct { R uint8 // Red Subpixel G uint8 // Green Subpixel B uint8 // Blue Subpixel O float64 // Opacity; value range 0-1 }
func (*ColorScheme) NRGBAColor ¶
func (c *ColorScheme) NRGBAColor() color.NRGBA
NRGBAColor converts figma color scheme to gioui nrgba color scheme.
type Dailer ¶
func DialerFunc ¶
DialerFunc returns a customized dialer function that is make it easier to control node level tcp connections especially after a shutdown. It also includes a timeout value preventing a connection waiting forever for a response to be returned.
type GradientColorScheme ¶
type GradientColorScheme struct { Color1 ColorScheme Color2 ColorScheme Blend1 float64 // percent of position along X axis where color1 blend ends. Blend2 float64 // percent of position along X axis where color2 blend ends. }
type HTTPAPIType ¶
type HTTPAPIType uint8
const ( // Below lists the Http APIs that have a privacy control implemented on them. GovernanceHTTPAPI HTTPAPIType = iota FeeRateHTTPAPI ExchangeHTTPAPI VspAPI UpdateAPI )
type NetworkType ¶
type NetworkType string
const ( Mainnet NetworkType = "mainnet" Testnet NetworkType = "testnet" Regression NetworkType = "regression" Simulation NetworkType = "simulation" DEXTest NetworkType = "dextest" Unknown NetworkType = "unknown" )
func ToNetworkType ¶
func ToNetworkType(str string) NetworkType
ToNetworkType maps the provided network string identifier to the available network type constants.
func (NetworkType) Display ¶
func (n NetworkType) Display() string
Display returns the title case network name to be displayed on the app UI.
type ProposalStatus ¶ added in v1.1.0
type ProposalStatus int
const ( ProposalStatusSynced ProposalStatus = iota ProposalStatusNewProposal ProposalStatusVoteStarted ProposalStatusVoteFinished )