-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/zapstore
- Loading branch information
Showing
10 changed files
with
163 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package service | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/getAlby/hub/events" | ||
"github.com/getAlby/hub/logger" | ||
"github.com/nbd-wtf/go-nostr" | ||
) | ||
|
||
type updateAppConsumer struct { | ||
events.EventSubscriber | ||
svc *service | ||
relay *nostr.Relay | ||
} | ||
|
||
// When a app is updated, re-publish the nip47 info event | ||
func (s *updateAppConsumer) ConsumeEvent(ctx context.Context, event *events.Event, globalProperties map[string]interface{}) { | ||
if event.Event != "nwc_app_updated" { | ||
return | ||
} | ||
|
||
properties, ok := event.Properties.(map[string]interface{}) | ||
if !ok { | ||
logger.Logger.WithField("event", event).Error("Failed to cast event.Properties to map") | ||
return | ||
} | ||
id, ok := properties["id"].(uint) | ||
if !ok { | ||
logger.Logger.WithField("event", event).Error("Failed to get app id") | ||
return | ||
} | ||
walletPrivKey, err := s.svc.keys.GetAppWalletKey(id) | ||
if err != nil { | ||
logger.Logger.WithError(err).Error("Failed to calculate app wallet priv key") | ||
return | ||
} | ||
walletPubKey, err := nostr.GetPublicKey(walletPrivKey) | ||
if err != nil { | ||
logger.Logger.WithError(err).Error("Failed to calculate app wallet pub key") | ||
return | ||
} | ||
|
||
if s.svc.keys.GetNostrPublicKey() != walletPubKey { | ||
// only need to re-publish the nip47 event info if it is not a legacy wallet | ||
|
||
_, err = s.svc.GetNip47Service().PublishNip47Info(ctx, s.relay, walletPubKey, walletPrivKey, s.svc.lnClient) | ||
if err != nil { | ||
logger.Logger.WithError(err).Error("Could not re-publish NIP47 info") | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters