mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-08 16:48:51 +00:00
wallet tokens drop
This commit is contained in:
30
wallet.go
30
wallet.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -172,6 +173,35 @@ var wallet = &cli.Command{
|
|||||||
closew()
|
closew()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
Commands: []*cli.Command{
|
||||||
|
{
|
||||||
|
Name: "drop",
|
||||||
|
Usage: "deletes a token from the wallet",
|
||||||
|
DisableSliceFlagSeparator: true,
|
||||||
|
ArgsUsage: "<id>...",
|
||||||
|
Action: func(ctx context.Context, c *cli.Command) error {
|
||||||
|
ids := c.Args().Slice()
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return fmt.Errorf("no token ids specified")
|
||||||
|
}
|
||||||
|
|
||||||
|
w, closew, err := prepareWallet(ctx, c)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, token := range w.Tokens {
|
||||||
|
if slices.Contains(ids, token.ID()) {
|
||||||
|
w.DropToken(ctx, token.ID())
|
||||||
|
log("dropped %s %d %s\n", token.ID(), token.Proofs.Amount(), strings.Split(token.Mint, "://")[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closew()
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "receive",
|
Name: "receive",
|
||||||
|
|||||||
Reference in New Issue
Block a user