mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
chore: check for an error when getting public key when creating new app (#1989)
This commit is contained in:
parent
a5f2c2d692
commit
d7e29a2eb6
1 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue