mint

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QuoteExpiryMins = 10
)

Variables

This section is empty.

Functions

func StartMintServer

func StartMintServer(server *MintServer)

Types

type BoltDB

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

func InitBolt

func InitBolt(path string) (*BoltDB, error)

func (*BoltDB) GetInvoice

func (b *BoltDB) GetInvoice(id string) *lightning.Invoice

func (*BoltDB) GetKeysets

func (db *BoltDB) GetKeysets() map[string]crypto.Keyset

func (*BoltDB) GetMeltQuote

func (b *BoltDB) GetMeltQuote(quoteId string) *MeltQuote

func (*BoltDB) GetProof

func (db *BoltDB) GetProof(secret string) *cashu.Proof

func (*BoltDB) SaveInvoice

func (b *BoltDB) SaveInvoice(invoice lightning.Invoice) error

func (*BoltDB) SaveKeyset

func (db *BoltDB) SaveKeyset(keyset *crypto.Keyset) error

func (*BoltDB) SaveMeltQuote

func (b *BoltDB) SaveMeltQuote(quote MeltQuote) error

func (*BoltDB) SaveProof

func (b *BoltDB) SaveProof(proof cashu.Proof) error

type Config

type Config struct {
	PrivateKey     string
	DerivationPath string
}

func GetConfig

func GetConfig() Config

type MeltQuote

type MeltQuote struct {
	Id             string
	InvoiceRequest string
	Amount         uint64
	FeeReserve     uint64
	Paid           bool
	Expiry         int64
	Preimage       string
}

type Mint

type Mint struct {

	// active keysets
	ActiveKeysets map[string]crypto.Keyset

	// map of all keysets (both active and inactive)
	Keysets map[string]crypto.Keyset

	LightningClient lightning.Client
	MintInfo        *nut06.MintInfo
	// contains filtered or unexported fields
}

func LoadMint

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

func (*Mint) GetMeltQuoteState

func (m *Mint) GetMeltQuoteState(method, quoteId string) (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(method, quoteId string) (nut04.PostMintQuoteBolt11Response, error)

GetMintQuoteState returns the state of a mint quote. Used to check whether a mint quote has been paid.

func (*Mint) MeltRequest

func (m *Mint) MeltRequest(method, request, unit string) (MeltQuote, error)

MeltRequest 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) MeltTokens

func (m *Mint) MeltTokens(method, quoteId string, proofs cashu.Proofs) (MeltQuote, error)

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

func (*Mint) MintTokens

func (m *Mint) MintTokens(method, id string, blindedMessages cashu.BlindedMessages) (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) RequestMintQuote

func (m *Mint) RequestMintQuote(method string, amount uint64, unit string) (nut04.PostMintQuoteBolt11Response, error)

RequestMintQuote will process a request to mint tokens and returns a mint quote response 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) 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) VerifyProofs

func (m *Mint) VerifyProofs(proofs cashu.Proofs) (bool, error)

type MintServer

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

func SetupMintServer

func SetupMintServer(config Config) (*MintServer, error)

func (*MintServer) LogInfo

func (ms *MintServer) LogInfo(format string, v ...any)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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