Documentation ¶
Index ¶
- Constants
- Variables
- func InitializeDatabase(wallet string)
- func PreRunFeni(cmd *cobra.Command, args []string)
- func RandStringRunes(n int) string
- func SumProofs(p []cashu.Proof) uint64
- type Balance
- type Balances
- type Client
- func (c Client) Check(data cashu.CheckSpendableRequest) (cashu.CheckSpendableResponse, error)
- func (c Client) CheckFee(CheckFeesRequest cashu.CheckFeesRequest) (*cashu.CheckFeesResponse, error)
- func (c Client) GetMint(amount int64) (lightning.Invoicer, error)
- func (c Client) KeySets() (*cashu.GetKeySetsResponse, error)
- func (c Client) Keys() (map[uint64]*secp256k1.PublicKey, error)
- func (c Client) KeysForKeySet(kid string) (map[uint64]*secp256k1.PublicKey, error)
- func (c Client) Melt(data cashu.MeltRequest) (*cashu.MeltResponse, error)
- func (c Client) Mint(data cashu.MintRequest, paymentHash string) (*cashu.MintResponse, error)
- func (c Client) Split(data cashu.SplitRequest) (*cashu.SplitResponse, error)
- type CobraPrompt
- type Mint
- type MintWallet
- func (w MintWallet) GetSpendableProofs() ([]cashu.Proof, error)
- func (w MintWallet) Mint(amount uint64, paymentHash string) ([]cashu.Proof, error)
- func (w MintWallet) PayLightning(proofs []cashu.Proof, invoice string) ([]cashu.Proof, error)
- func (w *MintWallet) Split(proofs []cashu.Proof, amount uint64, scndSecret string) (keep []cashu.Proof, send []cashu.Proof, err error)
- func (w MintWallet) SplitToSend(amount uint64, scndSecret string, setReserved bool) (keep []cashu.Proof, send []cashu.Proof, err error)
- type Mints
- type Pair
- type Proofs
- type Token
- type Tokens
- type WalletConfig
Constants ¶
View Source
const DynamicSuggestionsAnnotation = "cobra-prompt-dynamic-suggestions"
DynamicSuggestionsAnnotation for dynamic suggestions.
View Source
const PersistFlagValuesFlag = "persist-flag-values"
PersistFlagValuesFlag the flag that will be avaiailable when PersistFlagValues is true
Variables ¶
View Source
var GetLocksDynamic = func(annotationValue string) []prompt.Suggest { scripts, err := storage.GetScripts("") if err != nil { return nil } suggestions := make([]prompt.Suggest, 0) for _, script := range scripts { suggestions = append(suggestions, prompt.Suggest{Text: fmt.Sprintf("P2SH:%s", script.Address), Description: fmt.Sprintf("Your P2SH lock for receiving and sending cashu tokens")}) } return suggestions }
View Source
var GetMintsDynamic = func(annotationValue string) []prompt.Suggest { keysets, err := storage.GetKeySet() if err != nil { return nil } suggestions := make([]prompt.Suggest, 0) setBalanceAvailable := make(map[string]uint64) balances, err := Wallet.balancePerKeySet() if err != nil { panic(err) } filteredKeySets = lo.UniqBy[crypto.KeySet, string](keysets, func(k crypto.KeySet) string { if b := balances.ById(k.Id); b != nil { setBalanceAvailable[k.MintUrl] = b.Available } return k.MintUrl }) for i, set := range filteredKeySets { suggestions = append(suggestions, prompt.Suggest{ Text: fmt.Sprintf("%d", i), Description: fmt.Sprintf("Balance: %d sat URL: %s\n", setBalanceAvailable[set.MintUrl], set.MintUrl)}) } return suggestions }
View Source
var GetWalletsDynamic = func(annotationValue string) []prompt.Suggest { dirname, err := os.UserHomeDir() if err != nil { log.Fatal(err) } err = godotenv.Load() files, err := os.ReadDir(path.Join(dirname, ".cashu")) if err != nil { log.Fatal(err) } suggestions := make([]prompt.Suggest, 0) for _, file := range files { if file.IsDir() { suggestions = append(suggestions, prompt.Suggest{Text: file.Name(), Description: fmt.Sprintf("Wallet %s in your home folder", file.Name())}) } } return suggestions }
View Source
var Host string
View Source
var RootCmd = &cobra.Command{ Use: "feni", Short: "Cashu Feni is a cashu wallet application", Long: ``, Annotations: map[string]string{ DynamicSuggestionsAnnotation: getWalletsAnnotationValue, }, Run: func(cmd *cobra.Command, args []string) { }, }
View Source
var WalletUsed string
Functions ¶
func InitializeDatabase ¶
func InitializeDatabase(wallet string)
func PreRunFeni ¶
func RandStringRunes ¶
Types ¶
type Client ¶
type Client struct {
Url string
}
func (Client) Check ¶
func (c Client) Check(data cashu.CheckSpendableRequest) (cashu.CheckSpendableResponse, error)
func (Client) CheckFee ¶
func (c Client) CheckFee(CheckFeesRequest cashu.CheckFeesRequest) (*cashu.CheckFeesResponse, error)
func (Client) KeysForKeySet ¶ added in v0.1.7
func (Client) Melt ¶
func (c Client) Melt(data cashu.MeltRequest) (*cashu.MeltResponse, error)
func (Client) Mint ¶
func (c Client) Mint(data cashu.MintRequest, paymentHash string) (*cashu.MintResponse, error)
func (Client) Split ¶
func (c Client) Split(data cashu.SplitRequest) (*cashu.SplitResponse, error)
type CobraPrompt ¶
type CobraPrompt struct { // RootCmd is the start point, all its sub commands and flags will be available as suggestions RootCmd *cobra.Command // GoPromptOptions is for customize go-prompt // see https://github.com/c-bata/go-prompt/blob/master/option.go GoPromptOptions []prompt.Option // DynamicSuggestionsFunc will be executed if an command has CallbackAnnotation as an annotation. If it's included // the value will be provided to the DynamicSuggestionsFunc function. DynamicSuggestionsFunc func(annotationValue string, document *prompt.Document) []prompt.Suggest // PersistFlagValues will persist flags. For example have verbose turned on every command. PersistFlagValues bool // ShowHelpCommandAndFlags will make help command and flag for every command available. ShowHelpCommandAndFlags bool // DisableCompletionCommand will disable the default completion command for cobra DisableCompletionCommand bool // ShowHiddenCommands makes hidden commands available ShowHiddenCommands bool // ShowHiddenFlags makes hidden flags available ShowHiddenFlags bool // AddDefaultExitCommand adds a command for exiting prompt loop AddDefaultExitCommand bool // OnErrorFunc handle error for command.Execute, if not set print error and exit OnErrorFunc func(err error) // InArgsParser adds a custom parser for the command line arguments (default: strings.Fields) InArgsParser func(args string) []string // SuggestionFilter will be uses when filtering suggestions as typing SuggestionFilter func(suggestions []prompt.Suggest, document *prompt.Document) []prompt.Suggest }
CobraPrompt given a Cobra command it will make every flag and sub commands available as suggestions. Command.Short will be used as description for the suggestion.
func (CobraPrompt) Run ¶
func (co CobraPrompt) Run()
Run will automatically generate suggestions for all cobra commands and flags defined by RootCmd and execute the selected commands. Run will also reset all given flags by default, see PersistFlagValues
type MintWallet ¶
type MintWallet struct {
// contains filtered or unexported fields
}
var Wallet MintWallet
func (MintWallet) GetSpendableProofs ¶
func (w MintWallet) GetSpendableProofs() ([]cashu.Proof, error)
func (MintWallet) PayLightning ¶
type WalletConfig ¶
type WalletConfig struct { Debug bool `env:"DEBUG"` Lightning bool `env:"LIGHTNING"` MintServerHost string `env:"MINT_HOST"` MintServerPort string `env:"MINT_PORT"` Wallet string `env:"WALLET"` }
var Config WalletConfig
Click to show internal directories.
Click to hide internal directories.