nip60: just rely on nut08 overpaid fees to get change when melting, don't try to swap beforehand.

This commit is contained in:
fiatjaf
2025-01-30 09:45:00 -03:00
parent be65134354
commit f0054af4d8
5 changed files with 135 additions and 60 deletions

View File

@@ -59,7 +59,7 @@ func (w *Wallet) SendToken(ctx context.Context, amount uint64, opts ...SendOptio
w.tokensMu.Lock()
defer w.tokensMu.Unlock()
chosen, _, err := w.getProofsForSending(ctx, amount, ss.specificMint)
chosen, _, err := w.getProofsForSending(ctx, amount, ss.specificMint, nil)
if err != nil {
return "", err
}
@@ -138,7 +138,7 @@ func (w *Wallet) saveChangeAndDeleteUsedTokens(
deleteEvent := nostr.Event{
CreatedAt: nostr.Now(),
Kind: 5,
Tags: nostr.Tags{{"e", token.event.ID}, {"k", "7375"}},
Tags: nostr.Tags{{"e", token.event.ID}, {"k", "7375"}, {"alt", "deleting"}},
}
w.wl.kr.SignEvent(ctx, &deleteEvent)
w.wl.Changes <- deleteEvent
@@ -163,12 +163,16 @@ func (w *Wallet) getProofsForSending(
ctx context.Context,
amount uint64,
specificMint string,
excludeMints []string,
) (chosenTokens, uint64, error) {
byMint := make(map[string]chosenTokens)
for t, token := range w.Tokens {
if specificMint != "" && token.Mint != specificMint {
continue
}
if slices.Contains(excludeMints, token.Mint) {
continue
}
part, ok := byMint[token.Mint]
if !ok {