chore: check for an error when getting public key when creating new app (#1989)

This commit is contained in:
Roland 2025-12-16 23:07:27 +07:00 committed by GitHub
parent a5f2c2d692
commit d7e29a2eb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -73,15 +73,19 @@ func (svc *appsService) CreateApp(name string, pubkey string, maxAmountSat uint6
}
// ensure there is at least one scope
if scopes == nil || len(scopes) == 0 {
if len(scopes) == 0 {
return nil, "", errors.New("no scopes provided")
}
var pairingPublicKey string
var pairingSecretKey string
var err error
if pubkey == "" {
pairingSecretKey = nostr.GeneratePrivateKey()
pairingPublicKey, _ = nostr.GetPublicKey(pairingSecretKey)
pairingPublicKey, err = nostr.GetPublicKey(pairingSecretKey)
if err != nil {
return nil, "", err
}
} else {
pairingPublicKey = pubkey
//validate public key
@ -118,7 +122,7 @@ func (svc *appsService) CreateApp(name string, pubkey string, maxAmountSat uint6
app := db.App{Name: freeName, AppPubkey: pairingPublicKey, Isolated: isolated, Metadata: datatypes.JSON(metadataBytes)}
err := svc.db.Transaction(func(tx *gorm.DB) error {
err = svc.db.Transaction(func(tx *gorm.DB) error {
err := tx.Save(&app).Error
if err != nil {
return err