diff --git a/cmd/cashu/feni/config.go b/cmd/cashu/feni/config.go index 4a160cf..da95628 100644 --- a/cmd/cashu/feni/config.go +++ b/cmd/cashu/feni/config.go @@ -65,7 +65,7 @@ func StartClientConfiguration() { Wallet = MintWallet{ proofs: make([]cashu.Proof, 0), - client: &Client{Url: fmt.Sprintf("%s:%s", Config.MintServerHost, Config.MintServerPort)}, + Client: &Client{Url: fmt.Sprintf("%s:%s", Config.MintServerHost, Config.MintServerPort)}, } Wallet.loadDefaultMint() @@ -82,7 +82,7 @@ func (w *MintWallet) loadMint(keySetId string) { w.currentKeySet = &set } } - w.client.Url = w.currentKeySet.MintUrl + w.Client.Url = w.currentKeySet.MintUrl w.loadDefaultMint() } func (w *MintWallet) setCurrentKeySet(keySet crypto.KeySet) { @@ -103,7 +103,7 @@ func (w *MintWallet) loadDefaultMint() { keySet, _ := w.persistCurrentKeysSet() w.loadPersistedKeySets() w.setCurrentKeySet(keySet) - k, err := w.client.KeySets() + k, err := w.Client.KeySets() if err != nil { panic(err) } @@ -120,14 +120,14 @@ func (w *MintWallet) loadDefaultMint() { } func (w *MintWallet) persistCurrentKeysSet() (crypto.KeySet, error) { - activeKeys, err := w.client.Keys() + activeKeys, err := w.Client.Keys() if err != nil { panic(err) } return w.persistKeysSet(activeKeys) } func (w *MintWallet) persistKeysSet(keys map[uint64]*secp256k1.PublicKey) (crypto.KeySet, error) { - keySet := crypto.KeySet{MintUrl: w.client.Url, FirstSeen: time.Now(), PublicKeys: crypto.PublicKeyList{}} + keySet := crypto.KeySet{MintUrl: w.Client.Url, FirstSeen: time.Now(), PublicKeys: crypto.PublicKeyList{}} keySet.SetPublicKeyList(keys) keySet.DeriveKeySetId() err := storage.StoreKeySet(keySet) @@ -140,7 +140,7 @@ func (w *MintWallet) checkAndPersistKeySet(id string) error { var ks []crypto.KeySet var err error if ks, err = storage.GetKeySet(db.KeySetWithId(id)); err != nil || len(ks) == 0 { - keys, err := w.client.KeysForKeySet(id) + keys, err := w.Client.KeysForKeySet(id) if err != nil { return err } diff --git a/cmd/cashu/feni/invoice.go b/cmd/cashu/feni/invoice.go index 67aa7d1..511fa89 100644 --- a/cmd/cashu/feni/invoice.go +++ b/cmd/cashu/feni/invoice.go @@ -41,7 +41,7 @@ func mintCmd(cmd *cobra.Command, args []string) { } if hash == "" { var invoice lightning.Invoicer - invoice, err = Wallet.client.GetMint(int64(amount)) + invoice, err = Wallet.Client.GetMint(int64(amount)) if err != nil { panic(err) } @@ -80,7 +80,7 @@ func mintCmd(cmd *cobra.Command, args []string) { } func invalidate(proofs []cashu.Proof) error { - resp, err := Wallet.client.Check(cashu.CheckSpendableRequest{Proofs: proofs}) + resp, err := Wallet.Client.Check(cashu.CheckSpendableRequest{Proofs: proofs}) if err != nil { return err } diff --git a/cmd/cashu/feni/pay.go b/cmd/cashu/feni/pay.go index 458cdda..24cc43a 100644 --- a/cmd/cashu/feni/pay.go +++ b/cmd/cashu/feni/pay.go @@ -56,7 +56,7 @@ func pay(cmd *cobra.Command, args []string) { return } invoice := args[0] - fee, err := Wallet.client.CheckFee(cashu.CheckFeesRequest{Pr: invoice}) + fee, err := Wallet.Client.CheckFee(cashu.CheckFeesRequest{Pr: invoice}) if err != nil { log.Fatal(err) } diff --git a/cmd/cashu/feni/receive.go b/cmd/cashu/feni/receive.go index f519a02..e2a2939 100644 --- a/cmd/cashu/feni/receive.go +++ b/cmd/cashu/feni/receive.go @@ -96,11 +96,11 @@ func receive(cmd *cobra.Command, args []string) { log.Fatal("Aborted!") }*/ for _, token := range tokens.Token { - defaultUrl := Wallet.client.Url + defaultUrl := Wallet.Client.Url defer func() { - Wallet.client.Url = defaultUrl + Wallet.Client.Url = defaultUrl }() - Wallet.client.Url = token.Mint + Wallet.Client.Url = token.Mint _, _, err := Wallet.redeem(token.Proofs, script, signature) if err != nil { log.Fatal(err) @@ -124,10 +124,10 @@ func verifyMints(cmd cobra.Command, token Tokens) (trust bool) { continue } trust = false - u := Wallet.client.Url - Wallet.client.Url = m.Mint + u := Wallet.Client.Url + Wallet.Client.Url = m.Mint // fetch unknown keysets from mint - wks, err := Wallet.client.KeySets() + wks, err := Wallet.Client.KeySets() if err != nil { panic(err) } @@ -145,7 +145,7 @@ func verifyMints(cmd cobra.Command, token Tokens) (trust bool) { } // ask user to verify trust cmd.Printf("Warning: Tokens are from a mint you don't know yet.\n") - cmd.Printf("Mint URL: %s\n", Wallet.client.Url) + cmd.Printf("Mint URL: %s\n", Wallet.Client.Url) cmd.Printf("Mint keyset: %s\n", kid) cmd.Printf("Do you trust this mint and want to receive the tokens? (y/n)\n") trust = ask(&cmd) @@ -155,7 +155,7 @@ func verifyMints(cmd cobra.Command, token Tokens) (trust bool) { panic(err) } } - Wallet.client.Url = u // reset the url + Wallet.Client.Url = u // reset the url } return } diff --git a/cmd/cashu/feni/send.go b/cmd/cashu/feni/send.go index 19da71d..ecebcb6 100644 --- a/cmd/cashu/feni/send.go +++ b/cmd/cashu/feni/send.go @@ -77,7 +77,7 @@ func askMintSelection(cmd *cobra.Command) error { cmd.Printf("Mint: %d Balance: %d sat (available: %d) URL: %s\n", i+1, setBalance[set.MintUrl], setBalanceAvailable[set.MintUrl], set.MintUrl) } cmd.Printf("Select mint [1-%d, press enter default 1]\n\n", len(filteredKeySets)) - Wallet.client.Url = filteredKeySets[askInt(cmd)-1].MintUrl + Wallet.Client.Url = filteredKeySets[askInt(cmd)-1].MintUrl Wallet.loadDefaultMint() return nil } @@ -118,7 +118,7 @@ func send(cmd *cobra.Command, args []string) { p2sh = true } mint, _ := strconv.Atoi(args[1]) - Wallet.client.Url = filteredKeySets[mint].MintUrl + Wallet.Client.Url = filteredKeySets[mint].MintUrl Wallet.loadDefaultMint() amount, err := strconv.Atoi(args[0]) if err != nil { @@ -146,7 +146,7 @@ func send(cmd *cobra.Command, args []string) { func (w MintWallet) serializeToken(proofs []cashu.Proof, hideSecrets bool) (string, error) { // Create a new Token structure with the given proofs and an empty Mints map. token := Tokens{Token: make([]Token, 0)} - token.Token = append(token.Token, Token{Proofs: proofs, Mint: w.client.Url}) + token.Token = append(token.Token, Token{Proofs: proofs, Mint: w.Client.Url}) // Iterate over each proof in the `proofs` slice. for i := range proofs { // If `hideSecrets` is true, set the `Secret` field of the current proof to an empty string. diff --git a/cmd/cashu/feni/wallet.go b/cmd/cashu/feni/wallet.go index 68eb042..6f7c14d 100644 --- a/cmd/cashu/feni/wallet.go +++ b/cmd/cashu/feni/wallet.go @@ -40,7 +40,7 @@ type MintWallet struct { keySets []crypto.KeySet // current keySet id from mint server. proofs []cashu.Proof currentKeySet *crypto.KeySet - client *Client + Client *Client } var Wallet MintWallet @@ -118,7 +118,7 @@ func (w MintWallet) mint(amounts []uint64, paymentHash string) []cashu.Proof { panic(err) } req, privateKeys := constructOutputs(amounts, secrets) - blindedSignatures, err := w.client.Mint(req, paymentHash) + blindedSignatures, err := w.Client.Mint(req, paymentHash) if err != nil { panic(err) } @@ -241,7 +241,7 @@ func (w MintWallet) PayLightning(proofs []cashu.Proof, invoice string) ([]cashu. secrets = append(secrets, generateSecret()) } payloads, rs := constructOutputs(amounts, secrets) - res, err := w.client.Melt(cashu.MeltRequest{Proofs: proofs, Pr: invoice, Outputs: payloads.Outputs}) + res, err := w.Client.Melt(cashu.MeltRequest{Proofs: proofs, Pr: invoice, Outputs: payloads.Outputs}) if err != nil { return nil, err } @@ -391,7 +391,7 @@ func (w MintWallet) split(proofs []cashu.Proof, amount uint64, scndSecret string } // TODO -- check used secrets(secrtes) payloads, rs := constructOutputs(amounts, secrets) - response, err := w.client.Split(cashu.SplitRequest{Amount: amount, Proofs: proofs, Outputs: payloads.Outputs}) + response, err := w.Client.Split(cashu.SplitRequest{Amount: amount, Proofs: proofs, Outputs: payloads.Outputs}) if err != nil { return nil, nil, err }