Documentation
¶
Index ¶
- Variables
- func DeriveP2PK(key *hdkeychain.ExtendedKey) (*btcec.PrivateKey, error)
- func GetKeysetKeys(mintURL, id string) (crypto.PublicKeys, error)
- func GetMintActiveKeyset(mintURL string, unit cashu.Unit) (*crypto.WalletKeyset, error)
- func GetMintInactiveKeysets(mintURL string, unit cashu.Unit) (map[string]crypto.WalletKeyset, error)
- func InitStorage(path string) (storage.WalletDB, error)
- func Restore(walletPath, mnemonic string, mintsToRestore []string) (uint64, error)
- type Config
- type SendOptions
- type SendResult
- type Wallet
- func (w *Wallet) AddMint(mint string) (*walletMint, error)
- func (w *Wallet) CheckMeltQuoteState(quoteId string) (*nut05.PostMeltQuoteBolt11Response, error)
- func (w *Wallet) CurrentMint() string
- func (w *Wallet) GetBalance() uint64
- func (w *Wallet) GetBalanceByMints() map[string]uint64
- func (w *Wallet) GetMeltQuoteById(id string) *storage.MeltQuote
- func (w *Wallet) GetMeltQuotes() []storage.MeltQuote
- func (w *Wallet) GetMintQuoteById(id string) *storage.MintQuote
- func (w *Wallet) GetMintQuoteByPaymentRequest(request string) (*storage.MintQuote, error)
- func (w *Wallet) GetMintQuotes() []storage.MintQuote
- func (w *Wallet) GetPendingMeltQuotes() []string
- func (w *Wallet) GetReceivePubkey() *btcec.PublicKey
- func (w *Wallet) HTLCLockedProofs(amount uint64, mintURL string, preimage string, tags *nut11.P2PKTags, ...) (cashu.Proofs, error)
- func (w *Wallet) Melt(quoteId string) (*nut05.PostMeltQuoteBolt11Response, error)
- func (w *Wallet) MintQuoteState(quoteId string) (*nut04.PostMintQuoteBolt11Response, error)
- func (w *Wallet) MintSwap(amount uint64, from, to string) (uint64, error)
- func (w *Wallet) MintTokens(quoteId string) (uint64, error)
- func (w *Wallet) Mnemonic() string
- func (w *Wallet) MultiMintPayment(request string, split map[string]uint64) ([]nut05.PostMeltQuoteBolt11Response, error)
- func (w *Wallet) PendingBalance() uint64
- func (w *Wallet) Receive(token cashu.Token, swapToTrusted bool) (uint64, error)
- func (w *Wallet) ReceiveHTLC(token cashu.Token, preimage string) (uint64, error)
- func (w *Wallet) ReclaimUnspentProofs() (uint64, error)
- func (w *Wallet) RemoveSpentProofs() error
- func (w *Wallet) RequestMeltQuote(request, mint string) (*nut05.PostMeltQuoteBolt11Response, error)
- func (w *Wallet) RequestMint(amount uint64, mint string) (*nut04.PostMintQuoteBolt11Response, error)
- func (w *Wallet) Send(amount uint64, mintURL string, includeFees bool) (cashu.Proofs, error)
- func (w *Wallet) SendOffline(amount uint64, mintURL string, maxOverpayment uint64) (*SendResult, error)
- func (w *Wallet) SendToPubkey(amount uint64, mintURL string, pubkey *btcec.PublicKey, tags *nut11.P2PKTags, ...) (cashu.Proofs, error)
- func (w *Wallet) SendWithOptions(amount uint64, mintURL string, options SendOptions) (*SendResult, error)
- func (w *Wallet) Shutdown() error
- func (w *Wallet) TrustedMints() []string
- func (w *Wallet) UpdateMintURL(oldURL, newURL string) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DeriveP2PK ¶
func DeriveP2PK(key *hdkeychain.ExtendedKey) (*btcec.PrivateKey, error)
Derive key that wallet will use to receive locked ecash
func GetKeysetKeys ¶
func GetKeysetKeys(mintURL, id string) (crypto.PublicKeys, error)
func GetMintActiveKeyset ¶
GetMintActiveKeyset gets the active keyset with the specified unit
func GetMintInactiveKeysets ¶
Types ¶
type SendOptions ¶
type SendOptions struct {
// IncludeFees determines whether to include fees in the calculation
IncludeFees bool
// AllowOverpayment allows sending more than requested amount when exact change isn't available offline
AllowOverpayment bool
// MaxOverpaymentPercent limits overpayment to a percentage (0-100, default 0 = no limit)
MaxOverpaymentPercent uint
// MaxOverpaymentAbsolute limits overpayment to an absolute amount (0 = no limit)
MaxOverpaymentAbsolute uint64
}
SendOptions provides configuration for send operations
func DefaultSendOptions ¶
func DefaultSendOptions() SendOptions
DefaultSendOptions returns the default send options (backwards compatible)
type SendResult ¶
type SendResult struct {
// Proofs are the proofs that were sent
Proofs cashu.Proofs
// RequestedAmount is the amount that was requested
RequestedAmount uint64
// ActualAmount is the amount that was actually sent (may be higher due to overpayment)
ActualAmount uint64
// Overpayment is the difference between actual and requested amount
Overpayment uint64
// WasOffline indicates if the send was performed in offline mode
WasOffline bool
}
SendResult contains the result of a send operation
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
func LoadWallet ¶
func (*Wallet) CheckMeltQuoteState ¶
func (w *Wallet) CheckMeltQuoteState(quoteId string) (*nut05.PostMeltQuoteBolt11Response, error)
func (*Wallet) CurrentMint ¶
CurrentMint returns the current mint url
func (*Wallet) GetBalance ¶
GetBalance returns the total balance aggregated from all proofs
func (*Wallet) GetBalanceByMints ¶
GetBalanceByMints returns a map of string mint and a uint64 that represents the balance for that mint
func (*Wallet) GetMeltQuotes ¶
func (*Wallet) GetMintQuoteByPaymentRequest ¶
func (*Wallet) GetMintQuotes ¶
func (*Wallet) GetPendingMeltQuotes ¶
GetPendingMeltQuotes return a list of pending quote ids
func (*Wallet) GetReceivePubkey ¶
GetReceivePubkey retrieves public key to which the wallet can receive locked ecash
func (*Wallet) HTLCLockedProofs ¶
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 ¶
func (w *Wallet) MintQuoteState(quoteId string) (*nut04.PostMintQuoteBolt11Response, error)
func (*Wallet) MintTokens ¶
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) MultiMintPayment ¶
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 ¶
func (*Wallet) Receive ¶
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 ¶
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 ¶
ReclaimUnspentProofs will check the state of pending proofs and try to reclaim proofs that are in a unspent state
func (*Wallet) RemoveSpentProofs ¶
RemoveSpentProofs will check the state of pending proofs and remove the ones in spent state
func (*Wallet) RequestMeltQuote ¶
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) SendOffline ¶
func (w *Wallet) SendOffline(amount uint64, mintURL string, maxOverpayment uint64) (*SendResult, error)
SendOffline attempts to send the closest amount above the requested amount when exact change isn't available
func (*Wallet) SendToPubkey ¶
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) SendWithOptions ¶
func (w *Wallet) SendWithOptions(amount uint64, mintURL string, options SendOptions) (*SendResult, error)
SendWithOptions provides enhanced send functionality with configurable options