diff --git a/breez/breez.go b/breez/breez.go new file mode 100644 index 00000000..2654ae75 --- /dev/null +++ b/breez/breez.go @@ -0,0 +1,54 @@ +package main + +import ( + "context" + "log" + + "github.com/breez/breez-sdk-go/breez_sdk" +) + +type BreezService struct { + listener *BreezListener + svc *breez_sdk.BlockingBreezServices +} +type BreezListener struct{} + +func (BreezListener) OnEvent(e breez_sdk.BreezEvent) { + log.Printf("received event %#v", e) +} + +func NewBreezService(mnemonic, apiKey, inviteCode string) (result *BreezService, err error) { + seed, err := breez_sdk.MnemonicToSeed(mnemonic) + if err != nil { + return nil, err + } + nodeConfig := breez_sdk.NodeConfigGreenlight{ + Config: breez_sdk.GreenlightNodeConfig{ + InviteCode: &inviteCode, + }, + } + listener := BreezListener{} + config := breez_sdk.DefaultConfig(breez_sdk.EnvironmentTypeProduction, apiKey, nodeConfig) + svc, err := breez_sdk.Connect(config, seed, listener) + if err != nil { + return nil, err + } + //todo: init LSP (wait for Breez to fix issue) + return &BreezService{ + listener: &listener, + svc: svc, + }, nil +} + +func (bs *BreezService) SendPaymentSync(ctx context.Context, senderPubkey string, payReq string) (preimage string, err error) { + return "", nil + +} + +func (bs *BreezService) GetBalance(ctx context.Context, senderPubkey string) (balance int64, err error) { + return 0, nil +} + +func (bs *BreezService) MakeInvoice(ctx context.Context, senderPubkey string, amount int64, description string, descriptionHash string, expiry int64) (invoice string, paymentHash string, err error) { + return "", "", nil +} diff --git a/go.mod b/go.mod index d12c39f3..a76b054f 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/getAlby/nostr-wallet-connect go 1.20 require ( + github.com/breez/breez-sdk-go v0.1.5-beta.rc2 github.com/davrux/echo-logrus/v4 v4.0.3 github.com/gorilla/sessions v1.2.1 github.com/labstack/echo-contrib v0.14.1 diff --git a/go.sum b/go.sum index d7dc6030..855d247b 100644 --- a/go.sum +++ b/go.sum @@ -83,6 +83,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/breez/breez-sdk-go v0.1.5-beta.rc2 h1:B9XFtPMFYi6OPK0NCmm5dwF4sq4vnSaB4vcLTv/TkdQ= +github.com/breez/breez-sdk-go v0.1.5-beta.rc2/go.mod h1:EalYMEeQVwRzr6UXnF4QpLlpuWNwQQN9xwtDKNIutBo= github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=