Skip to content

Commit

Permalink
add breez provider
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiidb committed Aug 25, 2023
1 parent d4823a9 commit 9b607fe
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
54 changes: 54 additions & 0 deletions breez/breez.go
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 9b607fe

Please sign in to comment.