mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-29 15:22:28 +02:00
feat: update gonuts dependency
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/elnosh/gonuts/cashu/nuts/nut02"
|
||||
"github.com/elnosh/gonuts/cashu/nuts/nut03"
|
||||
"github.com/elnosh/gonuts/cashu/nuts/nut10"
|
||||
"github.com/elnosh/gonuts/cashu/nuts/nut13"
|
||||
"github.com/nbd-wtf/go-nostr/nip60/client"
|
||||
)
|
||||
|
||||
@@ -25,10 +26,33 @@ func (w *Wallet) swapProofs(
|
||||
targetAmount uint64,
|
||||
ss swapSettings,
|
||||
) (principal cashu.Proofs, change cashu.Proofs, err error) {
|
||||
keysetIdList := []string{}
|
||||
for i := range w.Mints {
|
||||
if w.Mints[i] != mint {
|
||||
keysets, err := client.GetAllKeysets(ctx, w.Mints[i])
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("could not get keysets for all previous keysets %s: %w", w.Mints[i], err)
|
||||
}
|
||||
|
||||
for j := range keysets {
|
||||
keysetIdList = append(keysetIdList, keysets[j].Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keysets, err := client.GetAllKeysets(ctx, mint)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to get all keysets for %s: %w", mint, err)
|
||||
}
|
||||
|
||||
for j := range keysets {
|
||||
err := nut13.CheckCollidingKeysets(keysetIdList, []string{keysets[j].Id})
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("encountered keyset collition for mint %s: %w", mint, err)
|
||||
}
|
||||
keysetIdList = append(keysetIdList, keysets[j].Id)
|
||||
}
|
||||
|
||||
activeKeyset, err := client.GetActiveKeyset(ctx, mint)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to get active keyset for %s: %w", mint, err)
|
||||
|
@@ -11,7 +11,9 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/elnosh/gonuts/cashu/nuts/nut13"
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/nbd-wtf/go-nostr/nip60/client"
|
||||
)
|
||||
|
||||
type Wallet struct {
|
||||
@@ -254,6 +256,18 @@ func (w *Wallet) AddMint(ctx context.Context, urls ...string) error {
|
||||
return fmt.Errorf("can't do write operations: missing PublishUpdate function")
|
||||
}
|
||||
|
||||
keysetIdList := []string{}
|
||||
for i := range w.Mints {
|
||||
keysets, err := client.GetAllKeysets(ctx, w.Mints[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for j := range keysets {
|
||||
keysetIdList = append(keysetIdList, keysets[j].Id)
|
||||
}
|
||||
}
|
||||
|
||||
for _, url := range urls {
|
||||
url, err := nostr.NormalizeHTTPURL(url)
|
||||
if err != nil {
|
||||
@@ -261,6 +275,18 @@ func (w *Wallet) AddMint(ctx context.Context, urls ...string) error {
|
||||
}
|
||||
|
||||
if !slices.Contains(w.Mints, url) {
|
||||
keysets, err := client.GetAllKeysets(ctx, url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for j := range keysets {
|
||||
err = nut13.CheckCollidingKeysets(keysetIdList, []string{keysets[j].Id})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
keysetIdList = append(keysetIdList, keysets[j].Id)
|
||||
}
|
||||
w.Mints = append(w.Mints, url)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user