mint

package
v0.0.0-...-3443ee6 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigDirName string = "nutmix"
View Source
const ConfigFileName string = "config.toml"
View Source
const LogFileName string = "nutmix.log"

Variables

View Source
var (
	AlreadyActiveProof  = errors.New("Proof already being spent")
	AlreadyActiveQuote  = errors.New("Quote already being spent")
	UsingInactiveKeyset = errors.New("Trying to use an inactive keyset")
)
View Source
var (
	ErrInvalidProof        = errors.New("Invalid proof")
	ErrQuoteNotPaid        = errors.New("Quote not paid")
	ErrMessageAmountToBig  = errors.New("Message amount is to big")
	ErrInvalidBlindMessage = errors.New("Invalid blind message")
)

errors types for validation

View Source
var (
	NETWORK_ENV                = "NETWORK"
	MINT_LIGHTNING_BACKEND_ENV = "MINT_LIGHTNING_BACKEND"
)

Functions

func CheckChainParams

func CheckChainParams(network string) (chaincfg.Params, error)

func DeriveKeysetFromSeeds

func DeriveKeysetFromSeeds(seeds []cashu.Seed, privateKey *secp256k1.PrivateKey) (map[string][]cashu.Keyset, map[string]cashu.KeysetMap, error)

Types

type ActiveProofs

type ActiveProofs struct {
	Proofs map[cashu.Proof]bool
	sync.Mutex
}

func (*ActiveProofs) AddProofs

func (a *ActiveProofs) AddProofs(proofs []cashu.Proof) error

func (*ActiveProofs) RemoveProofs

func (a *ActiveProofs) RemoveProofs(proofs []cashu.Proof) error

type ActiveQuote

type ActiveQuote struct {
	Quote map[string]bool
	sync.Mutex
}

func (*ActiveQuote) AddQuote

func (q *ActiveQuote) AddQuote(quote string) error

func (*ActiveQuote) RemoveQuote

func (q *ActiveQuote) RemoveQuote(quote string) error

type AddToDBFunc

type AddToDBFunc func(*pgxpool.Pool, bool, cashu.ACTION_STATE, string) error

type Config

type Config struct {
	NAME             string
	DESCRIPTION      string
	DESCRIPTION_LONG string
	MOTD             string
	EMAIL            string
	NOSTR            string

	NETWORK string

	MINT_LIGHTNING_BACKEND LightningBackend
	LND_GRPC_HOST          string
	LND_TLS_CERT           string
	LND_MACAROON           string

	MINT_LNBITS_ENDPOINT string
	MINT_LNBITS_KEY      string

	CLN_GRPC_HOST   string
	CLN_CA_CERT     string
	CLN_CLIENT_CERT string
	CLN_CLIENT_KEY  string
	CLN_MACAROON    string

	DATABASE_TYPE string
	DATABASE_URL  string

	PEG_OUT_ONLY       bool
	PEG_OUT_LIMIT_SATS *int
	PEG_IN_LIMIT_SATS  *int
}

func SetUpConfigFile

func SetUpConfigFile() (Config, error)

func (*Config) Default

func (c *Config) Default()

func (*Config) SetTOMLFile

func (c *Config) SetTOMLFile() error

func (*Config) UseEnviromentVars

func (c *Config) UseEnviromentVars()

type LightningBackend

type LightningBackend string
const CLNGRPC LightningBackend = "ClnGrpcWallet"
const FAKE_WALLET LightningBackend = "FakeWallet"
const LNBITS LightningBackend = "LNbitsWallet"
const LNDGRPC LightningBackend = "LndGrpcWallet"

func StringToLightningBackend

func StringToLightningBackend(text string) LightningBackend

type Mint

type Mint struct {
	ActiveKeysets    map[string]cashu.KeysetMap
	Keysets          map[string][]cashu.Keyset
	LightningBackend lightning.LightningBackend
	PendingProofs    []cashu.Proof
	ActiveProofs     *ActiveProofs
	ActiveQuotes     *ActiveQuote
	Config           Config
	MintPubkey       string
}

func SetUpMint

func SetUpMint(ctx context.Context, mint_privkey *secp256k1.PrivateKey, seeds []cashu.Seed, config Config) (*Mint, error)

func (*Mint) AddQuotesAndProofs

func (m *Mint) AddQuotesAndProofs(quote string, proofs []cashu.Proof) error

func (*Mint) CheckProofsAreSameUnit

func (m *Mint) CheckProofsAreSameUnit(proofs []cashu.Proof) (cashu.Unit, error)

func (*Mint) GetAllKeysets

func (m *Mint) GetAllKeysets() []cashu.Keyset

func (*Mint) GetKeysetById

func (m *Mint) GetKeysetById(id string) ([]cashu.Keyset, error)

func (*Mint) OrderActiveKeysByUnit

func (m *Mint) OrderActiveKeysByUnit() cashu.KeysResponse

func (*Mint) RemoveQuotesAndProofs

func (m *Mint) RemoveQuotesAndProofs(quote string, proofs []cashu.Proof)

func (*Mint) SignBlindedMessages

func (m *Mint) SignBlindedMessages(outputs []cashu.BlindedMessage, unit string) ([]cashu.BlindSignature, []cashu.RecoverSigDB, error)

func (*Mint) ValidateProof

func (m *Mint) ValidateProof(proof cashu.Proof, unit cashu.Unit, checkOutputs *bool, pubkeysFromProofs *map[*btcec.PublicKey]bool) error

func (*Mint) VerifyLightingPaymentHappened

func (m *Mint) VerifyLightingPaymentHappened(pool *pgxpool.Pool, paid bool, quote string, dbCall AddToDBFunc) (cashu.ACTION_STATE, string, error)

func (*Mint) VerifyListOfProofs

func (m *Mint) VerifyListOfProofs(proofs []cashu.Proof, blindMessages []cashu.BlindedMessage, unit cashu.Unit) error

type SeedType

type SeedType struct {
	Version int
	Active  bool
	Unit    cashu.Unit
}

func CheckForInactiveSeeds

func CheckForInactiveSeeds(seeds []cashu.Seed) ([]SeedType, error)

Jump to

Keyboard shortcuts

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