server

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SessionCookieName is the name of the HTTP-only session cookie
	SessionCookieName = "webwallet_session"
	// CSRFCookieName is the name of the CSRF token cookie (readable by JS)
	CSRFCookieName = "webwallet_csrf"
	// CSRFHeaderName is the header name for CSRF token validation
	CSRFHeaderName = "X-CSRF-Token"
	// SessionMaxAge is the session timeout in seconds (24 hours)
	SessionMaxAge = 86400
)

Variables

View Source
var (
	// ErrParseCurrencyAmount is returned when the input is unable to be parsed
	// into a currency unit due to a malformed amount.
	ErrParseCurrencyAmount = errors.New("malformed amount")
	// ErrParseCurrencyInteger is returned when the input is unable to be parsed
	// into a currency unit due to a non-integer value.
	ErrParseCurrencyInteger = errors.New("non-integer number of hastings")
	// ErrParseCurrencyUnits is returned when the input is unable to be parsed
	// into a currency unit due to missing units.
	ErrParseCurrencyUnits = errors.New("amount is missing currency units. Currency units are case sensitive")
	// ErrNegativeCurrency is the error that is returned if performing an
	// operation results in a negative currency.
	ErrNegativeCurrency = errors.New("negative currency not allowed")
	// ErrUint64Overflow is the error that is returned if converting to a
	// unit64 would cause an overflow.
	ErrUint64Overflow = errors.New("cannot return the uint64 of this currency - result is an overflow")
	// ZeroCurrency defines a currency of value zero.
	ZeroCurrency = types.NewCurrency64(0)
)
View Source
var (
	UI lorca.UI
)

Functions

func AttachNode

func AttachNode(node *node.Node)

AttachNode attaches the node to the HTTP server.

func BuildSolanaAddress added in v1.1.0

func BuildSolanaAddress(encodedString string) (types.SolanaAddress, error)

func ClearSessionCookie added in v1.5.0

func ClearSessionCookie(w http.ResponseWriter)

ClearSessionCookie removes the session cookies

func CloseAllWallets added in v0.1.4

func CloseAllWallets() (err error)

CloseAllWallets closes all wallets and detaches them from the node.

func GetCSRFToken added in v1.5.0

func GetCSRFToken(sessionID string) string

GetCSRFToken returns the CSRF token for a session (to include in forms/headers)

func GetSessionFromRequest added in v1.5.0

func GetSessionFromRequest(req *http.Request) string

GetSessionFromRequest extracts session ID from cookie (preferred) or falls back to form/query param (legacy)

func IsRunning added in v0.1.4

func IsRunning() bool

IsRunning returns true when the server is running

func IsSessionExpired added in v1.5.0

func IsSessionExpired(sessionID string) bool

IsSessionExpired checks if a session has expired

func NewCurrencyStr

func NewCurrencyStr(amount string) (types.Currency, error)

NewCurrencyStr creates a Currency value from a supplied string with unit suffix. Valid unit suffixes are: H, pS, nS, uS, mS, SCP, KS, MS, GS, TS, SPF Unit Suffixes are case sensitive.

func SetSessionCookie added in v1.5.0

func SetSessionCookie(w http.ResponseWriter, sessionID string)

SetSessionCookie sets the session ID as an HTTP-only cookie

func StartHTTPServer

func StartHTTPServer(webWalletConfig *wwConfig.WebWalletConfig)

StartHTTPServer starts the HTTP server to serve the GUI.

func UpdateSessionActivity added in v1.5.0

func UpdateSessionActivity(sessionID string)

UpdateSessionActivity updates the last access time for a session

func ValidateCSRFToken added in v1.5.0

func ValidateCSRFToken(req *http.Request, sessionID string) bool

ValidateCSRFToken validates the CSRF token for state-changing requests

Types

type AllowanceResponse added in v1.4.0

type AllowanceResponse struct {
	Regular  types.SolanaTransportAllowance            `json:"regular"`
	Premined map[string]types.SolanaTransportAllowance `json:"premined"`
	Airdrop  *types.SolanaTransportAllowance           `json:"airdrop,omitempty"`
	History  []TransportHistoryRecord                  `json:"history"`
	Balance  interface{}                               `json:"balance"`
	CoinType string                                    `json:"coinType"`
}

type BalInfo added in v1.1.0

type BalInfo struct {
	SCP            float64
	SCPUnconfirmed float64
	SPFA           uint64
	SPFB           uint64
	Claim          float64
	Whale          string
}

type JSONMessage added in v1.1.0

type JSONMessage struct {
	Success bool        `json:"success"`
	Message interface{} `json:"message"`
}

func NewErrorMessage added in v1.1.0

func NewErrorMessage(message interface{}) JSONMessage

func NewSuccessMessage added in v1.1.0

func NewSuccessMessage(message interface{}) JSONMessage

type RestWallet added in v1.1.0

type RestWallet struct {
	Name         string
	LastModified time.Time
}

type Session

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

Session is a struct that tracks session settings

type SummarizedTransaction

type SummarizedTransaction struct {
	TxnID     string          `json:"txn_id"`
	Type      string          `json:"type"`
	Time      types.Timestamp `json:"time"`
	Confirmed string          `json:"confirmed"`
	Scp       float64         `json:"scp"`
	ScpFee    float64         `json:"scp_fee"`
	SpfA      float64         `json:"spfa"`
	SpfB      float64         `json:"spfb"`
}

SummarizedTransaction is a transaction that has been formatted for· humans to read.

func ComputeSummarizedTransactions

func ComputeSummarizedTransactions(pts []modules.ProcessedTransaction, blockHeight types.BlockHeight, wwallet modules.Wallet) ([]SummarizedTransaction, error)

ComputeSummarizedTransactions creates a set of SummarizedTransactions from a set of ProcessedTransactions.

type TransactionHistoryLine added in v0.2.0

type TransactionHistoryLine struct {
	TransactionID      string          `json:"transaction_id"`
	ShortTransactionID string          `json:"short_transaction_id"`
	Type               string          `json:"type"`
	Time               types.Timestamp `json:"time"`
	Amount             string          `json:"amount"`
	AmountSCP          float64         `json:"amount_scp"`
	AmountSPFA         float64         `json:"amount_spfa"`
	AmountSPFB         float64         `json:"amount_spfb"`
	Fee                string          `json:"fee"`
	FeeSCP             float64         `json:"fee_scp"`
	Confirmed          string          `json:"confirmed"`
}

type TransactionHistoryPage added in v0.2.0

type TransactionHistoryPage struct {
	TransactionHistoryLines []TransactionHistoryLine `json:"lines"`
	Current                 int                      `json:"current"`
	Total                   int                      `json:"total"`
}

type TransportHistoryRecord added in v1.4.0

type TransportHistoryRecord struct {
	BurnID  types.TransactionID         `json:"burn_id"`
	Status  types.SolanaTransportStatus `json:"status"`
	Amount  string                      `json:"currency"`
	Created types.Timestamp             `json:"created"`
}

type TxDetails added in v1.1.0

type TxDetails struct {
	Timestamp types.Timestamp
	TxID      types.TransactionID
	TxType    modules.TXType
	TxBlock   types.BlockHeight
	Inputs    []TxInput
	Outputs   []TxOutput
}

type TxInput added in v1.1.0

type TxInput struct {
	Value    types.Currency
	Address  types.UnlockHash
	FundType string
}

type TxOutput added in v1.1.0

type TxOutput struct {
	Value    types.Currency
	Address  types.UnlockHash
	FundType string
}

type Vote added in v1.3.0

type Vote struct {
	StartDate      time.Time    `json:"start_date"`
	EndDate        time.Time    `json:"end_date"`
	Title          string       `json:"title"`
	Description    string       `json:"description"`
	DescriptionURL string       `json:"description_url"`
	VotedFor       string       `json:"voted_for"`
	VoteOptions    []VoteOption `json:"vote_options"`
}

type VoteOption added in v1.3.0

type VoteOption struct {
	Description string `json:"description"`
	VoteAddress string `json:"vote_address"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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