mirror of
https://github.com/fiatjaf/nak.git
synced 2026-10-05 15:18:23 +00:00
wallet: fix nutzap setup, --mint was read under the wrong name and never used, the mandatory pubkey tag was never set on the kind:10019, and --force didn't actually replace the private key.
This commit is contained in:
@@ -499,8 +499,13 @@ var wallet = &cli.Command{
|
|||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("missing --private-key")
|
return fmt.Errorf("missing --private-key")
|
||||||
}
|
}
|
||||||
} else if sk := c.String("private-key"); sk != "" && !c.Bool("force") {
|
} else if sk := c.String("private-key"); sk != "" {
|
||||||
return fmt.Errorf("refusing to replace existing private key, use the --force flag")
|
if !c.Bool("force") {
|
||||||
|
return fmt.Errorf("refusing to replace existing private key, use the --force flag")
|
||||||
|
}
|
||||||
|
if err := w.SetPrivateKey(ctx, sk); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kr, _, _ := gatherKeyerFromArguments(ctx, c)
|
kr, _, _ := gatherKeyerFromArguments(ctx, c)
|
||||||
@@ -517,13 +522,18 @@ var wallet = &cli.Command{
|
|||||||
info.ParseEvent(ie.Event)
|
info.ParseEvent(ie.Event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mints := c.StringSlice("mints"); len(mints) == 0 && len(info.Mints) == 0 {
|
if mints := c.StringSlice("mint"); len(mints) > 0 {
|
||||||
|
info.Mints = mints
|
||||||
|
} else if len(info.Mints) == 0 {
|
||||||
info.Mints = w.Mints
|
info.Mints = w.Mints
|
||||||
}
|
}
|
||||||
if len(info.Mints) == 0 {
|
if len(info.Mints) == 0 {
|
||||||
return fmt.Errorf("missing --mint")
|
return fmt.Errorf("missing --mint")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the pubkey tag is mandatory, without it no one can send us nutzaps
|
||||||
|
info.PublicKey = nostr.PubKey(w.PublicKey.SerializeCompressed()[1:])
|
||||||
|
|
||||||
evt := nostr.Event{}
|
evt := nostr.Event{}
|
||||||
if err := info.ToEvent(ctx, kr, &evt); err != nil {
|
if err := info.ToEvent(ctx, kr, &evt); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user