mint

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 5 minutes
	CACHE_ITEM_TTL    = 60 * 5
	CACHE_ITEMS_LIMIT = 10000
	// 2MB
	REQUEST_BODY_SIZE_LIMIT = 2 * 1024 * 1024

	ACTIVE_KEYSET = "active_keyset_key"
	// 1 day
	KEYSET_TTL = 60 * 60 * 24
)
View Source
const (
	BOLT11_MINT_QUOTE_TOPIC = "bolt11_mint_quote_topic"
	BOLT11_MELT_QUOTE_TOPIC = "bolt11_melt_quote_topic"
	PROOF_STATE_TOPIC       = "proof_state_topic"
)
View Source
const (
	QuoteExpiryMins = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache() *Cache

func (*Cache) DeleteExpired

func (c *Cache) DeleteExpired()

func (*Cache) Get

func (c *Cache) Get(key string) ([]byte, bool)

func (*Cache) Set

func (c *Cache) Set(key string, item []byte, expiration time.Duration)

type CacheItem

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

type Client

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

func NewClient

func NewClient(conn *websocket.Conn, manager *WebsocketManager) *Client

type Config

type Config struct {
	RotateKeyset      bool
	Port              int
	MintPath          string
	InputFeePpk       uint
	MintInfo          MintInfo
	Limits            MintLimits
	LightningClient   lightning.Client
	EnableMPP         bool
	EnableAdminServer bool
	LogLevel          LogLevel
	// NOTE: using this value for testing
	MeltTimeout *time.Duration
}

type LogLevel

type LogLevel int
const (
	Info LogLevel = iota
	Debug
	Disable
)

type MeltMethodSettings

type MeltMethodSettings struct {
	MinAmount uint64
	MaxAmount uint64
}

type Mint

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

func LoadMint

func LoadMint(config Config) (*Mint, error)

func (*Mint) GetActiveKeyset

func (m *Mint) GetActiveKeyset() nut01.Keyset

func (*Mint) GetKeysetById

func (m *Mint) GetKeysetById(id string) (nut01.Keyset, error)

func (*Mint) GetMeltQuoteState

func (m *Mint) GetMeltQuoteState(ctx context.Context, quoteId string) (storage.MeltQuote, error)

GetMeltQuoteState returns the state of a melt quote. Used to check whether a melt quote has been paid.

func (*Mint) GetMintQuoteState

func (m *Mint) GetMintQuoteState(quoteId string) (storage.MintQuote, error)

GetMintQuoteState returns the state of a mint quote.

func (*Mint) IssuedEcash

func (m *Mint) IssuedEcash() (map[string]uint64, error)

func (*Mint) ListKeysets

func (m *Mint) ListKeysets() nut02.GetKeysetsResponse

func (*Mint) MeltTokens

func (m *Mint) MeltTokens(ctx context.Context, meltTokensRequest nut05.PostMeltBolt11Request) (storage.MeltQuote, error)

MeltTokens verifies whether proofs provided are valid and proceeds to attempt payment.

func (*Mint) MintTokens

func (m *Mint) MintTokens(mintTokensRequest nut04.PostMintBolt11Request) (cashu.BlindedSignatures, error)

MintTokens verifies whether the mint quote with id has been paid and proceeds to sign the blindedMessages and return the BlindedSignatures if it was paid.

func (*Mint) ProofsStateCheck

func (m *Mint) ProofsStateCheck(Ys []string) ([]nut07.ProofState, error)

func (*Mint) RedeemedEcash

func (m *Mint) RedeemedEcash() (map[string]uint64, error)

func (*Mint) RequestMeltQuote

func (m *Mint) RequestMeltQuote(meltQuoteRequest nut05.PostMeltQuoteBolt11Request) (storage.MeltQuote, error)

RequestMeltQuote will process a request to melt tokens and return a MeltQuote. A melt is requested by a wallet to request the mint to pay an invoice.

func (*Mint) RequestMintQuote

func (m *Mint) RequestMintQuote(mintQuoteRequest nut04.PostMintQuoteBolt11Request) (storage.MintQuote, error)

RequestMintQuote will process a request to mint tokens and returns a mint quote or an error. The request to mint a token is explained in NUT-04 here: https://github.com/cashubtc/nuts/blob/main/04.md.

func (*Mint) RestoreSignatures

func (m *Mint) RestoreSignatures(blindedMessages cashu.BlindedMessages) (cashu.BlindedMessages, cashu.BlindedSignatures, error)

func (Mint) RetrieveMintInfo

func (m Mint) RetrieveMintInfo() (nut06.MintInfo, error)

func (*Mint) RotateKeyset

func (m *Mint) RotateKeyset(fee uint) (*nut02.Keyset, error)

func (*Mint) SetMintInfo

func (m *Mint) SetMintInfo(mintInfo MintInfo)

func (*Mint) Shutdown

func (m *Mint) Shutdown() error

func (*Mint) Swap

func (m *Mint) Swap(proofs cashu.Proofs, blindedMessages cashu.BlindedMessages) (cashu.BlindedSignatures, error)

Swap will process a request to swap tokens. A swap requires a set of valid proofs and blinded messages. If valid, the mint will sign the blindedMessages and invalidate the proofs that were used as input. It returns the BlindedSignatures.

func (*Mint) TotalBalance

func (m *Mint) TotalBalance() (uint64, error)

func (*Mint) TransactionFees

func (m *Mint) TransactionFees(inputs cashu.Proofs) uint

type MintInfo

type MintInfo struct {
	Name            string
	Description     string
	LongDescription string
	Contact         []nut06.ContactInfo
	Motd            string
	IconURL         string
	URLs            []string
}

type MintLimits

type MintLimits struct {
	MaxBalance      uint64
	MintingSettings MintMethodSettings
	MeltingSettings MeltMethodSettings
}

type MintMethodSettings

type MintMethodSettings struct {
	MinAmount uint64
	MaxAmount uint64
}

type MintQuotesSubClient

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

func NewMintQuotesSubClient

func NewMintQuotesSubClient(subId string, mintQuotes []storage.MintQuote, pubsub *pubsub.PubSub) *MintQuotesSubClient

func (*MintQuotesSubClient) Close

func (subClient *MintQuotesSubClient) Close()

func (*MintQuotesSubClient) Context

func (subClient *MintQuotesSubClient) Context() context.Context

func (*MintQuotesSubClient) Read

func (subClient *MintQuotesSubClient) Read() <-chan nut17.WsNotification

type MintServer

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

func SetupMintServer

func SetupMintServer(m *Mint, config ServerConfig) *MintServer

func (*MintServer) Shutdown

func (ms *MintServer) Shutdown() error

func (*MintServer) Start

func (ms *MintServer) Start() error

type ProofStatesSubClient

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

func NewProofStatesSubClient

func NewProofStatesSubClient(subId string, Ys []string, pubsub *pubsub.PubSub) *ProofStatesSubClient

func (*ProofStatesSubClient) Close

func (subClient *ProofStatesSubClient) Close()

func (*ProofStatesSubClient) Context

func (subClient *ProofStatesSubClient) Context() context.Context

func (*ProofStatesSubClient) Read

func (subClient *ProofStatesSubClient) Read() <-chan nut17.WsNotification

type ServerConfig

type ServerConfig struct {
	Port int
	// NOTE: using this value for testing
	MeltTimeout *time.Duration
}

type SubscriptionClient

type SubscriptionClient interface {
	// returns a channel to receive notifications for this subscription
	Read() <-chan nut17.WsNotification
	Context() context.Context
	Close()
}

SubscriptionClient interface for the different subscription kinds: - mint quotes - melt quotes - proof states

type WebsocketManager

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

func NewWebSocketManager

func NewWebSocketManager(mint *Mint) *WebsocketManager

func (*WebsocketManager) Shutdown

func (wm *WebsocketManager) Shutdown() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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