diff --git a/cashu/cashu.go b/cashu/cashu.go index 48190a5..3a66316 100644 --- a/cashu/cashu.go +++ b/cashu/cashu.go @@ -109,10 +109,7 @@ func (e ErrorResponse) Error() string { // CreateInvoice will generate a blank invoice func CreateInvoice() lightning.Invoicer { - if lightning.Config.Lightning.Enabled { - return lnbits.NewInvoice() - } - return nil + return lnbits.NewInvoice() } type Mint struct { diff --git a/cmd/cashu/feni/burn.go b/cmd/cashu/feni/burn.go index 0b98ac3..779b4f0 100644 --- a/cmd/cashu/feni/burn.go +++ b/cmd/cashu/feni/burn.go @@ -36,7 +36,7 @@ func burnCmd(wallet *wallet.Wallet, params cobraParameter) { proofs := make([]cashu.Proof, 0) var err error if all { - proofs, err = storage.GetReservedProofs() + proofs, err = wallet.Storage.GetReservedProofs() if err != nil { log.Fatal(err) } diff --git a/cmd/cashu/feni/feni.go b/cmd/cashu/feni/feni.go index 21ac719..c347d88 100644 --- a/cmd/cashu/feni/feni.go +++ b/cmd/cashu/feni/feni.go @@ -3,7 +3,6 @@ package feni import ( "fmt" "github.com/c-bata/go-prompt" - "github.com/cashubtc/cashu-feni/db" "github.com/cashubtc/cashu-feni/wallet" "github.com/joho/godotenv" log "github.com/sirupsen/logrus" @@ -12,8 +11,6 @@ import ( "path" ) -var storage db.MintStorage - const getWalletsAnnotationValue = "GetWallets" var GetWalletsDynamic = func(annotationValue string) []prompt.Suggest { diff --git a/cmd/cashu/feni/invoice.go b/cmd/cashu/feni/invoice.go index 5faf92f..5d91bbf 100644 --- a/cmd/cashu/feni/invoice.go +++ b/cmd/cashu/feni/invoice.go @@ -30,19 +30,13 @@ func mintCmd(wallet *wallet.Wallet, params cobraParameter) { panic(err) } if amount > 0 { - if !wallet.Config.Lightning { - if _, err := wallet.Mint(uint64(amount), hash); err != nil { - log.Error(err) - } - return - } if hash == "" { var invoice lightning.Invoicer invoice, err = wallet.Client.GetMint(int64(amount)) if err != nil { panic(err) } - err = storage.StoreLightningInvoice(invoice) + err = wallet.Storage.StoreLightningInvoice(invoice) if err != nil { log.Fatal(err) } diff --git a/cmd/cashu/feni/lock.go b/cmd/cashu/feni/lock.go index 949367c..e6b7886 100644 --- a/cmd/cashu/feni/lock.go +++ b/cmd/cashu/feni/lock.go @@ -27,10 +27,10 @@ func flagIsPay2ScriptHash() bool { } func lock(wallet *wallet.Wallet, params cobraParameter) { - fmt.Println(createP2SHLock()) + fmt.Println(createP2SHLock(wallet)) } -func createP2SHLock() *cashu.P2SHScript { +func createP2SHLock(wallet *wallet.Wallet) *cashu.P2SHScript { key := bitcoin.Step0CarolPrivateKey() txInRedeemScript := bitcoin.Step0CarolCheckSigRedeemScript(*key.PubKey()) fmt.Println(txInRedeemScript) @@ -45,7 +45,7 @@ func createP2SHLock() *cashu.P2SHScript { txInRedeemScriptB64 := base64.URLEncoding.EncodeToString(txInRedeemScript) txInSignatureB64 := base64.URLEncoding.EncodeToString(txInSignature.SignatureScript) p2SHScript := cashu.P2SHScript{Script: txInRedeemScriptB64, Signature: txInSignatureB64, Address: txInP2SHAdress.EncodeAddress()} - err = storage.StoreScript(p2SHScript) + err = wallet.Storage.StoreScript(p2SHScript) if err != nil { return nil } diff --git a/cmd/cashu/feni/locks.go b/cmd/cashu/feni/locks.go index 660c555..f05d513 100644 --- a/cmd/cashu/feni/locks.go +++ b/cmd/cashu/feni/locks.go @@ -15,8 +15,8 @@ func init() { const getLocksAnnotationValue = "GetLocks" -var GetLocksDynamic = func(annotationValue string) []prompt.Suggest { - scripts, err := storage.GetScripts("") +var GetLocksDynamic = func(wallet *wallet.Wallet, annotationValue string) []prompt.Suggest { + scripts, err := wallet.Storage.GetScripts("") if err != nil { return nil } @@ -39,14 +39,14 @@ var locksCommand = &cobra.Command{ } func locks(wallet *wallet.Wallet, params cobraParameter) { - scriptLocks := getP2SHLocks() + scriptLocks := getP2SHLocks(wallet) for _, l := range scriptLocks { fmt.Printf("P2SH:%s\n", l.Address) } } -func getP2SHLocks() []cashu.P2SHScript { - scripts, err := storage.GetScripts("") +func getP2SHLocks(wallet *wallet.Wallet) []cashu.P2SHScript { + scripts, err := wallet.Storage.GetScripts("") if err != nil { return nil } diff --git a/cmd/cashu/feni/pending.go b/cmd/cashu/feni/pending.go index 0f493e9..0ae5794 100644 --- a/cmd/cashu/feni/pending.go +++ b/cmd/cashu/feni/pending.go @@ -19,7 +19,7 @@ func init() { RootCmd.Command().AddCommand(pendingCommand) } func pendingCmd(wallet *wallet.Wallet, params cobraParameter) { - reserved, err := storage.GetReservedProofs() + reserved, err := wallet.Storage.GetReservedProofs() if err != nil { log.Fatal(err) } diff --git a/cmd/cashu/feni/prompt.go b/cmd/cashu/feni/prompt.go index 0c716cb..54a8afd 100644 --- a/cmd/cashu/feni/prompt.go +++ b/cmd/cashu/feni/prompt.go @@ -70,7 +70,7 @@ func DynamicSuggestion(cmd *RootCommand) func(annotationValue string, document * return suggestions } } else if document.Text == "locks " || document.Text == "-l " { - if suggestions := GetLocksDynamic(annotationValue); suggestions != nil { + if suggestions := GetLocksDynamic(cmd.wallet, annotationValue); suggestions != nil { return suggestions } } else if sendRegex.MatchString(document.Text) { diff --git a/cmd/cashu/feni/send.go b/cmd/cashu/feni/send.go index ddb116f..0790bcf 100644 --- a/cmd/cashu/feni/send.go +++ b/cmd/cashu/feni/send.go @@ -32,7 +32,7 @@ var sendCommand = &cobra.Command{ } var filteredKeySets []crypto.KeySet var GetMintsDynamic = func(wallet *wallet.Wallet, annotationValue string) []prompt.Suggest { - keysets, err := storage.GetKeySet() + keysets, err := wallet.Storage.GetKeySet() if err != nil { return nil } @@ -59,7 +59,7 @@ var GetMintsDynamic = func(wallet *wallet.Wallet, annotationValue string) []prom } func askMintSelection(wallet *wallet.Wallet, cmd *cobra.Command) error { - keysets, err := storage.GetKeySet() + keysets, err := wallet.Storage.GetKeySet() if err != nil { return nil }