storage

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KEYSETS_BUCKET        = "keysets"
	PROOFS_BUCKET         = "proofs"
	PENDING_PROOFS_BUCKET = "pending_proofs"
	MINT_QUOTES_BUCKET    = "mint_quotes"
	MELT_QUOTES_BUCKET    = "melt_quotes"
	INVOICES_BUCKET       = "invoices"
	SEED_BUCKET           = "seed"
	MNEMONIC_KEY          = "mnemonic"
)

Variables

View Source
var (
	ProofNotFound = errors.New("proof not found")
)

Functions

This section is empty.

Types

type BoltDB

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

func InitBolt

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

func (*BoltDB) AddPendingProofs added in v0.4.0

func (db *BoltDB) AddPendingProofs(proofs cashu.Proofs) error

func (*BoltDB) AddPendingProofsByQuoteId added in v0.3.0

func (db *BoltDB) AddPendingProofsByQuoteId(proofs cashu.Proofs, quoteId string) error

func (*BoltDB) Close added in v0.4.0

func (db *BoltDB) Close() error

func (*BoltDB) DeletePendingProofs added in v0.3.0

func (db *BoltDB) DeletePendingProofs(Ys []string) error

func (*BoltDB) DeletePendingProofsByQuoteId added in v0.3.0

func (db *BoltDB) DeletePendingProofsByQuoteId(quoteId string) error

func (*BoltDB) DeleteProof

func (db *BoltDB) DeleteProof(secret string) error

func (*BoltDB) GetInvoice

func (db *BoltDB) GetInvoice(paymentHash string) *Invoice

func (*BoltDB) GetInvoiceByQuoteId added in v0.3.0

func (db *BoltDB) GetInvoiceByQuoteId(quoteId string) *Invoice

func (*BoltDB) GetInvoices

func (db *BoltDB) GetInvoices() []Invoice

func (*BoltDB) GetKeyset added in v0.2.0

func (db *BoltDB) GetKeyset(keysetId string) *crypto.WalletKeyset

func (*BoltDB) GetKeysetCounter added in v0.2.0

func (db *BoltDB) GetKeysetCounter(keysetId string) uint32

func (*BoltDB) GetKeysets

func (db *BoltDB) GetKeysets() crypto.KeysetsMap

func (*BoltDB) GetMeltQuoteById added in v0.4.0

func (db *BoltDB) GetMeltQuoteById(id string) *MeltQuote

func (*BoltDB) GetMeltQuotes added in v0.4.0

func (db *BoltDB) GetMeltQuotes() []MeltQuote

func (*BoltDB) GetMintQuoteById added in v0.4.0

func (db *BoltDB) GetMintQuoteById(id string) *MintQuote

func (*BoltDB) GetMintQuotes added in v0.4.0

func (db *BoltDB) GetMintQuotes() []MintQuote

func (*BoltDB) GetMnemonic added in v0.2.0

func (db *BoltDB) GetMnemonic() string

func (*BoltDB) GetPendingProofs added in v0.3.0

func (db *BoltDB) GetPendingProofs() []DBProof

func (*BoltDB) GetPendingProofsByQuoteId added in v0.3.0

func (db *BoltDB) GetPendingProofsByQuoteId(quoteId string) []DBProof

func (*BoltDB) GetProofs

func (db *BoltDB) GetProofs() cashu.Proofs

return all proofs from db

func (*BoltDB) GetProofsByKeysetId

func (db *BoltDB) GetProofsByKeysetId(id string) cashu.Proofs

func (*BoltDB) GetSeed added in v0.2.0

func (db *BoltDB) GetSeed() []byte

func (*BoltDB) IncrementKeysetCounter added in v0.2.0

func (db *BoltDB) IncrementKeysetCounter(keysetId string, num uint32) error

func (*BoltDB) MigrateInvoicesToQuotes added in v0.4.0

func (db *BoltDB) MigrateInvoicesToQuotes() error

func (*BoltDB) SaveInvoice

func (db *BoltDB) SaveInvoice(invoice Invoice) error

func (*BoltDB) SaveKeyset

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

func (*BoltDB) SaveMeltQuote added in v0.4.0

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

func (*BoltDB) SaveMintQuote added in v0.4.0

func (db *BoltDB) SaveMintQuote(quote MintQuote) error

func (*BoltDB) SaveMnemonicSeed added in v0.2.0

func (db *BoltDB) SaveMnemonicSeed(mnemonic string, seed []byte)

func (*BoltDB) SaveProofs added in v0.3.0

func (db *BoltDB) SaveProofs(proofs cashu.Proofs) error

type DBProof added in v0.3.0

type DBProof struct {
	Y      string           `json:"y"`
	Amount uint64           `json:"amount"`
	Id     string           `json:"id"`
	Secret string           `json:"secret"`
	C      string           `json:"C"`
	DLEQ   *cashu.DLEQProof `json:"dleq,omitempty"`
	// set if pending proofs are tied to a melt quote
	MeltQuoteId string `json:"quote_id"`
}

type Invoice added in v0.2.0

type Invoice struct {
	TransactionType QuoteType
	// mint or melt quote id
	Id string
	// mint that issued quote
	Mint           string
	QuoteAmount    uint64
	InvoiceAmount  uint64
	PaymentRequest string
	PaymentHash    string
	Preimage       string
	CreatedAt      int64
	Paid           bool
	SettledAt      int64
	QuoteExpiry    uint64
}

type MeltQuote added in v0.4.0

type MeltQuote struct {
	QuoteId        string
	Mint           string
	Method         string
	State          nut05.State
	Unit           string
	PaymentRequest string
	Amount         uint64
	FeeReserve     uint64
	Preimage       string
	CreatedAt      int64
	SettledAt      int64
	QuoteExpiry    uint64
}

type MintQuote added in v0.4.0

type MintQuote struct {
	QuoteId        string
	Mint           string
	Method         string
	State          nut04.State
	Unit           string
	PaymentRequest string
	Amount         uint64
	CreatedAt      int64
	SettledAt      int64
	QuoteExpiry    uint64
}

type QuoteType added in v0.2.0

type QuoteType int
const (
	Mint QuoteType = iota + 1
	Melt
)

func (QuoteType) String added in v0.2.0

func (quote QuoteType) String() string

type WalletDB added in v0.3.0

type WalletDB interface {
	SaveMnemonicSeed(string, []byte)
	GetSeed() []byte
	GetMnemonic() string

	SaveProofs(cashu.Proofs) error
	GetProofs() cashu.Proofs
	GetProofsByKeysetId(string) cashu.Proofs
	DeleteProof(string) error

	AddPendingProofs(cashu.Proofs) error
	AddPendingProofsByQuoteId(cashu.Proofs, string) error
	GetPendingProofs() []DBProof
	GetPendingProofsByQuoteId(string) []DBProof
	DeletePendingProofs([]string) error
	DeletePendingProofsByQuoteId(string) error

	SaveKeyset(*crypto.WalletKeyset) error
	GetKeysets() crypto.KeysetsMap
	GetKeyset(string) *crypto.WalletKeyset
	IncrementKeysetCounter(string, uint32) error
	GetKeysetCounter(string) uint32

	SaveMintQuote(MintQuote) error
	GetMintQuotes() []MintQuote
	GetMintQuoteById(string) *MintQuote

	SaveMeltQuote(MeltQuote) error
	GetMeltQuotes() []MeltQuote
	GetMeltQuoteById(string) *MeltQuote

	Close() error
}

Jump to

Keyboard shortcuts

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