wallet

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 34 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMintNotExist            = errors.New("mint does not exist")
	ErrInsufficientMintBalance = errors.New("not enough funds in selected mint")
	ErrQuoteNotFound           = errors.New("quote not found")
)

Functions

func DeriveP2PK added in v0.2.0

func DeriveP2PK(key *hdkeychain.ExtendedKey) (*btcec.PrivateKey, error)

Derive key that wallet will use to receive locked ecash

func GetKeysetKeys added in v0.4.0

func GetKeysetKeys(mintURL, id string) (map[uint64]*secp256k1.PublicKey, error)

func GetMintActiveKeyset added in v0.4.0

func GetMintActiveKeyset(mintURL string, unit cashu.Unit) (*crypto.WalletKeyset, error)

GetMintActiveKeyset gets the active keyset with the specified unit

func GetMintInactiveKeysets

func GetMintInactiveKeysets(mintURL string, unit cashu.Unit) (map[string]crypto.WalletKeyset, error)

func InitStorage

func InitStorage(path string) (storage.WalletDB, error)

func Restore added in v0.2.0

func Restore(walletPath, mnemonic string, mintsToRestore []string) (uint64, error)

Types

type Config

type Config struct {
	WalletPath     string
	CurrentMintURL string
}

type Wallet

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

func LoadWallet

func LoadWallet(config Config) (*Wallet, error)

func (*Wallet) AddMint added in v0.4.0

func (w *Wallet) AddMint(mint string) (*walletMint, error)

AddMint adds the mint to the list of mints trusted by the wallet

func (*Wallet) CheckMeltQuoteState added in v0.3.0

func (w *Wallet) CheckMeltQuoteState(quoteId string) (*nut05.PostMeltQuoteBolt11Response, error)

func (*Wallet) CurrentMint

func (w *Wallet) CurrentMint() string

CurrentMint returns the current mint url

func (*Wallet) GetBalance

func (w *Wallet) GetBalance() uint64

GetBalance returns the total balance aggregated from all proofs

func (*Wallet) GetBalanceByMints

func (w *Wallet) GetBalanceByMints() map[string]uint64

GetBalanceByMints returns a map of string mint and a uint64 that represents the balance for that mint

func (*Wallet) GetMeltQuoteById added in v0.4.0

func (w *Wallet) GetMeltQuoteById(id string) *storage.MeltQuote

func (*Wallet) GetMeltQuotes added in v0.4.0

func (w *Wallet) GetMeltQuotes() []storage.MeltQuote

func (*Wallet) GetMintQuoteById added in v0.4.0

func (w *Wallet) GetMintQuoteById(id string) *storage.MintQuote

func (*Wallet) GetMintQuoteByPaymentRequest added in v0.4.0

func (w *Wallet) GetMintQuoteByPaymentRequest(request string) (*storage.MintQuote, error)

func (*Wallet) GetMintQuotes added in v0.4.0

func (w *Wallet) GetMintQuotes() []storage.MintQuote

func (*Wallet) GetPendingMeltQuotes added in v0.3.0

func (w *Wallet) GetPendingMeltQuotes() []string

GetPendingMeltQuotes return a list of pending quote ids

func (*Wallet) GetReceivePubkey added in v0.2.0

func (w *Wallet) GetReceivePubkey() *btcec.PublicKey

GetReceivePubkey retrieves public key to which the wallet can receive locked ecash

func (*Wallet) HTLCLockedProofs added in v0.3.0

func (w *Wallet) HTLCLockedProofs(
	amount uint64,
	mintURL string,
	preimage string,
	tags *nut11.P2PKTags,
	includeFees bool,
) (cashu.Proofs, error)

HTLCLockedProofs returns proofs that are locked to the hash of the preimage

func (*Wallet) Melt

func (w *Wallet) Melt(quoteId string) (*nut05.PostMeltQuoteBolt11Response, error)

Melt will melt proofs by requesting the mint to pay the payment request from the melt quote passed

func (*Wallet) MintQuoteState added in v0.3.0

func (w *Wallet) MintQuoteState(quoteId string) (*nut04.PostMintQuoteBolt11Response, error)

func (*Wallet) MintSwap added in v0.4.0

func (w *Wallet) MintSwap(amount uint64, from, to string) (uint64, error)

MintSwap will swap the amount from to the specified mint

func (*Wallet) MintTokens

func (w *Wallet) MintTokens(quoteId string) (uint64, error)

MintTokens will check whether if the mint quote has been paid. If yes, it will create blinded messages that will send to the mint to get the blinded signatures. If successful, it will unblind the signatures to generate proofs and store the proofs in the db.

func (*Wallet) Mnemonic added in v0.2.0

func (w *Wallet) Mnemonic() string

func (*Wallet) MultiMintPayment added in v0.4.0

func (w *Wallet) MultiMintPayment(request string, split map[string]uint64) ([]nut05.PostMeltQuoteBolt11Response, error)

MultiMintPayment tries an MPP according to NUT-15. The split is a map where the key is the mint and the uint64 is the amount in msat.

func (*Wallet) PendingBalance added in v0.3.0

func (w *Wallet) PendingBalance() uint64

func (*Wallet) Receive

func (w *Wallet) Receive(token cashu.Token, swapToTrusted bool) (uint64, error)

Receives Cashu token. If swap is true, it will swap the funds to the configured default mint. If false, it will add the proofs from the mint and add that mint to the list of trusted mints.

func (*Wallet) ReceiveHTLC added in v0.3.0

func (w *Wallet) ReceiveHTLC(token cashu.Token, preimage string) (uint64, error)

ReceiveHTLC will add the preimage and any signatures if needed in order to redeem the locked ecash. If successful, it will make a swap and store the new proofs. It will add the mint in the token to the list of trusted mints.

func (*Wallet) ReclaimUnspentProofs added in v0.4.0

func (w *Wallet) ReclaimUnspentProofs() (uint64, error)

ReclaimUnspentProofs will check the state of pending proofs and try to reclaim proofs that are in a unspent state

func (*Wallet) RemoveSpentProofs added in v0.4.0

func (w *Wallet) RemoveSpentProofs() error

RemoveSpentProofs will check the state of pending proofs and remove the ones in spent state

func (*Wallet) RequestMeltQuote added in v0.4.0

func (w *Wallet) RequestMeltQuote(request, mint string) (*nut05.PostMeltQuoteBolt11Response, error)

RequestMeltQuote will request a melt quote to the mint for the specified request

func (*Wallet) RequestMint

func (w *Wallet) RequestMint(amount uint64, mint string) (*nut04.PostMintQuoteBolt11Response, error)

RequestMint requests a mint quote to the mint for the specified amount

func (*Wallet) Send

func (w *Wallet) Send(amount uint64, mintURL string, includeFees bool) (cashu.Proofs, error)

Send will return proofs for the given amount

func (*Wallet) SendToPubkey added in v0.2.0

func (w *Wallet) SendToPubkey(
	amount uint64,
	mintURL string,
	pubkey *btcec.PublicKey,
	tags *nut11.P2PKTags,
	includeFees bool,
) (cashu.Proofs, error)

SendToPubkey returns proofs that are locked to the passed pubkey

func (*Wallet) Shutdown added in v0.4.0

func (w *Wallet) Shutdown() error

func (*Wallet) TrustedMints

func (w *Wallet) TrustedMints() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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