diff --git a/backend/api/apis.go b/backend/api/apis.go index 6e494d46..e54cd743 100644 --- a/backend/api/apis.go +++ b/backend/api/apis.go @@ -7,6 +7,7 @@ import ( documentsv3 "seed/backend/api/documents/v3alpha" entities "seed/backend/api/entities/v1alpha" networking "seed/backend/api/networking/v1alpha" + payments "seed/backend/api/payments/v1alpha" "seed/backend/blob" "seed/backend/core" "seed/backend/logging" @@ -27,8 +28,10 @@ type Server struct { Activity *activity.Server Syncing *syncing.Service DocumentsV3 *documentsv3.Server + Payments *payments.Server } +// Storage holds all the storing functionality. type Storage interface { DB() *sqlitex.Pool KeyStore() core.KeyStore @@ -38,24 +41,23 @@ type Storage interface { // New creates a new API server. func New( - ctx context.Context, repo Storage, idx *blob.Index, node *mttnet.Node, - wallet daemon.Wallet, sync *syncing.Service, activity *activity.Server, LogLevel string, + isMainnet bool, ) Server { db := repo.DB() - return Server{ Activity: activity, - Daemon: daemon.NewServer(repo, wallet, &p2pNodeSubset{node: node, sync: sync}), + Daemon: daemon.NewServer(repo, &p2pNodeSubset{node: node, sync: sync}), Networking: networking.NewServer(node, db, logging.New("seed/networking", LogLevel)), Entities: entities.NewServer(idx, sync), DocumentsV3: documentsv3.NewServer(repo.KeyStore(), idx, db, logging.New("seed/documents", LogLevel)), Syncing: sync, + Payments: payments.NewServer(logging.New("seed/payments", LogLevel), db, node, repo.KeyStore(), isMainnet), } } @@ -66,6 +68,7 @@ func (s Server) Register(srv *grpc.Server) { s.Networking.RegisterServer(srv) s.Entities.RegisterServer(srv) s.DocumentsV3.RegisterServer(srv) + s.Payments.RegisterServer(srv) } type p2pNodeSubset struct { diff --git a/backend/api/daemon/v1alpha/daemon.go b/backend/api/daemon/v1alpha/daemon.go index b42509c9..48131973 100644 --- a/backend/api/daemon/v1alpha/daemon.go +++ b/backend/api/daemon/v1alpha/daemon.go @@ -4,7 +4,6 @@ package daemon import ( context "context" - "fmt" "seed/backend/core" daemon "seed/backend/genproto/daemon/v1alpha" sync "sync" @@ -24,11 +23,6 @@ type Storage interface { KeyStore() core.KeyStore } -// Wallet is a subset of the wallet service used by this server. -type Wallet interface { - ConfigureSeedLNDHub(context.Context, core.KeyPair) error -} - // Node is a subset of the p2p node. type Node interface { ForceSync() error @@ -40,7 +34,6 @@ type Node interface { type Server struct { store Storage startTime time.Time - wallet Wallet p2p Node @@ -48,11 +41,7 @@ type Server struct { } // NewServer creates a new Server. -func NewServer(store Storage, w Wallet, n Node) *Server { - if w == nil { - panic("BUG: wallet is required") - } - +func NewServer(store Storage, n Node) *Server { if n == nil { panic("BUG: p2p node is required") } @@ -166,14 +155,6 @@ func (srv *Server) RegisterAccount(ctx context.Context, name string, kp core.Key return err } - // TODO(hm24): we don't need to do this here since now we have the keys always accessible, unless the user - // chooses not to store the keys... Do this at the time of creating the seed wallet (new method not insert - // wallet which is an external wallet) - if srv.wallet != nil { - if err := srv.wallet.ConfigureSeedLNDHub(ctx, kp); err != nil { - return fmt.Errorf("failed to configure wallet when registering: %w", err) - } - } return nil } diff --git a/backend/api/daemon/v1alpha/daemon_test.go b/backend/api/daemon/v1alpha/daemon_test.go index 0bc8e80c..169d1874 100644 --- a/backend/api/daemon/v1alpha/daemon_test.go +++ b/backend/api/daemon/v1alpha/daemon_test.go @@ -65,13 +65,7 @@ func newTestServer(t *testing.T, name string) *Server { require.NoError(t, err) t.Cleanup(func() { require.NoError(t, store.Close()) }) - return NewServer(store, &mockedWallet{}, &mockedP2PNode{}) -} - -type mockedWallet struct{} - -func (w *mockedWallet) ConfigureSeedLNDHub(context.Context, core.KeyPair) error { - return nil + return NewServer(store, &mockedP2PNode{}) } type mockedP2PNode struct{} diff --git a/backend/api/networking/v1alpha/networking_test.go b/backend/api/networking/v1alpha/networking_test.go index e7c0c7fe..53f2d483 100644 --- a/backend/api/networking/v1alpha/networking_test.go +++ b/backend/api/networking/v1alpha/networking_test.go @@ -23,14 +23,12 @@ func TestNetworkingGetPeerInfo(t *testing.T) { ctx := context.Background() pid := alice.Device.PeerID() - acc := alice.Account.Principal() pinfo, err := api.GetPeerInfo(ctx, &networking.GetPeerInfoRequest{ DeviceId: pid.String(), }) require.NoError(t, err) require.NotNil(t, pinfo) - require.Equal(t, acc.String(), pinfo.AccountId, "account ids must match") } func makeTestServer(t *testing.T, u coretest.Tester) *Server { diff --git a/backend/api/payments/v1alpha/invoices.go b/backend/api/payments/v1alpha/invoices.go new file mode 100644 index 00000000..53374570 --- /dev/null +++ b/backend/api/payments/v1alpha/invoices.go @@ -0,0 +1,235 @@ +// Package payments handles lightning payments. +package payments + +import ( + "context" + "errors" + "fmt" + "seed/backend/core" + payments "seed/backend/genproto/payments/v1alpha" + "seed/backend/lndhub" + "seed/backend/lndhub/lndhubsql" + "seed/backend/wallet/walletsql" + "strings" + + "google.golang.org/protobuf/types/known/emptypb" + + "go.uber.org/zap" +) + +// ListPaidInvoices returns the invoices that the wallet represented by walletID has paid. +func (srv *Server) ListPaidInvoices(ctx context.Context, in *payments.ListInvoicesRequest) (*payments.ListInvoicesResponse, error) { + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return nil, err + } + defer release() + + w, err := walletsql.GetWallet(conn, in.Id) + if err != nil { + srv.log.Debug("couldn't list wallets: " + err.Error()) + return nil, fmt.Errorf("couldn't list wallets") + } + if strings.ToLower(w.Type) != lndhubsql.LndhubWalletType && strings.ToLower(w.Type) != lndhubsql.LndhubGoWalletType { + err = fmt.Errorf("Couldn't get invoices form wallet type %s", w.Type) + srv.log.Debug(err.Error()) + return nil, err + } + invoices, err := srv.lightningClient.Lndhub.ListPaidInvoices(ctx, in.Id) + if err != nil { + srv.log.Debug("couldn't list outgoing invoices: " + err.Error()) + return nil, err + } + + ret := &payments.ListInvoicesResponse{} + for _, invoice := range invoices { + ret.Invoices = append(ret.Invoices, &payments.Invoice{ + PaymentHash: invoice.PaymentHash, + PaymentRequest: invoice.PaymentRequest, + Description: invoice.Description, + DescriptionHash: invoice.DescriptionHash, + PaymentPreimage: invoice.PaymentPreimage, + Destination: invoice.Destination, + Amount: invoice.Amount, + Fee: invoice.Fee, + Status: invoice.Status, + Type: invoice.Type, + ErrorMessage: invoice.ErrorMessage, + SettledAt: invoice.SettledAt, + ExpiresAt: invoice.ExpiresAt, + IsPaid: invoice.IsPaid, + Keysend: invoice.Keysend, + }) + } + return ret, nil +} + +// ListReceivednvoices returns the incoming invoices that the wallet represented by walletID has received. +func (srv *Server) ListReceivednvoices(ctx context.Context, in *payments.ListInvoicesRequest) (*payments.ListInvoicesResponse, error) { + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return nil, err + } + defer release() + + w, err := walletsql.GetWallet(conn, in.Id) + if err != nil { + srv.log.Debug("couldn't list wallets: " + err.Error()) + return nil, fmt.Errorf("couldn't list wallets: %w", err) + } + if strings.ToLower(w.Type) != lndhubsql.LndhubWalletType && strings.ToLower(w.Type) != lndhubsql.LndhubGoWalletType { + err = fmt.Errorf("Couldn't get invoices form wallet type %s", w.Type) + srv.log.Debug(err.Error()) + return nil, err + } + invoices, err := srv.lightningClient.Lndhub.ListReceivedInvoices(ctx, in.Id) + if err != nil { + srv.log.Debug("couldn't list incoming invoices: " + err.Error()) + return nil, err + } + ret := &payments.ListInvoicesResponse{} + for _, invoice := range invoices { + ret.Invoices = append(ret.Invoices, &payments.Invoice{ + PaymentHash: invoice.PaymentHash, + PaymentRequest: invoice.PaymentRequest, + Description: invoice.Description, + DescriptionHash: invoice.DescriptionHash, + PaymentPreimage: invoice.PaymentPreimage, + Destination: invoice.Destination, + Amount: invoice.Amount, + Fee: invoice.Fee, + Status: invoice.Status, + Type: invoice.Type, + ErrorMessage: invoice.ErrorMessage, + SettledAt: invoice.SettledAt, + ExpiresAt: invoice.ExpiresAt, + IsPaid: invoice.IsPaid, + Keysend: invoice.Keysend, + }) + } + return ret, nil +} + +// RequestLud6Invoice asks a remote peer to issue an invoice. The remote user can be either a lnaddres or a Seed account ID +// First an lndhub invoice request is attempted. If it fails, then a P2P its used to transmit the invoice. In that case, +// Any of the devices associated with the accountID can issue the invoice. The memo field is optional and can be left nil. +func (srv *Server) RequestLud6Invoice(ctx context.Context, in *payments.RequestLud6InvoiceRequest) (*payments.Payreq, error) { + payReq := &payments.Payreq{} + var err error + payReq.Payreq, err = srv.lightningClient.Lndhub.RequestLud6Invoice(ctx, in.URL, in.User, in.Amount, in.Memo) + //err = fmt.Errorf("force p2p transmission") + if err != nil { + srv.log.Debug("couldn't get invoice via lndhub, trying p2p...", zap.Error(err)) + account, err := core.DecodePrincipal(in.User) + if err != nil { + publicErr := fmt.Errorf("couldn't parse accountID string [%s], If using p2p transmission, User must be a valid accountID", in.User) + srv.log.Debug("error decoding cid "+publicErr.Error(), zap.Error(err)) + return payReq, publicErr + } + payReq.Payreq, err = srv.P2PInvoiceRequest(ctx, account, + InvoiceRequest{ + AmountSats: in.Amount, + Memo: in.Memo, + HoldInvoice: false, // TODO: Add support hold invoices + PreimageHash: []byte{}, // Only applicable to hold invoices + }) + if err != nil { + srv.log.Debug("couldn't get invoice via p2p", zap.Error(err)) + return payReq, fmt.Errorf("After trying to get the invoice locally Could not request invoice via P2P") + } + } + + return payReq, nil +} + +// CreateInvoice tries to generate an invoice locally. +func (srv *Server) CreateInvoice(ctx context.Context, in *payments.CreateInvoiceRequest) (*payments.Payreq, error) { + ret := &payments.Payreq{} + wallet, err := srv.GetWallet(ctx, &payments.WalletRequest{Id: in.Id}) + if in.Id == "" && in.Account != "" { + wallet, err = srv.GetDefaultWallet(ctx, &payments.GetDefaultWalletRequest{Account: in.Account}) + if err != nil { + return ret, fmt.Errorf("could not get default wallet to ask for a local invoice") + } + } + if err != nil { + return ret, fmt.Errorf("could not get default wallet to ask for a local invoice") + } + if wallet.Type != lndhubsql.LndhubWalletType && wallet.Type != lndhubsql.LndhubGoWalletType { + err = fmt.Errorf("Wallet type %s not compatible with local invoice creation", wallet.Type) + srv.log.Debug("couldn't create local invoice: " + err.Error()) + return ret, err + } + + ret.Payreq, err = srv.lightningClient.Lndhub.CreateLocalInvoice(ctx, wallet.Id, in.Amount, in.Memo) + if err != nil { + srv.log.Debug("couldn't create local invoice: " + err.Error()) + return ret, err + } + return ret, nil +} + +// PayInvoice tries to pay the provided invoice. If a walletID is provided, that wallet will be used instead of the default one +// If amountSats is provided, the invoice will be paid with that amount. This amount should be equal to the amount on the invoice +// unless the amount on the invoice is 0. +func (srv *Server) PayInvoice(ctx context.Context, in *payments.PayInvoiceRequest) (*emptypb.Empty, error) { + walletToPay := &payments.Wallet{} + var err error + var amountToPay int64 + + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return nil, err + } + defer release() + + if in.Id != "" { + w, err := walletsql.GetWallet(conn, in.Id) + if err != nil { + publicErr := fmt.Errorf("couldn't get wallet %s", in.Id) + srv.log.Debug("Could not get wallet", zap.Error(publicErr)) + return nil, publicErr + } + walletToPay.Account = w.Account + walletToPay.Address = w.Address + walletToPay.Id = w.ID + walletToPay.Name = w.Name + walletToPay.Type = w.Type + } else { + walletToPay, err = srv.GetDefaultWallet(ctx, &payments.GetDefaultWalletRequest{Account: in.Account}) + if err != nil { + return nil, fmt.Errorf("couldn't get default wallet to pay") + } + } + + if !isSupported(walletToPay.Type) { + err = fmt.Errorf("wallet type [%s] not supported to pay. Currently supported: [%v]", walletToPay.Type, supportedWallets) + srv.log.Debug(err.Error()) + return nil, err + } + + if in.Amount == 0 { + invoice, err := lndhub.DecodeInvoice(in.Payreq) + if err != nil { + publicError := fmt.Errorf("couldn't decode invoice [%s], please make sure it is a bolt-11 compatible invoice", in.Payreq) + srv.log.Debug(publicError.Error(), zap.String("msg", err.Error())) + return nil, publicError + } + amountToPay = int64(invoice.MilliSat.ToSatoshis()) + } else { + amountToPay = in.Amount + } + + if err = srv.lightningClient.Lndhub.PayInvoice(ctx, walletToPay.Id, in.Payreq, amountToPay); err != nil { + if strings.Contains(err.Error(), walletsql.NotEnoughBalance) { + return nil, fmt.Errorf("couldn't pay invoice with wallet [%s]: %w", walletToPay.Name, lndhubsql.ErrNotEnoughBalance) + } + if errors.Is(err, lndhubsql.ErrQtyMissmatch) { + return nil, fmt.Errorf("couldn't pay invoice, quantity in invoice differs from amount to pay [%d] :%w", amountToPay, lndhubsql.ErrQtyMissmatch) + } + srv.log.Debug("couldn't pay invoice", zap.String("msg", err.Error())) + return nil, fmt.Errorf("couldn't pay invoice") + } + + return nil, nil +} diff --git a/backend/api/payments/v1alpha/invoices_test.go b/backend/api/payments/v1alpha/invoices_test.go new file mode 100644 index 00000000..a68c6b49 --- /dev/null +++ b/backend/api/payments/v1alpha/invoices_test.go @@ -0,0 +1,131 @@ +package payments + +import ( + "context" + "encoding/hex" + "seed/backend/core" + payments "seed/backend/genproto/payments/v1alpha" + "seed/backend/lndhub" + "seed/backend/lndhub/lndhubsql" + "seed/backend/testutil" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestRequestLndHubInvoice(t *testing.T) { + testutil.Manual(t) + ctx := context.Background() + alice := makeTestService(t, "alice") + aliceAccs, err := alice.ks.ListKeys(ctx) + require.NoError(t, err) + require.Len(t, aliceAccs, 1) + alicePk, err := aliceAccs[0].PublicKey.Libp2pKey() + require.NoError(t, err) + bob := makeTestService(t, "bob") + bobAccs, err := bob.ks.ListKeys(ctx) + require.NoError(t, err) + require.Len(t, bobAccs, 1) + bobPk, err := bobAccs[0].PublicKey.Libp2pKey() + require.NoError(t, err) + bobKp, err := bob.ks.GetKey(ctx, core.PrincipalFromPubKey(bobPk).String()) + + require.NoError(t, err) + alicesWallet, err := alice.CreateWallet(ctx, &payments.CreateWalletRequest{Account: core.PrincipalFromPubKey(alicePk).String(), Name: "myWallet"}) + require.NoError(t, err) + defaultWallet, err := alice.GetDefaultWallet(ctx, &payments.GetDefaultWalletRequest{Account: alicesWallet.Account}) + require.NoError(t, err) + require.Equal(t, alicesWallet, defaultWallet) + _, err = alice.ExportWallet(ctx, &payments.WalletRequest{Id: alicesWallet.Id}) + require.NoError(t, err) + + login, err := bobKp.Sign([]byte(lndhub.SigningMessage)) + require.NoError(t, err) + + uri := "lndhub.go://" + core.PrincipalFromPubKey(bobPk).String() + ":" + hex.EncodeToString(login) + "@https://ln.testnet.seed.hyper.media" + bobsWallet, err := bob.ImportWallet(ctx, &payments.ImportWalletRequest{CredentialsUrl: uri, Account: core.PrincipalFromPubKey(bobPk).String(), Name: "default"}) + require.NoError(t, err) + + var amt int64 = 23 + var wrongAmt int64 = 24 + var memo = "test invoice" + + var payreq *payments.Payreq + + defaultWallet, err = bob.GetDefaultWallet(ctx, &payments.GetDefaultWalletRequest{Account: core.PrincipalFromPubKey(bobPk).String()}) + require.NoError(t, err) + require.Equal(t, bobsWallet, defaultWallet) + require.Eventually(t, func() bool { + conn, release, err := bob.pool.Conn(ctx) + require.NoError(t, err) + defer release() + _, err = lndhubsql.GetToken(conn, defaultWallet.Id) + return err == nil + }, 3*time.Second, 1*time.Second) + + require.Eventually(t, func() bool { + payreq, err = alice.RequestLud6Invoice(ctx, &payments.RequestLud6InvoiceRequest{ + URL: bobsWallet.Address, + User: core.PrincipalFromPubKey(bobPk).String(), + Amount: int64(amt), + Memo: memo, + }) + return err == nil + }, 8*time.Second, 2*time.Second) + invoice, err := lndhub.DecodeInvoice(payreq.Payreq) + require.NoError(t, err) + require.EqualValues(t, amt, invoice.MilliSat.ToSatoshis()) + require.EqualValues(t, memo, *invoice.Description) + req := &payments.PayInvoiceRequest{Payreq: payreq.Payreq, + Account: alicesWallet.Account, + Amount: wrongAmt} + _, err = alice.PayInvoice(ctx, req) + require.ErrorIs(t, err, lndhubsql.ErrQtyMissmatch) + req.Amount = amt + _, err = alice.PayInvoice(ctx, req) + require.ErrorIs(t, err, lndhubsql.ErrNotEnoughBalance) +} + +func TestRequestP2PInvoice(t *testing.T) { + t.Skip("Not implemented, as we don't have contacts (PID->Account) yet") + testutil.Manual(t) + + alice := makeTestService(t, "alice") + bob := makeTestService(t, "bob") + ctx := context.Background() + aliceAcc, err := alice.net.GetAccountByKeyName(ctx, "main") + require.NoError(t, err) + bobAccount, err := bob.net.GetAccountByKeyName(ctx, "main") + require.NoError(t, err) + require.NoError(t, alice.net.Connect(ctx, bob.net.AddrInfo())) + defaultWallet, err := bob.GetDefaultWallet(ctx, &payments.GetDefaultWalletRequest{Account: bobAccount.String()}) + require.NoError(t, err) + + var amt int64 = 23 + var wrongAmt int64 = 24 + var memo = "test invoice" + var payreq *payments.Payreq + req := &payments.RequestLud6InvoiceRequest{ + URL: defaultWallet.Address, + User: bobAccount.String(), + Amount: int64(amt), + Memo: memo, + } + require.Eventually(t, func() bool { + payreq, err = alice.RequestLud6Invoice(ctx, req) + return err == nil + }, 8*time.Second, 2*time.Second) + invoice, err := lndhub.DecodeInvoice(payreq.Payreq) + require.NoError(t, err) + require.EqualValues(t, amt, invoice.MilliSat.ToSatoshis()) + require.EqualValues(t, memo, *invoice.Description) + req2 := &payments.PayInvoiceRequest{Payreq: payreq.Payreq, + Account: aliceAcc.String(), + Amount: wrongAmt} + _, err = alice.PayInvoice(ctx, req2) + require.ErrorIs(t, err, lndhubsql.ErrQtyMissmatch) + req2.Amount = amt + _, err = alice.PayInvoice(ctx, req2) + require.ErrorIs(t, err, lndhubsql.ErrNotEnoughBalance) +} diff --git a/backend/api/payments/v1alpha/wallet.go b/backend/api/payments/v1alpha/wallet.go new file mode 100644 index 00000000..7d5ed84d --- /dev/null +++ b/backend/api/payments/v1alpha/wallet.go @@ -0,0 +1,593 @@ +package payments + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "errors" + "fmt" + "net/http" + "regexp" + "seed/backend/core" + payments "seed/backend/genproto/payments/v1alpha" + "seed/backend/lndhub" + "seed/backend/lndhub/lndhubsql" + "seed/backend/mttnet" + "seed/backend/wallet/walletsql" + "strings" + + "seed/backend/util/sqlite/sqlitex" + + "github.com/ipfs/go-cid" + "go.uber.org/zap" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" +) + +var ( + errAlreadyLndhubgoWallet = errors.New("Only one lndhub.go wallet is allowed and we already had one") + supportedWallets = []string{lndhubsql.LndhubWalletType, lndhubsql.LndhubGoWalletType} + validCredentials = regexp.MustCompile(`([A-Za-z0-9_\-\.]+):\/\/([0-9A-Za-z]+):([0-9a-f]+)@https:\/\/([A-Za-z0-9_\-\.]+)\/?$`) +) + +// AccountID is a handy alias of Cid. +type AccountID = cid.Cid + +// Server wraps everything necessary to deliver a wallet service. +type Server struct { + lightningClient lnclient + pool *sqlitex.Pool + net *mttnet.Node + log *zap.Logger + ks core.KeyStore +} + +// Credentials struct holds all we need to connect to different lightning nodes (lndhub, LND, core-lightning, ...). +type Credentials struct { + Domain string `json:"domain"` + WalletType string `json:"wallettype"` + Login string `json:"login"` + Password string `json:"password"` + Nickname string `json:"nickname,omitempty"` +} + +// NewServer is the constructor of the wallet service. +func NewServer(log *zap.Logger, db *sqlitex.Pool, net *mttnet.Node, ks core.KeyStore, mainnet bool) *Server { + lndhubDomain := "ln.testnet.seed.hyper.media" + lnaddressDomain := "ln.testnet.seed.hyper.media" + if mainnet { + //lndhubDomain is the domain for internal lndhub calls. + lndhubDomain = "ln.seed.hyper.media" + lnaddressDomain = "ln.seed.hyper.media" + } + srv := &Server{ + pool: db, + lightningClient: lnclient{ + Lndhub: lndhub.NewClient(&http.Client{}, db, lndhubDomain, lnaddressDomain), + }, + net: net, + log: log, + ks: ks, + } + srv.net.SetInvoicer(srv) + return srv +} + +type lnclient struct { + Lndhub *lndhub.Client + Lnd interface{} // TODO: implement LND client +} + +// InvoiceRequest holds the necessary fields for the request. Currently hold invoices are not supported, so they're omitted. +type InvoiceRequest struct { + AmountSats int64 `help:"The invoice amount in satoshis" default:"0"` + Memo string `help:"Optional requested memo to be attached in the invoice" default:""` + HoldInvoice bool `help:"If we request a hold invoice instead of a regular one. If true, then the following field is mandatory" default:"false"` + PreimageHash []byte `help:"Preimage hash of the requested hold invoice. If HoldInvoice flag is set to false this field is skipped" default:""` +} + +// RegisterServer registers the server with the gRPC server. +func (srv *Server) RegisterServer(rpc grpc.ServiceRegistrar) { + payments.RegisterWalletsServer(rpc, srv) + payments.RegisterInvoicesServer(rpc, srv) +} + +// P2PInvoiceRequest requests a remote account to issue an invoice so we can pay it. +// Any of the devices associated with the remote account can issue it. For each +// associated device we found online ,we ask if it can provide an invoice. +// If for some reason, that device cannot create the invoice (insufficient +// inbound liquidity) we ask the next device. We return in the first device that +// can issue the invoice. If none of them can, then an error is raised. +func (srv *Server) P2PInvoiceRequest(_ context.Context, _ core.Principal, _ InvoiceRequest) (string, error) { + return "", fmt.Errorf("Hm-24. Not implemented") + + /* + me, err := srv.keyStore.GetKey(ctx, srv.keyName) + if err != nil { + return "", err + } + if me.String() == account.String() { + err := fmt.Errorf("cannot remotely issue an invoice to myself") + srv.log.Debug(err.Error()) + return "", err + } + + var dels []hypersql.KeyDelegationsListResult + if err := srv.pool.Query(ctx, func(conn *sqlite.Conn) error { + list, err := hypersql.KeyDelegationsList(conn, account) + if err != nil { + return err + } + if len(list) == 0 { + return fmt.Errorf("request invoice: can't find devices for account %s", account) + } + + dels = list + + return nil + }); err != nil { + return "", err + } + + for _, del := range dels { + pid, err := core.Principal(del.KeyDelegationsViewDelegate).PeerID() + if err != nil { + return "", fmt.Errorf("failed to extract peer ID: %w", err) + } + p2pc, err := srv.net.Client(ctx, pid) + if err != nil { + continue + } + + remoteInvoice, err := p2pc.RequestInvoice(ctx, &p2p.RequestInvoiceRequest{ + AmountSats: request.AmountSats, + Memo: request.Memo, + HoldInvoice: request.HoldInvoice, + PreimageHash: request.PreimageHash, + }) + + if err != nil { + srv.log.Debug("p2p invoice request failed", zap.String("msg", err.Error())) + return "", fmt.Errorf("p2p invoice request failed") + } + + if remoteInvoice.PayReq == "" { + return "", fmt.Errorf("received an empty invoice from remote peer") + } + + return remoteInvoice.PayReq, nil + } + + return "", fmt.Errorf("couldn't get remote invoice from any peer") + */ +} + +// CreateWallet creates a seed wallet from a set of mnemonic words. (usually the same as the +// account). If the account was set with a password, then the same password has to be inserted here. +func (srv *Server) CreateWallet(ctx context.Context, in *payments.CreateWalletRequest) (ret *payments.Wallet, err error) { + kp, err := srv.ks.GetKey(ctx, in.Account) + if err != nil { + return ret, fmt.Errorf("Problems with provided account: %w", err) + } + signature, err := kp.Sign([]byte(lndhub.SigningMessage)) + if err != nil { + return ret, fmt.Errorf("Could not sign the login phrase with the provided account: %w", err) + } + + creds := Credentials{ + Domain: srv.lightningClient.Lndhub.GetLndaddressDomain(), + WalletType: lndhubsql.LndhubGoWalletType, + Login: kp.Principal().String(), + Password: hex.EncodeToString(signature), + Nickname: kp.Principal().String(), + } + credentialsURL, err := EncodeCredentialsURL(creds) + if err != nil { + return ret, fmt.Errorf("Error generating credentials: %w", err) + } + return srv.ImportWallet(ctx, &payments.ImportWalletRequest{ + CredentialsUrl: credentialsURL, + Account: creds.Login, + Name: in.Name, + }) +} + +// ImportWallet first tries to connect to the wallet with the provided credentials. +// ImportWallet returns the wallet actually inserted on success. The credentials are stored +// in plain text at the moment. +func (srv *Server) ImportWallet(ctx context.Context, in *payments.ImportWalletRequest) (*payments.Wallet, error) { + ret := &payments.Wallet{} + creds, err := DecodeCredentialsURL(in.CredentialsUrl) + if err != nil { + srv.log.Debug(err.Error()) + return ret, err + } + + if !isSupported(creds.WalletType) { + err = fmt.Errorf(" wallet type [%s] not supported. Currently supported: [%v]", creds.WalletType, supportedWallets) + srv.log.Debug(err.Error()) + return ret, err + } + + principal, err := core.DecodePrincipal(in.Account) + if err != nil { + return ret, fmt.Errorf("Wrong account %s: %w", in.Account, err) + } + _, bynaryAcc := principal.Explode() + ret.Id = URL2Id(in.CredentialsUrl, in.Account) + + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return ret, err + } + defer release() + + ret.Type = creds.WalletType + ret.Address = "https://" + creds.Domain + + if in.Name == "" { + ret.Name = in.Account + } else { + ret.Name = in.Name + } + ret.Account = in.Account + if creds.WalletType == lndhubsql.LndhubGoWalletType { + // Only one lndhub.go wallet is allowed + wallets, err := srv.ListWallets(ctx, &payments.ListWalletsRequest{Account: in.Account}) + if err != nil { + srv.log.Debug(err.Error()) + return ret, err + } + for i := 0; i < len(wallets.Wallets); i++ { + if wallets.Wallets[i].Type == lndhubsql.LndhubGoWalletType && wallets.Wallets[i].Account == in.Account { + err = fmt.Errorf("Only one type of %s wallet is allowed per account: %w", lndhubsql.LndhubGoWalletType, errAlreadyLndhubgoWallet) + srv.log.Debug(err.Error()) + return ret, err + } + } + if creds.Nickname == "" { + creds.Nickname = creds.Login + } + newWallet, err := srv.lightningClient.Lndhub.Create(ctx, ret.Address, ret.Id, creds.Login, creds.Password, creds.Nickname, bynaryAcc) + if err != nil { + srv.log.Warn("couldn't insert wallet", zap.String("Login", creds.Login), zap.String("Nickname", creds.Nickname), zap.Error(err)) + return ret, err + } + creds.Nickname = newWallet.Nickname + } + wallet2insert := walletsql.Wallet{ + ID: ret.Id, + Account: ret.Account, + Address: ret.Address, + Name: ret.Name, + Type: ret.Type, + } + if err = walletsql.InsertWallet(conn, wallet2insert, []byte(creds.Login), []byte(creds.Password), bynaryAcc); err != nil { + srv.log.Debug("couldn't insert wallet", zap.String("msg", err.Error())) + if errors.Is(err, walletsql.ErrDuplicateIndex) { + return ret, fmt.Errorf("couldn't insert wallet %s in the database. ID already exists", in.Name) + } + return ret, fmt.Errorf("couldn't insert wallet %s in the database", in.Name) + } + + // Trying to authenticate with the provided credentials + _, err = srv.lightningClient.Lndhub.Auth(ctx, ret.Id) + if err != nil { + _ = walletsql.RemoveWallet(conn, ret.Id) + srv.log.Warn("couldn't authenticate new wallet", zap.String("msg", err.Error())) + return ret, fmt.Errorf("couldn't authenticate new wallet %s", in.Name) + } + return ret, err +} + +// ListWallets returns all the wallets available in the database. If includeBalance is true, then +// ListWallets will also include the balance one every lndhub-like wallet. If false,then the call +// is quicker but no balance information will appear. If account is not blank, it will return only +// wallets from that account. +func (srv *Server) ListWallets(ctx context.Context, in *payments.ListWalletsRequest) (*payments.ListWalletsResponse, error) { + ret := &payments.ListWalletsResponse{Wallets: []*payments.Wallet{}} + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return nil, err + } + defer release() + + wallets, err := walletsql.ListWallets(conn, in.Account, -1) + if err != nil { + srv.log.Debug("couldn't list wallets", zap.String("msg", err.Error())) + return nil, fmt.Errorf("couldn't list wallets") + } + for _, w := range wallets { + ret.Wallets = append(ret.Wallets, &payments.Wallet{ + Id: w.ID, + Account: w.Account, + Address: w.Address, + Name: w.Name, + Type: w.Type, + }) + } + return ret, nil +} + +// RemoveWallet deletes the wallet given a valid ID string representing +// the url hash in case of Lndhub-type wallet or the pubkey in case of LND. +// If the removed wallet was the default wallet, a random wallet will be +// chosen as new default. Although it is advised that the user manually +// changes the default wallet after removing the previous default. +func (srv *Server) RemoveWallet(ctx context.Context, in *payments.WalletRequest) (*emptypb.Empty, error) { + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return nil, err + } + defer release() + + if err := walletsql.RemoveWallet(conn, in.Id); err != nil { + return nil, fmt.Errorf("couldn't remove wallet %s", in.Id) + } + // TODO: remove associated token db entries + return nil, nil +} + +// GetWalletBalance tries to contact the wallet's address to get the +// current balance in Satoshis. +func (srv *Server) GetWalletBalance(ctx context.Context, in *payments.WalletRequest) (*payments.GetWalletBalanceResponse, error) { + ret := &payments.GetWalletBalanceResponse{} + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return ret, err + } + defer release() + + wallet, err := walletsql.GetWallet(conn, in.Id) + if err != nil { + return ret, fmt.Errorf("Can't get the wallet with id %s", in.Id) + } + if wallet.Type != lndhubsql.LndhubGoWalletType && wallet.Type != lndhubsql.LndhubWalletType { + return ret, fmt.Errorf("Wallet type %s is not eligible to get balance", wallet.Type) + } + ret.Balance, err = srv.lightningClient.Lndhub.GetBalance(ctx, in.Id) + if err != nil { + srv.log.Debug("couldn't get wallet balance", zap.String("msg", err.Error())) + return ret, fmt.Errorf("couldn't get balance for wallet %s", in.Id) + } + return ret, nil +} + +// UpdateWalletName updates an existing wallet's name with the one provided. +// If the wallet represented by the id id does not exist, this function +// returns error. nil otherwise, along with the updated wallet. +func (srv *Server) UpdateWalletName(ctx context.Context, in *payments.UpdateWalletNameRequest) (*payments.Wallet, error) { + ret := &payments.Wallet{} + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return ret, err + } + defer release() + + updatedWallet, err := walletsql.UpdateWalletName(conn, in.Id, in.Name) + if err != nil { + srv.log.Debug("couldn't update wallet", zap.String("msg", err.Error())) + return ret, fmt.Errorf("couldn't update wallet %s", in.Id) + } + ret.Account = updatedWallet.Account + ret.Address = updatedWallet.Address + ret.Id = updatedWallet.ID + ret.Name = updatedWallet.Name + ret.Type = updatedWallet.Type + return ret, nil +} + +// SetDefaultWallet sets the default wallet to the one that matches walletID. +// Previous default wallet is replaced by the new one so only one can be +// the default at any given time. The default wallet is the first wallet ever +// created until manually changed. +func (srv *Server) SetDefaultWallet(ctx context.Context, in *payments.SetDefaultWalletRequest) (*payments.Wallet, error) { + ret := &payments.Wallet{} + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return ret, err + } + defer release() + + updatedWallet, err := walletsql.UpdateDefaultWallet(conn, in.Account, in.Id) + if err != nil { + srv.log.Warn("couldn't set default wallet: " + err.Error()) + return ret, err + } + ret.Account = updatedWallet.Account + ret.Address = updatedWallet.Address + ret.Id = updatedWallet.ID + ret.Name = updatedWallet.Name + ret.Type = updatedWallet.Type + return ret, err +} + +// ExportWallet returns the wallet credentials in uri format so the user can import it +// to an external app. the uri format is: +// ://:@https:// +// lndhub://c227a7fb5c71a22fac33:d2a48ab779aa1b02e858@https://lndhub.io +// If the ID is empty, then the builtin wallet is exported. +func (srv *Server) ExportWallet(ctx context.Context, in *payments.WalletRequest) (*payments.ExportWalletResponse, error) { + ret := &payments.ExportWalletResponse{} + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return ret, err + } + defer release() + if in.Id == "" { + return ret, fmt.Errorf("Wallet ID cannot be empty") + } + login, err := lndhubsql.GetLogin(conn, in.Id) + if err != nil { + srv.log.Debug(err.Error()) + return ret, err + } + password, err := lndhubsql.GetPassword(conn, in.Id) + if err != nil { + srv.log.Debug(err.Error()) + return ret, err + } + url, err := lndhubsql.GetAPIURL(conn, in.Id) + if err != nil { + srv.log.Debug(err.Error()) + return ret, err + } + splitURL := strings.Split(url, "//") + if len(splitURL) != 2 { + err = fmt.Errorf("Could not export wallet, unexpected url format [%s]", url) + srv.log.Debug(err.Error()) + return ret, err + } + ret.Credentials, err = EncodeCredentialsURL(Credentials{ + Domain: splitURL[1], + WalletType: lndhubsql.LndhubWalletType, + Login: login, + Password: password, + }) + + if err != nil { + srv.log.Debug("couldn't encode uri: " + err.Error()) + return ret, err + } + return ret, nil +} + +// UpdateLNAddress updates nickname on the lndhub.go database +// The update can fail if the nickname contain special characters or is already taken by another user. +// Since it is a user operation, if the login is a CID, then user must provide a token representing +// the pubkey whose private counterpart created the signature provided in password (like in create). +func (srv *Server) UpdateLNAddress(ctx context.Context, nickname, walletID string) error { + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return err + } + defer release() + w, err := walletsql.GetWallet(conn, walletID) + if err != nil { + return fmt.Errorf("Can't get wallet with ID %s: %w", walletID, err) + } + if w.Type != lndhubsql.LndhubGoWalletType && w.Type != lndhubsql.LndhubWalletType { + return fmt.Errorf("Selected wallet does not support lndaddress") + } + principal, err := core.DecodePrincipal(w.Account) + if err != nil { + return fmt.Errorf("Cant decode account %s: %w", w.Account, err) + } + _, token := principal.Explode() + + if err != nil { + return fmt.Errorf("Wrong account format%s: %w", principal.String(), err) + } + err = srv.lightningClient.Lndhub.UpdateNickname(ctx, w.ID, nickname, token) + if err != nil { + srv.log.Debug("couldn't update nickname: " + err.Error()) + return err + } + return nil +} + +// GetDefaultWallet gets the user's default wallet. If the user didn't manually +// update the default wallet, then the first wallet ever created is the default +// wallet. It will remain default until manually changed. +func (srv *Server) GetDefaultWallet(ctx context.Context, in *payments.GetDefaultWalletRequest) (*payments.Wallet, error) { + ret := &payments.Wallet{} + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return ret, err + } + defer release() + + w, err := walletsql.GetDefaultWallet(conn, in.Account) + if err != nil { + srv.log.Debug("couldn't getDefaultWallet: " + err.Error()) + return ret, err + } + ret.Account = w.Account + ret.Address = w.Address + ret.Id = w.ID + ret.Name = w.Name + ret.Type = w.Type + return ret, nil +} + +// GetWallet gets a specific wallet. +func (srv *Server) GetWallet(ctx context.Context, in *payments.WalletRequest) (*payments.Wallet, error) { + ret := &payments.Wallet{} + conn, release, err := srv.pool.Conn(ctx) + if err != nil { + return ret, err + } + defer release() + + w, err := walletsql.GetWallet(conn, in.Id) + if err != nil { + srv.log.Debug("couldn't getWallet: " + err.Error()) + return ret, err + } + ret.Account = w.Account + ret.Address = w.Address + ret.Id = w.ID + ret.Name = w.Name + ret.Type = w.Type + return ret, nil +} + +// GetLnAddress gets the account-wide ln address in the form of @ . +// Since it is a user operation, if the login is a CID, then user must provide a token representing +// the pubkey whose private counterpart created the signature provided in password (like in create). +func (srv *Server) GetLnAddress(ctx context.Context, walletID string) (string, error) { + lnaddress, err := srv.lightningClient.Lndhub.GetLnAddress(ctx, walletID) + if err != nil { + srv.log.Debug("couldn't get lnaddress", zap.Error(err)) + return "", fmt.Errorf("couldn't get lnaddress") + } + return lnaddress, nil +} + +// DecodeCredentialsURL takes a credential string of the form +// ://:@https:// +// lndhub://c227a7fb5c71a22fac33:d2a48ab779aa1b02e858@https://lndhub.io +func DecodeCredentialsURL(url string) (Credentials, error) { + credentials := Credentials{} + + res := validCredentials.FindStringSubmatch(url) + if res == nil || len(res) != 5 { + if res != nil { + return credentials, fmt.Errorf("credentials contained more than necessary fields. it should be " + + "://:@https://") + } + return credentials, fmt.Errorf("couldn't parse credentials, probably wrong format. it should be " + + "://:@https://") + } + credentials.WalletType = strings.ToLower(res[1]) + credentials.Login = res[2] + credentials.Password = res[3] + credentials.Domain = res[4] + return credentials, nil +} + +// URL2Id constructs a unique and collision-free ID out of a credentials URL and account. +func URL2Id(url string, account string) string { + h := sha256.Sum256(append([]byte(url), []byte(account)...)) + return hex.EncodeToString(h[:]) +} + +// EncodeCredentialsURL generates a credential URL out of credential parameters. +// the resulting url will have this format +// ://:@https:// +func EncodeCredentialsURL(creds Credentials) (string, error) { + url := creds.WalletType + "://" + creds.Login + ":" + creds.Password + "@https://" + creds.Domain + _, err := DecodeCredentialsURL(url) + return url, err +} + +func isSupported(walletType string) bool { + var supported bool + for _, supWalletType := range supportedWallets { + if walletType == supWalletType { + supported = true + break + } + } + return supported +} diff --git a/backend/api/payments/v1alpha/wallet_test.go b/backend/api/payments/v1alpha/wallet_test.go new file mode 100644 index 00000000..1ce8617b --- /dev/null +++ b/backend/api/payments/v1alpha/wallet_test.go @@ -0,0 +1,116 @@ +package payments + +import ( + "context" + "seed/backend/blob" + "seed/backend/config" + "seed/backend/core" + "seed/backend/core/coretest" + payments "seed/backend/genproto/payments/v1alpha" + "seed/backend/lndhub/lndhubsql" + "seed/backend/logging" + "seed/backend/mttnet" + "seed/backend/storage" + "seed/backend/testutil" + "seed/backend/util/future" + "testing" + "time" + + "seed/backend/util/sqlite/sqlitex" + + "github.com/stretchr/testify/require" + "go.uber.org/zap" +) + +func TestModifyWallets(t *testing.T) { + testutil.Manual(t) + ctx := context.Background() + alice := makeTestService(t, "alice") + aliceAccs, err := alice.ks.ListKeys(ctx) + require.NoError(t, err) + require.Len(t, aliceAccs, 1) + alicePk := aliceAccs[0].PublicKey.String() + require.NoError(t, err) + seedWallet, err := alice.CreateWallet(ctx, &payments.CreateWalletRequest{ + Account: alicePk, + Name: "myWallet", + }) + require.NoError(t, err) + defaultWallet, err := alice.GetDefaultWallet(ctx, &payments.GetDefaultWalletRequest{Account: seedWallet.Account}) + require.NoError(t, err) + require.Equal(t, seedWallet, defaultWallet) + require.Eventually(t, func() bool { + conn, release, err := alice.pool.Conn(ctx) + require.NoError(t, err) + defer release() + _, err = lndhubsql.GetToken(conn, defaultWallet.Id) + return err == nil + }, 3*time.Second, 1*time.Second) + require.EqualValues(t, lndhubsql.LndhubGoWalletType, defaultWallet.Type) + _, err = alice.RemoveWallet(ctx, &payments.WalletRequest{Id: defaultWallet.Id}) + require.Error(t, err) + const newName = "new wallet name" + _, err = alice.UpdateWalletName(ctx, &payments.UpdateWalletNameRequest{Id: defaultWallet.Id, Name: newName}) + require.NoError(t, err) + + wallets, err := alice.ListWallets(ctx, &payments.ListWalletsRequest{Account: seedWallet.Account}) + require.NoError(t, err) + require.EqualValues(t, 1, len(wallets.Wallets)) + require.EqualValues(t, newName, wallets.Wallets[0].Name) +} + +func makeTestService(t *testing.T, name string) *Server { + ctx, cancel := context.WithCancel(context.Background()) + u := coretest.NewTester(name) + db := storage.MakeTestMemoryDB(t) + device := u.Device + ks := core.NewMemoryKeyStore() + require.NoError(t, ks.StoreKey(ctx, device.Principal().String(), device)) + node, closenode := makeTestPeer(t, u, device, ks, db) + t.Cleanup(closenode) + /* + conn, release, err := db.Conn(context.Background()) + require.NoError(t, err) + defer release() + + signature, err := u.Account.Sign([]byte(lndhub.SigningMessage)) + require.NoError(t, err) + + require.NoError(t, lndhubsql.SetLoginSignature(conn, hex.EncodeToString(signature))) + */ + + t.Cleanup(cancel) + + return NewServer(logging.New("seed/wallet", "debug"), db, node, ks, false) +} + +func makeTestPeer(t *testing.T, u coretest.Tester, device core.KeyPair, ks core.KeyStore, db *sqlitex.Pool) (*mttnet.Node, context.CancelFunc) { + idx := blob.NewIndex(db, logging.New("seed/hyper", "debug"), nil) + + n, err := mttnet.New(config.P2P{ + NoRelay: true, + BootstrapPeers: nil, + NoMetrics: true, + }, device, ks, db, idx, zap.NewNop()) + require.NoError(t, err) + + errc := make(chan error, 1) + ctx, cancel := context.WithCancel(context.Background()) + f := future.New[*mttnet.Node]() + require.NoError(t, f.Resolve(n)) + go func() { + errc <- n.Start(ctx) + }() + + t.Cleanup(func() { + require.NoError(t, <-errc) + }) + + select { + case <-n.Ready(): + case err := <-errc: + require.NoError(t, err) + } + + return n, cancel +} diff --git a/backend/blob/index.go b/backend/blob/index.go index c137e1dd..bc1688ce 100644 --- a/backend/blob/index.go +++ b/backend/blob/index.go @@ -122,7 +122,7 @@ func (idx *Index) CanEditResource(ctx context.Context, resource IRI, author core return ok, status.Errorf(codes.NotFound, "resource %s not found", resource) } - dbAuthor, err := dbPublicKeysLookupID(conn, author) + dbAuthor, err := DbPublicKeysLookupID(conn, author) if err != nil { return ok, err } @@ -578,7 +578,7 @@ func (idx *indexingCtx) ensurePubKey(key core.Principal) (int64, error) { return id, nil } - res, err := dbPublicKeysLookupID(idx.conn, key) + res, err := DbPublicKeysLookupID(idx.conn, key) if err != nil { return 0, err } @@ -587,7 +587,7 @@ func (idx *indexingCtx) ensurePubKey(key core.Principal) (int64, error) { if res > 0 { id = res } else { - ins, err := dbPublicKeysInsert(idx.conn, key) + ins, err := DbPublicKeysInsert(idx.conn, key) if err != nil { return 0, err } diff --git a/backend/blob/index_sql.go b/backend/blob/index_sql.go index bc209bfe..b205087a 100644 --- a/backend/blob/index_sql.go +++ b/backend/blob/index_sql.go @@ -94,7 +94,8 @@ var qBlobsGetSize = dqb.Str(` WHERE blobs.multihash = :blobsMultihash `) -func dbPublicKeysLookupID(conn *sqlite.Conn, publicKeysPrincipal []byte) (int64, error) { +// DbPublicKeysLookupID gets the db index of a given account. +func DbPublicKeysLookupID(conn *sqlite.Conn, publicKeysPrincipal []byte) (int64, error) { before := func(stmt *sqlite.Stmt) { stmt.SetBytes(":publicKeysPrincipal", publicKeysPrincipal) } @@ -125,7 +126,40 @@ var qPublicKeysLookupID = dqb.Str(` LIMIT 1 `) -func dbPublicKeysInsert(conn *sqlite.Conn, principal []byte) (int64, error) { +// DbGetPublicKeyByID gets the account given its db Index. +func DbGetPublicKeyByID(conn *sqlite.Conn, id int64) (publicKeysPrincipal []byte, err error) { + before := func(stmt *sqlite.Stmt) { + stmt.SetInt64(":publicKeysID", id) + } + + var out []byte + + onStep := func(i int, stmt *sqlite.Stmt) error { + if i > 1 { + return errors.New("GetPublicKeyByID: more than one result return for a single-kind query") + } + + out = stmt.ColumnBytes(0) + return nil + } + + err = sqlitegen.ExecStmt(conn, qGetPublicKeyByID(), before, onStep) + if err != nil { + err = fmt.Errorf("failed query: GetPublicKeyByID: %w", err) + } + + return out, err +} + +var qGetPublicKeyByID = dqb.Str(` + SELECT public_keys.principal + FROM public_keys + WHERE public_keys.id = :publicKeysID + LIMIT 1 +`) + +// DbPublicKeysInsert inserts the provided account in the db. +func DbPublicKeysInsert(conn *sqlite.Conn, principal []byte) (int64, error) { var out int64 before := func(stmt *sqlite.Stmt) { diff --git a/backend/core/identity.go b/backend/core/identity.go index 144cc9b3..379ea162 100644 --- a/backend/core/identity.go +++ b/backend/core/identity.go @@ -48,7 +48,6 @@ func AccountFromMnemonic(m []string, passphrase string) (KeyPair, error) { // keyDerivationPath value according to SLIP-10 and BIP-44. // 104109 is the concatenation of Unicode code point values for 'hm' - stands for Hypermedia. // The first zero segment can be incremented to derive multiple accounts eventually. -// PR to add our derivation code to SLIP-44: https://github.com/satoshilabs/slips/pull/1742. const keyDerivationPath = "m/44'/104109'/0'" // AccountFromSeed creates an account key pair from a previously generated entropy. diff --git a/backend/daemon/daemon.go b/backend/daemon/daemon.go index 20d8d433..1260c3e5 100644 --- a/backend/daemon/daemon.go +++ b/backend/daemon/daemon.go @@ -14,7 +14,6 @@ import ( "seed/backend/api" activity "seed/backend/api/activity/v1alpha" - daemon "seed/backend/api/daemon/v1alpha" "seed/backend/blob" "seed/backend/config" "seed/backend/core" @@ -23,7 +22,6 @@ import ( "seed/backend/syncing" "seed/backend/util/cleanup" "seed/backend/util/future" - "seed/backend/wallet" "seed/backend/util/sqlite/sqlitex" @@ -61,7 +59,6 @@ type App struct { Net *mttnet.Node Syncing *syncing.Service Index *blob.Index - Wallet *wallet.Service } type options struct { @@ -176,13 +173,11 @@ func Load(ctx context.Context, cfg config.Config, r Storage, oo ...Option) (a *A return nil, err } activitySrv.SetSyncer(a.Syncing) - a.Wallet = wallet.New(ctx, logging.New("seed/wallet", cfg.LogLevel), a.Storage.DB(), a.Storage.KeyStore(), "main", a.Net, cfg.Lndhub.Mainnet) a.GRPCServer, a.GRPCListener, a.RPC, err = initGRPC(ctx, cfg.GRPC.Port, &a.clean, a.g, a.Storage, a.Index, a.Net, a.Syncing, activitySrv, - a.Wallet, - cfg.LogLevel, opts.grpc) + cfg.LogLevel, cfg.Lndhub.Mainnet, opts.grpc) if err != nil { return nil, err } @@ -203,7 +198,6 @@ func Load(ctx context.Context, cfg config.Config, r Storage, oo ...Option) (a *A }) a.HTTPServer, a.HTTPListener, err = initHTTP(cfg.HTTP.Port, a.GRPCServer, &a.clean, a.g, a.Index, - a.Wallet, fm, opts.extraHTTPHandlers...) if err != nil { return nil, err @@ -379,8 +373,8 @@ func initGRPC( node *mttnet.Node, sync *syncing.Service, activity *activity.Server, - wallet daemon.Wallet, LogLevel string, + isMainnet bool, opts grpcOpts, ) (srv *grpc.Server, lis net.Listener, rpc api.Server, err error) { lis, err = net.Listen("tcp", ":"+strconv.Itoa(port)) @@ -389,7 +383,7 @@ func initGRPC( } srv = grpc.NewServer(opts.serverOptions...) - rpc = api.New(ctx, repo, idx, node, wallet, sync, activity, LogLevel) + rpc = api.New(repo, idx, node, sync, activity, LogLevel, isMainnet) rpc.Register(srv) reflection.Register(srv) diff --git a/backend/daemon/http.go b/backend/daemon/http.go index 913c63bc..b7bb4c65 100644 --- a/backend/daemon/http.go +++ b/backend/daemon/http.go @@ -14,7 +14,6 @@ import ( "strconv" "time" - "github.com/99designs/gqlgen/graphql/playground" "github.com/gorilla/mux" "github.com/improbable-eng/grpc-web/go/grpcweb" "github.com/ipfs/boxo/blockstore" @@ -37,13 +36,6 @@ var ( date string ) -// setupGraphQLHandlers sets up the GraphQL endpoints. -// TODO(hm24) add the wallet service back. -func setupGraphQLHandlers(r *Router, wallet any) { - // r.Handle("/graphql", corsMiddleware(graphql.Handler(wallet)), 0) - r.Handle("/playground", playground.Handler("GraphQL Playground", "/graphql"), RouteNav) -} - // setupIPFSFileHandlers sets up the IPFS file endpoints for uploading and getting files. func setupIPFSFileHandlers(r *Router, h IPFSFileHandler) { r.Handle("/ipfs/file-upload", http.HandlerFunc(h.UploadFile), 0) @@ -135,7 +127,6 @@ func initHTTP( clean *cleanup.Stack, g *errgroup.Group, blobs blockstore.Blockstore, - wallet any, // TODO(hm24) put the wallet back in. ipfsHandler IPFSFileHandler, extraHandlers ...func(*Router), ) (srv *http.Server, lis net.Listener, err error) { @@ -147,7 +138,6 @@ func initHTTP( ) setupDebugHandlers(router, blobs) - setupGraphQLHandlers(router, wallet) setupIPFSFileHandlers(router, ipfsHandler) setupGRPCWebHandler(router, rpc) for _, handle := range extraHandlers { diff --git a/backend/genproto/p2p/v1alpha/p2p.pb.go b/backend/genproto/p2p/v1alpha/p2p.pb.go index 283baec5..decc52c4 100644 --- a/backend/genproto/p2p/v1alpha/p2p.pb.go +++ b/backend/genproto/p2p/v1alpha/p2p.pb.go @@ -199,12 +199,14 @@ type RequestInvoiceRequest struct { // The invoice amount in satoshis AmountSats int64 `protobuf:"varint,1,opt,name=amount_sats,json=amountSats,proto3" json:"amount_sats,omitempty"` + // Required. The account we request this invoice from + Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` // Optional requested memo to be attached in the invoice - Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"` + Memo string `protobuf:"bytes,3,opt,name=memo,proto3" json:"memo,omitempty"` // True to request a hold invoice instead of a regular one. If true, then preimage_hash should be filled - HoldInvoice bool `protobuf:"varint,3,opt,name=hold_invoice,json=holdInvoice,proto3" json:"hold_invoice,omitempty"` + HoldInvoice bool `protobuf:"varint,4,opt,name=hold_invoice,json=holdInvoice,proto3" json:"hold_invoice,omitempty"` // Preimage hash of the requested hold invoice. If hold_invoice is set to false this field is skipped - PreimageHash []byte `protobuf:"bytes,4,opt,name=preimage_hash,json=preimageHash,proto3" json:"preimage_hash,omitempty"` + PreimageHash []byte `protobuf:"bytes,5,opt,name=preimage_hash,json=preimageHash,proto3" json:"preimage_hash,omitempty"` } func (x *RequestInvoiceRequest) Reset() { @@ -246,6 +248,13 @@ func (x *RequestInvoiceRequest) GetAmountSats() int64 { return 0 } +func (x *RequestInvoiceRequest) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + func (x *RequestInvoiceRequest) GetMemo() string { if x != nil { return x.Memo @@ -524,70 +533,72 @@ var file_p2p_v1alpha_p2p_proto_rawDesc = []byte{ 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x94, 0x01, 0x0a, 0x15, 0x52, + 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xae, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x73, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x61, 0x6d, 0x6f, 0x75, 0x6e, - 0x74, 0x53, 0x61, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x68, 0x6f, 0x6c, - 0x64, 0x5f, 0x69, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0b, 0x68, 0x6f, 0x6c, 0x64, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x23, 0x0a, 0x0d, - 0x70, 0x72, 0x65, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x48, 0x61, 0x73, - 0x68, 0x22, 0x31, 0x0a, 0x16, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, - 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, - 0x61, 0x79, 0x5f, 0x72, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, - 0x79, 0x52, 0x65, 0x71, 0x22, 0x71, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x65, 0x72, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x70, 0x65, 0x65, - 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, - 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, - 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, - 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x30, 0x0a, 0x04, 0x42, 0x6c, 0x6f, 0x62, 0x12, - 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x63, 0x69, - 0x64, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x22, 0xc0, 0x01, 0x0a, 0x08, 0x50, 0x65, - 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x12, 0x53, 0x0a, 0x11, - 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, - 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x43, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x2a, 0x66, 0x0a, 0x10, - 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x4f, 0x54, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, - 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x41, 0x4e, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, - 0x54, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x41, 0x4e, 0x4e, 0x4f, 0x54, 0x5f, 0x43, 0x4f, - 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x4c, 0x49, 0x4d, 0x49, 0x54, - 0x45, 0x44, 0x10, 0x04, 0x32, 0xa3, 0x02, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12, 0x51, 0x0a, 0x09, - 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x12, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, + 0x74, 0x53, 0x61, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, + 0x65, 0x6d, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x68, 0x6f, 0x6c, 0x64, 0x5f, 0x69, 0x6e, 0x76, 0x6f, + 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x68, 0x6f, 0x6c, 0x64, 0x49, + 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x65, 0x69, 0x6d, 0x61, + 0x67, 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, + 0x72, 0x65, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x48, 0x61, 0x73, 0x68, 0x22, 0x31, 0x0a, 0x16, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x5f, 0x72, 0x65, 0x71, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x79, 0x52, 0x65, 0x71, 0x22, 0x71, + 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, + 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, + 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x22, 0x30, 0x0a, 0x04, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x63, + 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, + 0x73, 0x6f, 0x72, 0x22, 0xc0, 0x01, 0x0a, 0x08, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x12, 0x53, 0x0a, 0x11, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x2a, 0x66, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x4f, + 0x54, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, + 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, + 0x43, 0x41, 0x4e, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, 0x02, 0x12, 0x12, 0x0a, + 0x0e, 0x43, 0x41, 0x4e, 0x4e, 0x4f, 0x54, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, + 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x45, 0x44, 0x10, 0x04, 0x32, 0xa3, + 0x02, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12, 0x51, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, + 0x6f, 0x62, 0x73, 0x12, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, + 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, + 0x6c, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x63, 0x6f, + 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x30, 0x01, 0x12, 0x5c, 0x0a, 0x09, 0x4c, 0x69, 0x73, + 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x12, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, + 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, + 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x0e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x2b, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1a, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x30, 0x01, 0x12, - 0x5c, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x12, 0x26, 0x2e, 0x63, - 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, - 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, - 0x0e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, - 0x2b, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, - 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x63, - 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, - 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x27, 0x5a, 0x25, 0x73, 0x65, - 0x65, 0x64, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x32, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x3b, - 0x70, 0x32, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, + 0x64, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x27, 0x5a, 0x25, 0x73, 0x65, 0x65, 0x64, 0x2f, 0x62, 0x61, 0x63, + 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x32, + 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x3b, 0x70, 0x32, 0x70, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/backend/genproto/payments/v1alpha/invoices.pb.go b/backend/genproto/payments/v1alpha/invoices.pb.go new file mode 100644 index 00000000..1bbffd82 --- /dev/null +++ b/backend/genproto/payments/v1alpha/invoices.pb.go @@ -0,0 +1,1065 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v4.24.4 +// source: payments/v1alpha/invoices.proto + +package payments + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// String representation of a bolt11 invoice payment request. +type Payreq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Bolt11 invoice payment request. + Payreq string `protobuf:"bytes,1,opt,name=payreq,proto3" json:"payreq,omitempty"` +} + +func (x *Payreq) Reset() { + *x = Payreq{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Payreq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Payreq) ProtoMessage() {} + +func (x *Payreq) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Payreq.ProtoReflect.Descriptor instead. +func (*Payreq) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{0} +} + +func (x *Payreq) GetPayreq() string { + if x != nil { + return x.Payreq + } + return "" +} + +// The request to create a local invoice. Used to be paid. +type CreateInvoiceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Optional. The account we are creating the invoice from. The default wallet + // from that account will be used to issue the invoice. If the user wants to + // select an espedific wallet, then account must be blank and the user must + // provide a wallet id. + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + // Optional. In case account is not provided, the especific walletID + // to issue an invoice from. + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + // Required. The amount in satoshis we want the invoice. + Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` + // Optional. Description we want to include in the invoice. + Memo string `protobuf:"bytes,4,opt,name=memo,proto3" json:"memo,omitempty"` +} + +func (x *CreateInvoiceRequest) Reset() { + *x = CreateInvoiceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateInvoiceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateInvoiceRequest) ProtoMessage() {} + +func (x *CreateInvoiceRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateInvoiceRequest.ProtoReflect.Descriptor instead. +func (*CreateInvoiceRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateInvoiceRequest) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +func (x *CreateInvoiceRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CreateInvoiceRequest) GetAmount() int64 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *CreateInvoiceRequest) GetMemo() string { + if x != nil { + return x.Memo + } + return "" +} + +// To pay an invoice +type PayInvoiceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The payment request in plaintext representing the bolt-11 invoice to be paid + Payreq string `protobuf:"bytes,1,opt,name=payreq,proto3" json:"payreq,omitempty"` + // Optional. The account used to pay this invoice. The default wallet of this account will + // be used. If not provided, then an specific wallet ID must be provided + Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` + // Optional. Wallet id to pay the invoice with + Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` + // Optional. Amount in satoshis to pay. This should match the amount in the invoice. + // For zero-amount invoices, the user can put whatever amount it wants. + Amount int64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *PayInvoiceRequest) Reset() { + *x = PayInvoiceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PayInvoiceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PayInvoiceRequest) ProtoMessage() {} + +func (x *PayInvoiceRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PayInvoiceRequest.ProtoReflect.Descriptor instead. +func (*PayInvoiceRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{2} +} + +func (x *PayInvoiceRequest) GetPayreq() string { + if x != nil { + return x.Payreq + } + return "" +} + +func (x *PayInvoiceRequest) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +func (x *PayInvoiceRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *PayInvoiceRequest) GetAmount() int64 { + if x != nil { + return x.Amount + } + return 0 +} + +// Request to pay. +type RequestLud6InvoiceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. URL associated with the ln server. + URL string `protobuf:"bytes,1,opt,name=URL,proto3" json:"URL,omitempty"` + // Required. User to pay. + User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + // Required. Amount in satohis. + Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` + // Optional. String to be attached in the invoice. + Memo string `protobuf:"bytes,4,opt,name=memo,proto3" json:"memo,omitempty"` +} + +func (x *RequestLud6InvoiceRequest) Reset() { + *x = RequestLud6InvoiceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequestLud6InvoiceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestLud6InvoiceRequest) ProtoMessage() {} + +func (x *RequestLud6InvoiceRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestLud6InvoiceRequest.ProtoReflect.Descriptor instead. +func (*RequestLud6InvoiceRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{3} +} + +func (x *RequestLud6InvoiceRequest) GetURL() string { + if x != nil { + return x.URL + } + return "" +} + +func (x *RequestLud6InvoiceRequest) GetUser() string { + if x != nil { + return x.User + } + return "" +} + +func (x *RequestLud6InvoiceRequest) GetAmount() int64 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *RequestLud6InvoiceRequest) GetMemo() string { + if x != nil { + return x.Memo + } + return "" +} + +// Get the LNAddress of a wallet. +type GetLnAddressRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The wallet ID we want to know the lnaddress from. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetLnAddressRequest) Reset() { + *x = GetLnAddressRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetLnAddressRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetLnAddressRequest) ProtoMessage() {} + +func (x *GetLnAddressRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetLnAddressRequest.ProtoReflect.Descriptor instead. +func (*GetLnAddressRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{4} +} + +func (x *GetLnAddressRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +// The LNAddress of a wallet. +type LNAddress struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The account we want to know the lnaddress from. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (x *LNAddress) Reset() { + *x = LNAddress{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LNAddress) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LNAddress) ProtoMessage() {} + +func (x *LNAddress) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LNAddress.ProtoReflect.Descriptor instead. +func (*LNAddress) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{5} +} + +func (x *LNAddress) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +// Changes the lnaddress associated with a wallet. +type UpdateLNAddressRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The wallet we want to change its lnaddress. Not all wallets + // support lnaddresses + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // Required. The nickname of the new lnadress. The resultin lnaddress would be + // @ + Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` +} + +func (x *UpdateLNAddressRequest) Reset() { + *x = UpdateLNAddressRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateLNAddressRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateLNAddressRequest) ProtoMessage() {} + +func (x *UpdateLNAddressRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateLNAddressRequest.ProtoReflect.Descriptor instead. +func (*UpdateLNAddressRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateLNAddressRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *UpdateLNAddressRequest) GetNickname() string { + if x != nil { + return x.Nickname + } + return "" +} + +// List all invoices that has been paid with a wallet +type ListInvoicesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The wallet id from where we want the list of paid invoices + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *ListInvoicesRequest) Reset() { + *x = ListInvoicesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListInvoicesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListInvoicesRequest) ProtoMessage() {} + +func (x *ListInvoicesRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListInvoicesRequest.ProtoReflect.Descriptor instead. +func (*ListInvoicesRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{7} +} + +func (x *ListInvoicesRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +// Bolt11 Invoice +type Invoice struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The hash of the invoice. Unique identifier of the invoice + PaymentHash string `protobuf:"bytes,1,opt,name=payment_hash,json=paymentHash,proto3" json:"payment_hash,omitempty"` + // The string representation of the invoice + PaymentRequest string `protobuf:"bytes,2,opt,name=payment_request,json=paymentRequest,proto3" json:"payment_request,omitempty"` + // The description/memo/purpose of the invoice + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // The description hash + DescriptionHash string `protobuf:"bytes,4,opt,name=description_hash,json=descriptionHash,proto3" json:"description_hash,omitempty"` + // The preimage revealed upon settlement. Proof of payment. + PaymentPreimage string `protobuf:"bytes,5,opt,name=payment_preimage,json=paymentPreimage,proto3" json:"payment_preimage,omitempty"` + // The destination node of the payment. + Destination string `protobuf:"bytes,6,opt,name=destination,proto3" json:"destination,omitempty"` + // The amount in satoshis of the payment. + Amount int64 `protobuf:"varint,7,opt,name=amount,proto3" json:"amount,omitempty"` + // The fees paid in satoshis. + Fee int64 `protobuf:"varint,8,opt,name=fee,proto3" json:"fee,omitempty"` + // The satus of the invoice. + Status string `protobuf:"bytes,9,opt,name=status,proto3" json:"status,omitempty"` + // The type of invoice. + Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` + // Error message (if any) of the transaction. + ErrorMessage string `protobuf:"bytes,11,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` + // When the invoice was settled + SettledAt string `protobuf:"bytes,12,opt,name=settled_at,json=settledAt,proto3" json:"settled_at,omitempty"` + // When the invoice expires (if unpaid). + ExpiresAt string `protobuf:"bytes,13,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` + // Whether or not the invoice has been paid. + IsPaid bool `protobuf:"varint,14,opt,name=is_paid,json=isPaid,proto3" json:"is_paid,omitempty"` + // Whether or not this is a keysed payment. + Keysend bool `protobuf:"varint,15,opt,name=keysend,proto3" json:"keysend,omitempty"` +} + +func (x *Invoice) Reset() { + *x = Invoice{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Invoice) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Invoice) ProtoMessage() {} + +func (x *Invoice) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Invoice.ProtoReflect.Descriptor instead. +func (*Invoice) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{8} +} + +func (x *Invoice) GetPaymentHash() string { + if x != nil { + return x.PaymentHash + } + return "" +} + +func (x *Invoice) GetPaymentRequest() string { + if x != nil { + return x.PaymentRequest + } + return "" +} + +func (x *Invoice) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Invoice) GetDescriptionHash() string { + if x != nil { + return x.DescriptionHash + } + return "" +} + +func (x *Invoice) GetPaymentPreimage() string { + if x != nil { + return x.PaymentPreimage + } + return "" +} + +func (x *Invoice) GetDestination() string { + if x != nil { + return x.Destination + } + return "" +} + +func (x *Invoice) GetAmount() int64 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *Invoice) GetFee() int64 { + if x != nil { + return x.Fee + } + return 0 +} + +func (x *Invoice) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *Invoice) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Invoice) GetErrorMessage() string { + if x != nil { + return x.ErrorMessage + } + return "" +} + +func (x *Invoice) GetSettledAt() string { + if x != nil { + return x.SettledAt + } + return "" +} + +func (x *Invoice) GetExpiresAt() string { + if x != nil { + return x.ExpiresAt + } + return "" +} + +func (x *Invoice) GetIsPaid() bool { + if x != nil { + return x.IsPaid + } + return false +} + +func (x *Invoice) GetKeysend() bool { + if x != nil { + return x.Keysend + } + return false +} + +// List all invoices that has been paid with a wallet +type ListInvoicesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The wallet id from where we want the list of paid invoices + Invoices []*Invoice `protobuf:"bytes,1,rep,name=invoices,proto3" json:"invoices,omitempty"` +} + +func (x *ListInvoicesResponse) Reset() { + *x = ListInvoicesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListInvoicesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListInvoicesResponse) ProtoMessage() {} + +func (x *ListInvoicesResponse) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_invoices_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListInvoicesResponse.ProtoReflect.Descriptor instead. +func (*ListInvoicesResponse) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_invoices_proto_rawDescGZIP(), []int{9} +} + +func (x *ListInvoicesResponse) GetInvoices() []*Invoice { + if x != nil { + return x.Invoices + } + return nil +} + +var File_payments_v1alpha_invoices_proto protoreflect.FileDescriptor + +var file_payments_v1alpha_invoices_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2f, 0x69, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x1a, 0x1b, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, + 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x20, 0x0a, 0x06, 0x50, 0x61, 0x79, + 0x72, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x79, 0x72, 0x65, 0x71, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x79, 0x72, 0x65, 0x71, 0x22, 0x6c, 0x0a, 0x14, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x22, 0x6d, 0x0a, 0x11, 0x50, 0x61, 0x79, + 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, + 0x0a, 0x06, 0x70, 0x61, 0x79, 0x72, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x70, 0x61, 0x79, 0x72, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x6d, 0x0a, 0x19, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x4c, 0x75, 0x64, 0x36, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x55, 0x52, 0x4c, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x22, 0x25, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x4c, 0x6e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x25, + 0x0a, 0x09, 0x4c, 0x4e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x44, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, + 0x4e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x25, 0x0a, 0x13, 0x4c, + 0x69, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x22, 0xdb, 0x03, 0x0a, 0x07, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x21, + 0x0a, 0x0c, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, + 0x68, 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x68, 0x61, 0x73, 0x68, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x48, 0x61, 0x73, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x65, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x65, 0x69, 0x6d, 0x61, + 0x67, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, + 0x66, 0x65, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, 0x18, 0x0d, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x12, 0x17, 0x0a, + 0x07, 0x69, 0x73, 0x5f, 0x70, 0x61, 0x69, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, + 0x69, 0x73, 0x50, 0x61, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x73, 0x65, 0x6e, + 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x73, 0x65, 0x6e, 0x64, + 0x22, 0x56, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x08, 0x69, 0x6e, 0x76, 0x6f, + 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6d, + 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x08, + 0x69, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x32, 0xb0, 0x03, 0x0a, 0x08, 0x49, 0x6e, 0x76, + 0x6f, 0x69, 0x63, 0x65, 0x73, 0x12, 0x63, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, + 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, + 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, + 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x50, 0x61, 0x79, 0x72, 0x65, 0x71, 0x12, 0x52, 0x0a, 0x0a, 0x50, 0x61, + 0x79, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x2c, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, + 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x50, 0x61, 0x79, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x73, + 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x69, 0x64, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, + 0x65, 0x73, 0x12, 0x2e, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x76, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, + 0x76, 0x65, 0x64, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x12, 0x2e, 0x2e, 0x63, 0x6f, 0x6d, + 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x6d, + 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xc8, 0x02, 0x0a, 0x05, + 0x4c, 0x4e, 0x55, 0x52, 0x4c, 0x12, 0x6d, 0x0a, 0x12, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x4c, 0x75, 0x64, 0x36, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x34, 0x2e, 0x63, 0x6f, + 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, + 0x75, 0x64, 0x36, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x21, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x50, 0x61, + 0x79, 0x72, 0x65, 0x71, 0x12, 0x64, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4c, 0x6e, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x12, 0x2e, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, + 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, + 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x4c, 0x4e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x6a, 0x0a, 0x0f, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x4c, 0x4e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x31, 0x2e, + 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x4c, 0x4e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x4e, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x31, 0x5a, 0x2f, 0x73, 0x65, 0x65, 0x64, 0x2f, 0x62, + 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x3b, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_payments_v1alpha_invoices_proto_rawDescOnce sync.Once + file_payments_v1alpha_invoices_proto_rawDescData = file_payments_v1alpha_invoices_proto_rawDesc +) + +func file_payments_v1alpha_invoices_proto_rawDescGZIP() []byte { + file_payments_v1alpha_invoices_proto_rawDescOnce.Do(func() { + file_payments_v1alpha_invoices_proto_rawDescData = protoimpl.X.CompressGZIP(file_payments_v1alpha_invoices_proto_rawDescData) + }) + return file_payments_v1alpha_invoices_proto_rawDescData +} + +var file_payments_v1alpha_invoices_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_payments_v1alpha_invoices_proto_goTypes = []any{ + (*Payreq)(nil), // 0: com.seed.payments.v1alpha.Payreq + (*CreateInvoiceRequest)(nil), // 1: com.seed.payments.v1alpha.CreateInvoiceRequest + (*PayInvoiceRequest)(nil), // 2: com.seed.payments.v1alpha.PayInvoiceRequest + (*RequestLud6InvoiceRequest)(nil), // 3: com.seed.payments.v1alpha.RequestLud6InvoiceRequest + (*GetLnAddressRequest)(nil), // 4: com.seed.payments.v1alpha.GetLnAddressRequest + (*LNAddress)(nil), // 5: com.seed.payments.v1alpha.LNAddress + (*UpdateLNAddressRequest)(nil), // 6: com.seed.payments.v1alpha.UpdateLNAddressRequest + (*ListInvoicesRequest)(nil), // 7: com.seed.payments.v1alpha.ListInvoicesRequest + (*Invoice)(nil), // 8: com.seed.payments.v1alpha.Invoice + (*ListInvoicesResponse)(nil), // 9: com.seed.payments.v1alpha.ListInvoicesResponse + (*emptypb.Empty)(nil), // 10: google.protobuf.Empty +} +var file_payments_v1alpha_invoices_proto_depIdxs = []int32{ + 8, // 0: com.seed.payments.v1alpha.ListInvoicesResponse.invoices:type_name -> com.seed.payments.v1alpha.Invoice + 1, // 1: com.seed.payments.v1alpha.Invoices.CreateInvoice:input_type -> com.seed.payments.v1alpha.CreateInvoiceRequest + 2, // 2: com.seed.payments.v1alpha.Invoices.PayInvoice:input_type -> com.seed.payments.v1alpha.PayInvoiceRequest + 7, // 3: com.seed.payments.v1alpha.Invoices.ListPaidInvoices:input_type -> com.seed.payments.v1alpha.ListInvoicesRequest + 7, // 4: com.seed.payments.v1alpha.Invoices.ListReceivednvoices:input_type -> com.seed.payments.v1alpha.ListInvoicesRequest + 3, // 5: com.seed.payments.v1alpha.LNURL.RequestLud6Invoice:input_type -> com.seed.payments.v1alpha.RequestLud6InvoiceRequest + 4, // 6: com.seed.payments.v1alpha.LNURL.GetLnAddress:input_type -> com.seed.payments.v1alpha.GetLnAddressRequest + 6, // 7: com.seed.payments.v1alpha.LNURL.UpdateLNAddress:input_type -> com.seed.payments.v1alpha.UpdateLNAddressRequest + 0, // 8: com.seed.payments.v1alpha.Invoices.CreateInvoice:output_type -> com.seed.payments.v1alpha.Payreq + 10, // 9: com.seed.payments.v1alpha.Invoices.PayInvoice:output_type -> google.protobuf.Empty + 9, // 10: com.seed.payments.v1alpha.Invoices.ListPaidInvoices:output_type -> com.seed.payments.v1alpha.ListInvoicesResponse + 9, // 11: com.seed.payments.v1alpha.Invoices.ListReceivednvoices:output_type -> com.seed.payments.v1alpha.ListInvoicesResponse + 0, // 12: com.seed.payments.v1alpha.LNURL.RequestLud6Invoice:output_type -> com.seed.payments.v1alpha.Payreq + 5, // 13: com.seed.payments.v1alpha.LNURL.GetLnAddress:output_type -> com.seed.payments.v1alpha.LNAddress + 5, // 14: com.seed.payments.v1alpha.LNURL.UpdateLNAddress:output_type -> com.seed.payments.v1alpha.LNAddress + 8, // [8:15] is the sub-list for method output_type + 1, // [1:8] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_payments_v1alpha_invoices_proto_init() } +func file_payments_v1alpha_invoices_proto_init() { + if File_payments_v1alpha_invoices_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_payments_v1alpha_invoices_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Payreq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*CreateInvoiceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*PayInvoiceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*RequestLud6InvoiceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*GetLnAddressRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*LNAddress); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*UpdateLNAddressRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*ListInvoicesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*Invoice); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_invoices_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*ListInvoicesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_payments_v1alpha_invoices_proto_rawDesc, + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 2, + }, + GoTypes: file_payments_v1alpha_invoices_proto_goTypes, + DependencyIndexes: file_payments_v1alpha_invoices_proto_depIdxs, + MessageInfos: file_payments_v1alpha_invoices_proto_msgTypes, + }.Build() + File_payments_v1alpha_invoices_proto = out.File + file_payments_v1alpha_invoices_proto_rawDesc = nil + file_payments_v1alpha_invoices_proto_goTypes = nil + file_payments_v1alpha_invoices_proto_depIdxs = nil +} diff --git a/backend/genproto/payments/v1alpha/invoices_grpc.pb.go b/backend/genproto/payments/v1alpha/invoices_grpc.pb.go new file mode 100644 index 00000000..052ee679 --- /dev/null +++ b/backend/genproto/payments/v1alpha/invoices_grpc.pb.go @@ -0,0 +1,396 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v4.24.4 +// source: payments/v1alpha/invoices.proto + +package payments + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// InvoicesClient is the client API for Invoices service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type InvoicesClient interface { + // CreateInvoice creates a local invoice. Used to get paid. Typicaly + // seed users will call this remotely bc they don't know the lnaddress + // of the receiver, just their seed account. The local node, upon the + // request, issues an invoice. + CreateInvoice(ctx context.Context, in *CreateInvoiceRequest, opts ...grpc.CallOption) (*Payreq, error) + // PayInvoice Pays a bolt11 invoice. + PayInvoice(ctx context.Context, in *PayInvoiceRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // PayInvoice Pays a bolt11 invoice. + ListPaidInvoices(ctx context.Context, in *ListInvoicesRequest, opts ...grpc.CallOption) (*ListInvoicesResponse, error) + // PayInvoice Pays a bolt11 invoice. + ListReceivednvoices(ctx context.Context, in *ListInvoicesRequest, opts ...grpc.CallOption) (*ListInvoicesResponse, error) +} + +type invoicesClient struct { + cc grpc.ClientConnInterface +} + +func NewInvoicesClient(cc grpc.ClientConnInterface) InvoicesClient { + return &invoicesClient{cc} +} + +func (c *invoicesClient) CreateInvoice(ctx context.Context, in *CreateInvoiceRequest, opts ...grpc.CallOption) (*Payreq, error) { + out := new(Payreq) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Invoices/CreateInvoice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *invoicesClient) PayInvoice(ctx context.Context, in *PayInvoiceRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Invoices/PayInvoice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *invoicesClient) ListPaidInvoices(ctx context.Context, in *ListInvoicesRequest, opts ...grpc.CallOption) (*ListInvoicesResponse, error) { + out := new(ListInvoicesResponse) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Invoices/ListPaidInvoices", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *invoicesClient) ListReceivednvoices(ctx context.Context, in *ListInvoicesRequest, opts ...grpc.CallOption) (*ListInvoicesResponse, error) { + out := new(ListInvoicesResponse) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Invoices/ListReceivednvoices", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// InvoicesServer is the server API for Invoices service. +// All implementations should embed UnimplementedInvoicesServer +// for forward compatibility +type InvoicesServer interface { + // CreateInvoice creates a local invoice. Used to get paid. Typicaly + // seed users will call this remotely bc they don't know the lnaddress + // of the receiver, just their seed account. The local node, upon the + // request, issues an invoice. + CreateInvoice(context.Context, *CreateInvoiceRequest) (*Payreq, error) + // PayInvoice Pays a bolt11 invoice. + PayInvoice(context.Context, *PayInvoiceRequest) (*emptypb.Empty, error) + // PayInvoice Pays a bolt11 invoice. + ListPaidInvoices(context.Context, *ListInvoicesRequest) (*ListInvoicesResponse, error) + // PayInvoice Pays a bolt11 invoice. + ListReceivednvoices(context.Context, *ListInvoicesRequest) (*ListInvoicesResponse, error) +} + +// UnimplementedInvoicesServer should be embedded to have forward compatible implementations. +type UnimplementedInvoicesServer struct { +} + +func (UnimplementedInvoicesServer) CreateInvoice(context.Context, *CreateInvoiceRequest) (*Payreq, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateInvoice not implemented") +} +func (UnimplementedInvoicesServer) PayInvoice(context.Context, *PayInvoiceRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method PayInvoice not implemented") +} +func (UnimplementedInvoicesServer) ListPaidInvoices(context.Context, *ListInvoicesRequest) (*ListInvoicesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPaidInvoices not implemented") +} +func (UnimplementedInvoicesServer) ListReceivednvoices(context.Context, *ListInvoicesRequest) (*ListInvoicesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListReceivednvoices not implemented") +} + +// UnsafeInvoicesServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to InvoicesServer will +// result in compilation errors. +type UnsafeInvoicesServer interface { + mustEmbedUnimplementedInvoicesServer() +} + +func RegisterInvoicesServer(s grpc.ServiceRegistrar, srv InvoicesServer) { + s.RegisterService(&Invoices_ServiceDesc, srv) +} + +func _Invoices_CreateInvoice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateInvoiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InvoicesServer).CreateInvoice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Invoices/CreateInvoice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InvoicesServer).CreateInvoice(ctx, req.(*CreateInvoiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Invoices_PayInvoice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PayInvoiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InvoicesServer).PayInvoice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Invoices/PayInvoice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InvoicesServer).PayInvoice(ctx, req.(*PayInvoiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Invoices_ListPaidInvoices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListInvoicesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InvoicesServer).ListPaidInvoices(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Invoices/ListPaidInvoices", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InvoicesServer).ListPaidInvoices(ctx, req.(*ListInvoicesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Invoices_ListReceivednvoices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListInvoicesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InvoicesServer).ListReceivednvoices(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Invoices/ListReceivednvoices", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InvoicesServer).ListReceivednvoices(ctx, req.(*ListInvoicesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Invoices_ServiceDesc is the grpc.ServiceDesc for Invoices service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Invoices_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "com.seed.payments.v1alpha.Invoices", + HandlerType: (*InvoicesServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateInvoice", + Handler: _Invoices_CreateInvoice_Handler, + }, + { + MethodName: "PayInvoice", + Handler: _Invoices_PayInvoice_Handler, + }, + { + MethodName: "ListPaidInvoices", + Handler: _Invoices_ListPaidInvoices_Handler, + }, + { + MethodName: "ListReceivednvoices", + Handler: _Invoices_ListReceivednvoices_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "payments/v1alpha/invoices.proto", +} + +// LNURLClient is the client API for LNURL service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type LNURLClient interface { + // Request an invoice following the LNURL lud6 protocol + // (https://github.com/lnurl/luds/blob/luds/06.md). This does not require the + // caller to log in anywhere. Used to pay. + RequestLud6Invoice(ctx context.Context, in *RequestLud6InvoiceRequest, opts ...grpc.CallOption) (*Payreq, error) + // GetLnAddress gets the lnaddress (https://lightningaddress.com/) associated + // with a wallet. Not all wallets are lnaddress compatible. + GetLnAddress(ctx context.Context, in *GetLnAddressRequest, opts ...grpc.CallOption) (*LNAddress, error) + // UpdateLNAddress change the lnaddress of a specific wallet. + // LNaddress must be globally unique (like email addresses). + UpdateLNAddress(ctx context.Context, in *UpdateLNAddressRequest, opts ...grpc.CallOption) (*LNAddress, error) +} + +type lNURLClient struct { + cc grpc.ClientConnInterface +} + +func NewLNURLClient(cc grpc.ClientConnInterface) LNURLClient { + return &lNURLClient{cc} +} + +func (c *lNURLClient) RequestLud6Invoice(ctx context.Context, in *RequestLud6InvoiceRequest, opts ...grpc.CallOption) (*Payreq, error) { + out := new(Payreq) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.LNURL/RequestLud6Invoice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *lNURLClient) GetLnAddress(ctx context.Context, in *GetLnAddressRequest, opts ...grpc.CallOption) (*LNAddress, error) { + out := new(LNAddress) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.LNURL/GetLnAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *lNURLClient) UpdateLNAddress(ctx context.Context, in *UpdateLNAddressRequest, opts ...grpc.CallOption) (*LNAddress, error) { + out := new(LNAddress) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.LNURL/UpdateLNAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// LNURLServer is the server API for LNURL service. +// All implementations should embed UnimplementedLNURLServer +// for forward compatibility +type LNURLServer interface { + // Request an invoice following the LNURL lud6 protocol + // (https://github.com/lnurl/luds/blob/luds/06.md). This does not require the + // caller to log in anywhere. Used to pay. + RequestLud6Invoice(context.Context, *RequestLud6InvoiceRequest) (*Payreq, error) + // GetLnAddress gets the lnaddress (https://lightningaddress.com/) associated + // with a wallet. Not all wallets are lnaddress compatible. + GetLnAddress(context.Context, *GetLnAddressRequest) (*LNAddress, error) + // UpdateLNAddress change the lnaddress of a specific wallet. + // LNaddress must be globally unique (like email addresses). + UpdateLNAddress(context.Context, *UpdateLNAddressRequest) (*LNAddress, error) +} + +// UnimplementedLNURLServer should be embedded to have forward compatible implementations. +type UnimplementedLNURLServer struct { +} + +func (UnimplementedLNURLServer) RequestLud6Invoice(context.Context, *RequestLud6InvoiceRequest) (*Payreq, error) { + return nil, status.Errorf(codes.Unimplemented, "method RequestLud6Invoice not implemented") +} +func (UnimplementedLNURLServer) GetLnAddress(context.Context, *GetLnAddressRequest) (*LNAddress, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetLnAddress not implemented") +} +func (UnimplementedLNURLServer) UpdateLNAddress(context.Context, *UpdateLNAddressRequest) (*LNAddress, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateLNAddress not implemented") +} + +// UnsafeLNURLServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to LNURLServer will +// result in compilation errors. +type UnsafeLNURLServer interface { + mustEmbedUnimplementedLNURLServer() +} + +func RegisterLNURLServer(s grpc.ServiceRegistrar, srv LNURLServer) { + s.RegisterService(&LNURL_ServiceDesc, srv) +} + +func _LNURL_RequestLud6Invoice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RequestLud6InvoiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LNURLServer).RequestLud6Invoice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.LNURL/RequestLud6Invoice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LNURLServer).RequestLud6Invoice(ctx, req.(*RequestLud6InvoiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LNURL_GetLnAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetLnAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LNURLServer).GetLnAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.LNURL/GetLnAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LNURLServer).GetLnAddress(ctx, req.(*GetLnAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LNURL_UpdateLNAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateLNAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LNURLServer).UpdateLNAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.LNURL/UpdateLNAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LNURLServer).UpdateLNAddress(ctx, req.(*UpdateLNAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// LNURL_ServiceDesc is the grpc.ServiceDesc for LNURL service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var LNURL_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "com.seed.payments.v1alpha.LNURL", + HandlerType: (*LNURLServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RequestLud6Invoice", + Handler: _LNURL_RequestLud6Invoice_Handler, + }, + { + MethodName: "GetLnAddress", + Handler: _LNURL_GetLnAddress_Handler, + }, + { + MethodName: "UpdateLNAddress", + Handler: _LNURL_UpdateLNAddress_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "payments/v1alpha/invoices.proto", +} diff --git a/backend/genproto/payments/v1alpha/wallets.pb.go b/backend/genproto/payments/v1alpha/wallets.pb.go new file mode 100644 index 00000000..c3e296be --- /dev/null +++ b/backend/genproto/payments/v1alpha/wallets.pb.go @@ -0,0 +1,986 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v4.24.4 +// source: payments/v1alpha/wallets.proto + +package payments + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Representation of a wallet +type Wallet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Unique wallet identificator. Automatically generated. Unique across accounts. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // The account this wallet belongs to. + Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` + // Address of the LND node backing up this wallet. In case lndhub, this will be the + // URL to connect via rest api. In case LND wallet, this will be the gRPC address. + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` + // The name of the wallet. + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // The type of the wallet. + Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` +} + +func (x *Wallet) Reset() { + *x = Wallet{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Wallet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Wallet) ProtoMessage() {} + +func (x *Wallet) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Wallet.ProtoReflect.Descriptor instead. +func (*Wallet) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{0} +} + +func (x *Wallet) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Wallet) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +func (x *Wallet) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *Wallet) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Wallet) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +// The request to create a wallet. +type CreateWalletRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The account we are creating the wallet to. + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + // Required. Name of the wallet to be created. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *CreateWalletRequest) Reset() { + *x = CreateWalletRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateWalletRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateWalletRequest) ProtoMessage() {} + +func (x *CreateWalletRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateWalletRequest.ProtoReflect.Descriptor instead. +func (*CreateWalletRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateWalletRequest) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +func (x *CreateWalletRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// The request to import a wallet. +type ImportWalletRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The credentials to insert the new wallet in the format of + // ://:@https:// + CredentialsUrl string `protobuf:"bytes,1,opt,name=credentials_url,json=credentialsUrl,proto3" json:"credentials_url,omitempty"` + // Required. Account where this wallet will belong to. + Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` + // Required. The wallet name to be displayed. + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *ImportWalletRequest) Reset() { + *x = ImportWalletRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ImportWalletRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ImportWalletRequest) ProtoMessage() {} + +func (x *ImportWalletRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ImportWalletRequest.ProtoReflect.Descriptor instead. +func (*ImportWalletRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{2} +} + +func (x *ImportWalletRequest) GetCredentialsUrl() string { + if x != nil { + return x.CredentialsUrl + } + return "" +} + +func (x *ImportWalletRequest) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +func (x *ImportWalletRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// Exported credentials. +type ExportWalletResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The credentials url to be used with a compatible 3rd party app. + Credentials string `protobuf:"bytes,1,opt,name=credentials,proto3" json:"credentials,omitempty"` +} + +func (x *ExportWalletResponse) Reset() { + *x = ExportWalletResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExportWalletResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExportWalletResponse) ProtoMessage() {} + +func (x *ExportWalletResponse) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExportWalletResponse.ProtoReflect.Descriptor instead. +func (*ExportWalletResponse) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{3} +} + +func (x *ExportWalletResponse) GetCredentials() string { + if x != nil { + return x.Credentials + } + return "" +} + +// The request to get an lndhub wallet. +type WalletRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. Id of the wallet to operate with + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *WalletRequest) Reset() { + *x = WalletRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WalletRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WalletRequest) ProtoMessage() {} + +func (x *WalletRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WalletRequest.ProtoReflect.Descriptor instead. +func (*WalletRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{4} +} + +func (x *WalletRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +// The wallet's balance in satohis. +type GetWalletBalanceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The wallet's balance in satohis. + Balance uint64 `protobuf:"varint,1,opt,name=balance,proto3" json:"balance,omitempty"` +} + +func (x *GetWalletBalanceResponse) Reset() { + *x = GetWalletBalanceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetWalletBalanceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetWalletBalanceResponse) ProtoMessage() {} + +func (x *GetWalletBalanceResponse) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetWalletBalanceResponse.ProtoReflect.Descriptor instead. +func (*GetWalletBalanceResponse) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{5} +} + +func (x *GetWalletBalanceResponse) GetBalance() uint64 { + if x != nil { + return x.Balance + } + return 0 +} + +// The request to list all wallets under a certain account. +type ListWalletsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. Account to list wallets from. + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *ListWalletsRequest) Reset() { + *x = ListWalletsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListWalletsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListWalletsRequest) ProtoMessage() {} + +func (x *ListWalletsRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListWalletsRequest.ProtoReflect.Descriptor instead. +func (*ListWalletsRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{6} +} + +func (x *ListWalletsRequest) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +// All the wallets under a certain account. +type ListWalletsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Wallets under the account. + Wallets []*Wallet `protobuf:"bytes,1,rep,name=wallets,proto3" json:"wallets,omitempty"` +} + +func (x *ListWalletsResponse) Reset() { + *x = ListWalletsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListWalletsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListWalletsResponse) ProtoMessage() {} + +func (x *ListWalletsResponse) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListWalletsResponse.ProtoReflect.Descriptor instead. +func (*ListWalletsResponse) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{7} +} + +func (x *ListWalletsResponse) GetWallets() []*Wallet { + if x != nil { + return x.Wallets + } + return nil +} + +// The request to update a wallet +type UpdateWalletNameRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The wallet id to be modified. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // Required. The new wallet's name. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *UpdateWalletNameRequest) Reset() { + *x = UpdateWalletNameRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateWalletNameRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateWalletNameRequest) ProtoMessage() {} + +func (x *UpdateWalletNameRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateWalletNameRequest.ProtoReflect.Descriptor instead. +func (*UpdateWalletNameRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{8} +} + +func (x *UpdateWalletNameRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *UpdateWalletNameRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// Gets the account's default wallet. +type GetDefaultWalletRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *GetDefaultWalletRequest) Reset() { + *x = GetDefaultWalletRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetDefaultWalletRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDefaultWalletRequest) ProtoMessage() {} + +func (x *GetDefaultWalletRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetDefaultWalletRequest.ProtoReflect.Descriptor instead. +func (*GetDefaultWalletRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{9} +} + +func (x *GetDefaultWalletRequest) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +// Sets the default wallet used for payments. +type SetDefaultWalletRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Required. The wallet id to set as default. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // Required. The account the provided wallet is going to + // be the default. + Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *SetDefaultWalletRequest) Reset() { + *x = SetDefaultWalletRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetDefaultWalletRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetDefaultWalletRequest) ProtoMessage() {} + +func (x *SetDefaultWalletRequest) ProtoReflect() protoreflect.Message { + mi := &file_payments_v1alpha_wallets_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetDefaultWalletRequest.ProtoReflect.Descriptor instead. +func (*SetDefaultWalletRequest) Descriptor() ([]byte, []int) { + return file_payments_v1alpha_wallets_proto_rawDescGZIP(), []int{10} +} + +func (x *SetDefaultWalletRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *SetDefaultWalletRequest) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +var File_payments_v1alpha_wallets_proto protoreflect.FileDescriptor + +var file_payments_v1alpha_wallets_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2f, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, + 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x06, 0x57, 0x61, 0x6c, 0x6c, + 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x43, + 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x22, 0x6c, 0x0a, 0x13, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x61, 0x6c, + 0x6c, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x72, + 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, + 0x55, 0x72, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x22, 0x38, 0x0a, 0x14, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x65, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x22, 0x1f, 0x0a, 0x0d, 0x57, + 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x34, 0x0a, 0x18, + 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x61, 0x6c, 0x61, + 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x65, 0x22, 0x2e, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x22, 0x52, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x07, 0x77, 0x61, 0x6c, + 0x6c, 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x6f, 0x6d, + 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x07, 0x77, + 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x22, 0x3d, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x33, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x43, 0x0a, 0x17, 0x53, 0x65, + 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, + 0x88, 0x08, 0x0a, 0x07, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x12, 0x61, 0x0a, 0x0c, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x12, 0x2e, 0x2e, 0x63, 0x6f, + 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x57, 0x61, + 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x63, 0x6f, + 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x12, 0x50, + 0x0a, 0x0c, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x12, 0x28, + 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x57, 0x61, 0x6c, 0x6c, 0x65, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x12, 0x61, 0x0a, 0x0c, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, + 0x12, 0x2e, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x49, 0x6d, 0x70, + 0x6f, 0x72, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x21, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x57, 0x61, 0x6c, + 0x6c, 0x65, 0x74, 0x12, 0x69, 0x0a, 0x0c, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x61, 0x6c, + 0x6c, 0x65, 0x74, 0x12, 0x28, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, + 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, + 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, + 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, + 0x0a, 0x10, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x65, 0x12, 0x28, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x57, + 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, + 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, + 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x6c, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, + 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2e, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, + 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x58, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x12, 0x28, 0x2e, 0x63, + 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, + 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x12, 0x69, 0x0a, 0x10, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x32, 0x2e, + 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x21, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x57, 0x61, + 0x6c, 0x6c, 0x65, 0x74, 0x12, 0x69, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, + 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x57, + 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x63, + 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x12, + 0x69, 0x0a, 0x10, 0x53, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x57, 0x61, 0x6c, + 0x6c, 0x65, 0x74, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x65, 0x64, 0x2e, 0x70, + 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x53, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, + 0x65, 0x64, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x42, 0x31, 0x5a, 0x2f, 0x73, 0x65, + 0x65, 0x64, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x3b, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_payments_v1alpha_wallets_proto_rawDescOnce sync.Once + file_payments_v1alpha_wallets_proto_rawDescData = file_payments_v1alpha_wallets_proto_rawDesc +) + +func file_payments_v1alpha_wallets_proto_rawDescGZIP() []byte { + file_payments_v1alpha_wallets_proto_rawDescOnce.Do(func() { + file_payments_v1alpha_wallets_proto_rawDescData = protoimpl.X.CompressGZIP(file_payments_v1alpha_wallets_proto_rawDescData) + }) + return file_payments_v1alpha_wallets_proto_rawDescData +} + +var file_payments_v1alpha_wallets_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_payments_v1alpha_wallets_proto_goTypes = []any{ + (*Wallet)(nil), // 0: com.seed.payments.v1alpha.Wallet + (*CreateWalletRequest)(nil), // 1: com.seed.payments.v1alpha.CreateWalletRequest + (*ImportWalletRequest)(nil), // 2: com.seed.payments.v1alpha.ImportWalletRequest + (*ExportWalletResponse)(nil), // 3: com.seed.payments.v1alpha.ExportWalletResponse + (*WalletRequest)(nil), // 4: com.seed.payments.v1alpha.WalletRequest + (*GetWalletBalanceResponse)(nil), // 5: com.seed.payments.v1alpha.GetWalletBalanceResponse + (*ListWalletsRequest)(nil), // 6: com.seed.payments.v1alpha.ListWalletsRequest + (*ListWalletsResponse)(nil), // 7: com.seed.payments.v1alpha.ListWalletsResponse + (*UpdateWalletNameRequest)(nil), // 8: com.seed.payments.v1alpha.UpdateWalletNameRequest + (*GetDefaultWalletRequest)(nil), // 9: com.seed.payments.v1alpha.GetDefaultWalletRequest + (*SetDefaultWalletRequest)(nil), // 10: com.seed.payments.v1alpha.SetDefaultWalletRequest + (*emptypb.Empty)(nil), // 11: google.protobuf.Empty +} +var file_payments_v1alpha_wallets_proto_depIdxs = []int32{ + 0, // 0: com.seed.payments.v1alpha.ListWalletsResponse.wallets:type_name -> com.seed.payments.v1alpha.Wallet + 1, // 1: com.seed.payments.v1alpha.Wallets.CreateWallet:input_type -> com.seed.payments.v1alpha.CreateWalletRequest + 4, // 2: com.seed.payments.v1alpha.Wallets.RemoveWallet:input_type -> com.seed.payments.v1alpha.WalletRequest + 2, // 3: com.seed.payments.v1alpha.Wallets.ImportWallet:input_type -> com.seed.payments.v1alpha.ImportWalletRequest + 4, // 4: com.seed.payments.v1alpha.Wallets.ExportWallet:input_type -> com.seed.payments.v1alpha.WalletRequest + 4, // 5: com.seed.payments.v1alpha.Wallets.GetWalletBalance:input_type -> com.seed.payments.v1alpha.WalletRequest + 6, // 6: com.seed.payments.v1alpha.Wallets.ListWallets:input_type -> com.seed.payments.v1alpha.ListWalletsRequest + 4, // 7: com.seed.payments.v1alpha.Wallets.GetWallet:input_type -> com.seed.payments.v1alpha.WalletRequest + 8, // 8: com.seed.payments.v1alpha.Wallets.UpdateWalletName:input_type -> com.seed.payments.v1alpha.UpdateWalletNameRequest + 9, // 9: com.seed.payments.v1alpha.Wallets.GetDefaultWallet:input_type -> com.seed.payments.v1alpha.GetDefaultWalletRequest + 10, // 10: com.seed.payments.v1alpha.Wallets.SetDefaultWallet:input_type -> com.seed.payments.v1alpha.SetDefaultWalletRequest + 0, // 11: com.seed.payments.v1alpha.Wallets.CreateWallet:output_type -> com.seed.payments.v1alpha.Wallet + 11, // 12: com.seed.payments.v1alpha.Wallets.RemoveWallet:output_type -> google.protobuf.Empty + 0, // 13: com.seed.payments.v1alpha.Wallets.ImportWallet:output_type -> com.seed.payments.v1alpha.Wallet + 3, // 14: com.seed.payments.v1alpha.Wallets.ExportWallet:output_type -> com.seed.payments.v1alpha.ExportWalletResponse + 5, // 15: com.seed.payments.v1alpha.Wallets.GetWalletBalance:output_type -> com.seed.payments.v1alpha.GetWalletBalanceResponse + 7, // 16: com.seed.payments.v1alpha.Wallets.ListWallets:output_type -> com.seed.payments.v1alpha.ListWalletsResponse + 0, // 17: com.seed.payments.v1alpha.Wallets.GetWallet:output_type -> com.seed.payments.v1alpha.Wallet + 0, // 18: com.seed.payments.v1alpha.Wallets.UpdateWalletName:output_type -> com.seed.payments.v1alpha.Wallet + 0, // 19: com.seed.payments.v1alpha.Wallets.GetDefaultWallet:output_type -> com.seed.payments.v1alpha.Wallet + 0, // 20: com.seed.payments.v1alpha.Wallets.SetDefaultWallet:output_type -> com.seed.payments.v1alpha.Wallet + 11, // [11:21] is the sub-list for method output_type + 1, // [1:11] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_payments_v1alpha_wallets_proto_init() } +func file_payments_v1alpha_wallets_proto_init() { + if File_payments_v1alpha_wallets_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_payments_v1alpha_wallets_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Wallet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*CreateWalletRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*ImportWalletRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*ExportWalletResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*WalletRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*GetWalletBalanceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*ListWalletsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*ListWalletsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*UpdateWalletNameRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*GetDefaultWalletRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_payments_v1alpha_wallets_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*SetDefaultWalletRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_payments_v1alpha_wallets_proto_rawDesc, + NumEnums: 0, + NumMessages: 11, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_payments_v1alpha_wallets_proto_goTypes, + DependencyIndexes: file_payments_v1alpha_wallets_proto_depIdxs, + MessageInfos: file_payments_v1alpha_wallets_proto_msgTypes, + }.Build() + File_payments_v1alpha_wallets_proto = out.File + file_payments_v1alpha_wallets_proto_rawDesc = nil + file_payments_v1alpha_wallets_proto_goTypes = nil + file_payments_v1alpha_wallets_proto_depIdxs = nil +} diff --git a/backend/genproto/payments/v1alpha/wallets_grpc.pb.go b/backend/genproto/payments/v1alpha/wallets_grpc.pb.go new file mode 100644 index 00000000..87f954e3 --- /dev/null +++ b/backend/genproto/payments/v1alpha/wallets_grpc.pb.go @@ -0,0 +1,458 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v4.24.4 +// source: payments/v1alpha/wallets.proto + +package payments + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// WalletsClient is the client API for Wallets service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type WalletsClient interface { + // CreateWallet Created a seed wallet based on mnemonics. + CreateWallet(ctx context.Context, in *CreateWalletRequest, opts ...grpc.CallOption) (*Wallet, error) + // RemoveWallet deletes a wallet locally. It can be later imported + // with the necessary credentials and no funds will be lost. + RemoveWallet(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // ImportWallet Imports a 3rd party (compatible) wallet with credentials. + ImportWallet(ctx context.Context, in *ImportWalletRequest, opts ...grpc.CallOption) (*Wallet, error) + // ExportWallet Export the wallet credentials so they can be imported and + // used with a 3rd party compatible app. + ExportWallet(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*ExportWalletResponse, error) + // ListWallets lists all available wallets for the account. + GetWalletBalance(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*GetWalletBalanceResponse, error) + // ListWallets lists all available wallets for the account. + ListWallets(ctx context.Context, in *ListWalletsRequest, opts ...grpc.CallOption) (*ListWalletsResponse, error) + // GetWallet gets a specific wallet. + GetWallet(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*Wallet, error) + // UpdateWalletName changes the name of the wallet. This does not have any + // implications on payments. Name is just for user convenience. + UpdateWalletName(ctx context.Context, in *UpdateWalletNameRequest, opts ...grpc.CallOption) (*Wallet, error) + // GetDefaultWallet returns the default wallet where payments are going + // to be collected at. Also, this wallet will be used to make payments. + GetDefaultWallet(ctx context.Context, in *GetDefaultWalletRequest, opts ...grpc.CallOption) (*Wallet, error) + // SetDefaultWallet changes the default wallet where payments are going + // to be collected at. Also, this wallet will be used to make payments. + SetDefaultWallet(ctx context.Context, in *SetDefaultWalletRequest, opts ...grpc.CallOption) (*Wallet, error) +} + +type walletsClient struct { + cc grpc.ClientConnInterface +} + +func NewWalletsClient(cc grpc.ClientConnInterface) WalletsClient { + return &walletsClient{cc} +} + +func (c *walletsClient) CreateWallet(ctx context.Context, in *CreateWalletRequest, opts ...grpc.CallOption) (*Wallet, error) { + out := new(Wallet) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/CreateWallet", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) RemoveWallet(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/RemoveWallet", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) ImportWallet(ctx context.Context, in *ImportWalletRequest, opts ...grpc.CallOption) (*Wallet, error) { + out := new(Wallet) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/ImportWallet", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) ExportWallet(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*ExportWalletResponse, error) { + out := new(ExportWalletResponse) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/ExportWallet", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) GetWalletBalance(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*GetWalletBalanceResponse, error) { + out := new(GetWalletBalanceResponse) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/GetWalletBalance", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) ListWallets(ctx context.Context, in *ListWalletsRequest, opts ...grpc.CallOption) (*ListWalletsResponse, error) { + out := new(ListWalletsResponse) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/ListWallets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) GetWallet(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*Wallet, error) { + out := new(Wallet) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/GetWallet", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) UpdateWalletName(ctx context.Context, in *UpdateWalletNameRequest, opts ...grpc.CallOption) (*Wallet, error) { + out := new(Wallet) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/UpdateWalletName", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) GetDefaultWallet(ctx context.Context, in *GetDefaultWalletRequest, opts ...grpc.CallOption) (*Wallet, error) { + out := new(Wallet) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/GetDefaultWallet", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *walletsClient) SetDefaultWallet(ctx context.Context, in *SetDefaultWalletRequest, opts ...grpc.CallOption) (*Wallet, error) { + out := new(Wallet) + err := c.cc.Invoke(ctx, "/com.seed.payments.v1alpha.Wallets/SetDefaultWallet", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// WalletsServer is the server API for Wallets service. +// All implementations should embed UnimplementedWalletsServer +// for forward compatibility +type WalletsServer interface { + // CreateWallet Created a seed wallet based on mnemonics. + CreateWallet(context.Context, *CreateWalletRequest) (*Wallet, error) + // RemoveWallet deletes a wallet locally. It can be later imported + // with the necessary credentials and no funds will be lost. + RemoveWallet(context.Context, *WalletRequest) (*emptypb.Empty, error) + // ImportWallet Imports a 3rd party (compatible) wallet with credentials. + ImportWallet(context.Context, *ImportWalletRequest) (*Wallet, error) + // ExportWallet Export the wallet credentials so they can be imported and + // used with a 3rd party compatible app. + ExportWallet(context.Context, *WalletRequest) (*ExportWalletResponse, error) + // ListWallets lists all available wallets for the account. + GetWalletBalance(context.Context, *WalletRequest) (*GetWalletBalanceResponse, error) + // ListWallets lists all available wallets for the account. + ListWallets(context.Context, *ListWalletsRequest) (*ListWalletsResponse, error) + // GetWallet gets a specific wallet. + GetWallet(context.Context, *WalletRequest) (*Wallet, error) + // UpdateWalletName changes the name of the wallet. This does not have any + // implications on payments. Name is just for user convenience. + UpdateWalletName(context.Context, *UpdateWalletNameRequest) (*Wallet, error) + // GetDefaultWallet returns the default wallet where payments are going + // to be collected at. Also, this wallet will be used to make payments. + GetDefaultWallet(context.Context, *GetDefaultWalletRequest) (*Wallet, error) + // SetDefaultWallet changes the default wallet where payments are going + // to be collected at. Also, this wallet will be used to make payments. + SetDefaultWallet(context.Context, *SetDefaultWalletRequest) (*Wallet, error) +} + +// UnimplementedWalletsServer should be embedded to have forward compatible implementations. +type UnimplementedWalletsServer struct { +} + +func (UnimplementedWalletsServer) CreateWallet(context.Context, *CreateWalletRequest) (*Wallet, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateWallet not implemented") +} +func (UnimplementedWalletsServer) RemoveWallet(context.Context, *WalletRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveWallet not implemented") +} +func (UnimplementedWalletsServer) ImportWallet(context.Context, *ImportWalletRequest) (*Wallet, error) { + return nil, status.Errorf(codes.Unimplemented, "method ImportWallet not implemented") +} +func (UnimplementedWalletsServer) ExportWallet(context.Context, *WalletRequest) (*ExportWalletResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExportWallet not implemented") +} +func (UnimplementedWalletsServer) GetWalletBalance(context.Context, *WalletRequest) (*GetWalletBalanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetWalletBalance not implemented") +} +func (UnimplementedWalletsServer) ListWallets(context.Context, *ListWalletsRequest) (*ListWalletsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListWallets not implemented") +} +func (UnimplementedWalletsServer) GetWallet(context.Context, *WalletRequest) (*Wallet, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetWallet not implemented") +} +func (UnimplementedWalletsServer) UpdateWalletName(context.Context, *UpdateWalletNameRequest) (*Wallet, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateWalletName not implemented") +} +func (UnimplementedWalletsServer) GetDefaultWallet(context.Context, *GetDefaultWalletRequest) (*Wallet, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDefaultWallet not implemented") +} +func (UnimplementedWalletsServer) SetDefaultWallet(context.Context, *SetDefaultWalletRequest) (*Wallet, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetDefaultWallet not implemented") +} + +// UnsafeWalletsServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to WalletsServer will +// result in compilation errors. +type UnsafeWalletsServer interface { + mustEmbedUnimplementedWalletsServer() +} + +func RegisterWalletsServer(s grpc.ServiceRegistrar, srv WalletsServer) { + s.RegisterService(&Wallets_ServiceDesc, srv) +} + +func _Wallets_CreateWallet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateWalletRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).CreateWallet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/CreateWallet", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).CreateWallet(ctx, req.(*CreateWalletRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_RemoveWallet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WalletRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).RemoveWallet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/RemoveWallet", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).RemoveWallet(ctx, req.(*WalletRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_ImportWallet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ImportWalletRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).ImportWallet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/ImportWallet", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).ImportWallet(ctx, req.(*ImportWalletRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_ExportWallet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WalletRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).ExportWallet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/ExportWallet", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).ExportWallet(ctx, req.(*WalletRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_GetWalletBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WalletRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).GetWalletBalance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/GetWalletBalance", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).GetWalletBalance(ctx, req.(*WalletRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_ListWallets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListWalletsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).ListWallets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/ListWallets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).ListWallets(ctx, req.(*ListWalletsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_GetWallet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WalletRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).GetWallet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/GetWallet", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).GetWallet(ctx, req.(*WalletRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_UpdateWalletName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateWalletNameRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).UpdateWalletName(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/UpdateWalletName", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).UpdateWalletName(ctx, req.(*UpdateWalletNameRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_GetDefaultWallet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDefaultWalletRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).GetDefaultWallet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/GetDefaultWallet", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).GetDefaultWallet(ctx, req.(*GetDefaultWalletRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Wallets_SetDefaultWallet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetDefaultWalletRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletsServer).SetDefaultWallet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.seed.payments.v1alpha.Wallets/SetDefaultWallet", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletsServer).SetDefaultWallet(ctx, req.(*SetDefaultWalletRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Wallets_ServiceDesc is the grpc.ServiceDesc for Wallets service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Wallets_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "com.seed.payments.v1alpha.Wallets", + HandlerType: (*WalletsServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateWallet", + Handler: _Wallets_CreateWallet_Handler, + }, + { + MethodName: "RemoveWallet", + Handler: _Wallets_RemoveWallet_Handler, + }, + { + MethodName: "ImportWallet", + Handler: _Wallets_ImportWallet_Handler, + }, + { + MethodName: "ExportWallet", + Handler: _Wallets_ExportWallet_Handler, + }, + { + MethodName: "GetWalletBalance", + Handler: _Wallets_GetWalletBalance_Handler, + }, + { + MethodName: "ListWallets", + Handler: _Wallets_ListWallets_Handler, + }, + { + MethodName: "GetWallet", + Handler: _Wallets_GetWallet_Handler, + }, + { + MethodName: "UpdateWalletName", + Handler: _Wallets_UpdateWalletName_Handler, + }, + { + MethodName: "GetDefaultWallet", + Handler: _Wallets_GetDefaultWallet_Handler, + }, + { + MethodName: "SetDefaultWallet", + Handler: _Wallets_SetDefaultWallet_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "payments/v1alpha/wallets.proto", +} diff --git a/backend/graphql/README.md b/backend/graphql/README.md deleted file mode 100644 index 588cdec9..00000000 --- a/backend/graphql/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# Seed Daemon GraphQL API Implementation - -This package implement the GraphQL API exposed by the Seed daemon. - -Some of the code here is generated with [gqlgen](https://github.com/99designs/gqlgen). - -See the [config](./gqlgen.yml) for more details. - -The idea is to implement the resolver logic inside the `internal` package, and expose the final `http.Handler` from the root of this package, -taking the necessary dependencies for implementation inside the server constructor. - -You can run the app and go to `http://localhost:55001/playground` in your browser to inspect the GraphQL Playground. - -To create a new wallet, execute - -```graphql -mutation { - setupLndHubWallet( - input: { - url: "lndhub://c02fa7989240c12194fc:7d06cfd829af4790116f@https://lndhub.io" - name: "testWallet" - } - ) { - wallet { - id - name - __typename - balanceSats - } - } -} -``` - -And to retrieve the wallet info - -```graphql -query { - me { - wallets { - name - balanceSats - id - } - lnaddress - } -} -``` - -To Request invoice with query variables - -```graphql -mutation RequestInvoice($input: RequestInvoiceInput!) { - requestInvoice(input: $input) { - paymentRequest - } -} -``` - -Query variables: - -```graphql -{ "input": { - "accountID": "b3972ae93c1c386769ea6453c7c42cbf936401e439cba129fa8373594eff74ae", - "amountSats": 0, - "memo": "memo test" -}} -``` - -To pay an invoice - -```graphql -mutation PayInvoice($input: PayInvoiceInput!) { - payInvoice(input: $input) { - walletID - } -} -``` - -Query variables: - -```graphql -{ "input": { - "paymentRequest": "lnbc1500n1psm3c9qpp5xmhxxnh7jj9apr0ne7wkvc0rcnfxqql40a96cz62dxxqwng68l4qdpa2fjkzep6yp2x7upqxyczqmt0wd6zqatnv4n82mpqw35xjmn8wvs8gmeqv3hjqcqzpgxqr23ssp5353mj0hx08lhjzn7l9afkv88ham0dyr4d2h5nx6dmn9739ejaq2q9qyyssqenm9wk9vgwl6xr3kt23p4we0v9nkm3g8jrx6kz5vj2nfvkgmx4wr96nsakeex0y7glwpdxnxk3wzfvgc33yyhx5u32r4qekrs7uch4sqejfltp" -}} -``` - -To list payments - -```graphql -query listInvoices($wID: ID!, $excExpired: Boolean, $excUnpaid: Boolean){ - payments(walletID: $wID, excludeExpired: $excExpired, excludeUnpaid: $excUnpaid) { - sent{ - IsPaid - ExpiresAt - Amount - Description - } - received { - IsPaid - ExpiresAt - Amount - Description - } - } -} -``` -Query variables: - -```graphql -{ "wID": "97186e34480d6aabcf59ebd37a893a0d02223f6a38822c8e6213c810384f0dc7", - "excExpired": true,"excUnpaid": false} -``` \ No newline at end of file diff --git a/backend/graphql/gen.go b/backend/graphql/gen.go deleted file mode 100644 index c5c4663a..00000000 --- a/backend/graphql/gen.go +++ /dev/null @@ -1,3 +0,0 @@ -package graphql - -//go:generate gqlgen generate diff --git a/backend/graphql/gqlgen.yml b/backend/graphql/gqlgen.yml deleted file mode 100644 index 274edb3f..00000000 --- a/backend/graphql/gqlgen.yml +++ /dev/null @@ -1,49 +0,0 @@ -# Where are all the schema files located? globs are supported eg src/**/*.graphqls -schema: - - ../../graphql/*.graphql - -# Where should the generated server code go? -exec: - filename: internal/generated/exec.go - package: generated - -# Where should any generated models go? -model: - filename: internal/generated/models_gen.go - package: generated - -# Where should the resolver implementations go? -resolver: - layout: follow-schema - dir: internal/resolver - package: resolver - -struct_tag: json - -omit_slice_element_pointers: true - -# Optional: set to speed up generation time by not performing a final validation pass. -# skip_validation: true - -# gqlgen will search for any type names in the schema in these go packages -# if they match it will use them, otherwise it will generate them. -autobind: - - "seed/backend/graphql/internal/model" - -# This section declares type mapping between the GraphQL and go type systems -# -# The first line in each type will be used as defaults for resolver arguments and -# modelgen, the others will be allowed when binding to fields. Configure them to -# your liking -models: - ID: - model: - - github.com/99designs/gqlgen/graphql.ID - - github.com/99designs/gqlgen/graphql.Int - - github.com/99designs/gqlgen/graphql.Int64 - - github.com/99designs/gqlgen/graphql.Int32 - Int: - model: - - github.com/99designs/gqlgen/graphql.Int - - github.com/99designs/gqlgen/graphql.Int64 - - github.com/99designs/gqlgen/graphql.Int32 diff --git a/backend/graphql/graphql.go b/backend/graphql/graphql.go deleted file mode 100644 index bdfacccf..00000000 --- a/backend/graphql/graphql.go +++ /dev/null @@ -1,16 +0,0 @@ -// Package graphql exposes a GraphQL API from the Seed Daemon. -package graphql - -import ( - "seed/backend/graphql/internal/generated" - "seed/backend/graphql/internal/resolver" - - "github.com/99designs/gqlgen/graphql/handler" -) - -// Handler creates a new GraphQL API Server. It implements http.Handler. -func Handler(svc resolver.Service) *handler.Server { - return handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{ - Resolvers: resolver.New(svc), - })) -} diff --git a/backend/graphql/internal/generated/exec.go b/backend/graphql/internal/generated/exec.go deleted file mode 100644 index a5d010cf..00000000 --- a/backend/graphql/internal/generated/exec.go +++ /dev/null @@ -1,7322 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "bytes" - "context" - "errors" - "fmt" - "seed/backend/graphql/internal/model" - "strconv" - "sync" - "sync/atomic" - - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - gqlparser "github.com/vektah/gqlparser/v2" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Me() MeResolver - Mutation() MutationResolver - Query() QueryResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - DeleteWalletPayload struct { - ID func(childComplexity int) int - } - - ExportWalletPayload struct { - Credentials func(childComplexity int) int - } - - ImportWalletPayload struct { - Wallet func(childComplexity int) int - } - - Invoice struct { - Amount func(childComplexity int) int - Description func(childComplexity int) int - DescriptionHash func(childComplexity int) int - Destination func(childComplexity int) int - ErrorMessage func(childComplexity int) int - ExpiresAt func(childComplexity int) int - Fee func(childComplexity int) int - IsPaid func(childComplexity int) int - Keysend func(childComplexity int) int - PaymentHash func(childComplexity int) int - PaymentPreimage func(childComplexity int) int - PaymentRequest func(childComplexity int) int - SettledAt func(childComplexity int) int - Status func(childComplexity int) int - Type func(childComplexity int) int - } - - LndHubWallet struct { - APIURL func(childComplexity int) int - BalanceSats func(childComplexity int) int - ID func(childComplexity int) int - IsDefault func(childComplexity int) int - Name func(childComplexity int) int - } - - Me struct { - Lnaddress func(childComplexity int) int - Wallets func(childComplexity int) int - } - - Mutation struct { - DeleteWallet func(childComplexity int, input DeleteWalletInput) int - ExportWallet func(childComplexity int, input ExportWalletInput) int - ImportWallet func(childComplexity int, input ImportWalletInput) int - PayInvoice func(childComplexity int, input PayInvoiceInput) int - RequestInvoice func(childComplexity int, input RequestInvoiceInput) int - SetDefaultWallet func(childComplexity int, input SetDefaultWalletInput) int - UpdateNickname func(childComplexity int, input UpdateNicknameInput) int - UpdateWallet func(childComplexity int, input UpdateWalletInput) int - } - - PayInvoicePayload struct { - WalletID func(childComplexity int) int - } - - Payments struct { - Received func(childComplexity int) int - Sent func(childComplexity int) int - } - - Query struct { - Me func(childComplexity int) int - Payments func(childComplexity int, walletID string, excludeUnpaid *bool, excludeKeysend *bool, excludeExpired *bool) int - } - - RequestInvoicePayload struct { - PaymentRequest func(childComplexity int) int - } - - SetDefaultWalletPayload struct { - Wallet func(childComplexity int) int - } - - UpdateNicknamePayload struct { - Nickname func(childComplexity int) int - } - - UpdateWalletPayload struct { - Wallet func(childComplexity int) int - } -} - -type MeResolver interface { - Wallets(ctx context.Context, obj *Me) ([]LightningWallet, error) - Lnaddress(ctx context.Context, obj *Me) (*string, error) -} -type MutationResolver interface { - SetDefaultWallet(ctx context.Context, input SetDefaultWalletInput) (*SetDefaultWalletPayload, error) - UpdateWallet(ctx context.Context, input UpdateWalletInput) (*UpdateWalletPayload, error) - DeleteWallet(ctx context.Context, input DeleteWalletInput) (*DeleteWalletPayload, error) - ExportWallet(ctx context.Context, input ExportWalletInput) (*ExportWalletPayload, error) - ImportWallet(ctx context.Context, input ImportWalletInput) (*ImportWalletPayload, error) - RequestInvoice(ctx context.Context, input RequestInvoiceInput) (*RequestInvoicePayload, error) - PayInvoice(ctx context.Context, input PayInvoiceInput) (*PayInvoicePayload, error) - UpdateNickname(ctx context.Context, input UpdateNicknameInput) (*UpdateNicknamePayload, error) -} -type QueryResolver interface { - Me(ctx context.Context) (*Me, error) - Payments(ctx context.Context, walletID string, excludeUnpaid *bool, excludeKeysend *bool, excludeExpired *bool) (*Payments, error) -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} - _ = ec - switch typeName + "." + field { - - case "DeleteWalletPayload.id": - if e.complexity.DeleteWalletPayload.ID == nil { - break - } - - return e.complexity.DeleteWalletPayload.ID(childComplexity), true - - case "ExportWalletPayload.credentials": - if e.complexity.ExportWalletPayload.Credentials == nil { - break - } - - return e.complexity.ExportWalletPayload.Credentials(childComplexity), true - - case "ImportWalletPayload.wallet": - if e.complexity.ImportWalletPayload.Wallet == nil { - break - } - - return e.complexity.ImportWalletPayload.Wallet(childComplexity), true - - case "Invoice.Amount": - if e.complexity.Invoice.Amount == nil { - break - } - - return e.complexity.Invoice.Amount(childComplexity), true - - case "Invoice.Description": - if e.complexity.Invoice.Description == nil { - break - } - - return e.complexity.Invoice.Description(childComplexity), true - - case "Invoice.DescriptionHash": - if e.complexity.Invoice.DescriptionHash == nil { - break - } - - return e.complexity.Invoice.DescriptionHash(childComplexity), true - - case "Invoice.Destination": - if e.complexity.Invoice.Destination == nil { - break - } - - return e.complexity.Invoice.Destination(childComplexity), true - - case "Invoice.ErrorMessage": - if e.complexity.Invoice.ErrorMessage == nil { - break - } - - return e.complexity.Invoice.ErrorMessage(childComplexity), true - - case "Invoice.ExpiresAt": - if e.complexity.Invoice.ExpiresAt == nil { - break - } - - return e.complexity.Invoice.ExpiresAt(childComplexity), true - - case "Invoice.Fee": - if e.complexity.Invoice.Fee == nil { - break - } - - return e.complexity.Invoice.Fee(childComplexity), true - - case "Invoice.IsPaid": - if e.complexity.Invoice.IsPaid == nil { - break - } - - return e.complexity.Invoice.IsPaid(childComplexity), true - - case "Invoice.Keysend": - if e.complexity.Invoice.Keysend == nil { - break - } - - return e.complexity.Invoice.Keysend(childComplexity), true - - case "Invoice.PaymentHash": - if e.complexity.Invoice.PaymentHash == nil { - break - } - - return e.complexity.Invoice.PaymentHash(childComplexity), true - - case "Invoice.PaymentPreimage": - if e.complexity.Invoice.PaymentPreimage == nil { - break - } - - return e.complexity.Invoice.PaymentPreimage(childComplexity), true - - case "Invoice.PaymentRequest": - if e.complexity.Invoice.PaymentRequest == nil { - break - } - - return e.complexity.Invoice.PaymentRequest(childComplexity), true - - case "Invoice.SettledAt": - if e.complexity.Invoice.SettledAt == nil { - break - } - - return e.complexity.Invoice.SettledAt(childComplexity), true - - case "Invoice.Status": - if e.complexity.Invoice.Status == nil { - break - } - - return e.complexity.Invoice.Status(childComplexity), true - - case "Invoice.Type": - if e.complexity.Invoice.Type == nil { - break - } - - return e.complexity.Invoice.Type(childComplexity), true - - case "LndHubWallet.apiURL": - if e.complexity.LndHubWallet.APIURL == nil { - break - } - - return e.complexity.LndHubWallet.APIURL(childComplexity), true - - case "LndHubWallet.balanceSats": - if e.complexity.LndHubWallet.BalanceSats == nil { - break - } - - return e.complexity.LndHubWallet.BalanceSats(childComplexity), true - - case "LndHubWallet.id": - if e.complexity.LndHubWallet.ID == nil { - break - } - - return e.complexity.LndHubWallet.ID(childComplexity), true - - case "LndHubWallet.isDefault": - if e.complexity.LndHubWallet.IsDefault == nil { - break - } - - return e.complexity.LndHubWallet.IsDefault(childComplexity), true - - case "LndHubWallet.name": - if e.complexity.LndHubWallet.Name == nil { - break - } - - return e.complexity.LndHubWallet.Name(childComplexity), true - - case "Me.lnaddress": - if e.complexity.Me.Lnaddress == nil { - break - } - - return e.complexity.Me.Lnaddress(childComplexity), true - - case "Me.wallets": - if e.complexity.Me.Wallets == nil { - break - } - - return e.complexity.Me.Wallets(childComplexity), true - - case "Mutation.deleteWallet": - if e.complexity.Mutation.DeleteWallet == nil { - break - } - - args, err := ec.field_Mutation_deleteWallet_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.DeleteWallet(childComplexity, args["input"].(DeleteWalletInput)), true - - case "Mutation.exportWallet": - if e.complexity.Mutation.ExportWallet == nil { - break - } - - args, err := ec.field_Mutation_exportWallet_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.ExportWallet(childComplexity, args["input"].(ExportWalletInput)), true - - case "Mutation.importWallet": - if e.complexity.Mutation.ImportWallet == nil { - break - } - - args, err := ec.field_Mutation_importWallet_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.ImportWallet(childComplexity, args["input"].(ImportWalletInput)), true - - case "Mutation.payInvoice": - if e.complexity.Mutation.PayInvoice == nil { - break - } - - args, err := ec.field_Mutation_payInvoice_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.PayInvoice(childComplexity, args["input"].(PayInvoiceInput)), true - - case "Mutation.requestInvoice": - if e.complexity.Mutation.RequestInvoice == nil { - break - } - - args, err := ec.field_Mutation_requestInvoice_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.RequestInvoice(childComplexity, args["input"].(RequestInvoiceInput)), true - - case "Mutation.setDefaultWallet": - if e.complexity.Mutation.SetDefaultWallet == nil { - break - } - - args, err := ec.field_Mutation_setDefaultWallet_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.SetDefaultWallet(childComplexity, args["input"].(SetDefaultWalletInput)), true - - case "Mutation.updateNickname": - if e.complexity.Mutation.UpdateNickname == nil { - break - } - - args, err := ec.field_Mutation_updateNickname_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.UpdateNickname(childComplexity, args["input"].(UpdateNicknameInput)), true - - case "Mutation.updateWallet": - if e.complexity.Mutation.UpdateWallet == nil { - break - } - - args, err := ec.field_Mutation_updateWallet_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.UpdateWallet(childComplexity, args["input"].(UpdateWalletInput)), true - - case "PayInvoicePayload.walletID": - if e.complexity.PayInvoicePayload.WalletID == nil { - break - } - - return e.complexity.PayInvoicePayload.WalletID(childComplexity), true - - case "Payments.received": - if e.complexity.Payments.Received == nil { - break - } - - return e.complexity.Payments.Received(childComplexity), true - - case "Payments.sent": - if e.complexity.Payments.Sent == nil { - break - } - - return e.complexity.Payments.Sent(childComplexity), true - - case "Query.me": - if e.complexity.Query.Me == nil { - break - } - - return e.complexity.Query.Me(childComplexity), true - - case "Query.payments": - if e.complexity.Query.Payments == nil { - break - } - - args, err := ec.field_Query_payments_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Payments(childComplexity, args["walletID"].(string), args["excludeUnpaid"].(*bool), args["excludeKeysend"].(*bool), args["excludeExpired"].(*bool)), true - - case "RequestInvoicePayload.paymentRequest": - if e.complexity.RequestInvoicePayload.PaymentRequest == nil { - break - } - - return e.complexity.RequestInvoicePayload.PaymentRequest(childComplexity), true - - case "SetDefaultWalletPayload.wallet": - if e.complexity.SetDefaultWalletPayload.Wallet == nil { - break - } - - return e.complexity.SetDefaultWalletPayload.Wallet(childComplexity), true - - case "UpdateNicknamePayload.nickname": - if e.complexity.UpdateNicknamePayload.Nickname == nil { - break - } - - return e.complexity.UpdateNicknamePayload.Nickname(childComplexity), true - - case "UpdateWalletPayload.wallet": - if e.complexity.UpdateWalletPayload.Wallet == nil { - break - } - - return e.complexity.UpdateWalletPayload.Wallet(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { - rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} - inputUnmarshalMap := graphql.BuildUnmarshalerMap( - ec.unmarshalInputDeleteWalletInput, - ec.unmarshalInputExportWalletInput, - ec.unmarshalInputImportWalletInput, - ec.unmarshalInputPayInvoiceInput, - ec.unmarshalInputRequestInvoiceInput, - ec.unmarshalInputSetDefaultWalletInput, - ec.unmarshalInputUpdateNicknameInput, - ec.unmarshalInputUpdateWalletInput, - ) - first := true - - switch rc.Operation.Operation { - case ast.Query: - return func(ctx context.Context) *graphql.Response { - if !first { - return nil - } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Query(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), - } - } - case ast.Mutation: - return func(ctx context.Context) *graphql.Response { - if !first { - return nil - } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Mutation(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), - } - } - - default: - return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) - } -} - -type executionContext struct { - *graphql.OperationContext - *executableSchema -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var sources = []*ast.Source{ - {Name: "../../../../graphql/schema.graphql", Input: `""" -Built-in directive for Go's gqlgen library. -""" -directive @goModel( - model: String - models: [String!] -) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION - -""" -Built-in directive for Go's gqlgen library. -""" -directive @goField( - forceResolver: Boolean - name: String -) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION - -""" -Lightning Network payment request encoded as a string. -Ready to be encoded as a QR code for wallets to scan and pay. -""" -scalar LightningPaymentRequest - -""" -Bitcoin amount in sats. -Should be interpreted as a large-enough unsigned integer type. -""" -scalar Satoshis - -""" -Top-level queries. -""" -type Query { - """ - Information about the current user. - """ - me: Me! - - """ - Information about payments. - """ - payments( - walletID: ID! - excludeUnpaid: Boolean - excludeKeysend: Boolean - excludeExpired: Boolean - ): Payments! -} - -""" -Information about the current user. -""" -type Me { - """ - List configured Lightning wallets. - """ - wallets: [LightningWallet!] @goField(forceResolver: true) - - """ - Account-wide Lightning addres (lnaddress) - """ - lnaddress: String @goField(forceResolver: true) -} - -""" -Information about payments -""" -type Payments { - """ - Payments made. They can be unconfirmed - """ - sent: [Invoice] - """ - Payments received. They can be unconfirmed - """ - received: [Invoice] -} - -""" -Top-level mutations. -""" -type Mutation { - """ - Set an existing wallet to be the default one. Initially, the first configured wallet - automatically becomes the default one. - """ - setDefaultWallet(input: SetDefaultWalletInput!): SetDefaultWalletPayload! - - """ - Update existing wallet. - """ - updateWallet(input: UpdateWalletInput!): UpdateWalletPayload! - - """ - Delete existing wallet. - """ - deleteWallet(input: DeleteWalletInput!): DeleteWalletPayload! - - """ - Export wallet to use it with an external application. - """ - exportWallet(input: ExportWalletInput!): ExportWalletPayload! - - """ - Import wallet to use it in seed. - """ - importWallet(input: ImportWalletInput!): ImportWalletPayload! - - """ - Request an invoice from a user. The user can be either a Seed Account ID or a ln address. - """ - requestInvoice(input: RequestInvoiceInput!): RequestInvoicePayload! - - """ - Pay invoice with a previously configured wallet. - """ - payInvoice(input: PayInvoiceInput!): PayInvoicePayload! - - """ - Update lnaddress' nickname. - """ - updateNickname(input: UpdateNicknameInput!): UpdateNicknamePayload! -} - -""" -Input for setting the default wallet. -""" -input SetDefaultWalletInput { - """ - ID of the wallet to become the default one. - """ - id: ID! -} - -""" -Response after setting default wallet. -""" -type SetDefaultWalletPayload { - """ - The new default wallet. - """ - wallet: LightningWallet! -} - -""" -Input to update Lightning wallets. -""" -input UpdateWalletInput { - """ - ID of the wallet to be updated. - """ - id: ID! - - """ - New name for the wallet. - """ - name: String! -} - -""" -Response with the updated wallet. -""" -type UpdateWalletPayload { - """ - Updated wallet. - """ - wallet: LightningWallet! -} - -""" -Input to delete a wallet. -""" -input DeleteWalletInput { - """ - ID of the wallet to be deleted. - """ - id: ID! -} - -""" -Response after deleting a wallet. -""" -type DeleteWalletPayload { - """ - ID of the deleted wallet. - """ - id: ID! -} - -""" -Input to export a wallet. -""" -input ExportWalletInput { - """ - ID of the wallet to be exported. If empty, the built-in wallet will be exported. - """ - id: ID! -} - -""" -Response after exporting a wallet. -""" -type ExportWalletPayload { - """ - credentials of the exported wallet. - """ - credentials: String! -} - - -""" -Input to export a wallet. -""" -input ImportWalletInput { - """ - Local name for this wallet. - """ - name: String! - - """ - Credential string to connect to imported wallet service. - """ - url: String! -} - -""" -Response after exporting a wallet. -""" -type ImportWalletPayload { - """ - Stored wallet. - """ - wallet: LightningWallet! -} - -""" -Input for requesting an invoice. -""" -input RequestInvoiceInput { - """ - Seed Account ID or lnaddress we want the invoice from. Can be ourselves. - """ - user: String! - - """ - Amount in Satoshis the invoice should be created for. - """ - amountSats: Satoshis! - - """ - Optional description for the invoice. - """ - memo: String -} - -""" -Response with the invoice to pay. -""" -type RequestInvoicePayload { - """ - Payment request is a string-encoded Lightning Network Payment Request. - It's ready to be used in a wallet app to pay. - """ - paymentRequest: LightningPaymentRequest! -} - -""" -Input to pay an invoice. -""" -input PayInvoiceInput { - """ - Previously obtained payment request we want to pay for. - """ - paymentRequest: LightningPaymentRequest! - - """ - Optional amount in satoshis to pay. In case this is not defined, - The amount showed in the invoice will be paid. If amountSats is - provided, then the invoice amount will be override. This will cause - an error unless both amounts are the same or the invoice amount is 0. - """ - amountSats: Satoshis - - """ - Optional ID of the wallet to pay with. Otherwise the default one will be used. - """ - walletID: ID -} - -""" -Response after paying an invoice. -""" -type PayInvoicePayload { - """ - Wallet ID that was used to pay the invoice. - """ - walletID: ID! -} - -""" -Input to update lnaddress' nickname. -""" -input UpdateNicknameInput { - """ - New nickname to update. - """ - nickname: String! -} - -""" -Response after updating the nickname. -""" -type UpdateNicknamePayload { - """ - Updated Nickname. - """ - nickname: String! -} - -""" -Common interface for Lightning wallets. We support different types. -""" -interface LightningWallet { - """ - Globally unique ID of the wallet. Public key. - """ - id: ID! - - """ - Local-only name of the wallet. For user's convenience. - """ - name: String! - - """ - Balance in Satoshis. - """ - balanceSats: Satoshis! - - """ - If this wallet is the default wallet to send/receive automatic payments - """ - isDefault: Boolean! -} - -""" -Lightning wallet compatible with LndHub. -""" -type LndHubWallet implements LightningWallet { - """ - Globally unique ID of the wallet. Since this type of wallet doesn't have unique addresses - we decided to use the cryptographic hash of the credentials URL as an ID. - """ - id: ID! - - """ - URL of the LndHub server this wallet is connected to. - """ - apiURL: String! - - """ - Name of the wallet. - """ - name: String! - - """ - Balance in Satoshis. - """ - balanceSats: Satoshis! - - """ - If this wallet is the default wallet to send/receive automatic payments - """ - isDefault: Boolean! -} - -""" -Lightning Invoices -""" -type Invoice { - """ - Preimage hash of the payment. - """ - PaymentHash: String - """ - Bolt-11 encoded invoice. - """ - PaymentRequest: String - """ - Memo field of the invoice. - """ - Description: String - """ - Memo hash in case its too long - """ - DescriptionHash: String - """ - Invoice secret known at settlement. Proof of payment - """ - PaymentPreimage: String - """ - Payee lightning node ID. - """ - Destination: String - """ - Invoice quantity in satoshis. - """ - Amount: Satoshis! - """ - Fees incurred by the payer when paying the invoice - """ - Fee: Satoshis - """ - Status of the invoice. (Settled, in-flight, expired, ...) - """ - Status: String - """ - Invoice tyoe - """ - Type: String - """ - Error of the invoice - """ - ErrorMessage: String - """ - Settlement date - """ - SettledAt: String - """ - Expiring date. - """ - ExpiresAt: String - """ - If the invoice has been paid or not. - """ - IsPaid: Boolean - """ - Whether or not this is a made up invoice corrensponding with a keysend payment - """ - Keysend: Boolean -} -`, BuiltIn: false}, -} -var parsedSchema = gqlparser.MustLoadSchema(sources...) - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -func (ec *executionContext) field_Mutation_deleteWallet_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 DeleteWalletInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNDeleteWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐDeleteWalletInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_exportWallet_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ExportWalletInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNExportWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐExportWalletInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_importWallet_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ImportWalletInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNImportWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐImportWalletInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_payInvoice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 PayInvoiceInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNPayInvoiceInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐPayInvoiceInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_requestInvoice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 RequestInvoiceInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNRequestInvoiceInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐRequestInvoiceInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_setDefaultWallet_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 SetDefaultWalletInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNSetDefaultWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐSetDefaultWalletInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_updateNickname_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 UpdateNicknameInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNUpdateNicknameInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateNicknameInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_updateWallet_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 UpdateWalletInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNUpdateWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateWalletInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_payments_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["walletID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("walletID")) - arg0, err = ec.unmarshalNID2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["walletID"] = arg0 - var arg1 *bool - if tmp, ok := rawArgs["excludeUnpaid"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("excludeUnpaid")) - arg1, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["excludeUnpaid"] = arg1 - var arg2 *bool - if tmp, ok := rawArgs["excludeKeysend"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("excludeKeysend")) - arg2, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["excludeKeysend"] = arg2 - var arg3 *bool - if tmp, ok := rawArgs["excludeExpired"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("excludeExpired")) - arg3, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["excludeExpired"] = arg3 - return args, nil -} - -func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _DeleteWalletPayload_id(ctx context.Context, field graphql.CollectedField, obj *DeleteWalletPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_DeleteWalletPayload_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_DeleteWalletPayload_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "DeleteWalletPayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _ExportWalletPayload_credentials(ctx context.Context, field graphql.CollectedField, obj *ExportWalletPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ExportWalletPayload_credentials(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Credentials, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ExportWalletPayload_credentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ExportWalletPayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _ImportWalletPayload_wallet(ctx context.Context, field graphql.CollectedField, obj *ImportWalletPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ImportWalletPayload_wallet(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Wallet, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(LightningWallet) - fc.Result = res - return ec.marshalNLightningWallet2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐLightningWallet(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_ImportWalletPayload_wallet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ImportWalletPayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_PaymentHash(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_PaymentHash(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PaymentHash, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_PaymentHash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_PaymentRequest(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_PaymentRequest(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PaymentRequest, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_PaymentRequest(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_Description(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_Description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_Description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_DescriptionHash(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_DescriptionHash(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DescriptionHash, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_DescriptionHash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_PaymentPreimage(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_PaymentPreimage(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PaymentPreimage, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_PaymentPreimage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_Destination(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_Destination(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Destination, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_Destination(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_Amount(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_Amount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Amount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(model.Satoshis) - fc.Result = res - return ec.marshalNSatoshis2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_Amount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Satoshis does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_Fee(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_Fee(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fee, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*model.Satoshis) - fc.Result = res - return ec.marshalOSatoshis2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_Fee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Satoshis does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_Status(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_Status(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Status, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_Status(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_Type(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_Type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_Type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_ErrorMessage(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_ErrorMessage(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ErrorMessage, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_ErrorMessage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_SettledAt(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_SettledAt(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SettledAt, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_SettledAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_ExpiresAt(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_ExpiresAt(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ExpiresAt, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_ExpiresAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_IsPaid(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_IsPaid(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsPaid, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - fc.Result = res - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_IsPaid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Invoice_Keysend(ctx context.Context, field graphql.CollectedField, obj *Invoice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Invoice_Keysend(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Keysend, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - fc.Result = res - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Invoice_Keysend(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Invoice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _LndHubWallet_id(ctx context.Context, field graphql.CollectedField, obj *LndHubWallet) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LndHubWallet_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_LndHubWallet_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "LndHubWallet", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _LndHubWallet_apiURL(ctx context.Context, field graphql.CollectedField, obj *LndHubWallet) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LndHubWallet_apiURL(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.APIURL, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_LndHubWallet_apiURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "LndHubWallet", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _LndHubWallet_name(ctx context.Context, field graphql.CollectedField, obj *LndHubWallet) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LndHubWallet_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_LndHubWallet_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "LndHubWallet", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _LndHubWallet_balanceSats(ctx context.Context, field graphql.CollectedField, obj *LndHubWallet) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LndHubWallet_balanceSats(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.BalanceSats, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(model.Satoshis) - fc.Result = res - return ec.marshalNSatoshis2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_LndHubWallet_balanceSats(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "LndHubWallet", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Satoshis does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _LndHubWallet_isDefault(ctx context.Context, field graphql.CollectedField, obj *LndHubWallet) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LndHubWallet_isDefault(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDefault, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_LndHubWallet_isDefault(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "LndHubWallet", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Me_wallets(ctx context.Context, field graphql.CollectedField, obj *Me) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Me_wallets(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Me().Wallets(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]LightningWallet) - fc.Result = res - return ec.marshalOLightningWallet2ᚕseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐLightningWalletᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Me_wallets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Me", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") - }, - } - return fc, nil -} - -func (ec *executionContext) _Me_lnaddress(ctx context.Context, field graphql.CollectedField, obj *Me) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Me_lnaddress(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Me().Lnaddress(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Me_lnaddress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Me", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Mutation_setDefaultWallet(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_setDefaultWallet(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SetDefaultWallet(rctx, fc.Args["input"].(SetDefaultWalletInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*SetDefaultWalletPayload) - fc.Result = res - return ec.marshalNSetDefaultWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐSetDefaultWalletPayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_setDefaultWallet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "wallet": - return ec.fieldContext_SetDefaultWalletPayload_wallet(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SetDefaultWalletPayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_setDefaultWallet_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_updateWallet(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateWallet(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateWallet(rctx, fc.Args["input"].(UpdateWalletInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*UpdateWalletPayload) - fc.Result = res - return ec.marshalNUpdateWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateWalletPayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_updateWallet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "wallet": - return ec.fieldContext_UpdateWalletPayload_wallet(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UpdateWalletPayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateWallet_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_deleteWallet(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteWallet(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteWallet(rctx, fc.Args["input"].(DeleteWalletInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*DeleteWalletPayload) - fc.Result = res - return ec.marshalNDeleteWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐDeleteWalletPayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_deleteWallet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_DeleteWalletPayload_id(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type DeleteWalletPayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteWallet_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_exportWallet(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_exportWallet(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ExportWallet(rctx, fc.Args["input"].(ExportWalletInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ExportWalletPayload) - fc.Result = res - return ec.marshalNExportWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐExportWalletPayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_exportWallet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "credentials": - return ec.fieldContext_ExportWalletPayload_credentials(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ExportWalletPayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_exportWallet_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_importWallet(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_importWallet(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ImportWallet(rctx, fc.Args["input"].(ImportWalletInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ImportWalletPayload) - fc.Result = res - return ec.marshalNImportWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐImportWalletPayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_importWallet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "wallet": - return ec.fieldContext_ImportWalletPayload_wallet(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ImportWalletPayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_importWallet_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_requestInvoice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_requestInvoice(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RequestInvoice(rctx, fc.Args["input"].(RequestInvoiceInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*RequestInvoicePayload) - fc.Result = res - return ec.marshalNRequestInvoicePayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐRequestInvoicePayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_requestInvoice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "paymentRequest": - return ec.fieldContext_RequestInvoicePayload_paymentRequest(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type RequestInvoicePayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_requestInvoice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_payInvoice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_payInvoice(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().PayInvoice(rctx, fc.Args["input"].(PayInvoiceInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*PayInvoicePayload) - fc.Result = res - return ec.marshalNPayInvoicePayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐPayInvoicePayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_payInvoice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "walletID": - return ec.fieldContext_PayInvoicePayload_walletID(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PayInvoicePayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_payInvoice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_updateNickname(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateNickname(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateNickname(rctx, fc.Args["input"].(UpdateNicknameInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*UpdateNicknamePayload) - fc.Result = res - return ec.marshalNUpdateNicknamePayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateNicknamePayload(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_updateNickname(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "nickname": - return ec.fieldContext_UpdateNicknamePayload_nickname(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UpdateNicknamePayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateNickname_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _PayInvoicePayload_walletID(ctx context.Context, field graphql.CollectedField, obj *PayInvoicePayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PayInvoicePayload_walletID(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.WalletID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PayInvoicePayload_walletID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PayInvoicePayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Payments_sent(ctx context.Context, field graphql.CollectedField, obj *Payments) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Payments_sent(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Sent, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*Invoice) - fc.Result = res - return ec.marshalOInvoice2ᚕᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐInvoice(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Payments_sent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Payments", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "PaymentHash": - return ec.fieldContext_Invoice_PaymentHash(ctx, field) - case "PaymentRequest": - return ec.fieldContext_Invoice_PaymentRequest(ctx, field) - case "Description": - return ec.fieldContext_Invoice_Description(ctx, field) - case "DescriptionHash": - return ec.fieldContext_Invoice_DescriptionHash(ctx, field) - case "PaymentPreimage": - return ec.fieldContext_Invoice_PaymentPreimage(ctx, field) - case "Destination": - return ec.fieldContext_Invoice_Destination(ctx, field) - case "Amount": - return ec.fieldContext_Invoice_Amount(ctx, field) - case "Fee": - return ec.fieldContext_Invoice_Fee(ctx, field) - case "Status": - return ec.fieldContext_Invoice_Status(ctx, field) - case "Type": - return ec.fieldContext_Invoice_Type(ctx, field) - case "ErrorMessage": - return ec.fieldContext_Invoice_ErrorMessage(ctx, field) - case "SettledAt": - return ec.fieldContext_Invoice_SettledAt(ctx, field) - case "ExpiresAt": - return ec.fieldContext_Invoice_ExpiresAt(ctx, field) - case "IsPaid": - return ec.fieldContext_Invoice_IsPaid(ctx, field) - case "Keysend": - return ec.fieldContext_Invoice_Keysend(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Invoice", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Payments_received(ctx context.Context, field graphql.CollectedField, obj *Payments) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Payments_received(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Received, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*Invoice) - fc.Result = res - return ec.marshalOInvoice2ᚕᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐInvoice(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Payments_received(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Payments", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "PaymentHash": - return ec.fieldContext_Invoice_PaymentHash(ctx, field) - case "PaymentRequest": - return ec.fieldContext_Invoice_PaymentRequest(ctx, field) - case "Description": - return ec.fieldContext_Invoice_Description(ctx, field) - case "DescriptionHash": - return ec.fieldContext_Invoice_DescriptionHash(ctx, field) - case "PaymentPreimage": - return ec.fieldContext_Invoice_PaymentPreimage(ctx, field) - case "Destination": - return ec.fieldContext_Invoice_Destination(ctx, field) - case "Amount": - return ec.fieldContext_Invoice_Amount(ctx, field) - case "Fee": - return ec.fieldContext_Invoice_Fee(ctx, field) - case "Status": - return ec.fieldContext_Invoice_Status(ctx, field) - case "Type": - return ec.fieldContext_Invoice_Type(ctx, field) - case "ErrorMessage": - return ec.fieldContext_Invoice_ErrorMessage(ctx, field) - case "SettledAt": - return ec.fieldContext_Invoice_SettledAt(ctx, field) - case "ExpiresAt": - return ec.fieldContext_Invoice_ExpiresAt(ctx, field) - case "IsPaid": - return ec.fieldContext_Invoice_IsPaid(ctx, field) - case "Keysend": - return ec.fieldContext_Invoice_Keysend(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Invoice", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_me(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Me(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*Me) - fc.Result = res - return ec.marshalNMe2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐMe(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "wallets": - return ec.fieldContext_Me_wallets(ctx, field) - case "lnaddress": - return ec.fieldContext_Me_lnaddress(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Me", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_payments(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_payments(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Payments(rctx, fc.Args["walletID"].(string), fc.Args["excludeUnpaid"].(*bool), fc.Args["excludeKeysend"].(*bool), fc.Args["excludeExpired"].(*bool)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*Payments) - fc.Result = res - return ec.marshalNPayments2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐPayments(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_payments(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "sent": - return ec.fieldContext_Payments_sent(ctx, field) - case "received": - return ec.fieldContext_Payments_received(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Payments", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_payments_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _RequestInvoicePayload_paymentRequest(ctx context.Context, field graphql.CollectedField, obj *RequestInvoicePayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_RequestInvoicePayload_paymentRequest(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PaymentRequest, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(model.LightningPaymentRequest) - fc.Result = res - return ec.marshalNLightningPaymentRequest2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐLightningPaymentRequest(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_RequestInvoicePayload_paymentRequest(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "RequestInvoicePayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type LightningPaymentRequest does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _SetDefaultWalletPayload_wallet(ctx context.Context, field graphql.CollectedField, obj *SetDefaultWalletPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SetDefaultWalletPayload_wallet(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Wallet, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(LightningWallet) - fc.Result = res - return ec.marshalNLightningWallet2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐLightningWallet(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SetDefaultWalletPayload_wallet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SetDefaultWalletPayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") - }, - } - return fc, nil -} - -func (ec *executionContext) _UpdateNicknamePayload_nickname(ctx context.Context, field graphql.CollectedField, obj *UpdateNicknamePayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UpdateNicknamePayload_nickname(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Nickname, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_UpdateNicknamePayload_nickname(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "UpdateNicknamePayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _UpdateWalletPayload_wallet(ctx context.Context, field graphql.CollectedField, obj *UpdateWalletPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UpdateWalletPayload_wallet(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Wallet, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(LightningWallet) - fc.Result = res - return ec.marshalNLightningWallet2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐLightningWallet(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_UpdateWalletPayload_wallet(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "UpdateWalletPayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - fc.Result = res - return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Directive) - fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __TypeKind does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SpecifiedByURL(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputDeleteWalletInput(ctx context.Context, obj interface{}) (DeleteWalletInput, error) { - var it DeleteWalletInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"id"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "id": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalNID2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputExportWalletInput(ctx context.Context, obj interface{}) (ExportWalletInput, error) { - var it ExportWalletInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"id"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "id": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalNID2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputImportWalletInput(ctx context.Context, obj interface{}) (ImportWalletInput, error) { - var it ImportWalletInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"name", "url"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "name": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "url": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) - it.URL, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputPayInvoiceInput(ctx context.Context, obj interface{}) (PayInvoiceInput, error) { - var it PayInvoiceInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"paymentRequest", "amountSats", "walletID"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "paymentRequest": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paymentRequest")) - it.PaymentRequest, err = ec.unmarshalNLightningPaymentRequest2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐLightningPaymentRequest(ctx, v) - if err != nil { - return it, err - } - case "amountSats": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("amountSats")) - it.AmountSats, err = ec.unmarshalOSatoshis2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx, v) - if err != nil { - return it, err - } - case "walletID": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("walletID")) - it.WalletID, err = ec.unmarshalOID2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputRequestInvoiceInput(ctx context.Context, obj interface{}) (RequestInvoiceInput, error) { - var it RequestInvoiceInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"user", "amountSats", "memo"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "user": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("user")) - it.User, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "amountSats": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("amountSats")) - it.AmountSats, err = ec.unmarshalNSatoshis2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx, v) - if err != nil { - return it, err - } - case "memo": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("memo")) - it.Memo, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputSetDefaultWalletInput(ctx context.Context, obj interface{}) (SetDefaultWalletInput, error) { - var it SetDefaultWalletInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"id"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "id": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalNID2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputUpdateNicknameInput(ctx context.Context, obj interface{}) (UpdateNicknameInput, error) { - var it UpdateNicknameInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"nickname"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "nickname": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nickname")) - it.Nickname, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputUpdateWalletInput(ctx context.Context, obj interface{}) (UpdateWalletInput, error) { - var it UpdateWalletInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"id", "name"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "id": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalNID2string(ctx, v) - if err != nil { - return it, err - } - case "name": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -func (ec *executionContext) _LightningWallet(ctx context.Context, sel ast.SelectionSet, obj LightningWallet) graphql.Marshaler { - switch obj := (obj).(type) { - case nil: - return graphql.Null - case LndHubWallet: - return ec._LndHubWallet(ctx, sel, &obj) - case *LndHubWallet: - if obj == nil { - return graphql.Null - } - return ec._LndHubWallet(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var deleteWalletPayloadImplementors = []string{"DeleteWalletPayload"} - -func (ec *executionContext) _DeleteWalletPayload(ctx context.Context, sel ast.SelectionSet, obj *DeleteWalletPayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, deleteWalletPayloadImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("DeleteWalletPayload") - case "id": - - out.Values[i] = ec._DeleteWalletPayload_id(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var exportWalletPayloadImplementors = []string{"ExportWalletPayload"} - -func (ec *executionContext) _ExportWalletPayload(ctx context.Context, sel ast.SelectionSet, obj *ExportWalletPayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, exportWalletPayloadImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ExportWalletPayload") - case "credentials": - - out.Values[i] = ec._ExportWalletPayload_credentials(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var importWalletPayloadImplementors = []string{"ImportWalletPayload"} - -func (ec *executionContext) _ImportWalletPayload(ctx context.Context, sel ast.SelectionSet, obj *ImportWalletPayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, importWalletPayloadImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ImportWalletPayload") - case "wallet": - - out.Values[i] = ec._ImportWalletPayload_wallet(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var invoiceImplementors = []string{"Invoice"} - -func (ec *executionContext) _Invoice(ctx context.Context, sel ast.SelectionSet, obj *Invoice) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, invoiceImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Invoice") - case "PaymentHash": - - out.Values[i] = ec._Invoice_PaymentHash(ctx, field, obj) - - case "PaymentRequest": - - out.Values[i] = ec._Invoice_PaymentRequest(ctx, field, obj) - - case "Description": - - out.Values[i] = ec._Invoice_Description(ctx, field, obj) - - case "DescriptionHash": - - out.Values[i] = ec._Invoice_DescriptionHash(ctx, field, obj) - - case "PaymentPreimage": - - out.Values[i] = ec._Invoice_PaymentPreimage(ctx, field, obj) - - case "Destination": - - out.Values[i] = ec._Invoice_Destination(ctx, field, obj) - - case "Amount": - - out.Values[i] = ec._Invoice_Amount(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "Fee": - - out.Values[i] = ec._Invoice_Fee(ctx, field, obj) - - case "Status": - - out.Values[i] = ec._Invoice_Status(ctx, field, obj) - - case "Type": - - out.Values[i] = ec._Invoice_Type(ctx, field, obj) - - case "ErrorMessage": - - out.Values[i] = ec._Invoice_ErrorMessage(ctx, field, obj) - - case "SettledAt": - - out.Values[i] = ec._Invoice_SettledAt(ctx, field, obj) - - case "ExpiresAt": - - out.Values[i] = ec._Invoice_ExpiresAt(ctx, field, obj) - - case "IsPaid": - - out.Values[i] = ec._Invoice_IsPaid(ctx, field, obj) - - case "Keysend": - - out.Values[i] = ec._Invoice_Keysend(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var lndHubWalletImplementors = []string{"LndHubWallet", "LightningWallet"} - -func (ec *executionContext) _LndHubWallet(ctx context.Context, sel ast.SelectionSet, obj *LndHubWallet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, lndHubWalletImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("LndHubWallet") - case "id": - - out.Values[i] = ec._LndHubWallet_id(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "apiURL": - - out.Values[i] = ec._LndHubWallet_apiURL(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "name": - - out.Values[i] = ec._LndHubWallet_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "balanceSats": - - out.Values[i] = ec._LndHubWallet_balanceSats(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "isDefault": - - out.Values[i] = ec._LndHubWallet_isDefault(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var meImplementors = []string{"Me"} - -func (ec *executionContext) _Me(ctx context.Context, sel ast.SelectionSet, obj *Me) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, meImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Me") - case "wallets": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Me_wallets(ctx, field, obj) - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - case "lnaddress": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Me_lnaddress(ctx, field, obj) - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var mutationImplementors = []string{"Mutation"} - -func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Mutation", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Mutation") - case "setDefaultWallet": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_setDefaultWallet(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "updateWallet": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateWallet(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "deleteWallet": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_deleteWallet(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "exportWallet": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_exportWallet(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "importWallet": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_importWallet(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "requestInvoice": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_requestInvoice(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "payInvoice": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_payInvoice(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "updateNickname": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateNickname(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var payInvoicePayloadImplementors = []string{"PayInvoicePayload"} - -func (ec *executionContext) _PayInvoicePayload(ctx context.Context, sel ast.SelectionSet, obj *PayInvoicePayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, payInvoicePayloadImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PayInvoicePayload") - case "walletID": - - out.Values[i] = ec._PayInvoicePayload_walletID(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var paymentsImplementors = []string{"Payments"} - -func (ec *executionContext) _Payments(ctx context.Context, sel ast.SelectionSet, obj *Payments) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, paymentsImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Payments") - case "sent": - - out.Values[i] = ec._Payments_sent(ctx, field, obj) - - case "received": - - out.Values[i] = ec._Payments_received(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var queryImplementors = []string{"Query"} - -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "me": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_me(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "payments": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_payments(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "__type": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___type(ctx, field) - }) - - case "__schema": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___schema(ctx, field) - }) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var requestInvoicePayloadImplementors = []string{"RequestInvoicePayload"} - -func (ec *executionContext) _RequestInvoicePayload(ctx context.Context, sel ast.SelectionSet, obj *RequestInvoicePayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, requestInvoicePayloadImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("RequestInvoicePayload") - case "paymentRequest": - - out.Values[i] = ec._RequestInvoicePayload_paymentRequest(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var setDefaultWalletPayloadImplementors = []string{"SetDefaultWalletPayload"} - -func (ec *executionContext) _SetDefaultWalletPayload(ctx context.Context, sel ast.SelectionSet, obj *SetDefaultWalletPayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, setDefaultWalletPayloadImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("SetDefaultWalletPayload") - case "wallet": - - out.Values[i] = ec._SetDefaultWalletPayload_wallet(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var updateNicknamePayloadImplementors = []string{"UpdateNicknamePayload"} - -func (ec *executionContext) _UpdateNicknamePayload(ctx context.Context, sel ast.SelectionSet, obj *UpdateNicknamePayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, updateNicknamePayloadImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("UpdateNicknamePayload") - case "nickname": - - out.Values[i] = ec._UpdateNicknamePayload_nickname(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var updateWalletPayloadImplementors = []string{"UpdateWalletPayload"} - -func (ec *executionContext) _UpdateWalletPayload(ctx context.Context, sel ast.SelectionSet, obj *UpdateWalletPayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, updateWalletPayloadImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("UpdateWalletPayload") - case "wallet": - - out.Values[i] = ec._UpdateWalletPayload_wallet(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __DirectiveImplementors = []string{"__Directive"} - -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - - out.Values[i] = ec.___Directive_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - - out.Values[i] = ec.___Directive_description(ctx, field, obj) - - case "locations": - - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "args": - - out.Values[i] = ec.___Directive_args(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "isRepeatable": - - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __EnumValueImplementors = []string{"__EnumValue"} - -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - - case "isDeprecated": - - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "deprecationReason": - - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __FieldImplementors = []string{"__Field"} - -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - - out.Values[i] = ec.___Field_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - - out.Values[i] = ec.___Field_description(ctx, field, obj) - - case "args": - - out.Values[i] = ec.___Field_args(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "type": - - out.Values[i] = ec.___Field_type(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "isDeprecated": - - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "deprecationReason": - - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __InputValueImplementors = []string{"__InputValue"} - -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - - case "type": - - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "defaultValue": - - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __SchemaImplementors = []string{"__Schema"} - -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "description": - - out.Values[i] = ec.___Schema_description(ctx, field, obj) - - case "types": - - out.Values[i] = ec.___Schema_types(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "queryType": - - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "mutationType": - - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - - case "subscriptionType": - - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - - case "directives": - - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __TypeImplementors = []string{"__Type"} - -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - - out.Values[i] = ec.___Type_kind(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "name": - - out.Values[i] = ec.___Type_name(ctx, field, obj) - - case "description": - - out.Values[i] = ec.___Type_description(ctx, field, obj) - - case "fields": - - out.Values[i] = ec.___Type_fields(ctx, field, obj) - - case "interfaces": - - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - - case "possibleTypes": - - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - - case "enumValues": - - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - - case "inputFields": - - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - - case "ofType": - - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - - case "specifiedByURL": - - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNDeleteWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐDeleteWalletInput(ctx context.Context, v interface{}) (DeleteWalletInput, error) { - res, err := ec.unmarshalInputDeleteWalletInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNDeleteWalletPayload2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐDeleteWalletPayload(ctx context.Context, sel ast.SelectionSet, v DeleteWalletPayload) graphql.Marshaler { - return ec._DeleteWalletPayload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNDeleteWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐDeleteWalletPayload(ctx context.Context, sel ast.SelectionSet, v *DeleteWalletPayload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._DeleteWalletPayload(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNExportWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐExportWalletInput(ctx context.Context, v interface{}) (ExportWalletInput, error) { - res, err := ec.unmarshalInputExportWalletInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNExportWalletPayload2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐExportWalletPayload(ctx context.Context, sel ast.SelectionSet, v ExportWalletPayload) graphql.Marshaler { - return ec._ExportWalletPayload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNExportWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐExportWalletPayload(ctx context.Context, sel ast.SelectionSet, v *ExportWalletPayload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._ExportWalletPayload(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalID(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNImportWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐImportWalletInput(ctx context.Context, v interface{}) (ImportWalletInput, error) { - res, err := ec.unmarshalInputImportWalletInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNImportWalletPayload2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐImportWalletPayload(ctx context.Context, sel ast.SelectionSet, v ImportWalletPayload) graphql.Marshaler { - return ec._ImportWalletPayload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNImportWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐImportWalletPayload(ctx context.Context, sel ast.SelectionSet, v *ImportWalletPayload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._ImportWalletPayload(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNLightningPaymentRequest2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐLightningPaymentRequest(ctx context.Context, v interface{}) (model.LightningPaymentRequest, error) { - tmp, err := graphql.UnmarshalString(v) - res := model.LightningPaymentRequest(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNLightningPaymentRequest2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐLightningPaymentRequest(ctx context.Context, sel ast.SelectionSet, v model.LightningPaymentRequest) graphql.Marshaler { - res := graphql.MarshalString(string(v)) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) marshalNLightningWallet2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐLightningWallet(ctx context.Context, sel ast.SelectionSet, v LightningWallet) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._LightningWallet(ctx, sel, v) -} - -func (ec *executionContext) marshalNMe2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐMe(ctx context.Context, sel ast.SelectionSet, v Me) graphql.Marshaler { - return ec._Me(ctx, sel, &v) -} - -func (ec *executionContext) marshalNMe2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐMe(ctx context.Context, sel ast.SelectionSet, v *Me) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._Me(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNPayInvoiceInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐPayInvoiceInput(ctx context.Context, v interface{}) (PayInvoiceInput, error) { - res, err := ec.unmarshalInputPayInvoiceInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNPayInvoicePayload2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐPayInvoicePayload(ctx context.Context, sel ast.SelectionSet, v PayInvoicePayload) graphql.Marshaler { - return ec._PayInvoicePayload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNPayInvoicePayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐPayInvoicePayload(ctx context.Context, sel ast.SelectionSet, v *PayInvoicePayload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._PayInvoicePayload(ctx, sel, v) -} - -func (ec *executionContext) marshalNPayments2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐPayments(ctx context.Context, sel ast.SelectionSet, v Payments) graphql.Marshaler { - return ec._Payments(ctx, sel, &v) -} - -func (ec *executionContext) marshalNPayments2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐPayments(ctx context.Context, sel ast.SelectionSet, v *Payments) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._Payments(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNRequestInvoiceInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐRequestInvoiceInput(ctx context.Context, v interface{}) (RequestInvoiceInput, error) { - res, err := ec.unmarshalInputRequestInvoiceInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNRequestInvoicePayload2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐRequestInvoicePayload(ctx context.Context, sel ast.SelectionSet, v RequestInvoicePayload) graphql.Marshaler { - return ec._RequestInvoicePayload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNRequestInvoicePayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐRequestInvoicePayload(ctx context.Context, sel ast.SelectionSet, v *RequestInvoicePayload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._RequestInvoicePayload(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNSatoshis2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx context.Context, v interface{}) (model.Satoshis, error) { - var res model.Satoshis - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNSatoshis2seedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx context.Context, sel ast.SelectionSet, v model.Satoshis) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalNSetDefaultWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐSetDefaultWalletInput(ctx context.Context, v interface{}) (SetDefaultWalletInput, error) { - res, err := ec.unmarshalInputSetDefaultWalletInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNSetDefaultWalletPayload2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐSetDefaultWalletPayload(ctx context.Context, sel ast.SelectionSet, v SetDefaultWalletPayload) graphql.Marshaler { - return ec._SetDefaultWalletPayload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNSetDefaultWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐSetDefaultWalletPayload(ctx context.Context, sel ast.SelectionSet, v *SetDefaultWalletPayload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._SetDefaultWalletPayload(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNUpdateNicknameInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateNicknameInput(ctx context.Context, v interface{}) (UpdateNicknameInput, error) { - res, err := ec.unmarshalInputUpdateNicknameInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNUpdateNicknamePayload2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateNicknamePayload(ctx context.Context, sel ast.SelectionSet, v UpdateNicknamePayload) graphql.Marshaler { - return ec._UpdateNicknamePayload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNUpdateNicknamePayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateNicknamePayload(ctx context.Context, sel ast.SelectionSet, v *UpdateNicknamePayload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._UpdateNicknamePayload(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNUpdateWalletInput2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateWalletInput(ctx context.Context, v interface{}) (UpdateWalletInput, error) { - res, err := ec.unmarshalInputUpdateWalletInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNUpdateWalletPayload2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateWalletPayload(ctx context.Context, sel ast.SelectionSet, v UpdateWalletPayload) graphql.Marshaler { - return ec._UpdateWalletPayload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNUpdateWalletPayload2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐUpdateWalletPayload(ctx context.Context, sel ast.SelectionSet, v *UpdateWalletPayload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._UpdateWalletPayload(ctx, sel, v) -} - -func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - return res -} - -func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalBoolean(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalBoolean(*v) - return res -} - -func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalID(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalID(*v) - return res -} - -func (ec *executionContext) marshalOInvoice2ᚕᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐInvoice(ctx context.Context, sel ast.SelectionSet, v []*Invoice) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOInvoice2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐInvoice(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOInvoice2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐInvoice(ctx context.Context, sel ast.SelectionSet, v *Invoice) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Invoice(ctx, sel, v) -} - -func (ec *executionContext) marshalOLightningWallet2ᚕseedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐLightningWalletᚄ(ctx context.Context, sel ast.SelectionSet, v []LightningWallet) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNLightningWallet2seedᚋbackendᚋgraphqlᚋinternalᚋgeneratedᚐLightningWallet(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOSatoshis2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx context.Context, v interface{}) (*model.Satoshis, error) { - if v == nil { - return nil, nil - } - var res = new(model.Satoshis) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOSatoshis2ᚖseedᚋbackendᚋgraphqlᚋinternalᚋmodelᚐSatoshis(ctx context.Context, sel ast.SelectionSet, v *model.Satoshis) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNString2string(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalString(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalString(*v) - return res -} - -func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - -func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/backend/graphql/internal/generated/models_gen.go b/backend/graphql/internal/generated/models_gen.go deleted file mode 100644 index 17359744..00000000 --- a/backend/graphql/internal/generated/models_gen.go +++ /dev/null @@ -1,211 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "seed/backend/graphql/internal/model" -) - -// Common interface for Lightning wallets. We support different types. -type LightningWallet interface { - IsLightningWallet() - // Globally unique ID of the wallet. Public key. - GetID() string - // Local-only name of the wallet. For user's convenience. - GetName() string - // Balance in Satoshis. - GetBalanceSats() model.Satoshis - // If this wallet is the default wallet to send/receive automatic payments - GetIsDefault() bool -} - -// Input to delete a wallet. -type DeleteWalletInput struct { - // ID of the wallet to be deleted. - ID string `json:"id"` -} - -// Response after deleting a wallet. -type DeleteWalletPayload struct { - // ID of the deleted wallet. - ID string `json:"id"` -} - -// Input to export a wallet. -type ExportWalletInput struct { - // ID of the wallet to be exported. If empty, the built-in wallet will be exported. - ID string `json:"id"` -} - -// Response after exporting a wallet. -type ExportWalletPayload struct { - // credentials of the exported wallet. - Credentials string `json:"credentials"` -} - -// Input to export a wallet. -type ImportWalletInput struct { - // Local name for this wallet. - Name string `json:"name"` - // Credential string to connect to imported wallet service. - URL string `json:"url"` -} - -// Response after exporting a wallet. -type ImportWalletPayload struct { - // Stored wallet. - Wallet LightningWallet `json:"wallet"` -} - -// Lightning Invoices -type Invoice struct { - // Preimage hash of the payment. - PaymentHash *string `json:"PaymentHash"` - // Bolt-11 encoded invoice. - PaymentRequest *string `json:"PaymentRequest"` - // Memo field of the invoice. - Description *string `json:"Description"` - // Memo hash in case its too long - DescriptionHash *string `json:"DescriptionHash"` - // Invoice secret known at settlement. Proof of payment - PaymentPreimage *string `json:"PaymentPreimage"` - // Payee lightning node ID. - Destination *string `json:"Destination"` - // Invoice quantity in satoshis. - Amount model.Satoshis `json:"Amount"` - // Fees incurred by the payer when paying the invoice - Fee *model.Satoshis `json:"Fee"` - // Status of the invoice. (Settled, in-flight, expired, ...) - Status *string `json:"Status"` - // Invoice tyoe - Type *string `json:"Type"` - // Error of the invoice - ErrorMessage *string `json:"ErrorMessage"` - // Settlement date - SettledAt *string `json:"SettledAt"` - // Expiring date. - ExpiresAt *string `json:"ExpiresAt"` - // If the invoice has been paid or not. - IsPaid *bool `json:"IsPaid"` - // Whether or not this is a made up invoice corrensponding with a keysend payment - Keysend *bool `json:"Keysend"` -} - -// Lightning wallet compatible with LndHub. -type LndHubWallet struct { - // Globally unique ID of the wallet. Since this type of wallet doesn't have unique addresses - // we decided to use the cryptographic hash of the credentials URL as an ID. - ID string `json:"id"` - // URL of the LndHub server this wallet is connected to. - APIURL string `json:"apiURL"` - // Name of the wallet. - Name string `json:"name"` - // Balance in Satoshis. - BalanceSats model.Satoshis `json:"balanceSats"` - // If this wallet is the default wallet to send/receive automatic payments - IsDefault bool `json:"isDefault"` -} - -func (LndHubWallet) IsLightningWallet() {} - -// Globally unique ID of the wallet. Public key. -func (this LndHubWallet) GetID() string { return this.ID } - -// Local-only name of the wallet. For user's convenience. -func (this LndHubWallet) GetName() string { return this.Name } - -// Balance in Satoshis. -func (this LndHubWallet) GetBalanceSats() model.Satoshis { return this.BalanceSats } - -// If this wallet is the default wallet to send/receive automatic payments -func (this LndHubWallet) GetIsDefault() bool { return this.IsDefault } - -// Information about the current user. -type Me struct { - // List configured Lightning wallets. - Wallets []LightningWallet `json:"wallets"` - // Account-wide Lightning addres (lnaddress) - Lnaddress *string `json:"lnaddress"` -} - -// Input to pay an invoice. -type PayInvoiceInput struct { - // Previously obtained payment request we want to pay for. - PaymentRequest model.LightningPaymentRequest `json:"paymentRequest"` - // Optional amount in satoshis to pay. In case this is not defined, - // The amount showed in the invoice will be paid. If amountSats is - // provided, then the invoice amount will be override. This will cause - // an error unless both amounts are the same or the invoice amount is 0. - AmountSats *model.Satoshis `json:"amountSats"` - // Optional ID of the wallet to pay with. Otherwise the default one will be used. - WalletID *string `json:"walletID"` -} - -// Response after paying an invoice. -type PayInvoicePayload struct { - // Wallet ID that was used to pay the invoice. - WalletID string `json:"walletID"` -} - -// Information about payments -type Payments struct { - // Payments made. They can be unconfirmed - Sent []*Invoice `json:"sent"` - // Payments received. They can be unconfirmed - Received []*Invoice `json:"received"` -} - -// Input for requesting an invoice. -type RequestInvoiceInput struct { - // Seed Account ID or lnaddress we want the invoice from. Can be ourselves. - User string `json:"user"` - // Amount in Satoshis the invoice should be created for. - AmountSats model.Satoshis `json:"amountSats"` - // Optional description for the invoice. - Memo *string `json:"memo"` -} - -// Response with the invoice to pay. -type RequestInvoicePayload struct { - // Payment request is a string-encoded Lightning Network Payment Request. - // It's ready to be used in a wallet app to pay. - PaymentRequest model.LightningPaymentRequest `json:"paymentRequest"` -} - -// Input for setting the default wallet. -type SetDefaultWalletInput struct { - // ID of the wallet to become the default one. - ID string `json:"id"` -} - -// Response after setting default wallet. -type SetDefaultWalletPayload struct { - // The new default wallet. - Wallet LightningWallet `json:"wallet"` -} - -// Input to update lnaddress' nickname. -type UpdateNicknameInput struct { - // New nickname to update. - Nickname string `json:"nickname"` -} - -// Response after updating the nickname. -type UpdateNicknamePayload struct { - // Updated Nickname. - Nickname string `json:"nickname"` -} - -// Input to update Lightning wallets. -type UpdateWalletInput struct { - // ID of the wallet to be updated. - ID string `json:"id"` - // New name for the wallet. - Name string `json:"name"` -} - -// Response with the updated wallet. -type UpdateWalletPayload struct { - // Updated wallet. - Wallet LightningWallet `json:"wallet"` -} diff --git a/backend/graphql/internal/model/model.go b/backend/graphql/internal/model/model.go deleted file mode 100644 index 71f27c18..00000000 --- a/backend/graphql/internal/model/model.go +++ /dev/null @@ -1,48 +0,0 @@ -// Package model exposes overrides for autogenerated GraphQL models. -package model - -import ( - "encoding/json" - "errors" - "io" -) - -// Satoshis implements the custom GraphQL scalar. -type Satoshis int64 - -// MarshalGQL implements the graphql.Marshaler interface found in -// gqlgen, allowing the type to be marshaled by gqlgen and sent over -// the wire. -func (b Satoshis) MarshalGQL(w io.Writer) { - if err := json.NewEncoder(w).Encode(b); err != nil { - panic(err) - } -} - -// UnmarshalGQL implements the graphql.Unmarshaler interface found in -// gqlgen, allowing the type to be received by a graphql client and unmarshaled. -func (b *Satoshis) UnmarshalGQL(v interface{}) error { - var err error - - // check first if it is already in int64 - conv, ok := v.(int64) - - if !ok { - check, ok := v.(json.Number) - if !ok { - return errors.New("BigInt must be a valid integer value") - } - - conv, err = check.Int64() - if err != nil { - return err - } - } - - *b = Satoshis(conv) - - return nil -} - -// LightningPaymentRequest implement the custom GraphQL scalar. -type LightningPaymentRequest string diff --git a/backend/graphql/internal/resolver/resolver.go b/backend/graphql/internal/resolver/resolver.go deleted file mode 100644 index a515ae32..00000000 --- a/backend/graphql/internal/resolver/resolver.go +++ /dev/null @@ -1,43 +0,0 @@ -package resolver - -import ( - "context" - "seed/backend/lndhub" - wallet "seed/backend/wallet/walletsql" -) - -// This file will not be regenerated automatically. -// -// It serves as dependency injection for your app, add any dependencies you require here. - -// Service declares the needed functionality for the Resolver to work. This is to avoid -// implementing domain business logic inside the resolver. Think if this abstraction is needed at all. -// But let's be careful, and not make the resolver be very aware of the intricacies of our domain logic. -type Service interface { - GetLnAddress(context.Context) (string, error) - InsertWallet(context.Context, string, string) (wallet.Wallet, error) - ListWallets(context.Context, bool) ([]wallet.Wallet, error) - DeleteWallet(context.Context, string) error - UpdateWalletName(context.Context, string, string) (wallet.Wallet, error) - SetDefaultWallet(context.Context, string) (wallet.Wallet, error) - GetDefaultWallet(context.Context) (wallet.Wallet, error) - ExportWallet(context.Context, string) (string, error) - RequestRemoteInvoice(context.Context, string, int64, *string) (string, error) - CreateLocalInvoice(context.Context, int64, *string) (string, error) - PayInvoice(context.Context, string, *string, *uint64) (string, error) - ListPaidInvoices(context.Context, string) ([]lndhub.Invoice, error) - ListReceivednvoices(context.Context, string) ([]lndhub.Invoice, error) - UpdateLnaddressNickname(context.Context, string) error -} - -// Resolver is the root of the GraphQL API. -type Resolver struct { - svc Service -} - -// New creates a new Resolver. -func New(svc Service) *Resolver { - return &Resolver{ - svc: svc, - } -} diff --git a/backend/graphql/internal/resolver/schema.resolvers.go b/backend/graphql/internal/resolver/schema.resolvers.go deleted file mode 100644 index 4a89616c..00000000 --- a/backend/graphql/internal/resolver/schema.resolvers.go +++ /dev/null @@ -1,261 +0,0 @@ -package resolver - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.22 - -import ( - "context" - "fmt" - "seed/backend/graphql/internal/generated" - "seed/backend/graphql/internal/model" - "seed/backend/lndhub" - "strings" - "time" -) - -// Wallets is the resolver for the wallets field. -func (r *meResolver) Wallets(ctx context.Context, obj *generated.Me) ([]generated.LightningWallet, error) { - wallets, err := r.svc.ListWallets(ctx, true) - ret := []generated.LightningWallet{} - - if err != nil { - return ret, err - } - defaultWallet, err := r.svc.GetDefaultWallet(ctx) - if err != nil { - return ret, err - } - - for _, w := range wallets { - ret = append(ret, generated.LndHubWallet{ - ID: w.ID, - APIURL: w.Address, - Name: w.Name, - BalanceSats: model.Satoshis(w.Balance), - IsDefault: w.ID == defaultWallet.ID, - }) - } - - return ret, nil -} - -// Lnaddress is the resolver for the lnaddress field. -func (r *meResolver) Lnaddress(ctx context.Context, obj *generated.Me) (*string, error) { - lnaddress, err := r.svc.GetLnAddress(ctx) - if err != nil { - return nil, err - } - return &lnaddress, nil -} - -// SetDefaultWallet is the resolver for the setDefaultWallet field. -func (r *mutationResolver) SetDefaultWallet(ctx context.Context, input generated.SetDefaultWalletInput) (*generated.SetDefaultWalletPayload, error) { - defaultWallet, err := r.svc.SetDefaultWallet(ctx, input.ID) - if err != nil { - return nil, err - } - - return &generated.SetDefaultWalletPayload{ - Wallet: &generated.LndHubWallet{ - APIURL: defaultWallet.Address, - Name: defaultWallet.Name, - BalanceSats: model.Satoshis(defaultWallet.Balance), - ID: defaultWallet.ID, - }, - }, nil -} - -// UpdateWallet is the resolver for the updateWallet field. -func (r *mutationResolver) UpdateWallet(ctx context.Context, input generated.UpdateWalletInput) (*generated.UpdateWalletPayload, error) { - newWallet, err := r.svc.UpdateWalletName(ctx, input.ID, input.Name) - if err != nil { - return nil, err - } - - return &generated.UpdateWalletPayload{ - Wallet: &generated.LndHubWallet{ - APIURL: newWallet.Address, - Name: newWallet.Name, - BalanceSats: model.Satoshis(newWallet.Balance), - ID: newWallet.ID, - }, - }, nil -} - -// DeleteWallet is the resolver for the deleteWallet field. -func (r *mutationResolver) DeleteWallet(ctx context.Context, input generated.DeleteWalletInput) (*generated.DeleteWalletPayload, error) { - if err := r.svc.DeleteWallet(ctx, input.ID); err != nil { - return nil, err - } - - return &generated.DeleteWalletPayload{ID: input.ID}, nil -} - -// ExportWallet is the resolver for the exportWallet field. -func (r *mutationResolver) ExportWallet(ctx context.Context, input generated.ExportWalletInput) (*generated.ExportWalletPayload, error) { - uri, err := r.svc.ExportWallet(ctx, input.ID) - if err != nil { - return &generated.ExportWalletPayload{}, err - } - return &generated.ExportWalletPayload{Credentials: uri}, nil -} - -// ImportWallet is the resolver for the importWallet field. -func (r *mutationResolver) ImportWallet(ctx context.Context, input generated.ImportWalletInput) (*generated.ImportWalletPayload, error) { - lndhubWallet, err := r.svc.InsertWallet(ctx, input.URL, input.Name) - if err != nil { - return nil, err - } - - defaultWallet, err := r.svc.GetDefaultWallet(ctx) - if err != nil { - r.svc.DeleteWallet(ctx, lndhubWallet.ID) - return nil, fmt.Errorf("Reverting wallet import: %w", err) - } - - return &generated.ImportWalletPayload{ - Wallet: &generated.LndHubWallet{ - APIURL: lndhubWallet.Address, - Name: lndhubWallet.Name, - BalanceSats: model.Satoshis(lndhubWallet.Balance), - ID: lndhubWallet.ID, - IsDefault: defaultWallet.ID == lndhubWallet.ID, - }, - }, nil -} - -// RequestInvoice is the resolver for the requestInvoice field. -func (r *mutationResolver) RequestInvoice(ctx context.Context, input generated.RequestInvoiceInput) (*generated.RequestInvoicePayload, error) { - lnaddress := strings.Split(input.User, "@") - if len(lnaddress) == 2 && !strings.Contains(lnaddress[1], "seed") { - return nil, fmt.Errorf("currently only supported seed lndaddress") - } - payReq, err := r.svc.RequestRemoteInvoice(ctx, lnaddress[0], int64(input.AmountSats), input.Memo) - if err != nil { - return nil, err - } - return &generated.RequestInvoicePayload{PaymentRequest: model.LightningPaymentRequest(payReq)}, nil -} - -// PayInvoice is the resolver for the payInvoice field. -func (r *mutationResolver) PayInvoice(ctx context.Context, input generated.PayInvoiceInput) (*generated.PayInvoicePayload, error) { - var amount uint64 - if input.AmountSats != nil { - amount = uint64(*input.AmountSats) - } else { - amount = 0 - } - - walletID, err := r.svc.PayInvoice(ctx, string(input.PaymentRequest), input.WalletID, &amount) - if err != nil { - return nil, err - } - - return &generated.PayInvoicePayload{ - WalletID: walletID, - }, nil -} - -// UpdateNickname is the resolver for the updateNickname field. -func (r *mutationResolver) UpdateNickname(ctx context.Context, input generated.UpdateNicknameInput) (*generated.UpdateNicknamePayload, error) { - return &generated.UpdateNicknamePayload{Nickname: input.Nickname}, r.svc.UpdateLnaddressNickname(ctx, input.Nickname) -} - -// Me is the resolver for the me field. -func (r *queryResolver) Me(ctx context.Context) (*generated.Me, error) { - return &generated.Me{}, nil -} - -// Payments is the resolver for the payments field. -func (r *queryResolver) Payments(ctx context.Context, walletID string, excludeUnpaid *bool, excludeKeysend *bool, excludeExpired *bool) (*generated.Payments, error) { - var ret generated.Payments - received, err := r.svc.ListReceivednvoices(ctx, walletID) - if err != nil { - return &ret, err - } - sent, err := r.svc.ListPaidInvoices(ctx, walletID) - if err != nil { - return &ret, err - } - validRxInvoices := make([]lndhub.Invoice, len(received)) - for i, invoice := range received { - incInvoice := false - if excludeExpired != nil && *excludeExpired { - expiresAt, err := time.Parse(time.RFC3339, invoice.ExpiresAt) - if err != nil { - return &ret, fmt.Errorf("can't parse expiration date: %w", err) - } - incInvoice = time.Until(expiresAt) > 0 - } - if (excludeUnpaid == nil || (excludeUnpaid != nil && !*excludeUnpaid) || (excludeUnpaid != nil && *excludeUnpaid && invoice.IsPaid)) && - (excludeKeysend == nil || (excludeKeysend != nil && !*excludeKeysend) || (excludeKeysend != nil && *excludeKeysend && invoice.Keysend)) && - (excludeExpired == nil || (excludeExpired != nil && !*excludeExpired) || incInvoice) { - validRxInvoices[i] = invoice // otherwise the address is always the same - ret.Received = append(ret.Received, &generated.Invoice{ - PaymentHash: &validRxInvoices[i].PaymentHash, - PaymentRequest: &validRxInvoices[i].PaymentRequest, - Description: &validRxInvoices[i].Description, - DescriptionHash: &validRxInvoices[i].Description, - PaymentPreimage: &validRxInvoices[i].PaymentHash, - Destination: &validRxInvoices[i].Destination, - Amount: model.Satoshis(validRxInvoices[i].Amount), - Fee: (*model.Satoshis)(&validRxInvoices[i].Fee), - Status: &validRxInvoices[i].Status, - Type: &validRxInvoices[i].Type, - ErrorMessage: &validRxInvoices[i].ErrorMessage, - SettledAt: &validRxInvoices[i].SettledAt, - ExpiresAt: &validRxInvoices[i].ExpiresAt, - IsPaid: &validRxInvoices[i].IsPaid, - Keysend: &validRxInvoices[i].Keysend, - }) - } - } - validTxInvoices := make([]lndhub.Invoice, len(sent)) - for i, invoice := range sent { - incInvoice := false - if excludeExpired != nil && *excludeExpired { - expiresAt, err := time.Parse(time.RFC3339, invoice.ExpiresAt) - if err != nil { - return &ret, fmt.Errorf("can't parse expiration date: %w", err) - } - incInvoice = time.Until(expiresAt) > 0 - } - if (excludeUnpaid == nil || (excludeUnpaid != nil && !*excludeUnpaid) || (excludeUnpaid != nil && *excludeUnpaid && invoice.IsPaid)) && - (excludeKeysend == nil || (excludeKeysend != nil && !*excludeKeysend) || (excludeKeysend != nil && *excludeKeysend && invoice.Keysend)) && - (excludeExpired == nil || (excludeExpired != nil && !*excludeExpired) || incInvoice) { - validTxInvoices[i] = invoice // otherwise the address is always the same - ret.Sent = append(ret.Sent, &generated.Invoice{ - PaymentHash: &validTxInvoices[i].PaymentHash, - PaymentRequest: &validTxInvoices[i].PaymentRequest, - Description: &validTxInvoices[i].Description, - DescriptionHash: &validTxInvoices[i].Description, - PaymentPreimage: &validTxInvoices[i].PaymentHash, - Destination: &validTxInvoices[i].Destination, - Amount: model.Satoshis(validTxInvoices[i].Amount), - Fee: (*model.Satoshis)(&validTxInvoices[i].Fee), - Status: &validTxInvoices[i].Status, - Type: &validTxInvoices[i].Type, - ErrorMessage: &validTxInvoices[i].ErrorMessage, - SettledAt: &validTxInvoices[i].SettledAt, - ExpiresAt: &validTxInvoices[i].ExpiresAt, - IsPaid: &validTxInvoices[i].IsPaid, - Keysend: &validTxInvoices[i].Keysend, - }) - } - } - return &ret, nil -} - -// Me returns generated.MeResolver implementation. -func (r *Resolver) Me() generated.MeResolver { return &meResolver{r} } - -// Mutation returns generated.MutationResolver implementation. -func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } - -// Query returns generated.QueryResolver implementation. -func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } - -type meResolver struct{ *Resolver } -type mutationResolver struct{ *Resolver } -type queryResolver struct{ *Resolver } diff --git a/backend/lndhub/lndhub.go b/backend/lndhub/lndhub.go index ae09db33..6ae2b63b 100644 --- a/backend/lndhub/lndhub.go +++ b/backend/lndhub/lndhub.go @@ -12,6 +12,7 @@ import ( "net/http" "seed/backend/core" lndhub "seed/backend/lndhub/lndhubsql" + "seed/backend/wallet/walletsql" "strconv" "strings" "time" @@ -37,7 +38,7 @@ const ( getReceivedInvoicesRoute = "/v2/invoices/incoming" // SigningMessage is the fixed message to sign. The server must have the same message. - SigningMessage = "sign in into mintter lndhub" + SigningMessage = "sign in into seed lndhub" ) type httpRequest struct { @@ -54,11 +55,9 @@ type lndhubErrorTemplate struct { // Client stores all the necessary structs to perform wallet operations. type Client struct { - http *http.Client - db *sqlitex.Pool - WalletID string - keyStorage core.KeyStore - keyName string + http *http.Client + db *sqlitex.Pool + //WalletID string lndhubDomain string lnaddressDomain string } @@ -68,7 +67,9 @@ type createRequest struct { Password string `json:"password"` Nickname string `json:"nickname"` } -type createResponse struct { + +// CreateResponse is a short wallet description used as a return value. +type CreateResponse struct { Login string `mapstructure:"login"` Password string `mapstructure:"password"` Nickname string `mapstructure:"nickname"` @@ -104,12 +105,10 @@ type Invoice struct { // NewClient returns an instance of an lndhub client. The id is the credentials URI // hash that acts as an index in the wallet table. -func NewClient(ctx context.Context, h *http.Client, db *sqlitex.Pool, keyStorage core.KeyStore, keyName, lndhubDomain, lnaddressDomain string) *Client { +func NewClient(h *http.Client, db *sqlitex.Pool, lndhubDomain, lnaddressDomain string) *Client { return &Client{ http: h, db: db, - keyStorage: keyStorage, - keyName: keyName, lndhubDomain: lndhubDomain, lnaddressDomain: lnaddressDomain, } @@ -126,31 +125,20 @@ func (c *Client) GetLndaddressDomain() string { } // Create creates an account or changes the nickname on already created one. If the login is a CID, then the password must -// be the signature of the message 'sign in into mintter lndhub' and the token the pubkey whose private counterpart +// be the signature of the message 'sign in into seed lndhub' and the token the pubkey whose private counterpart // was used to sign the password. If login is not a CID, then there is no need for the token and password can be // anything. Nickname can be anything in both cases as long as it's unique across all seed lndhub users (it will // fail otherwise). -func (c *Client) Create(ctx context.Context, connectionURL, login, pass, nickname string) (createResponse, error) { - var resp createResponse - kp, err := c.keyStorage.GetKey(ctx, c.keyName) - if err != nil { - return resp, fmt.Errorf("could not get signing key, is account initialized?: %w", err) - } - pubKey, err := kp.ID().ExtractPublicKey() - if err != nil { - return resp, fmt.Errorf("Invalid pubkey: %w", err) - } - pubKeyBytes, err := pubKey.Raw() - if err != nil { - return resp, fmt.Errorf("Invalid pubkey: %w", err) - } +func (c *Client) Create(ctx context.Context, connectionURL, walletID, login, pass, nickname string, token []byte) (CreateResponse, error) { + var resp CreateResponse conn, release, err := c.db.Conn(ctx) if err != nil { return resp, err } defer release() - err = c.do(ctx, conn, httpRequest{ + + err = c.do(ctx, conn, walletID, httpRequest{ URL: connectionURL + createRoute, Method: http.MethodPost, Payload: createRequest{ @@ -158,7 +146,7 @@ func (c *Client) Create(ctx context.Context, connectionURL, login, pass, nicknam Password: pass, // signed message Nickname: strings.ToLower(nickname), }, - Token: hex.EncodeToString(pubKeyBytes), + Token: hex.EncodeToString(token), }, 2, &resp) if err != nil { return resp, err @@ -171,17 +159,13 @@ func (c *Client) Create(ctx context.Context, connectionURL, login, pass, nicknam // The update can fail if the nickname contain special characters or is already taken by another user. // Since it is a user operation, if the login is a CID, then user must provide a token representing // the pubkey whose private counterpart created the signature provided in password (like in create). -func (c *Client) UpdateNickname(ctx context.Context, nickname string) error { +func (c *Client) UpdateNickname(ctx context.Context, walletID, nickname string, token []byte) error { for _, c := range nickname { if unicode.IsUpper(c) && unicode.IsLetter(c) { return fmt.Errorf("Nickname cannot contain uppercase letters %s", nickname) } } - kp, err := c.keyStorage.GetKey(ctx, c.keyName) - if err != nil { - return fmt.Errorf("could not get signing key, is account initialized?: %w", err) - } - var resp createResponse + var resp CreateResponse conn, release, err := c.db.Conn(ctx) if err != nil { @@ -189,28 +173,20 @@ func (c *Client) UpdateNickname(ctx context.Context, nickname string) error { } defer release() - login, err := lndhub.GetLogin(conn, c.WalletID) + login, err := lndhub.GetLogin(conn, walletID) if err != nil { return err } - pass, err := lndhub.GetPassword(conn, c.WalletID) + pass, err := lndhub.GetPassword(conn, walletID) if err != nil { return err } - connectionURL, err := lndhub.GetAPIURL(conn, c.WalletID) + connectionURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return err } - pubKey, err := kp.ID().ExtractPublicKey() - if err != nil { - return fmt.Errorf("Invalid pubkey: %w", err) - } - pubKeyBytes, err := pubKey.Raw() - if err != nil { - return fmt.Errorf("Invalid pubkey: %w", err) - } - err = c.do(ctx, conn, httpRequest{ + err = c.do(ctx, conn, walletID, httpRequest{ URL: connectionURL + createRoute, Method: http.MethodPost, Payload: createRequest{ @@ -218,7 +194,7 @@ func (c *Client) UpdateNickname(ctx context.Context, nickname string) error { Password: pass, // signed message Nickname: nickname, }, - Token: hex.EncodeToString(pubKeyBytes), // this token is the pubkey bytes whose private counterpart was used to sign the password + Token: hex.EncodeToString(token), // this token is the pubkey bytes whose private counterpart was used to sign the password }, 2, &resp) if err != nil { return err @@ -233,27 +209,37 @@ func (c *Client) UpdateNickname(ctx context.Context, nickname string) error { // GetLnAddress gets the account-wide ln address in the form of @ . // Since it is a user operation, if the login is a CID, then user must provide a token representing // the pubkey whose private counterpart created the signature provided in password (like in create). -func (c *Client) GetLnAddress(ctx context.Context) (string, error) { +func (c *Client) GetLnAddress(ctx context.Context, walletID string) (string, error) { conn, release, err := c.db.Conn(ctx) if err != nil { return "", err } defer release() - login, err := lndhub.GetLogin(conn, c.WalletID) + login, err := lndhub.GetLogin(conn, walletID) if err != nil { return "", err } - pass, err := lndhub.GetPassword(conn, c.WalletID) + pass, err := lndhub.GetPassword(conn, walletID) if err != nil { return "", err } - connectionURL, err := lndhub.GetAPIURL(conn, c.WalletID) + connectionURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return "", err } + w, err := walletsql.GetWallet(conn, walletID) + if err != nil { + return "", fmt.Errorf("wallet [%s] not found: %w", walletID, err) + } + principal, err := core.DecodePrincipal(w.Account) + if err != nil { + return "", fmt.Errorf("Wrong account %s: %w", w.Account, err) + } + _, token := principal.Explode() + + user, err := c.Create(ctx, connectionURL, walletID, login, pass, "", token) // create with valid credentials and blank nickname fills the nickname - user, err := c.Create(ctx, connectionURL, login, pass, "") // create with valid credentials and blank nickname fills the nickname if err != nil { return "", err } @@ -262,7 +248,7 @@ func (c *Client) GetLnAddress(ctx context.Context) (string, error) { // Auth tries to get authorized on the lndhub service pointed by apiBaseURL. // There must be a credentials stored in the database. -func (c *Client) Auth(ctx context.Context) (string, error) { +func (c *Client) Auth(ctx context.Context, walletID string) (string, error) { var resp authResponse conn, release, err := c.db.Conn(ctx) @@ -271,19 +257,19 @@ func (c *Client) Auth(ctx context.Context) (string, error) { } defer release() - login, err := lndhub.GetLogin(conn, c.WalletID) + login, err := lndhub.GetLogin(conn, walletID) if err != nil { return resp.AccessToken, err } - pass, err := lndhub.GetPassword(conn, c.WalletID) + pass, err := lndhub.GetPassword(conn, walletID) if err != nil { return resp.AccessToken, err } - apiBaseURL, err := lndhub.GetAPIURL(conn, c.WalletID) + apiBaseURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return "", err } - err = c.do(ctx, conn, httpRequest{ + err = c.do(ctx, conn, walletID, httpRequest{ URL: apiBaseURL + authRoute, Method: http.MethodPost, Payload: authRequest{ @@ -294,11 +280,11 @@ func (c *Client) Auth(ctx context.Context) (string, error) { if err != nil { return resp.AccessToken, err } - return resp.AccessToken, lndhub.SetToken(conn, c.WalletID, resp.AccessToken) + return resp.AccessToken, lndhub.SetToken(conn, walletID, resp.AccessToken) } // GetBalance gets the confirmed balance in satoshis of the account. -func (c *Client) GetBalance(ctx context.Context) (uint64, error) { +func (c *Client) GetBalance(ctx context.Context, walletID string) (uint64, error) { type btcBalance struct { Sats uint64 `mapstructure:"AvailableBalance"` } @@ -313,16 +299,16 @@ func (c *Client) GetBalance(ctx context.Context) (uint64, error) { defer release() var resp balanceResponse - token, err := lndhub.GetToken(conn, c.WalletID) + token, err := lndhub.GetToken(conn, walletID) if err != nil { return resp.Btc.Sats, err } - apiBaseURL, err := lndhub.GetAPIURL(conn, c.WalletID) + apiBaseURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return resp.Btc.Sats, err } - err = c.do(ctx, conn, httpRequest{ + err = c.do(ctx, conn, walletID, httpRequest{ URL: apiBaseURL + balanceRoute, Method: http.MethodGet, Token: token, @@ -331,7 +317,7 @@ func (c *Client) GetBalance(ctx context.Context) (uint64, error) { } // ListPaidInvoices returns a list of outgoing invoices. -func (c *Client) ListPaidInvoices(ctx context.Context) ([]Invoice, error) { +func (c *Client) ListPaidInvoices(ctx context.Context, walletID string) ([]Invoice, error) { conn, release, err := c.db.Conn(ctx) if err != nil { return nil, err @@ -343,16 +329,16 @@ func (c *Client) ListPaidInvoices(ctx context.Context) ([]Invoice, error) { } var resp ListInvoicesResponse - token, err := lndhub.GetToken(conn, c.WalletID) + token, err := lndhub.GetToken(conn, walletID) if err != nil { return resp.Invoices, err } - apiBaseURL, err := lndhub.GetAPIURL(conn, c.WalletID) + apiBaseURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return resp.Invoices, err } - err = c.do(ctx, conn, httpRequest{ + err = c.do(ctx, conn, walletID, httpRequest{ URL: apiBaseURL + getPaidInvoicesRoute, Method: http.MethodGet, Token: token, @@ -361,7 +347,7 @@ func (c *Client) ListPaidInvoices(ctx context.Context) ([]Invoice, error) { } // ListReceivedInvoices returns a list of incoming invoices. -func (c *Client) ListReceivedInvoices(ctx context.Context) ([]Invoice, error) { +func (c *Client) ListReceivedInvoices(ctx context.Context, walletID string) ([]Invoice, error) { conn, release, err := c.db.Conn(ctx) if err != nil { return nil, err @@ -373,16 +359,16 @@ func (c *Client) ListReceivedInvoices(ctx context.Context) ([]Invoice, error) { } var resp ListInvoicesResponse - token, err := lndhub.GetToken(conn, c.WalletID) + token, err := lndhub.GetToken(conn, walletID) if err != nil { return resp.Invoices, err } - apiBaseURL, err := lndhub.GetAPIURL(conn, c.WalletID) + apiBaseURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return resp.Invoices, err } - err = c.do(ctx, conn, httpRequest{ + err = c.do(ctx, conn, walletID, httpRequest{ URL: apiBaseURL + getReceivedInvoicesRoute, Method: http.MethodGet, Token: token, @@ -394,7 +380,7 @@ func (c *Client) ListReceivedInvoices(ctx context.Context) ([]Invoice, error) { // for the internal node . We accept a short memo or description of purpose // of payment, to attach along with the invoice. The generated invoice will // have an expiration time of 24 hours and a random preimage. -func (c *Client) CreateLocalInvoice(ctx context.Context, sats int64, memo string) (string, error) { +func (c *Client) CreateLocalInvoice(ctx context.Context, walletID string, sats int64, memo string) (string, error) { type createLocalInvoiceRequest struct { Amt int64 `json:"amt"` Memo string `json:"memo"` @@ -413,16 +399,16 @@ func (c *Client) CreateLocalInvoice(ctx context.Context, sats int64, memo string } defer release() - token, err := lndhub.GetToken(conn, c.WalletID) + token, err := lndhub.GetToken(conn, walletID) if err != nil { return resp.PayReq, err } - apiBaseURL, err := lndhub.GetAPIURL(conn, c.WalletID) + apiBaseURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return resp.PayReq, err } - err = c.do(ctx, conn, httpRequest{ + err = c.do(ctx, conn, walletID, httpRequest{ URL: apiBaseURL + createInvoiceRoute, Method: http.MethodPost, Token: token, @@ -435,12 +421,12 @@ func (c *Client) CreateLocalInvoice(ctx context.Context, sats int64, memo string return resp.PayReq, err } -// RequestRemoteInvoice request a remote peer via lndhub an invoice of amount +// RequestLud6Invoice request a remote peer via lndhub an invoice of amount // sats (in satoshis). The remote user can be either a lnaddres user or a // seed account ID. We accept a short memo or description of purpose of // payment, to attach along with the invoice. The generated invoice will have // an expirationtime of 24 hours and a random preimage. -func (c *Client) RequestRemoteInvoice(ctx context.Context, remoteUser string, amountSats int64, memo string) (string, error) { +func (c *Client) RequestLud6Invoice(ctx context.Context, baseURL, remoteUser string, amountSats int64, memo string) (string, error) { type requestRemoteInvoiceResponse struct { PayReq string `mapstructure:"pr"` } @@ -453,13 +439,8 @@ func (c *Client) RequestRemoteInvoice(ctx context.Context, remoteUser string, am } defer release() - apiBaseURL, err := lndhub.GetAPIURL(conn, c.WalletID) - if err != nil { - return resp.PayReq, err - } - - err = c.do(ctx, conn, httpRequest{ - URL: apiBaseURL + requestInvoiceRoute + "?user=" + remoteUser + "&amount=" + strconv.FormatInt(amountSats*1000, 10) + "&memo=" + strings.ReplaceAll(memo, " ", "+"), + err = c.do(ctx, conn, "", httpRequest{ + URL: baseURL + requestInvoiceRoute + "?user=" + remoteUser + "&amount=" + strconv.FormatInt(amountSats*1000, 10) + "&memo=" + strings.ReplaceAll(memo, " ", "+"), Method: http.MethodGet, }, 2, &resp) @@ -479,18 +460,18 @@ func DecodeInvoice(payReq string) (*zpay32.Invoice, error) { } // PayInvoice tries to pay the invoice provided. With the amount provided in satoshis. The -// enconded amount in the invoice should match the provided amount as a double check in case +// encoded amount in the invoice should match the provided amount as a double check in case // the amount on the invoice is different than 0. -func (c *Client) PayInvoice(ctx context.Context, payReq string, sats uint64) error { +func (c *Client) PayInvoice(ctx context.Context, walletID, payReq string, sats int64) error { if invoice, err := DecodeInvoice(payReq); err != nil { return nil - } else if uint64(invoice.MilliSat.ToSatoshis()) != 0 && uint64(invoice.MilliSat.ToSatoshis()) != sats { - return fmt.Errorf("Invoice amt is %s sats and provided amount is %d sats: %w", invoice.MilliSat.ToSatoshis().String(), int64(sats), lndhub.ErrQtyMissmatch) + } else if invoice.MilliSat.ToSatoshis() != 0 && int64(invoice.MilliSat.ToSatoshis()) != sats { + return fmt.Errorf("Invoice amt is %s sats and provided amount is %d sats: %w", invoice.MilliSat.ToSatoshis().String(), sats, lndhub.ErrQtyMissmatch) } type payInvoiceRequest struct { Invoice string `json:"invoice"` - Amount uint64 `json:"amount"` + Amount int64 `json:"amount"` } conn, release, err := c.db.Conn(ctx) @@ -499,16 +480,16 @@ func (c *Client) PayInvoice(ctx context.Context, payReq string, sats uint64) err } defer release() - token, err := lndhub.GetToken(conn, c.WalletID) + token, err := lndhub.GetToken(conn, walletID) if err != nil { return err } - apiBaseURL, err := lndhub.GetAPIURL(conn, c.WalletID) + apiBaseURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return err } - err = c.do(ctx, conn, httpRequest{ + err = c.do(ctx, conn, walletID, httpRequest{ URL: apiBaseURL + payInvoiceRoute, Method: http.MethodPost, Token: token, @@ -520,7 +501,7 @@ func (c *Client) PayInvoice(ctx context.Context, payReq string, sats uint64) err return err } -func (c *Client) do(ctx context.Context, conn *sqlite.Conn, request httpRequest, maxAttempts uint, respValue interface{}) error { +func (c *Client) do(ctx context.Context, conn *sqlite.Conn, walletID string, request httpRequest, maxAttempts uint, respValue interface{}) error { var bodyRaw io.Reader var genericResponse map[string]interface{} var errorRes lndhubErrorTemplate @@ -572,20 +553,20 @@ func (c *Client) do(ctx context.Context, conn *sqlite.Conn, request httpRequest, var authResp authResponse // Check if token expired and we need to issue one if ok && strings.Contains(errMsg.(string), "bad auth") { - login, err := lndhub.GetLogin(conn, c.WalletID) + login, err := lndhub.GetLogin(conn, walletID) if err != nil { return err } - pass, err := lndhub.GetPassword(conn, c.WalletID) + pass, err := lndhub.GetPassword(conn, walletID) if err != nil { return err } - apiBaseURL, err := lndhub.GetAPIURL(conn, c.WalletID) + apiBaseURL, err := lndhub.GetAPIURL(conn, walletID) if err != nil { return err } - err = c.do(ctx, conn, httpRequest{ + err = c.do(ctx, conn, walletID, httpRequest{ URL: apiBaseURL + authRoute, Method: http.MethodPost, Payload: authRequest{ @@ -596,7 +577,7 @@ func (c *Client) do(ctx context.Context, conn *sqlite.Conn, request httpRequest, if err != nil { return err } - if err = lndhub.SetToken(conn, c.WalletID, authResp.AccessToken); err != nil { + if err = lndhub.SetToken(conn, walletID, authResp.AccessToken); err != nil { return err } } diff --git a/backend/lndhub/lndhub_test.go b/backend/lndhub/lndhub_test.go index 9bb63e17..5c75dfd5 100644 --- a/backend/lndhub/lndhub_test.go +++ b/backend/lndhub/lndhub_test.go @@ -14,15 +14,16 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/stretchr/testify/require" "seed/backend/util/sqlite" "seed/backend/util/sqlite/sqlitex" + + "github.com/btcsuite/btcd/btcutil" + "github.com/stretchr/testify/require" ) const ( - lndhubDomain = "ln.testnet.mintter.com" - lnaddressDomain = "ln.testnet.mintter.com" + lndhubDomain = "ln.testnet.seed.hyper.media" + lnaddressDomain = "ln.testnet.seed.hyper.media" connectionURL = "https://" + lndhubDomain ) @@ -44,49 +45,44 @@ func TestCreate(t *testing.T) { defer cancel() keypair, err := core.NewKeyPairRandom() require.NoError(t, err) - pubKeyBytes, err := keypair.PublicKey.MarshalBinary() + token, err := keypair.PublicKey.Wrapped().Raw() require.NoError(t, err) - ks := core.NewMemoryKeyStore() login := keypair.String() passwordBytes, err := keypair.Sign([]byte(SigningMessage)) password := hex.EncodeToString(passwordBytes) require.NoError(t, err) - lndHubClient := NewClient(context.Background(), &http.Client{}, pool, ks, "main", lndhubDomain, lnaddressDomain) - lndHubClient.WalletID = credentials2Id("lndhub.go", login, password, lndhubDomain) + lndHubClient := NewClient(&http.Client{}, pool, lndhubDomain, lnaddressDomain) + walletID := credentials2Id("lndhub.go", login, password, lndhubDomain, token) makeTestWallet(t, conn, walletsql.Wallet{ - ID: lndHubClient.WalletID, + ID: walletID, Address: connectionURL, Name: nickname, Type: "lndhub.go", - Balance: 0, - }, login, password, hex.EncodeToString(pubKeyBytes)) + Account: keypair.Principal().String(), + }, login, password, hex.EncodeToString(token)) - user, err := lndHubClient.Create(ctx, connectionURL, login, password, nickname) - require.Error(t, err) - require.NoError(t, ks.StoreKey(ctx, "main", keypair)) - user, err = lndHubClient.Create(ctx, connectionURL, login, password, nickname) + user, err := lndHubClient.Create(ctx, connectionURL, walletID, login, password, nickname, token) require.NoError(t, err) require.EqualValues(t, login, user.Login) require.EqualValues(t, password, user.Password) require.EqualValues(t, strings.ToLower(nickname), user.Nickname) - require.NoError(t, err) - _, err = lndHubClient.Auth(ctx) + _, err = lndHubClient.Auth(ctx, walletID) require.NoError(t, err) var newNickname = randStringRunes(8) - err = lndHubClient.UpdateNickname(ctx, strings.ToUpper(newNickname)) + err = lndHubClient.UpdateNickname(ctx, walletID, strings.ToUpper(newNickname), token) require.Error(t, err) newNickname = strings.ToLower(newNickname) - err = lndHubClient.UpdateNickname(ctx, newNickname) + err = lndHubClient.UpdateNickname(ctx, walletID, newNickname, token) require.NoError(t, err) - lnaddress, err := lndHubClient.GetLnAddress(ctx) + lnaddress, err := lndHubClient.GetLnAddress(ctx, walletID) require.NoError(t, err) require.EqualValues(t, newNickname+"@"+lnaddressDomain, lnaddress) - balance, err := lndHubClient.GetBalance(ctx) + balance, err := lndHubClient.GetBalance(ctx, walletID) require.NoError(t, err) require.EqualValues(t, 0, balance) - payreq, err := lndHubClient.CreateLocalInvoice(ctx, invoiceAmt, invoiceMemo) + payreq, err := lndHubClient.CreateLocalInvoice(ctx, walletID, invoiceAmt, invoiceMemo) require.NoError(t, err) decodedInvoice, err := DecodeInvoice(payreq) require.NoError(t, err) @@ -94,17 +90,17 @@ func TestCreate(t *testing.T) { require.EqualValues(t, invoiceAmt, uint64(decodedInvoice.MilliSat.ToSatoshis())) const invoiceMemo2 = "zero invoice test amount" - _, err = lndHubClient.RequestRemoteInvoice(ctx, newNickname, 0, invoiceMemo2) + _, err = lndHubClient.RequestLud6Invoice(ctx, "https://ln.testnet.seed.hyper.media", newNickname, 0, invoiceMemo2) require.Error(t, err) const invoiceMemo3 = "non-zero invoice test amount" const amt = 233 - payreq, err = lndHubClient.RequestRemoteInvoice(ctx, newNickname, amt, invoiceMemo3) + payreq, err = lndHubClient.RequestLud6Invoice(ctx, "https://ln.testnet.seed.hyper.media", newNickname, amt, invoiceMemo3) require.NoError(t, err) decodedInvoice, err = DecodeInvoice(payreq) require.NoError(t, err) require.EqualValues(t, invoiceMemo3, *decodedInvoice.Description) require.EqualValues(t, amt, decodedInvoice.MilliSat.ToSatoshis().ToUnit(btcutil.AmountSatoshi)) // when amt is zero, the result is nil - invoices, err := lndHubClient.ListReceivedInvoices(ctx) + invoices, err := lndHubClient.ListReceivedInvoices(ctx, walletID) require.NoError(t, err) require.GreaterOrEqual(t, len(invoices), 1) //TODO: test for invoice metadata @@ -132,8 +128,8 @@ func makeConn(t *testing.T) (*sqlitex.Pool, error) { return storage.MakeTestDB(t), nil } -func credentials2Id(wType, login, password, domain string) string { +func credentials2Id(wType, login, password, domain string, account []byte) string { url := wType + "://" + login + ":" + password + "@https://" + domain - h := sha256.Sum256([]byte(url)) + h := sha256.Sum256(append([]byte(url), account...)) return hex.EncodeToString(h[:]) } diff --git a/backend/lndhub/lndhubsql/lndhub.go b/backend/lndhub/lndhubsql/lndhub.go index 3955b9f6..a06b0bb4 100644 --- a/backend/lndhub/lndhubsql/lndhub.go +++ b/backend/lndhub/lndhubsql/lndhub.go @@ -70,19 +70,3 @@ func SetToken(conn *sqlite.Conn, id, token string) error { return setToken(conn, []byte(token), id) // TODO: decrypt token before returning } - -// SetLoginSignature stores the sigature (hex representation) of the -// signed login message to access to account settings in lndhub.go. -func SetLoginSignature(conn *sqlite.Conn, signature string) error { - return setLoginSignature(conn, LoginSignatureKey, signature) -} - -// GetLoginSignature returns the sigature (hex representation) of the -// signed login message to access to account settings in lndhub.go. -func GetLoginSignature(conn *sqlite.Conn) (string, error) { - res, err := getLoginSignature(conn, LoginSignatureKey) - if err == nil && res.KVValue == "" { - return "", fmt.Errorf("Could not find any signature associated with self node: %w", ErrEmptyResult) - } - return res.KVValue, err -} diff --git a/backend/mttnet/mttnet.go b/backend/mttnet/mttnet.go index 46e939ab..d7b23cab 100644 --- a/backend/mttnet/mttnet.go +++ b/backend/mttnet/mttnet.go @@ -275,49 +275,59 @@ func (n *Node) ArePrivateIPsAllowed() bool { return !n.cfg.NoPrivateIps } -// AccountForDevice returns the linked AccountID of a given device. -func (n *Node) AccountForDevice(ctx context.Context, pid peer.ID) (core.Principal, error) { - // TODO(hm24): How to know the public key of other peers? - if n.p2p.Network().LocalPeer() == pid { - pk, err := n.keys.GetKey(ctx, "main") - if err != nil { - return nil, fmt.Errorf("Can't get account for this device. Has the user registered any key?") - } - return pk.PublicKey.Principal(), nil +// GetAccountByKeyName returns the account attached to the given named key. +func (n *Node) GetAccountByKeyName(ctx context.Context, keyName string) (core.Principal, error) { + pk, err := n.keys.GetKey(ctx, keyName) + if err != nil { + return nil, fmt.Errorf("Can't get account for this device: %w", err) } - return nil, fmt.Errorf("Can't know the account of a peer different than myself.") + return pk.PublicKey.Principal(), nil +} + +// AccountForDevice returns the linked AccountID of a given device. +func (n *Node) AccountForDevice(_ context.Context, _ peer.ID) (core.Principal, error) { + // TODO(hm24): When we have contacts we can do it. + return nil, fmt.Errorf("Not ready until we have contacts. Use GetAccountByKeyName instead") /* - var out core.Principal - if err := n.blobs.Query(ctx, func(conn *sqlite.Conn) error { - pk, err := pid.ExtractPublicKey() + if n.p2p.Network().LocalPeer() == pid { + pk, err := n.keys.GetKey(ctx, "main") if err != nil { - return err + return nil, fmt.Errorf("Can't get account for this device. Has the user registered any key?") } + return pk.PublicKey.Principal(), nil + } - delegate := core.PrincipalFromPubKey(pk) + var out core.Principal + if err := n.blobs.Query(ctx, func(conn *sqlite.Conn) error { + pk, err := pid.ExtractPublicKey() + if err != nil { + return err + } - list, err := hypersql.KeyDelegationsListByDelegate(conn, delegate) - if err != nil { - return err - } - if len(list) == 0 { - return fmt.Errorf("not found key delegation for peer: %s", pid) - } + delegate := core.PrincipalFromPubKey(pk) - if len(list) > 1 { - n.log.Warn("MoreThanOneKeyDelegation", zap.String("peer", pid.String())) - } + list, err := hypersql.KeyDelegationsListByDelegate(conn, delegate) + if err != nil { + return err + } + if len(list) == 0 { + return fmt.Errorf("not found key delegation for peer: %s", pid) + } - del := list[0] + if len(list) > 1 { + n.log.Warn("MoreThanOneKeyDelegation", zap.String("peer", pid.String())) + } - out = core.Principal(del.KeyDelegationsViewIssuer) + del := list[0] - return nil - }); err != nil { - return nil, err - } + out = core.Principal(del.KeyDelegationsViewIssuer) + + return nil + }); err != nil { + return nil, err + } - return out, nil + return out, nil */ } diff --git a/backend/mttnet/payments.go b/backend/mttnet/payments.go index f37d669f..f38c22d0 100644 --- a/backend/mttnet/payments.go +++ b/backend/mttnet/payments.go @@ -3,6 +3,7 @@ package mttnet import ( "context" p2p "seed/backend/genproto/p2p/v1alpha" + invoices "seed/backend/genproto/payments/v1alpha" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -11,7 +12,7 @@ import ( // Invoicer is a subset of a Lightning node that allows to issue invoices. // It is used when a remote peer wants to pay our node. type Invoicer interface { - CreateLocalInvoice(ctx context.Context, amountSats int64, memo *string) (string, error) + CreateInvoice(ctx context.Context, in *invoices.CreateInvoiceRequest) (*invoices.Payreq, error) } // RequestInvoice creates a local invoice. @@ -20,13 +21,17 @@ func (srv *rpcMux) RequestInvoice(ctx context.Context, in *p2p.RequestInvoiceReq if n.invoicer == nil { return nil, status.Errorf(codes.Unimplemented, "method RequestInvoice not ready yet") } - - invoice, err := n.invoicer.CreateLocalInvoice(ctx, in.AmountSats, &in.Memo) + req := invoices.CreateInvoiceRequest{ + Account: in.Account, + Amount: in.AmountSats, + Memo: in.Memo, + } + invoice, err := n.invoicer.CreateInvoice(ctx, &req) if err != nil { return nil, err } return &p2p.RequestInvoiceResponse{ - PayReq: invoice, + PayReq: invoice.Payreq, }, nil } diff --git a/backend/storage/schema.gen.go b/backend/storage/schema.gen.go index 49687cb7..ced1ad5c 100644 --- a/backend/storage/schema.gen.go +++ b/backend/storage/schema.gen.go @@ -229,8 +229,8 @@ const ( // Table wallets. const ( Wallets sqlitegen.Table = "wallets" + WalletsAccount sqlitegen.Column = "wallets.account" WalletsAddress sqlitegen.Column = "wallets.address" - WalletsBalance sqlitegen.Column = "wallets.balance" WalletsID sqlitegen.Column = "wallets.id" WalletsLogin sqlitegen.Column = "wallets.login" WalletsName sqlitegen.Column = "wallets.name" @@ -242,8 +242,8 @@ const ( // Table wallets. Plain strings. const ( T_Wallets = "wallets" + C_WalletsAccount = "wallets.account" C_WalletsAddress = "wallets.address" - C_WalletsBalance = "wallets.balance" C_WalletsID = "wallets.id" C_WalletsLogin = "wallets.login" C_WalletsName = "wallets.name" @@ -305,8 +305,8 @@ var Schema = sqlitegen.Schema{ SubscriptionsInsertTime: {Table: Subscriptions, SQLType: "INTEGER"}, SubscriptionsIRI: {Table: Subscriptions, SQLType: "TEXT"}, SubscriptionsIsRecursive: {Table: Subscriptions, SQLType: "BOOLEAN"}, + WalletsAccount: {Table: Wallets, SQLType: "INTEGER"}, WalletsAddress: {Table: Wallets, SQLType: "TEXT"}, - WalletsBalance: {Table: Wallets, SQLType: "INTEGER"}, WalletsID: {Table: Wallets, SQLType: "TEXT"}, WalletsLogin: {Table: Wallets, SQLType: "BLOB"}, WalletsName: {Table: Wallets, SQLType: "TEXT"}, diff --git a/backend/storage/schema.gensum b/backend/storage/schema.gensum index 25e16874..93b4dccc 100644 --- a/backend/storage/schema.gensum +++ b/backend/storage/schema.gensum @@ -1,2 +1,2 @@ -srcs: 8dcde9e3e65941bdf5379bb99f0e3a1c -outs: 162107c46bd6d17ddacb73d9cfeafa6d +srcs: 9e756dce477991aa8a605c8092d03eec +outs: 5ee2eb1c256cb6e82b196c1be69e883d diff --git a/backend/storage/schema.sql b/backend/storage/schema.sql index 60e8c74f..fd0dd8b0 100644 --- a/backend/storage/schema.sql +++ b/backend/storage/schema.sql @@ -200,8 +200,10 @@ CREATE TABLE peers ( -- Stores Lightning wallets both externals (imported wallets like bluewallet -- based on lndhub) and internals (based on the LND embedded node). CREATE TABLE wallets ( - -- Wallet unique ID. Is the connection uri hash. + -- Wallet unique ID. Is the connection uri hashed with the account. id TEXT PRIMARY KEY, + -- Account + account INTEGER REFERENCES public_keys (id) ON DELETE CASCADE NOT NULL, -- The type of the wallet. type TEXT CHECK( type IN ('lnd','lndhub.go','lndhub') ) NOT NULL DEFAULT 'lndhub.go', -- Address of the LND node backing up this wallet. In case lndhub, this will be the @@ -216,7 +218,7 @@ CREATE TABLE wallets ( -- The Authentication token of the wallet. api token in case of lndhub token BLOB, -- Human readable name to help the user identify each wallet - name TEXT NOT NULL, - -- The balance in satoshis - balance INTEGER DEFAULT 0 + name TEXT NOT NULL ); +CREATE INDEX wallets_by_account ON wallets (account); + diff --git a/backend/storage/storage_migrations.go b/backend/storage/storage_migrations.go index f07ec73d..f4729b31 100644 --- a/backend/storage/storage_migrations.go +++ b/backend/storage/storage_migrations.go @@ -54,6 +54,24 @@ var migrations = []migration{ {Version: "2024-10-19.01", Run: func(_ *Store, _ *sqlite.Conn) error { return nil }}, + {Version: "2024-11-01.01", Run: func(_ *Store, conn *sqlite.Conn) error { + return sqlitex.ExecScript(conn, sqlfmt(` + DROP TABLE IF EXISTS wallets; + CREATE TABLE wallets ( + id TEXT PRIMARY KEY, + account INTEGER REFERENCES public_keys (id) ON DELETE CASCADE NOT NULL, + type TEXT CHECK( type IN ('lnd','lndhub.go','lndhub') ) NOT NULL DEFAULT 'lndhub.go', + address TEXT NOT NULL, + login BLOB NOT NULL, + password BLOB NOT NULL, + token BLOB, + name TEXT NOT NULL + ); + CREATE INDEX wallets_by_account ON wallets (account); + DELETE FROM kv WHERE key = 'default_wallet'; + DELETE FROM kv WHERE key = 'lndhub_login_signature'; + `)) + }}, } func desiredVersion() string { diff --git a/backend/wallet/wallet.go b/backend/wallet/wallet.go deleted file mode 100644 index 42de9667..00000000 --- a/backend/wallet/wallet.go +++ /dev/null @@ -1,702 +0,0 @@ -package wallet - -import ( - "context" - "crypto/sha256" - "encoding/hex" - "errors" - "fmt" - "net/http" - "regexp" - "seed/backend/core" - "seed/backend/lndhub" - "seed/backend/lndhub/lndhubsql" - "seed/backend/mttnet" - "seed/backend/wallet/walletsql" - wallet "seed/backend/wallet/walletsql" - "strings" - - "seed/backend/util/sqlite/sqlitex" - - "github.com/ipfs/go-cid" - "go.uber.org/zap" -) - -var ( - errAlreadyLndhubgoWallet = errors.New("Only one lndhub.go wallet is allowed and we already had one") - supportedWallets = []string{lndhubsql.LndhubWalletType, lndhubsql.LndhubGoWalletType} - validCredentials = regexp.MustCompile(`([A-Za-z0-9_\-\.]+):\/\/([0-9A-Za-z]+):([0-9a-f]+)@https:\/\/([A-Za-z0-9_\-\.]+)\/?$`) -) - -// AccountID is a handy alias of Cid. -type AccountID = cid.Cid - -// Service wraps everything necessary to deliver a wallet service. -type Service struct { - lightningClient lnclient - pool *sqlitex.Pool - net *mttnet.Node - log *zap.Logger - keyStore core.KeyStore - keyName string -} - -// Credentials struct holds all we need to connect to different lightning nodes (lndhub, LND, core-lightning, ...). -type Credentials struct { - Domain string `json:"domain"` - WalletType string `json:"wallettype"` - Login string `json:"login"` - Password string `json:"password"` - Nickname string `json:"nickname,omitempty"` - Token string `json:"token,omitempty"` - ID string `json:"id,omitempty"` -} - -// New is the constructor of the wallet service. Since it needs to authenticate to the internal wallet provider (lndhub) -// it may take time in case node is offline. This is why it's initialized in a gorutine and calls to the service functions -// will fail until the initial wallet is successfully initialized. -func New(ctx context.Context, log *zap.Logger, db *sqlitex.Pool, ks core.KeyStore, keyName string, net *mttnet.Node, mainnet bool) *Service { - lndhubDomain := "ln.testnet.mintter.com" - lnaddressDomain := "ln.testnet.mintter.com" - if mainnet { - //lndhubDomain is the domain for internal lndhub calls. - lndhubDomain = "ln.mintter.com" - lnaddressDomain = "ln.mintter.com" - } - srv := &Service{ - pool: db, - lightningClient: lnclient{ - Lndhub: lndhub.NewClient(ctx, &http.Client{}, db, ks, keyName, lndhubDomain, lnaddressDomain), - }, - net: net, - log: log, - keyStore: ks, - keyName: keyName, - } - srv.net.SetInvoicer(srv) - // Check if the user already had a lndhub wallet (reusing db) - // if not, then Auth will simply fail. - conn, release, err := db.Conn(ctx) - if err != nil { - panic(err) - } - defer release() - defaultWallet, err := walletsql.GetDefaultWallet(conn) - if err != nil { - log.Warn("Problem getting default wallet", zap.Error(err)) - return srv - } - if defaultWallet.Type == lndhubsql.LndhubGoWalletType { - srv.lightningClient.Lndhub.WalletID = defaultWallet.ID - return srv - } - wallets, err := walletsql.ListWallets(conn, 1) - if err != nil { - log.Warn("Could not get if db already had wallets", zap.Error(err)) - return srv - } - - for _, w := range wallets { - if w.Type == lndhubsql.LndhubGoWalletType { - srv.lightningClient.Lndhub.WalletID = w.ID - return srv - } - } - log.Info("None of the wallets already in db is lndhub compatible.", zap.Int("Number of wallets", len(wallets))) - - return srv -} - -type lnclient struct { - Lndhub *lndhub.Client - Lnd interface{} // TODO: implement LND client -} - -// InvoiceRequest holds the necessary fields for the request. Currently hold invoices are not supported, so they're omitted. -type InvoiceRequest struct { - AmountSats int64 `help:"The invoice amount in satoshis" default:"0"` - Memo string `help:"Optional requested memo to be attached in the invoice" default:""` - HoldInvoice bool `help:"If we request a hold invoice instead of a regular one. If true, then the following field is mandatory" default:"false"` - PreimageHash []byte `help:"Preimage hash of the requested hold invoice. If HoldInvoice flag is set to false this field is skipped" default:""` -} - -// P2PInvoiceRequest requests a remote account to issue an invoice so we can pay it. -// Any of the devices associated with the remote account can issue it. For each -// associated device we found online ,we ask if it can provide an invoice. -// If for some reason, that device cannot create the invoice (insufficient -// inbound liquidity) we ask the next device. We return in the first device that -// can issue the invoice. If none of them can, then an error is raised. -func (srv *Service) P2PInvoiceRequest(ctx context.Context, account core.Principal, request InvoiceRequest) (string, error) { - return "", fmt.Errorf("Hm-24. Not implemented") - /* - me, err := srv.keyStore.GetKey(ctx, srv.keyName) - if err != nil { - return "", err - } - if me.String() == account.String() { - err := fmt.Errorf("cannot remotely issue an invoice to myself") - srv.log.Debug(err.Error()) - return "", err - } - - var dels []hypersql.KeyDelegationsListResult - if err := srv.pool.Query(ctx, func(conn *sqlite.Conn) error { - list, err := hypersql.KeyDelegationsList(conn, account) - if err != nil { - return err - } - if len(list) == 0 { - return fmt.Errorf("request invoice: can't find devices for account %s", account) - } - - dels = list - - return nil - }); err != nil { - return "", err - } - - for _, del := range dels { - pid, err := core.Principal(del.KeyDelegationsViewDelegate).PeerID() - if err != nil { - return "", fmt.Errorf("failed to extract peer ID: %w", err) - } - p2pc, err := srv.net.Client(ctx, pid) - if err != nil { - continue - } - - remoteInvoice, err := p2pc.RequestInvoice(ctx, &p2p.RequestInvoiceRequest{ - AmountSats: request.AmountSats, - Memo: request.Memo, - HoldInvoice: request.HoldInvoice, - PreimageHash: request.PreimageHash, - }) - - if err != nil { - srv.log.Debug("p2p invoice request failed", zap.String("msg", err.Error())) - return "", fmt.Errorf("p2p invoice request failed") - } - - if remoteInvoice.PayReq == "" { - return "", fmt.Errorf("received an empty invoice from remote peer") - } - - return remoteInvoice.PayReq, nil - } - - return "", fmt.Errorf("couldn't get remote invoice from any peer") - */ -} - -// InsertWallet first tries to connect to the wallet with the provided credentials. On -// success, gets the wallet balance and inserts all that information in the database. -// InsertWallet returns the wallet actually inserted on success. The credentias are stored -// in plain text at the moment. -func (srv *Service) InsertWallet(ctx context.Context, credentialsURL, name string) (wallet.Wallet, error) { - var err error - var ret wallet.Wallet - - creds, err := DecodeCredentialsURL(credentialsURL) - if err != nil { - srv.log.Debug(err.Error()) - return ret, err - } - - if !isSupported(creds.WalletType) { - err = fmt.Errorf(" wallet type [%s] not supported. Currently supported: [%v]", creds.WalletType, supportedWallets) - srv.log.Debug(err.Error()) - return ret, err - } - if creds.WalletType == lndhubsql.LndhubGoWalletType || creds.WalletType == lndhubsql.LndhubWalletType { - srv.lightningClient.Lndhub.WalletID = URL2Id(credentialsURL) - } - - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return ret, err - } - defer release() - - ret.Type = creds.WalletType - ret.Address = "https://" + creds.Domain - ret.ID = creds.ID - ret.Name = name - if creds.WalletType == lndhubsql.LndhubGoWalletType { - // Only one lndhub.go wallet is allowed - wallets, err := srv.ListWallets(ctx, false) - if err != nil { - srv.log.Debug(err.Error()) - return ret, err - } - for i := 0; i < len(wallets); i++ { - if wallets[i].Type == lndhubsql.LndhubGoWalletType { - err = fmt.Errorf("Only one type of %s wallet is allowed: %w", lndhubsql.LndhubGoWalletType, errAlreadyLndhubgoWallet) - srv.log.Debug(err.Error()) - return wallets[i], err - } - } - if creds.Nickname == "" { - creds.Nickname = creds.Login - } - newWallet, err := srv.lightningClient.Lndhub.Create(ctx, ret.Address, creds.Login, creds.Password, creds.Nickname) - if err != nil { - srv.log.Warn("couldn't insert wallet", zap.String("Login", creds.Login), zap.String("Nickname", creds.Nickname), zap.Error(err)) - return ret, err - } - creds.Nickname = newWallet.Nickname - } - - if err = wallet.InsertWallet(conn, ret, []byte(creds.Login), []byte(creds.Password), []byte(creds.Token)); err != nil { - srv.log.Debug("couldn't insert wallet", zap.String("msg", err.Error())) - if errors.Is(err, walletsql.ErrDuplicateIndex) { - return ret, fmt.Errorf("couldn't insert wallet %s in the database. ID already exists", name) - } - return ret, fmt.Errorf("couldn't insert wallet %s in the database", name) - } - - // Trying to authenticate with the provided credentials - creds.Token, err = srv.lightningClient.Lndhub.Auth(ctx) - if err != nil { - _ = wallet.RemoveWallet(conn, ret.ID) - srv.log.Warn("couldn't authenticate new wallet", zap.String("msg", err.Error())) - return ret, fmt.Errorf("couldn't authenticate new wallet %s", name) - } - - return ret, err -} - -// ListWallets returns all the wallets available in the database. If includeBalance is tru, then -// ListWallets will also include the balance one every lndhub-like wallet. If false,then the call -// is quicker but no balance information will appear. -func (srv *Service) ListWallets(ctx context.Context, includeBalance bool) ([]wallet.Wallet, error) { - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return nil, err - } - defer release() - - wallets, err := wallet.ListWallets(conn, -1) - if err != nil { - srv.log.Debug("couldn't list wallets", zap.String("msg", err.Error())) - return nil, fmt.Errorf("couldn't list wallets") - } - for i, w := range wallets { - if includeBalance && (strings.ToLower(w.Type) == lndhubsql.LndhubWalletType || strings.ToLower(w.Type) == lndhubsql.LndhubGoWalletType) { - balance, err := srv.lightningClient.Lndhub.GetBalance(ctx) - if err != nil { - srv.log.Debug("couldn't get balance", zap.String("wallet", w.Name), zap.String("error", err.Error())) - return nil, fmt.Errorf("couldn't get balance from wallet %s", w.Name) - } - wallets[i].Balance = int64(balance) - } - } - return wallets, nil -} - -// DeleteWallet removes the wallet given a valid ID string representing -// the url hash in case of Lndhub-type wallet or the pubkey in case of LND. -// If the removed wallet was the default wallet, a random wallet will be -// chosen as new default. Although it is advised that the user manually -// changes the default wallet after removing the previous default. -func (srv *Service) DeleteWallet(ctx context.Context, walletID string) error { - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return err - } - defer release() - - if err := wallet.RemoveWallet(conn, walletID); err != nil { - return fmt.Errorf("couldn't remove wallet %s", walletID) - } - // TODO: remove associated token db entries - return nil -} - -// UpdateWalletName updates an existing wallet's name with the one provided. -// If the wallet represented by the id id does not exist, this function -// returns error. nil otherwise, along with the updated wallet. -func (srv *Service) UpdateWalletName(ctx context.Context, walletID string, newName string) (ret wallet.Wallet, err error) { - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return ret, err - } - defer release() - - if ret, err = wallet.UpdateWalletName(conn, walletID, newName); err != nil { - srv.log.Debug("couldn't update wallet", zap.String("msg", err.Error())) - return ret, fmt.Errorf("couldn't update wallet %s", walletID) - } - - return ret, nil -} - -// SetDefaultWallet sets the default wallet to the one that matches walletID. -// Previous default wallet is replaced by the new one so only one can be -// the default at any given time. The default wallet is the first wallet ever -// created until manually changed. -func (srv *Service) SetDefaultWallet(ctx context.Context, walletID string) (ret wallet.Wallet, err error) { - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return ret, err - } - defer release() - - wallet, err := wallet.UpdateDefaultWallet(conn, walletID) - if err != nil { - srv.log.Debug("couldn't set default wallet: " + err.Error()) - } - return wallet, err -} - -// ExportWallet returns the wallet credentials in uri format so the user can import it -// to an external app. the uri format is: -// ://:@https:// -// lndhub://c227a7fb5c71a22fac33:d2a48ab779aa1b02e858@https://lndhub.io -// If the ID is empty, then the builtin wallet is exported. -func (srv *Service) ExportWallet(ctx context.Context, walletID string) (string, error) { - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return "", err - } - defer release() - var uri string - if walletID == "" { - loginSignature, err := lndhubsql.GetLoginSignature(conn) - if err != nil { - return "", err - } - me, err := srv.keyStore.GetKey(ctx, srv.keyName) - if err != nil { - return "", err - } - uri, err = EncodeCredentialsURL(Credentials{ - Domain: srv.lightningClient.Lndhub.GetLndhubDomain(), - WalletType: lndhubsql.LndhubGoWalletType, - Login: me.String(), - Password: loginSignature, - }) - if err != nil { - return "", err - } - } else { - login, err := lndhubsql.GetLogin(conn, walletID) - if err != nil { - srv.log.Debug(err.Error()) - return "", err - } - password, err := lndhubsql.GetPassword(conn, walletID) - if err != nil { - srv.log.Debug(err.Error()) - return "", err - } - url, err := lndhubsql.GetAPIURL(conn, walletID) - if err != nil { - srv.log.Debug(err.Error()) - return "", err - } - splitURL := strings.Split(url, "//") - if len(splitURL) != 2 { - err = fmt.Errorf("Could not export wallet, unexpected url format [%s]", url) - srv.log.Debug(err.Error()) - return "", err - } - uri, err = EncodeCredentialsURL(Credentials{ - Domain: splitURL[1], - WalletType: lndhubsql.LndhubWalletType, - Login: login, - Password: password, - ID: walletID, - }) - } - if err != nil { - srv.log.Debug("couldn't encode uri: " + err.Error()) - return "", err - } - return uri, nil -} - -// UpdateLnaddressNickname updates nickname on the lndhub.go database -// The update can fail if the nickname contain special characters or is already taken by another user. -// Since it is a user operation, if the login is a CID, then user must provide a token representing -// the pubkey whose private counterpart created the signature provided in password (like in create). -func (srv *Service) UpdateLnaddressNickname(ctx context.Context, nickname string) error { - err := srv.lightningClient.Lndhub.UpdateNickname(ctx, nickname) - if err != nil { - srv.log.Debug("couldn't update nickname: " + err.Error()) - return err - } - return nil -} - -// GetDefaultWallet gets the user's default wallet. If the user didn't manually -// update the default wallet, then the first wallet ever created is the default -// wallet. It will remain default until manually changed. -func (srv *Service) GetDefaultWallet(ctx context.Context) (ret wallet.Wallet, err error) { - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return ret, err - } - defer release() - - w, err := wallet.GetDefaultWallet(conn) - if err != nil { - srv.log.Debug("couldn't getDefaultWallet: " + err.Error()) - return wallet.Wallet{}, err - } - return w, nil -} - -// ListPaidInvoices returns the invoices that the wallet represented by walletID has paid. -func (srv *Service) ListPaidInvoices(ctx context.Context, walletID string) ([]lndhub.Invoice, error) { - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return nil, err - } - defer release() - - w, err := wallet.GetWallet(conn, walletID) - if err != nil { - srv.log.Debug("couldn't list wallets: " + err.Error()) - return nil, fmt.Errorf("couldn't list wallets") - } - if strings.ToLower(w.Type) != lndhubsql.LndhubWalletType && strings.ToLower(w.Type) != lndhubsql.LndhubGoWalletType { - err = fmt.Errorf("Couldn't get invoices form wallet type %s", w.Type) - srv.log.Debug(err.Error()) - return nil, err - } - invoices, err := srv.lightningClient.Lndhub.ListPaidInvoices(ctx) - if err != nil { - srv.log.Debug("couldn't list outgoing invoices: " + err.Error()) - return nil, err - } - return invoices, nil -} - -// ListReceivednvoices returns the incoming invoices that the wallet represented by walletID has received. -func (srv *Service) ListReceivednvoices(ctx context.Context, walletID string) ([]lndhub.Invoice, error) { - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return nil, err - } - defer release() - - w, err := wallet.GetWallet(conn, walletID) - if err != nil { - srv.log.Debug("couldn't list wallets: " + err.Error()) - return nil, fmt.Errorf("couldn't list wallets: %w", err) - } - if strings.ToLower(w.Type) != lndhubsql.LndhubWalletType && strings.ToLower(w.Type) != lndhubsql.LndhubGoWalletType { - err = fmt.Errorf("Couldn't get invoices form wallet type %s", w.Type) - srv.log.Debug(err.Error()) - return nil, err - } - invoices, err := srv.lightningClient.Lndhub.ListReceivedInvoices(ctx) - if err != nil { - srv.log.Debug("couldn't list incoming invoices: " + err.Error()) - return nil, err - } - return invoices, nil -} - -// RequestRemoteInvoice asks a remote peer to issue an invoice. The remote user can be either a lnaddres or a Seed account ID -// First an lndhub invoice request is attempted. In it fails, then a P2P its used to transmit the invoice. In that case, -// Any of the devices associated with the accountID can issue the invoice. The memo field is optional and can be left nil. -func (srv *Service) RequestRemoteInvoice(ctx context.Context, remoteUser string, amountSats int64, memo *string) (string, error) { - invoiceMemo := "" - if memo != nil { - invoiceMemo = *memo - } - var payReq string - var err error - payReq, err = srv.lightningClient.Lndhub.RequestRemoteInvoice(ctx, remoteUser, amountSats, invoiceMemo) - //err = fmt.Errorf("force p2p transmission") - if err != nil { - srv.log.Debug("couldn't get invoice via lndhub, trying p2p...", zap.String("error", err.Error())) - account, err := core.DecodePrincipal(remoteUser) - if err != nil { - publicErr := fmt.Errorf("couldn't parse accountID string [%s], If using p2p transmission, remoteUser must be a valid accountID", remoteUser) - srv.log.Debug("error decoding cid "+publicErr.Error(), zap.String("error", err.Error())) - return "", publicErr - } - payReq, err = srv.P2PInvoiceRequest(ctx, account, - InvoiceRequest{ - AmountSats: amountSats, - Memo: invoiceMemo, - HoldInvoice: false, // TODO: Add support hold invoices - PreimageHash: []byte{}, // Only aplicable to hold invoices - }) - if err != nil { - srv.log.Debug("couldn't get invoice via p2p", zap.String("error", err.Error())) - return "", fmt.Errorf("Could not request invoice via P2P") - } - } - - return payReq, nil -} - -// CreateLocalInvoice tries to generate an invoice locally from the default wallet The memo field is optional and can be left nil. -func (srv *Service) CreateLocalInvoice(ctx context.Context, amountSats int64, memo *string) (string, error) { - invoiceMemo := "" - if memo != nil { - invoiceMemo = *memo - } - - defaultWallet, err := srv.GetDefaultWallet(ctx) - if err != nil { - return "", fmt.Errorf("could not get default wallet to ask for a local invoice") - } - - if defaultWallet.Type != lndhubsql.LndhubWalletType && defaultWallet.Type != lndhubsql.LndhubGoWalletType { - err = fmt.Errorf("Wallet type %s not compatible with local invoice creation", defaultWallet.Type) - srv.log.Debug("couldn't create local invoice: " + err.Error()) - return "", err - } - payreq, err := srv.lightningClient.Lndhub.CreateLocalInvoice(ctx, amountSats, invoiceMemo) - if err != nil { - srv.log.Debug("couldn't create local invoice: " + err.Error()) - return "", err - } - return payreq, nil -} - -// PayInvoice tries to pay the provided invoice. If a walletID is provided, that wallet will be used instead of the default one -// If amountSats is provided, the invoice will be paid with that amount. This amount should be equal to the amount on the invoice -// unless the amount on the invoice is 0. -func (srv *Service) PayInvoice(ctx context.Context, payReq string, walletID *string, amountSats *uint64) (string, error) { - var walletToPay wallet.Wallet - var err error - var amountToPay uint64 - - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return "", err - } - defer release() - - if walletID != nil { - walletToPay, err = wallet.GetWallet(conn, *walletID) - if err != nil { - publicErr := fmt.Errorf("couldn't get wallet %s", *walletID) - srv.log.Debug(publicErr.Error(), zap.String("msg", err.Error())) - return "", publicErr - } - } else { - walletToPay, err = srv.GetDefaultWallet(ctx) - if err != nil { - return "", fmt.Errorf("couldn't get default wallet to pay") - } - } - - if !isSupported(walletToPay.Type) { - err = fmt.Errorf("wallet type [%s] not supported to pay. Currently supported: [%v]", walletToPay.Type, supportedWallets) - srv.log.Debug(err.Error()) - return "", err - } - - if amountSats == nil || *amountSats == 0 { - invoice, err := lndhub.DecodeInvoice(payReq) - if err != nil { - publicError := fmt.Errorf("couldn't decode invoice [%s], please make sure it is a bolt-11 compatible invoice", payReq) - srv.log.Debug(publicError.Error(), zap.String("msg", err.Error())) - return "", publicError - } - amountToPay = uint64(invoice.MilliSat.ToSatoshis()) - } else { - amountToPay = *amountSats - } - - if err = srv.lightningClient.Lndhub.PayInvoice(ctx, payReq, amountToPay); err != nil { - if strings.Contains(err.Error(), wallet.NotEnoughBalance) { - return "", fmt.Errorf("couldn't pay invoice with wallet [%s]: %w", walletToPay.Name, lndhubsql.ErrNotEnoughBalance) - } - if errors.Is(err, lndhubsql.ErrQtyMissmatch) { - return "", fmt.Errorf("couldn't pay invoice, quantity in invoice differs from amount to pay [%d] :%w", amountToPay, lndhubsql.ErrQtyMissmatch) - } - srv.log.Debug("couldn't pay invoice", zap.String("msg", err.Error())) - return "", fmt.Errorf("couldn't pay invoice") - } - - return walletToPay.ID, nil -} - -// GetLnAddress gets the account-wide ln address in the form of @ . -// Since it is a user operation, if the login is a CID, then user must provide a token representing -// the pubkey whose private counterpart created the signature provided in password (like in create). -func (srv *Service) GetLnAddress(ctx context.Context) (string, error) { - lnaddress, err := srv.lightningClient.Lndhub.GetLnAddress(ctx) - if err != nil { - srv.log.Debug("couldn't get lnaddress", zap.String("msg", err.Error())) - return "", fmt.Errorf("couldn't get lnaddress") - } - return lnaddress, nil -} - -// ConfigureSeedLNDHub uses the account private key to generate credentials for the default -// Seed custodial LNDHub wallet. -func (srv *Service) ConfigureSeedLNDHub(ctx context.Context, acc core.KeyPair) error { - signature, err := acc.Sign([]byte(lndhub.SigningMessage)) - if err != nil { - return err - } - conn, release, err := srv.pool.Conn(ctx) - if err != nil { - return err - } - defer release() - - if err := lndhubsql.SetLoginSignature(conn, hex.EncodeToString(signature)); err != nil { - return err - } - - return nil -} - -// DecodeCredentialsURL takes a credential string of the form -// ://:@https:// -// lndhub://c227a7fb5c71a22fac33:d2a48ab779aa1b02e858@https://lndhub.io -func DecodeCredentialsURL(url string) (Credentials, error) { - credentials := Credentials{} - - res := validCredentials.FindStringSubmatch(url) - if res == nil || len(res) != 5 { - if res != nil { - return credentials, fmt.Errorf("credentials contained more than necessary fields. it should be " + - "://:@https://") - } - return credentials, fmt.Errorf("couldn't parse credentials, probably wrong format. it should be " + - "://:@https://") - } - credentials.WalletType = strings.ToLower(res[1]) - credentials.Login = res[2] - credentials.Password = res[3] - credentials.Domain = res[4] - credentials.ID = URL2Id(url) - return credentials, nil -} - -// URL2Id constructs a unique and collision-free ID out of a credentials URL. -func URL2Id(url string) string { - h := sha256.Sum256([]byte(url)) - return hex.EncodeToString(h[:]) -} - -// EncodeCredentialsURL generates a credential URL out of credential parameters. -// the resulting url will have this format -// ://:@https:// -func EncodeCredentialsURL(creds Credentials) (string, error) { - url := creds.WalletType + "://" + creds.Login + ":" + creds.Password + "@https://" + creds.Domain - _, err := DecodeCredentialsURL(url) - return url, err -} - -func isSupported(walletType string) bool { - var supported bool - for _, supWalletType := range supportedWallets { - if walletType == supWalletType { - supported = true - break - } - } - return supported -} diff --git a/backend/wallet/wallet_test.go b/backend/wallet/wallet_test.go deleted file mode 100644 index e6cac172..00000000 --- a/backend/wallet/wallet_test.go +++ /dev/null @@ -1,193 +0,0 @@ -package wallet - -import ( - "context" - "encoding/hex" - "seed/backend/blob" - "seed/backend/config" - "seed/backend/core" - "seed/backend/core/coretest" - "seed/backend/lndhub" - "seed/backend/lndhub/lndhubsql" - "seed/backend/logging" - "seed/backend/mttnet" - "seed/backend/storage" - "seed/backend/testutil" - "seed/backend/util/future" - "seed/backend/wallet/walletsql" - "testing" - "time" - - "seed/backend/util/sqlite/sqlitex" - - "github.com/stretchr/testify/require" - "go.uber.org/zap" -) - -func TestModifyWallets(t *testing.T) { - testutil.Manual(t) - - alice := makeTestService(t, "alice") - - ctx := context.Background() - var err error - var defaultWallet walletsql.Wallet - uri, err := alice.ExportWallet(ctx, "") - require.NoError(t, err) - seedWallet, err := alice.InsertWallet(ctx, uri, "default") - require.NoError(t, err) - require.Eventually(t, func() bool { defaultWallet, err = alice.GetDefaultWallet(ctx); return err == nil }, 7*time.Second, 2*time.Second) - require.Equal(t, seedWallet, defaultWallet) - require.Eventually(t, func() bool { - conn, release, err := alice.pool.Conn(ctx) - require.NoError(t, err) - defer release() - _, err = lndhubsql.GetToken(conn, defaultWallet.ID) - return err == nil - }, 3*time.Second, 1*time.Second) - require.EqualValues(t, lndhubsql.LndhubGoWalletType, defaultWallet.Type) - err = alice.DeleteWallet(ctx, defaultWallet.ID) - require.Error(t, err) - const newName = "new wallet name" - _, err = alice.UpdateWalletName(ctx, defaultWallet.ID, newName) - require.NoError(t, err) - - wallets, err := alice.ListWallets(ctx, true) - require.NoError(t, err) - require.EqualValues(t, 1, len(wallets)) - require.EqualValues(t, newName, wallets[0].Name) -} - -func TestRequestLndHubInvoice(t *testing.T) { - testutil.Manual(t) - - var err error - alice := makeTestService(t, "alice") - bob := makeTestService(t, "bob") - ctx := context.Background() - aliceURI, err := alice.ExportWallet(ctx, "") - require.NoError(t, err) - _, err = alice.InsertWallet(ctx, aliceURI, "default") - require.NoError(t, err) - bobURI, err := bob.ExportWallet(ctx, "") - require.NoError(t, err) - _, err = bob.InsertWallet(ctx, bobURI, "default") - require.NoError(t, err) - - kp, err := bob.keyStore.GetKey(ctx, "main") - require.NoError(t, err) - bobAccount := kp.Principal() - var amt uint64 = 23 - var wrongAmt uint64 = 24 - var memo = "test invoice" - - var payreq string - var defaultWallet walletsql.Wallet - require.Eventually(t, func() bool { defaultWallet, err = bob.GetDefaultWallet(ctx); return err == nil }, 7*time.Second, 3*time.Second) - require.Eventually(t, func() bool { - conn, release, err := bob.pool.Conn(ctx) - require.NoError(t, err) - defer release() - _, err = lndhubsql.GetToken(conn, defaultWallet.ID) - return err == nil - }, 3*time.Second, 1*time.Second) - require.Eventually(t, func() bool { - payreq, err = alice.RequestRemoteInvoice(ctx, bobAccount.String(), int64(amt), &memo) - return err == nil - }, 8*time.Second, 2*time.Second) - invoice, err := lndhub.DecodeInvoice(payreq) - require.NoError(t, err) - require.EqualValues(t, amt, invoice.MilliSat.ToSatoshis()) - require.EqualValues(t, memo, *invoice.Description) - _, err = alice.PayInvoice(ctx, payreq, nil, &wrongAmt) - require.ErrorIs(t, err, lndhubsql.ErrQtyMissmatch) - _, err = alice.PayInvoice(ctx, payreq, nil, &amt) - require.ErrorIs(t, err, lndhubsql.ErrNotEnoughBalance) -} - -func TestRequestP2PInvoice(t *testing.T) { - testutil.Manual(t) - - alice := makeTestService(t, "alice") - bob := makeTestService(t, "bob") - ctx := context.Background() - - bobAccount, err := bob.net.AccountForDevice(ctx, bob.net.AddrInfo().ID) - require.NoError(t, err) - require.NoError(t, alice.net.Connect(ctx, bob.net.AddrInfo())) - - var amt uint64 = 23 - var wrongAmt uint64 = 24 - var memo = "test invoice" - var payreq string - require.Eventually(t, func() bool { - payreq, err = alice.RequestRemoteInvoice(ctx, bobAccount.String(), int64(amt), &memo) - return err == nil - }, 8*time.Second, 2*time.Second) - invoice, err := lndhub.DecodeInvoice(payreq) - require.NoError(t, err) - require.EqualValues(t, amt, invoice.MilliSat.ToSatoshis()) - require.EqualValues(t, memo, *invoice.Description) - _, err = alice.PayInvoice(ctx, payreq, nil, &wrongAmt) - require.ErrorIs(t, err, lndhubsql.ErrQtyMissmatch) - _, err = alice.PayInvoice(ctx, payreq, nil, &amt) - require.ErrorIs(t, err, lndhubsql.ErrNotEnoughBalance) -} - -func makeTestService(t *testing.T, name string) *Service { - u := coretest.NewTester(name) - db := storage.MakeTestMemoryDB(t) - device := u.Device - ks := core.NewMemoryKeyStore() - - node, closenode := makeTestPeer(t, u, device, ks, db) - t.Cleanup(closenode) - - conn, release, err := db.Conn(context.Background()) - require.NoError(t, err) - defer release() - - signature, err := u.Account.Sign([]byte(lndhub.SigningMessage)) - require.NoError(t, err) - - require.NoError(t, lndhubsql.SetLoginSignature(conn, hex.EncodeToString(signature))) - - ctx, cancel := context.WithCancel(context.Background()) - - t.Cleanup(cancel) - require.NoError(t, ks.StoreKey(ctx, "main", u.Account)) - srv := New(ctx, logging.New("seed/wallet", "debug"), db, ks, "main", node, false) - - return srv -} - -func makeTestPeer(t *testing.T, u coretest.Tester, device core.KeyPair, ks core.KeyStore, db *sqlitex.Pool) (*mttnet.Node, context.CancelFunc) { - idx := blob.NewIndex(db, logging.New("seed/hyper", "debug"), nil) - - n, err := mttnet.New(config.P2P{ - NoRelay: true, - BootstrapPeers: nil, - NoMetrics: true, - }, device, ks, db, idx, zap.NewNop()) - require.NoError(t, err) - - errc := make(chan error, 1) - ctx, cancel := context.WithCancel(context.Background()) - f := future.New[*mttnet.Node]() - require.NoError(t, f.Resolve(n)) - go func() { - errc <- n.Start(ctx) - }() - - t.Cleanup(func() { - require.NoError(t, <-errc) - }) - - select { - case <-n.Ready(): - case err := <-errc: - require.NoError(t, err) - } - - return n, cancel -} diff --git a/backend/wallet/walletsql/queries.gen.go b/backend/wallet/walletsql/queries.gen.go index 066f179a..eca204c7 100644 --- a/backend/wallet/walletsql/queries.gen.go +++ b/backend/wallet/walletsql/queries.gen.go @@ -12,19 +12,19 @@ import ( var _ = errors.New -func insertWallet(conn *sqlite.Conn, walletsID string, walletsAddress string, walletsType string, walletsLogin []byte, walletsPassword []byte, walletsToken []byte, walletsName string, walletsBalance int64) error { - const query = `INSERT INTO wallets (id, address, type, login, password, token, name, balance) -VALUES (:walletsID, :walletsAddress, :walletsType, :walletsLogin, :walletsPassword, :walletsToken, :walletsName, :walletsBalance)` +func insertWallet(conn *sqlite.Conn, walletsID string, walletsAccount int64, walletsAddress string, walletsType string, walletsLogin []byte, walletsPassword []byte, walletsToken []byte, walletsName string) error { + const query = `INSERT INTO wallets (id, account, address, type, login, password, token, name) +VALUES (:walletsID, :walletsAccount, :walletsAddress, :walletsType, :walletsLogin, :walletsPassword, :walletsToken, :walletsName)` before := func(stmt *sqlite.Stmt) { stmt.SetText(":walletsID", walletsID) + stmt.SetInt64(":walletsAccount", walletsAccount) stmt.SetText(":walletsAddress", walletsAddress) stmt.SetText(":walletsType", walletsType) stmt.SetBytes(":walletsLogin", walletsLogin) stmt.SetBytes(":walletsPassword", walletsPassword) stmt.SetBytes(":walletsToken", walletsToken) stmt.SetText(":walletsName", walletsName) - stmt.SetInt64(":walletsBalance", walletsBalance) } onStep := func(i int, stmt *sqlite.Stmt) error { @@ -41,14 +41,14 @@ VALUES (:walletsID, :walletsAddress, :walletsType, :walletsLogin, :walletsPasswo type getWalletResult struct { WalletsID string + WalletsAccount int64 WalletsAddress string WalletsName string - WalletsBalance int64 WalletsType string } func getWallet(conn *sqlite.Conn, walletsID string) (getWalletResult, error) { - const query = `SELECT wallets.id, wallets.address, wallets.name, wallets.balance, wallets.type + const query = `SELECT wallets.id, wallets.account, wallets.address, wallets.name, wallets.type FROM wallets WHERE wallets.id = :walletsID` var out getWalletResult @@ -63,9 +63,9 @@ FROM wallets WHERE wallets.id = :walletsID` } out.WalletsID = stmt.ColumnText(0) - out.WalletsAddress = stmt.ColumnText(1) - out.WalletsName = stmt.ColumnText(2) - out.WalletsBalance = stmt.ColumnInt64(3) + out.WalletsAccount = stmt.ColumnInt64(1) + out.WalletsAddress = stmt.ColumnText(2) + out.WalletsName = stmt.ColumnText(3) out.WalletsType = stmt.ColumnText(4) return nil } @@ -80,14 +80,14 @@ FROM wallets WHERE wallets.id = :walletsID` type listWalletsResult struct { WalletsID string + WalletsAccount int64 WalletsAddress string WalletsName string WalletsType string - WalletsBalance int64 } func listWallets(conn *sqlite.Conn, cursor string, limit int64) ([]listWalletsResult, error) { - const query = `SELECT wallets.id, wallets.address, wallets.name, wallets.type, wallets.balance FROM wallets WHERE wallets.id > :cursor LIMIT :limit` + const query = `SELECT wallets.id, wallets.account, wallets.address, wallets.name, wallets.type FROM wallets WHERE wallets.id > :cursor LIMIT :limit` var out []listWalletsResult @@ -99,10 +99,10 @@ func listWallets(conn *sqlite.Conn, cursor string, limit int64) ([]listWalletsRe onStep := func(i int, stmt *sqlite.Stmt) error { out = append(out, listWalletsResult{ WalletsID: stmt.ColumnText(0), - WalletsAddress: stmt.ColumnText(1), - WalletsName: stmt.ColumnText(2), - WalletsType: stmt.ColumnText(3), - WalletsBalance: stmt.ColumnInt64(4), + WalletsAccount: stmt.ColumnInt64(1), + WalletsAddress: stmt.ColumnText(2), + WalletsName: stmt.ColumnText(3), + WalletsType: stmt.ColumnText(4), }) return nil @@ -116,51 +116,7 @@ func listWallets(conn *sqlite.Conn, cursor string, limit int64) ([]listWalletsRe return out, err } -type getDefaultWalletResult struct { - WalletsID string - WalletsAddress string - WalletsName string - WalletsBalance int64 - WalletsType string - KVValue string -} - -func getDefaultWallet(conn *sqlite.Conn, key string) (getDefaultWalletResult, error) { - const query = `SELECT wallets.id, wallets.address, wallets.name, wallets.balance, wallets.type -FROM wallets -WHERE wallets.id IN (SELECT kv.value -FROM kv -WHERE kv.key = :key )` - - var out getDefaultWalletResult - - before := func(stmt *sqlite.Stmt) { - stmt.SetText(":key", key) - } - - onStep := func(i int, stmt *sqlite.Stmt) error { - if i > 1 { - return errors.New("getDefaultWallet: more than one result return for a single-kind query") - } - - out.WalletsID = stmt.ColumnText(0) - out.WalletsAddress = stmt.ColumnText(1) - out.WalletsName = stmt.ColumnText(2) - out.WalletsBalance = stmt.ColumnInt64(3) - out.WalletsType = stmt.ColumnText(4) - out.KVValue = stmt.ColumnText(5) - return nil - } - - err := sqlitegen.ExecStmt(conn, query, before, onStep) - if err != nil { - err = fmt.Errorf("failed query: getDefaultWallet: %w", err) - } - - return out, err -} - -func setDefaultWallet(conn *sqlite.Conn, kvKey string, kvValue string) error { +func setLoginSignature(conn *sqlite.Conn, kvKey string, kvValue string) error { const query = `INSERT OR REPLACE INTO kv (key, value) VALUES (:kvKey, :kvValue)` @@ -175,26 +131,7 @@ VALUES (:kvKey, :kvValue)` err := sqlitegen.ExecStmt(conn, query, before, onStep) if err != nil { - err = fmt.Errorf("failed query: setDefaultWallet: %w", err) - } - - return err -} - -func removeDefaultWallet(conn *sqlite.Conn, key string) error { - const query = `DELETE FROM kv WHERE kv.key = :key ` - - before := func(stmt *sqlite.Stmt) { - stmt.SetText(":key", key) - } - - onStep := func(i int, stmt *sqlite.Stmt) error { - return nil - } - - err := sqlitegen.ExecStmt(conn, query, before, onStep) - if err != nil { - err = fmt.Errorf("failed query: removeDefaultWallet: %w", err) + err = fmt.Errorf("failed query: setLoginSignature: %w", err) } return err diff --git a/backend/wallet/walletsql/queries.gensum b/backend/wallet/walletsql/queries.gensum index d4eea430..85f8b54f 100644 --- a/backend/wallet/walletsql/queries.gensum +++ b/backend/wallet/walletsql/queries.gensum @@ -1,2 +1,2 @@ -srcs: d9749e3cd270da39b57a35de8a3506cc -outs: ca668fff3d567f3e691fd18e83c120d5 +srcs: 056fd408cc9797bbd913fe411f178f6b +outs: 4d8ae6977eb714d49014d37072c1b464 diff --git a/backend/wallet/walletsql/queries.go b/backend/wallet/walletsql/queries.go index b61d61f5..0d5661d6 100644 --- a/backend/wallet/walletsql/queries.go +++ b/backend/wallet/walletsql/queries.go @@ -11,24 +11,24 @@ var _ = generateQueries const ( // DefaultWalletKey is the column name of the meta table where the default wallet id is stored. - DefaultWalletKey = "default_wallet" + DefaultWalletKey = "default_wallets" ) //go:generate gorun -tags codegen generateQueries func generateQueries() error { code, err := sqlitegen.CodegenQueries("walletsql", qb.MakeQuery(storage.Schema, "insertWallet", sqlitegen.QueryKindExec, - qb.Insert(storage.WalletsID, storage.WalletsAddress, storage.WalletsType, - storage.WalletsLogin, storage.WalletsPassword, storage.WalletsToken, - storage.WalletsName, storage.WalletsBalance), + qb.Insert(storage.WalletsID, storage.WalletsAccount, storage.WalletsAddress, + storage.WalletsType, storage.WalletsLogin, storage.WalletsPassword, + storage.WalletsToken, storage.WalletsName), ), qb.MakeQuery(storage.Schema, "getWallet", sqlitegen.QueryKindSingle, "SELECT", qb.Results( qb.ResultCol(storage.WalletsID), + qb.ResultCol(storage.WalletsAccount), qb.ResultCol(storage.WalletsAddress), qb.ResultCol(storage.WalletsName), - qb.ResultCol(storage.WalletsBalance), qb.ResultCol(storage.WalletsType), ), qb.Line, "FROM", storage.Wallets, @@ -38,33 +38,17 @@ func generateQueries() error { qb.MakeQuery(storage.Schema, "listWallets", sqlitegen.QueryKindMany, "SELECT", qb.Results( qb.ResultCol(storage.WalletsID), + qb.ResultCol(storage.WalletsAccount), qb.ResultCol(storage.WalletsAddress), qb.ResultCol(storage.WalletsName), qb.ResultCol(storage.WalletsType), - qb.ResultCol(storage.WalletsBalance), ), "FROM", storage.Wallets, "WHERE", storage.WalletsID, ">", qb.Var("cursor", sqlitegen.TypeText), "LIMIT", qb.Var("limit", sqlitegen.TypeInt), ), - qb.MakeQuery(storage.Schema, "getDefaultWallet", sqlitegen.QueryKindSingle, - "SELECT", qb.Results( - qb.ResultCol(storage.WalletsID), - qb.ResultCol(storage.WalletsAddress), - qb.ResultCol(storage.WalletsName), - qb.ResultCol(storage.WalletsBalance), - qb.ResultCol(storage.WalletsType), - ), qb.Line, - "FROM", storage.Wallets, qb.Line, - "WHERE", storage.WalletsID, "IN (SELECT", qb.Results( - qb.ResultCol(storage.KVValue), - ), qb.Line, - "FROM", storage.KV, qb.Line, - "WHERE", storage.KVKey, "=", qb.Var("key", sqlitegen.TypeText), ")", - ), - - qb.MakeQuery(storage.Schema, "setDefaultWallet", sqlitegen.QueryKindExec, + qb.MakeQuery(storage.Schema, "setLoginSignature", sqlitegen.QueryKindExec, "INSERT OR REPLACE INTO", storage.KV, qb.ListColShort( storage.KVKey, storage.KVValue, @@ -75,11 +59,6 @@ func generateQueries() error { ), ), - qb.MakeQuery(storage.Schema, "removeDefaultWallet", sqlitegen.QueryKindExec, - "DELETE FROM", storage.KV, - "WHERE", storage.KVKey, "=", qb.Var("key", sqlitegen.TypeText), "", - ), - qb.MakeQuery(storage.Schema, "updateWalletName", sqlitegen.QueryKindExec, "UPDATE", storage.Wallets, "SET", qb.ListColShort( storage.WalletsName, diff --git a/backend/wallet/walletsql/wallet.go b/backend/wallet/walletsql/wallet.go index 8cb258e3..b69b69b0 100644 --- a/backend/wallet/walletsql/wallet.go +++ b/backend/wallet/walletsql/wallet.go @@ -3,10 +3,14 @@ package walletsql import ( "errors" "fmt" + "seed/backend/blob" + "seed/backend/core" "seed/backend/lndhub/lndhubsql" - "strings" - + "seed/backend/storage" "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + "seed/backend/util/sqlitegen" + "strings" ) const ( @@ -19,15 +23,17 @@ const ( var ( // ErrDuplicateIndex is thrown when db identifies a duplicate entry on a unique key. ErrDuplicateIndex = errors.New("duplicate entry") + // ErrNoDefaultWallet is thrown when there is not a default wallet for a certain account. + ErrNoDefaultWallet = errors.New("No default wallet set") ) // Wallet is the representation of a lightning wallet. type Wallet struct { ID string `mapstructure:"id"` + Account string `mapstructure:"account"` Address string `marstructure:"address"` Name string `mapstructure:"name"` Type string `mapstructure:"type"` - Balance int64 `mapstructure:"balance"` } // GetWallet retrieves information about the specific wallet identified with id string @@ -46,12 +52,16 @@ func GetWallet(conn *sqlite.Conn, walletID string) (Wallet, error) { if wallet.WalletsID == "" { return Wallet{}, fmt.Errorf("No wallet found with id %s", walletID) } + principal, err := blob.DbGetPublicKeyByID(conn, wallet.WalletsAccount) + if err != nil { + return Wallet{}, fmt.Errorf("Problem getting the wallet's account %s", walletID) + } ret := Wallet{ ID: wallet.WalletsID, Address: wallet.WalletsAddress, Name: wallet.WalletsName, Type: wallet.WalletsType, - Balance: int64(wallet.WalletsBalance), + Account: core.Principal(principal).String(), } return ret, err @@ -61,8 +71,9 @@ func GetWallet(conn *sqlite.Conn, walletID string) (Wallet, error) { // If there are no wallets, an empty slice will be returned // If there are wallets to show, ListWallets will return up // to limit wallets. In case limit <=0, ListWallets will return -// all wallets available. -func ListWallets(conn *sqlite.Conn, limit int) ([]Wallet, error) { +// all wallets available. If accounts is not blank then ListWallets +// will return only wallets for that account. +func ListWallets(conn *sqlite.Conn, account string, limit int) ([]Wallet, error) { var resultArray []Wallet res, err := listWallets(conn, "", int64(limit)) @@ -71,13 +82,21 @@ func ListWallets(conn *sqlite.Conn, limit int) ([]Wallet, error) { } for _, s := range res { + principal, err := blob.DbGetPublicKeyByID(conn, s.WalletsAccount) + if err != nil { + return resultArray, fmt.Errorf("Problem getting the wallet's account %s", s.WalletsID) + } + acc := core.Principal(principal).String() + if account != "" && account != acc { + continue + } resultArray = append(resultArray, Wallet{ ID: s.WalletsID, Address: s.WalletsAddress, Name: s.WalletsName, Type: s.WalletsType, - Balance: int64(s.WalletsBalance), + Account: acc, }) } @@ -92,9 +111,22 @@ func InsertWallet(conn *sqlite.Conn, wallet Wallet, login, password, token []byt if len(wallet.ID) != idcharLength { return fmt.Errorf("wallet id must be a %d character string. Got %d", idcharLength, len(wallet.ID)) } - - if err := insertWallet(conn, wallet.ID, wallet.Address, strings.ToLower(wallet.Type), - login, password, token, wallet.Name, int64(wallet.Balance)); err != nil { + principal, err := core.DecodePrincipal(wallet.Account) + if err != nil { + return fmt.Errorf("Could not decode provided account %s: %w", wallet.Account, err) + } + accountID, err := blob.DbPublicKeysLookupID(conn, principal) + if err != nil { + return fmt.Errorf("Problem finding provided account %s : %w", wallet.Account, err) + } + if accountID == 0 { + accountID, err = blob.DbPublicKeysInsert(conn, principal) + if err != nil { + return fmt.Errorf("Error inserting new account %s: %w", principal.String(), err) + } + } + if err := insertWallet(conn, wallet.ID, accountID, wallet.Address, strings.ToLower(wallet.Type), + login, password, token, wallet.Name); err != nil { if strings.Contains(err.Error(), "UNIQUE constraint failed") { return fmt.Errorf("couldn't insert wallet: %w", ErrDuplicateIndex) } @@ -102,45 +134,52 @@ func InsertWallet(conn *sqlite.Conn, wallet Wallet, login, password, token []byt } //If the previously inserted was the first one, then it should be the default as well - nwallets, err := getWalletCount(conn) - if err != nil { - return fmt.Errorf("couldn't get wallet count: %w", err) - } - - if nwallets.Count == 1 { - if err = setDefaultWallet(conn, DefaultWalletKey, wallet.ID); err != nil { - return fmt.Errorf("couldn't set newly created wallet to default: %w", err) + if _, err := GetDefaultWallet(conn, principal.String()); err != nil { + if errors.Is(err, ErrNoDefaultWallet) { + query := createSetDefaultWalletQuery(wallet.Account, wallet.ID) + if err := sqlitex.Exec(conn, query, nil); err != nil { + return fmt.Errorf("couldn't set newly created wallet to default: %w", err) + } + return nil } + _ = removeWallet(conn, wallet.ID) + return fmt.Errorf("couldn't set default wallet") } - return nil } // GetDefaultWallet gets the user's default wallet. If the user didn't manually // update the default wallet, then the first wallet ever created is the default -// wallet. It will remain default until manually changed. -func GetDefaultWallet(conn *sqlite.Conn) (Wallet, error) { - ret, err := getDefaultWallet(conn, DefaultWalletKey) +// wallet. It will remain default until manually changed. There is a default wallet per account. +func GetDefaultWallet(conn *sqlite.Conn, account string) (w Wallet, err error) { + query := createGetDefaultWalletQuery(account) + var acc int64 + if err = sqlitex.Exec(conn, query, func(stmt *sqlite.Stmt) error { + w.ID = stmt.ColumnText(0) + acc = stmt.ColumnInt64(1) + w.Address = stmt.ColumnText(2) + w.Name = stmt.ColumnText(3) + w.Type = stmt.ColumnText(4) + return nil + }); err != nil { + return w, fmt.Errorf("Could not get default wallet: %w", err) + } + principal, err := blob.DbGetPublicKeyByID(conn, acc) if err != nil { - return Wallet{}, err + return w, fmt.Errorf("Could not decode default wallet account: %w", err) } - if ret.WalletsID == "" { - return Wallet{}, fmt.Errorf("No default wallet found") + if principal == nil { + return w, ErrNoDefaultWallet } - return Wallet{ - ID: ret.WalletsID, - Address: ret.WalletsAddress, - Name: ret.WalletsName, - Type: ret.WalletsType, - Balance: int64(ret.WalletsBalance), - }, nil + w.Account = core.Principal(principal).String() + return w, err } // UpdateDefaultWallet sets the default wallet to the one that matches newIdx // previous default wallet is replaced by the new one so only one can be // the default at any given time. The default wallet is the first wallet ever // created until manually changed. -func UpdateDefaultWallet(conn *sqlite.Conn, newID string) (Wallet, error) { +func UpdateDefaultWallet(conn *sqlite.Conn, account, newID string) (Wallet, error) { var err error if len(newID) != idcharLength { @@ -151,8 +190,11 @@ func UpdateDefaultWallet(conn *sqlite.Conn, newID string) (Wallet, error) { if err != nil { return Wallet{}, fmt.Errorf("cannot make %s default: %w", newID, err) } - - if err := setDefaultWallet(conn, DefaultWalletKey, newID); err != nil { + if defaultWallet.Account != account { + return Wallet{}, fmt.Errorf("New default wallet id %s does not belong to account %s. Please, import that wallet first in the account", newID, account) + } + query := createSetDefaultWalletQuery(account, newID) + if err := sqlitex.Exec(conn, query, nil); err != nil { return Wallet{}, fmt.Errorf("cannot set %s as default wallet: %w", newID, err) } @@ -186,8 +228,11 @@ func RemoveWallet(conn *sqlite.Conn, id string) error { if err != nil { return fmt.Errorf("couldn't find wallet for deletion, probably already deleted") } - - defaultWallet, err := GetDefaultWallet(conn) + principal, err := blob.DbGetPublicKeyByID(conn, wallet2delete.WalletsAccount) + if err != nil { + return fmt.Errorf("Problem getting the wallet's account %s", wallet2delete.WalletsID) + } + defaultWallet, err := GetDefaultWallet(conn, core.Principal(principal).String()) if err != nil { return fmt.Errorf("couldn't get default wallet while deleting walletID %s", id) } @@ -202,24 +247,43 @@ func RemoveWallet(conn *sqlite.Conn, id string) error { //If the previously inserted was the default, then we should set a new default if defaultWallet.ID == id { - nwallets, err := getWalletCount(conn) - + newDefaultWallet, err := ListWallets(conn, core.Principal(principal).String(), 1) if err != nil { return fmt.Errorf("couldn't get wallet count") } - if nwallets.Count != 0 { - newDefaultWallet, err := ListWallets(conn, 1) + if len(newDefaultWallet) != 0 { + principal, err := core.DecodePrincipal(newDefaultWallet[0].Account) if err != nil { - return fmt.Errorf("couldn't list wallets") + return fmt.Errorf("Could not decode provided account %s: %w", newDefaultWallet[0].Account, err) } - if err = setDefaultWallet(conn, DefaultWalletKey, newDefaultWallet[0].ID); err != nil { + + query := createSetDefaultWalletQuery(core.Principal(principal).String(), newDefaultWallet[0].ID) + if err := sqlitex.Exec(conn, query, nil); err != nil { return fmt.Errorf("couldn't pick a wallet to be the new default after deleting the old one") } - } else if err = removeDefaultWallet(conn, DefaultWalletKey); err != nil { - return fmt.Errorf("couldn't remove default wallet after deleting the last one") + } else { + query := createRemoveDefaultWalletQuery(core.Principal(principal).String()) + if err := sqlitex.Exec(conn, query, nil); err != nil { + return fmt.Errorf("couldn't remove default wallet after deleting the last one") + } } } return nil } + +func createRemoveDefaultWalletQuery(account string) string { + cond := "SELECT json_remove(json((SELECT " + storage.KVValue + " FROM " + storage.T_KV + " WHERE " + storage.KVKey + "='" + DefaultWalletKey + "')),'$." + sqlitegen.Column(account) + "') FROM " + storage.T_KV + " WHERE " + storage.KVKey + " = '" + DefaultWalletKey + "'" + return "INSERT OR REPLACE INTO " + storage.T_KV + "(" + storage.KVKey.ShortName() + ", " + storage.KVValue.ShortName() + ") VALUES ('" + DefaultWalletKey + "',(" + cond.String() + "));" +} + +func createSetDefaultWalletQuery(account, walletID string) string { + cond := "CASE WHEN (SELECT json(" + storage.KVValue + ") from " + storage.T_KV + " WHERE " + storage.KVKey + "='" + DefaultWalletKey + "') IS NOT NULL THEN json_set((SELECT json(" + storage.KVValue + ") FROM " + storage.T_KV + " WHERE " + storage.KVKey + "='" + DefaultWalletKey + "'),'$." + sqlitegen.Column(account) + "','" + sqlitegen.Column(walletID) + "') ELSE json_set('{}','$." + sqlitegen.Column(account) + "','" + sqlitegen.Column(walletID) + "') END" + return "INSERT OR REPLACE INTO " + storage.T_KV + "(" + storage.KVKey.ShortName() + ", " + storage.KVValue.ShortName() + ") VALUES ('" + DefaultWalletKey + "'," + cond.String() + ");" +} + +func createGetDefaultWalletQuery(account string) string { + cond := "SELECT json_extract(json((SELECT " + storage.KVValue + " FROM " + storage.T_KV + " WHERE " + storage.KVKey + "='" + DefaultWalletKey + "')),'$." + sqlitegen.Column(account) + "') FROM " + storage.T_KV + " WHERE " + storage.KVKey + " = '" + DefaultWalletKey + "')" + return ("SELECT " + storage.WalletsID + ", " + storage.WalletsAccount + ", " + storage.WalletsAddress + ", " + storage.WalletsName + ", " + storage.WalletsType + " FROM " + sqlitegen.Column(storage.T_Wallets) + " WHERE " + storage.WalletsID + " = (" + cond + ";").String() +} diff --git a/backend/wallet/walletsql/wallet_test.go b/backend/wallet/walletsql/wallet_test.go index 2c2efab4..a9af81ea 100644 --- a/backend/wallet/walletsql/wallet_test.go +++ b/backend/wallet/walletsql/wallet_test.go @@ -10,22 +10,24 @@ import ( ) const ( - id1 = "2bd1fb78d1fbc89ea80629500b58b6f50da462b36c9fdc893776593f33cb6d46" - address1 = "https://lndhub.io" - name1 = "my LND wallet" - type1 = "LND" - balance1 int64 = 0 - - id2 = "fcbe2645d60556c3842971934ee836eec07898fa8357597c37fd86377fa95478" - address2 = "https://lndhub.io" - name2 = "my LNDHub wallet" - type2 = "LNDHUB" - balance2 int64 = 102345 - - id3 = "6e703a77440228295fb18cfaf9ca5fcb80a110354d346a6ad8525464d7cd8178" - name3 = "my LNDHub.go wallet" - type3 = "lndhub.go" - balance3 int64 = 102345 + id1 = "2bd1fb78d1fbc89ea80629500b58b6f50da462b36c9fdc893776593f33cb6d46" + account1 = "z6Mkw6sXCVij4x7RnqKfp2CB9PH7gMscFRaL8vur2vdrfopq" + address1 = "https://lndhub.io" + name1 = "my LND wallet" + type1 = "LND" + + id2 = "fcbe2645d60556c3842971934ee836eec07898fa8357597c37fd86377fa95478" + account2 = "z6MkfnTm9rs3KYGb1ZJN1R4GBNCGAk1xBojhjmfpU8RkdUnc" + address2 = "https://lndhub.io" + name2 = "my LNDHub wallet" + type2 = "LNDHUB" + + id3 = "6e703a77440228295fb18cfaf9ca5fcb80a110354d346a6ad8525464d7cd8178" + account3 = "z6MktoFgiExx97vBehL2V99Pqv1qifiWJbEdd1pUaPAib2nM" + name3 = "my LNDHub.go wallet" + type3 = "lndhub.go" + + id4 = "6e703a77440228295fb18cfaf9ca5fcb80a110354d346a6ad8525464d7cd8174" ) var ( @@ -36,7 +38,6 @@ var ( func TestQueries(t *testing.T) { pool := storage.MakeTestDB(t) - conn, release, err := pool.Conn(context.Background()) require.NoError(t, err) defer release() @@ -44,10 +45,10 @@ func TestQueries(t *testing.T) { { err = InsertWallet(conn, Wallet{ ID: id1, + Account: account1, Address: address1, Name: name1, Type: type1, - Balance: balance1, }, login, pass, nil) require.NoError(t, err) @@ -58,24 +59,29 @@ func TestQueries(t *testing.T) { require.Equal(t, address1, got.WalletsAddress) require.Equal(t, name1, got.WalletsName) require.Equal(t, strings.ToLower(type1), got.WalletsType) - require.Equal(t, balance1, got.WalletsBalance) - defaultWallet, err := GetDefaultWallet(conn) + defaultWallet, err := GetDefaultWallet(conn, account1) require.NoError(t, err) require.Equal(t, defaultWallet.ID, got.WalletsID) + defaultWallet, err = GetDefaultWallet(conn, account2) + require.Error(t, err) + err = InsertWallet(conn, Wallet{ ID: id2, + Account: account2, Address: address2, Name: name2, Type: type2, - Balance: balance2, }, login, pass, token) require.NoError(t, err) - defaultWallet, err = GetDefaultWallet(conn) + got2, err := getWallet(conn, id2) require.NoError(t, err) - require.Equal(t, defaultWallet.ID, got.WalletsID) + + defaultWallet, err = GetDefaultWallet(conn, account2) + require.NoError(t, err) + require.Equal(t, defaultWallet.ID, got2.WalletsID) got, err = getWallet(conn, id2) require.NoError(t, err) @@ -84,28 +90,42 @@ func TestQueries(t *testing.T) { require.Equal(t, address2, got.WalletsAddress) require.Equal(t, name2, got.WalletsName) require.Equal(t, strings.ToLower(type2), got.WalletsType) - require.Equal(t, balance2, got.WalletsBalance) err = InsertWallet(conn, Wallet{ ID: id2, + Account: account2, Name: name2, Type: type2, - Balance: balance2, }, login, pass, nil) require.Error(t, err) - newDefaultWallet, err := UpdateDefaultWallet(conn, id2) + _, err = UpdateDefaultWallet(conn, account1, id2) + require.Error(t, err) + + err = InsertWallet(conn, Wallet{ + ID: id4, + Account: account1, + Name: name2, + Type: type2, + }, login, pass, nil) + require.NoError(t, err) + + _, err = UpdateDefaultWallet(conn, account1, id2) + require.Error(t, err) + + newDefaultWallet, err := UpdateDefaultWallet(conn, account1, id4) require.NoError(t, err) - require.Equal(t, newDefaultWallet.ID, got.WalletsID) + + require.Equal(t, newDefaultWallet.ID, id4) nwallets, err := getWalletCount(conn) require.NoError(t, err) - require.Equal(t, int64(2), nwallets.Count) + require.Equal(t, int64(3), nwallets.Count) require.NoError(t, RemoveWallet(conn, newDefaultWallet.ID)) - defaultWallet, err = GetDefaultWallet(conn) + defaultWallet, err = GetDefaultWallet(conn, account2) require.NoError(t, err) - require.Equal(t, defaultWallet.ID, id1) + require.Equal(t, defaultWallet.ID, id2) newwallet1, err := UpdateWalletName(conn, id1, name2) require.NoError(t, err) @@ -113,18 +133,21 @@ func TestQueries(t *testing.T) { err = InsertWallet(conn, Wallet{ ID: id3, + Account: account3, Name: name3, Type: type3, - Balance: balance3, }, login, pass, token) require.NoError(t, err) - newDefaultWallet, err = UpdateDefaultWallet(conn, id3) + newDefaultWallet, err = UpdateDefaultWallet(conn, account3, id3) require.NoError(t, err) require.Equal(t, id3, newDefaultWallet.ID) nwallets, err = getWalletCount(conn) require.NoError(t, err) - require.Equal(t, int64(2), nwallets.Count) + require.Equal(t, int64(3), nwallets.Count) + require.NoError(t, RemoveWallet(conn, id1)) + require.NoError(t, RemoveWallet(conn, id2)) + require.Error(t, RemoveWallet(conn, id3)) } } diff --git a/docs/docs/build-system.md b/docs/docs/build-system.md index 20ebe379..8417fbfa 100644 --- a/docs/docs/build-system.md +++ b/docs/docs/build-system.md @@ -46,7 +46,7 @@ We generate some amount of code here, mostly for Go and JavaScript, based on the We has to implement some tricks to efficiently generate code, because our build system actually prefers to generate code at build time. If you change some file that is a source for code generation (like a Protobuf file) make sure to run `./dev gen` before committing or building: it will check if the generated code is up to date, and run the code generators if necessary. -If you create new files for code generationg, look around `BUILD.plz` files inside `proto`, `backend`, and `graphql` directories for some examples. +If you create new files for code generationg, look around `BUILD.plz` files inside `proto` and `backend` directories for some examples. You can list code generation targets with `plz query filter -i 'generated:gen'`. diff --git a/frontend/packages/shared/src/client/.generated/payments/v1alpha/invoices_connect.ts b/frontend/packages/shared/src/client/.generated/payments/v1alpha/invoices_connect.ts new file mode 100644 index 00000000..834b72b1 --- /dev/null +++ b/frontend/packages/shared/src/client/.generated/payments/v1alpha/invoices_connect.ts @@ -0,0 +1,114 @@ +// @generated by protoc-gen-connect-es v1.1.3 with parameter "target=ts,import_extension=none" +// @generated from file payments/v1alpha/invoices.proto (package com.seed.payments.v1alpha, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { CreateInvoiceRequest, GetLnAddressRequest, ListInvoicesRequest, ListInvoicesResponse, LNAddress, PayInvoiceRequest, Payreq, RequestLud6InvoiceRequest, UpdateLNAddressRequest } from "./invoices_pb"; +import { Empty, MethodKind } from "@bufbuild/protobuf"; + +/** + * Invoices service deals with invoices and payments of invoices. + * + * @generated from service com.seed.payments.v1alpha.Invoices + */ +export const Invoices = { + typeName: "com.seed.payments.v1alpha.Invoices", + methods: { + /** + * CreateInvoice creates a local invoice. Used to get paid. Typicaly + * seed users will call this remotely bc they don't know the lnaddress + * of the receiver, just their seed account. The local node, upon the + * request, issues an invoice. + * + * @generated from rpc com.seed.payments.v1alpha.Invoices.CreateInvoice + */ + createInvoice: { + name: "CreateInvoice", + I: CreateInvoiceRequest, + O: Payreq, + kind: MethodKind.Unary, + }, + /** + * PayInvoice Pays a bolt11 invoice. + * + * @generated from rpc com.seed.payments.v1alpha.Invoices.PayInvoice + */ + payInvoice: { + name: "PayInvoice", + I: PayInvoiceRequest, + O: Empty, + kind: MethodKind.Unary, + }, + /** + * PayInvoice Pays a bolt11 invoice. + * + * @generated from rpc com.seed.payments.v1alpha.Invoices.ListPaidInvoices + */ + listPaidInvoices: { + name: "ListPaidInvoices", + I: ListInvoicesRequest, + O: ListInvoicesResponse, + kind: MethodKind.Unary, + }, + /** + * PayInvoice Pays a bolt11 invoice. + * + * @generated from rpc com.seed.payments.v1alpha.Invoices.ListReceivednvoices + */ + listReceivednvoices: { + name: "ListReceivednvoices", + I: ListInvoicesRequest, + O: ListInvoicesResponse, + kind: MethodKind.Unary, + }, + } +} as const; + +/** + * LNURL service provides LNURL (https://github.com/lnurl) compatibility. + * + * @generated from service com.seed.payments.v1alpha.LNURL + */ +export const LNURL = { + typeName: "com.seed.payments.v1alpha.LNURL", + methods: { + /** + * Request an invoice following the LNURL lud6 protocol + * (https://github.com/lnurl/luds/blob/luds/06.md). This does not require the + * caller to log in anywhere. Used to pay. + * + * @generated from rpc com.seed.payments.v1alpha.LNURL.RequestLud6Invoice + */ + requestLud6Invoice: { + name: "RequestLud6Invoice", + I: RequestLud6InvoiceRequest, + O: Payreq, + kind: MethodKind.Unary, + }, + /** + * GetLnAddress gets the lnaddress (https://lightningaddress.com/) associated + * with a wallet. Not all wallets are lnaddress compatible. + * + * @generated from rpc com.seed.payments.v1alpha.LNURL.GetLnAddress + */ + getLnAddress: { + name: "GetLnAddress", + I: GetLnAddressRequest, + O: LNAddress, + kind: MethodKind.Unary, + }, + /** + * UpdateLNAddress change the lnaddress of a specific wallet. + * LNaddress must be globally unique (like email addresses). + * + * @generated from rpc com.seed.payments.v1alpha.LNURL.UpdateLNAddress + */ + updateLNAddress: { + name: "UpdateLNAddress", + I: UpdateLNAddressRequest, + O: LNAddress, + kind: MethodKind.Unary, + }, + } +} as const; + diff --git a/frontend/packages/shared/src/client/.generated/payments/v1alpha/invoices_pb.ts b/frontend/packages/shared/src/client/.generated/payments/v1alpha/invoices_pb.ts new file mode 100644 index 00000000..b83ff384 --- /dev/null +++ b/frontend/packages/shared/src/client/.generated/payments/v1alpha/invoices_pb.ts @@ -0,0 +1,618 @@ +// @generated by protoc-gen-es v1.4.1 with parameter "target=ts,import_extension=none" +// @generated from file payments/v1alpha/invoices.proto (package com.seed.payments.v1alpha, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * String representation of a bolt11 invoice payment request. + * + * @generated from message com.seed.payments.v1alpha.Payreq + */ +export class Payreq extends Message { + /** + * Bolt11 invoice payment request. + * + * @generated from field: string payreq = 1; + */ + payreq = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.Payreq"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "payreq", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Payreq { + return new Payreq().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Payreq { + return new Payreq().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Payreq { + return new Payreq().fromJsonString(jsonString, options); + } + + static equals(a: Payreq | PlainMessage | undefined, b: Payreq | PlainMessage | undefined): boolean { + return proto3.util.equals(Payreq, a, b); + } +} + +/** + * The request to create a local invoice. Used to be paid. + * + * @generated from message com.seed.payments.v1alpha.CreateInvoiceRequest + */ +export class CreateInvoiceRequest extends Message { + /** + * Optional. The account we are creating the invoice from. The default wallet + * from that account will be used to issue the invoice. If the user wants to + * select an espedific wallet, then account must be blank and the user must + * provide a wallet id. + * + * @generated from field: string account = 1; + */ + account = ""; + + /** + * Optional. In case account is not provided, the especific walletID + * to issue an invoice from. + * + * @generated from field: string id = 2; + */ + id = ""; + + /** + * Required. The amount in satoshis we want the invoice. + * + * @generated from field: int64 amount = 3; + */ + amount = protoInt64.zero; + + /** + * Optional. Description we want to include in the invoice. + * + * @generated from field: string memo = 4; + */ + memo = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.CreateInvoiceRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "account", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "amount", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 4, name: "memo", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CreateInvoiceRequest { + return new CreateInvoiceRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CreateInvoiceRequest { + return new CreateInvoiceRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CreateInvoiceRequest { + return new CreateInvoiceRequest().fromJsonString(jsonString, options); + } + + static equals(a: CreateInvoiceRequest | PlainMessage | undefined, b: CreateInvoiceRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(CreateInvoiceRequest, a, b); + } +} + +/** + * To pay an invoice + * + * @generated from message com.seed.payments.v1alpha.PayInvoiceRequest + */ +export class PayInvoiceRequest extends Message { + /** + * Required. The payment request in plaintext representing the bolt-11 invoice to be paid + * + * @generated from field: string payreq = 1; + */ + payreq = ""; + + /** + * Optional. The account used to pay this invoice. The default wallet of this account will + * be used. If not provided, then an specific wallet ID must be provided + * + * @generated from field: string account = 2; + */ + account = ""; + + /** + * Optional. Wallet id to pay the invoice with + * + * @generated from field: string id = 3; + */ + id = ""; + + /** + * Optional. Amount in satoshis to pay. This should match the amount in the invoice. + * For zero-amount invoices, the user can put whatever amount it wants. + * + * @generated from field: int64 amount = 4; + */ + amount = protoInt64.zero; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.PayInvoiceRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "payreq", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "account", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "amount", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): PayInvoiceRequest { + return new PayInvoiceRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): PayInvoiceRequest { + return new PayInvoiceRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): PayInvoiceRequest { + return new PayInvoiceRequest().fromJsonString(jsonString, options); + } + + static equals(a: PayInvoiceRequest | PlainMessage | undefined, b: PayInvoiceRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(PayInvoiceRequest, a, b); + } +} + +/** + * Request to pay. + * + * @generated from message com.seed.payments.v1alpha.RequestLud6InvoiceRequest + */ +export class RequestLud6InvoiceRequest extends Message { + /** + * Required. URL associated with the ln server. + * + * @generated from field: string URL = 1; + */ + URL = ""; + + /** + * Required. User to pay. + * + * @generated from field: string user = 2; + */ + user = ""; + + /** + * Required. Amount in satohis. + * + * @generated from field: int64 amount = 3; + */ + amount = protoInt64.zero; + + /** + * Optional. String to be attached in the invoice. + * + * @generated from field: string memo = 4; + */ + memo = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.RequestLud6InvoiceRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "URL", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "user", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "amount", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 4, name: "memo", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): RequestLud6InvoiceRequest { + return new RequestLud6InvoiceRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): RequestLud6InvoiceRequest { + return new RequestLud6InvoiceRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): RequestLud6InvoiceRequest { + return new RequestLud6InvoiceRequest().fromJsonString(jsonString, options); + } + + static equals(a: RequestLud6InvoiceRequest | PlainMessage | undefined, b: RequestLud6InvoiceRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(RequestLud6InvoiceRequest, a, b); + } +} + +/** + * Get the LNAddress of a wallet. + * + * @generated from message com.seed.payments.v1alpha.GetLnAddressRequest + */ +export class GetLnAddressRequest extends Message { + /** + * Required. The wallet ID we want to know the lnaddress from. + * + * @generated from field: string id = 1; + */ + id = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.GetLnAddressRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetLnAddressRequest { + return new GetLnAddressRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetLnAddressRequest { + return new GetLnAddressRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetLnAddressRequest { + return new GetLnAddressRequest().fromJsonString(jsonString, options); + } + + static equals(a: GetLnAddressRequest | PlainMessage | undefined, b: GetLnAddressRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(GetLnAddressRequest, a, b); + } +} + +/** + * The LNAddress of a wallet. + * + * @generated from message com.seed.payments.v1alpha.LNAddress + */ +export class LNAddress extends Message { + /** + * Required. The account we want to know the lnaddress from. + * + * @generated from field: string address = 1; + */ + address = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.LNAddress"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): LNAddress { + return new LNAddress().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): LNAddress { + return new LNAddress().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): LNAddress { + return new LNAddress().fromJsonString(jsonString, options); + } + + static equals(a: LNAddress | PlainMessage | undefined, b: LNAddress | PlainMessage | undefined): boolean { + return proto3.util.equals(LNAddress, a, b); + } +} + +/** + * Changes the lnaddress associated with a wallet. + * + * @generated from message com.seed.payments.v1alpha.UpdateLNAddressRequest + */ +export class UpdateLNAddressRequest extends Message { + /** + * Required. The wallet we want to change its lnaddress. Not all wallets + * support lnaddresses + * + * @generated from field: string id = 1; + */ + id = ""; + + /** + * Required. The nickname of the new lnadress. The resultin lnaddress would be + * @ + * + * @generated from field: string nickname = 2; + */ + nickname = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.UpdateLNAddressRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "nickname", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateLNAddressRequest { + return new UpdateLNAddressRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateLNAddressRequest { + return new UpdateLNAddressRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdateLNAddressRequest { + return new UpdateLNAddressRequest().fromJsonString(jsonString, options); + } + + static equals(a: UpdateLNAddressRequest | PlainMessage | undefined, b: UpdateLNAddressRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(UpdateLNAddressRequest, a, b); + } +} + +/** + * List all invoices that has been paid with a wallet + * + * @generated from message com.seed.payments.v1alpha.ListInvoicesRequest + */ +export class ListInvoicesRequest extends Message { + /** + * Required. The wallet id from where we want the list of paid invoices + * + * @generated from field: string id = 1; + */ + id = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.ListInvoicesRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ListInvoicesRequest { + return new ListInvoicesRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ListInvoicesRequest { + return new ListInvoicesRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ListInvoicesRequest { + return new ListInvoicesRequest().fromJsonString(jsonString, options); + } + + static equals(a: ListInvoicesRequest | PlainMessage | undefined, b: ListInvoicesRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(ListInvoicesRequest, a, b); + } +} + +/** + * Bolt11 Invoice + * + * @generated from message com.seed.payments.v1alpha.Invoice + */ +export class Invoice extends Message { + /** + * The hash of the invoice. Unique identifier of the invoice + * + * @generated from field: string payment_hash = 1; + */ + paymentHash = ""; + + /** + * The string representation of the invoice + * + * @generated from field: string payment_request = 2; + */ + paymentRequest = ""; + + /** + * The description/memo/purpose of the invoice + * + * @generated from field: string description = 3; + */ + description = ""; + + /** + * The description hash + * + * @generated from field: string description_hash = 4; + */ + descriptionHash = ""; + + /** + * The preimage revealed upon settlement. Proof of payment. + * + * @generated from field: string payment_preimage = 5; + */ + paymentPreimage = ""; + + /** + * The destination node of the payment. + * + * @generated from field: string destination = 6; + */ + destination = ""; + + /** + * The amount in satoshis of the payment. + * + * @generated from field: int64 amount = 7; + */ + amount = protoInt64.zero; + + /** + * The fees paid in satoshis. + * + * @generated from field: int64 fee = 8; + */ + fee = protoInt64.zero; + + /** + * The satus of the invoice. + * + * @generated from field: string status = 9; + */ + status = ""; + + /** + * The type of invoice. + * + * @generated from field: string type = 10; + */ + type = ""; + + /** + * Error message (if any) of the transaction. + * + * @generated from field: string error_message = 11; + */ + errorMessage = ""; + + /** + * When the invoice was settled + * + * @generated from field: string settled_at = 12; + */ + settledAt = ""; + + /** + * When the invoice expires (if unpaid). + * + * @generated from field: string expires_at = 13; + */ + expiresAt = ""; + + /** + * Whether or not the invoice has been paid. + * + * @generated from field: bool is_paid = 14; + */ + isPaid = false; + + /** + * Whether or not this is a keysed payment. + * + * @generated from field: bool keysend = 15; + */ + keysend = false; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.Invoice"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "payment_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "payment_request", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "description", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "description_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 5, name: "payment_preimage", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "destination", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 7, name: "amount", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 8, name: "fee", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 9, name: "status", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 10, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 11, name: "error_message", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 12, name: "settled_at", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 13, name: "expires_at", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 14, name: "is_paid", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 15, name: "keysend", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Invoice { + return new Invoice().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Invoice { + return new Invoice().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Invoice { + return new Invoice().fromJsonString(jsonString, options); + } + + static equals(a: Invoice | PlainMessage | undefined, b: Invoice | PlainMessage | undefined): boolean { + return proto3.util.equals(Invoice, a, b); + } +} + +/** + * List all invoices that has been paid with a wallet + * + * @generated from message com.seed.payments.v1alpha.ListInvoicesResponse + */ +export class ListInvoicesResponse extends Message { + /** + * Required. The wallet id from where we want the list of paid invoices + * + * @generated from field: repeated com.seed.payments.v1alpha.Invoice invoices = 1; + */ + invoices: Invoice[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.ListInvoicesResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "invoices", kind: "message", T: Invoice, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ListInvoicesResponse { + return new ListInvoicesResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ListInvoicesResponse { + return new ListInvoicesResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ListInvoicesResponse { + return new ListInvoicesResponse().fromJsonString(jsonString, options); + } + + static equals(a: ListInvoicesResponse | PlainMessage | undefined, b: ListInvoicesResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(ListInvoicesResponse, a, b); + } +} + diff --git a/frontend/packages/shared/src/client/.generated/payments/v1alpha/wallets_connect.ts b/frontend/packages/shared/src/client/.generated/payments/v1alpha/wallets_connect.ts new file mode 100644 index 00000000..b54c92ed --- /dev/null +++ b/frontend/packages/shared/src/client/.generated/payments/v1alpha/wallets_connect.ts @@ -0,0 +1,132 @@ +// @generated by protoc-gen-connect-es v1.1.3 with parameter "target=ts,import_extension=none" +// @generated from file payments/v1alpha/wallets.proto (package com.seed.payments.v1alpha, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { CreateWalletRequest, ExportWalletResponse, GetDefaultWalletRequest, GetWalletBalanceResponse, ImportWalletRequest, ListWalletsRequest, ListWalletsResponse, SetDefaultWalletRequest, UpdateWalletNameRequest, Wallet, WalletRequest } from "./wallets_pb"; +import { Empty, MethodKind } from "@bufbuild/protobuf"; + +/** + * @generated from service com.seed.payments.v1alpha.Wallets + */ +export const Wallets = { + typeName: "com.seed.payments.v1alpha.Wallets", + methods: { + /** + * CreateWallet Created a seed wallet based on mnemonics. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.CreateWallet + */ + createWallet: { + name: "CreateWallet", + I: CreateWalletRequest, + O: Wallet, + kind: MethodKind.Unary, + }, + /** + * RemoveWallet deletes a wallet locally. It can be later imported + * with the necessary credentials and no funds will be lost. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.RemoveWallet + */ + removeWallet: { + name: "RemoveWallet", + I: WalletRequest, + O: Empty, + kind: MethodKind.Unary, + }, + /** + * ImportWallet Imports a 3rd party (compatible) wallet with credentials. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.ImportWallet + */ + importWallet: { + name: "ImportWallet", + I: ImportWalletRequest, + O: Wallet, + kind: MethodKind.Unary, + }, + /** + * ExportWallet Export the wallet credentials so they can be imported and + * used with a 3rd party compatible app. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.ExportWallet + */ + exportWallet: { + name: "ExportWallet", + I: WalletRequest, + O: ExportWalletResponse, + kind: MethodKind.Unary, + }, + /** + * ListWallets lists all available wallets for the account. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.GetWalletBalance + */ + getWalletBalance: { + name: "GetWalletBalance", + I: WalletRequest, + O: GetWalletBalanceResponse, + kind: MethodKind.Unary, + }, + /** + * ListWallets lists all available wallets for the account. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.ListWallets + */ + listWallets: { + name: "ListWallets", + I: ListWalletsRequest, + O: ListWalletsResponse, + kind: MethodKind.Unary, + }, + /** + * GetWallet gets a specific wallet. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.GetWallet + */ + getWallet: { + name: "GetWallet", + I: WalletRequest, + O: Wallet, + kind: MethodKind.Unary, + }, + /** + * UpdateWalletName changes the name of the wallet. This does not have any + * implications on payments. Name is just for user convenience. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.UpdateWalletName + */ + updateWalletName: { + name: "UpdateWalletName", + I: UpdateWalletNameRequest, + O: Wallet, + kind: MethodKind.Unary, + }, + /** + * GetDefaultWallet returns the default wallet where payments are going + * to be collected at. Also, this wallet will be used to make payments. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.GetDefaultWallet + */ + getDefaultWallet: { + name: "GetDefaultWallet", + I: GetDefaultWalletRequest, + O: Wallet, + kind: MethodKind.Unary, + }, + /** + * SetDefaultWallet changes the default wallet where payments are going + * to be collected at. Also, this wallet will be used to make payments. + * + * @generated from rpc com.seed.payments.v1alpha.Wallets.SetDefaultWallet + */ + setDefaultWallet: { + name: "SetDefaultWallet", + I: SetDefaultWalletRequest, + O: Wallet, + kind: MethodKind.Unary, + }, + } +} as const; + diff --git a/frontend/packages/shared/src/client/.generated/payments/v1alpha/wallets_pb.ts b/frontend/packages/shared/src/client/.generated/payments/v1alpha/wallets_pb.ts new file mode 100644 index 00000000..c4524cac --- /dev/null +++ b/frontend/packages/shared/src/client/.generated/payments/v1alpha/wallets_pb.ts @@ -0,0 +1,532 @@ +// @generated by protoc-gen-es v1.4.1 with parameter "target=ts,import_extension=none" +// @generated from file payments/v1alpha/wallets.proto (package com.seed.payments.v1alpha, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * Representation of a wallet + * + * @generated from message com.seed.payments.v1alpha.Wallet + */ +export class Wallet extends Message { + /** + * Unique wallet identificator. Automatically generated. Unique across accounts. + * + * @generated from field: string id = 1; + */ + id = ""; + + /** + * The account this wallet belongs to. + * + * @generated from field: string account = 2; + */ + account = ""; + + /** + * Address of the LND node backing up this wallet. In case lndhub, this will be the + * URL to connect via rest api. In case LND wallet, this will be the gRPC address. + * + * @generated from field: string address = 3; + */ + address = ""; + + /** + * The name of the wallet. + * + * @generated from field: string name = 4; + */ + name = ""; + + /** + * The type of the wallet. + * + * @generated from field: string type = 5; + */ + type = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.Wallet"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "account", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 5, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Wallet { + return new Wallet().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Wallet { + return new Wallet().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Wallet { + return new Wallet().fromJsonString(jsonString, options); + } + + static equals(a: Wallet | PlainMessage | undefined, b: Wallet | PlainMessage | undefined): boolean { + return proto3.util.equals(Wallet, a, b); + } +} + +/** + * The request to create a wallet. + * + * @generated from message com.seed.payments.v1alpha.CreateWalletRequest + */ +export class CreateWalletRequest extends Message { + /** + * Required. The account we are creating the wallet to. + * + * @generated from field: string account = 1; + */ + account = ""; + + /** + * Required. Name of the wallet to be created. + * + * @generated from field: string name = 2; + */ + name = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.CreateWalletRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "account", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CreateWalletRequest { + return new CreateWalletRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CreateWalletRequest { + return new CreateWalletRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CreateWalletRequest { + return new CreateWalletRequest().fromJsonString(jsonString, options); + } + + static equals(a: CreateWalletRequest | PlainMessage | undefined, b: CreateWalletRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(CreateWalletRequest, a, b); + } +} + +/** + * The request to import a wallet. + * + * @generated from message com.seed.payments.v1alpha.ImportWalletRequest + */ +export class ImportWalletRequest extends Message { + /** + * Required. The credentials to insert the new wallet in the format of + * ://:@https:// + * + * @generated from field: string credentials_url = 1; + */ + credentialsUrl = ""; + + /** + * Required. Account where this wallet will belong to. + * + * @generated from field: string account = 2; + */ + account = ""; + + /** + * Required. The wallet name to be displayed. + * + * @generated from field: string name = 3; + */ + name = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.ImportWalletRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "credentials_url", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "account", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ImportWalletRequest { + return new ImportWalletRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ImportWalletRequest { + return new ImportWalletRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ImportWalletRequest { + return new ImportWalletRequest().fromJsonString(jsonString, options); + } + + static equals(a: ImportWalletRequest | PlainMessage | undefined, b: ImportWalletRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(ImportWalletRequest, a, b); + } +} + +/** + * Exported credentials. + * + * @generated from message com.seed.payments.v1alpha.ExportWalletResponse + */ +export class ExportWalletResponse extends Message { + /** + * The credentials url to be used with a compatible 3rd party app. + * + * @generated from field: string credentials = 1; + */ + credentials = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.ExportWalletResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "credentials", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ExportWalletResponse { + return new ExportWalletResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ExportWalletResponse { + return new ExportWalletResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ExportWalletResponse { + return new ExportWalletResponse().fromJsonString(jsonString, options); + } + + static equals(a: ExportWalletResponse | PlainMessage | undefined, b: ExportWalletResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(ExportWalletResponse, a, b); + } +} + +/** + * The request to get an lndhub wallet. + * + * @generated from message com.seed.payments.v1alpha.WalletRequest + */ +export class WalletRequest extends Message { + /** + * Required. Id of the wallet to operate with + * + * @generated from field: string id = 1; + */ + id = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.WalletRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WalletRequest { + return new WalletRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WalletRequest { + return new WalletRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WalletRequest { + return new WalletRequest().fromJsonString(jsonString, options); + } + + static equals(a: WalletRequest | PlainMessage | undefined, b: WalletRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(WalletRequest, a, b); + } +} + +/** + * The wallet's balance in satohis. + * + * @generated from message com.seed.payments.v1alpha.GetWalletBalanceResponse + */ +export class GetWalletBalanceResponse extends Message { + /** + * The wallet's balance in satohis. + * + * @generated from field: uint64 balance = 1; + */ + balance = protoInt64.zero; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.GetWalletBalanceResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "balance", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetWalletBalanceResponse { + return new GetWalletBalanceResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetWalletBalanceResponse { + return new GetWalletBalanceResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetWalletBalanceResponse { + return new GetWalletBalanceResponse().fromJsonString(jsonString, options); + } + + static equals(a: GetWalletBalanceResponse | PlainMessage | undefined, b: GetWalletBalanceResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(GetWalletBalanceResponse, a, b); + } +} + +/** + * The request to list all wallets under a certain account. + * + * @generated from message com.seed.payments.v1alpha.ListWalletsRequest + */ +export class ListWalletsRequest extends Message { + /** + * Required. Account to list wallets from. + * + * @generated from field: string account = 1; + */ + account = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.ListWalletsRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "account", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ListWalletsRequest { + return new ListWalletsRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ListWalletsRequest { + return new ListWalletsRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ListWalletsRequest { + return new ListWalletsRequest().fromJsonString(jsonString, options); + } + + static equals(a: ListWalletsRequest | PlainMessage | undefined, b: ListWalletsRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(ListWalletsRequest, a, b); + } +} + +/** + * All the wallets under a certain account. + * + * @generated from message com.seed.payments.v1alpha.ListWalletsResponse + */ +export class ListWalletsResponse extends Message { + /** + * Wallets under the account. + * + * @generated from field: repeated com.seed.payments.v1alpha.Wallet wallets = 1; + */ + wallets: Wallet[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.ListWalletsResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "wallets", kind: "message", T: Wallet, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ListWalletsResponse { + return new ListWalletsResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ListWalletsResponse { + return new ListWalletsResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ListWalletsResponse { + return new ListWalletsResponse().fromJsonString(jsonString, options); + } + + static equals(a: ListWalletsResponse | PlainMessage | undefined, b: ListWalletsResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(ListWalletsResponse, a, b); + } +} + +/** + * The request to update a wallet + * + * @generated from message com.seed.payments.v1alpha.UpdateWalletNameRequest + */ +export class UpdateWalletNameRequest extends Message { + /** + * Required. The wallet id to be modified. + * + * @generated from field: string id = 1; + */ + id = ""; + + /** + * Required. The new wallet's name. + * + * @generated from field: string name = 2; + */ + name = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.UpdateWalletNameRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateWalletNameRequest { + return new UpdateWalletNameRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateWalletNameRequest { + return new UpdateWalletNameRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdateWalletNameRequest { + return new UpdateWalletNameRequest().fromJsonString(jsonString, options); + } + + static equals(a: UpdateWalletNameRequest | PlainMessage | undefined, b: UpdateWalletNameRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(UpdateWalletNameRequest, a, b); + } +} + +/** + * Gets the account's default wallet. + * + * @generated from message com.seed.payments.v1alpha.GetDefaultWalletRequest + */ +export class GetDefaultWalletRequest extends Message { + /** + * @generated from field: string account = 1; + */ + account = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.GetDefaultWalletRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "account", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetDefaultWalletRequest { + return new GetDefaultWalletRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetDefaultWalletRequest { + return new GetDefaultWalletRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetDefaultWalletRequest { + return new GetDefaultWalletRequest().fromJsonString(jsonString, options); + } + + static equals(a: GetDefaultWalletRequest | PlainMessage | undefined, b: GetDefaultWalletRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(GetDefaultWalletRequest, a, b); + } +} + +/** + * Sets the default wallet used for payments. + * + * @generated from message com.seed.payments.v1alpha.SetDefaultWalletRequest + */ +export class SetDefaultWalletRequest extends Message { + /** + * Required. The wallet id to set as default. + * + * @generated from field: string id = 1; + */ + id = ""; + + /** + * Required. The account the provided wallet is going to + * be the default. + * + * @generated from field: string account = 2; + */ + account = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "com.seed.payments.v1alpha.SetDefaultWalletRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "account", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): SetDefaultWalletRequest { + return new SetDefaultWalletRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): SetDefaultWalletRequest { + return new SetDefaultWalletRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): SetDefaultWalletRequest { + return new SetDefaultWalletRequest().fromJsonString(jsonString, options); + } + + static equals(a: SetDefaultWalletRequest | PlainMessage | undefined, b: SetDefaultWalletRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(SetDefaultWalletRequest, a, b); + } +} + diff --git a/graphql/BUILD.plz b/graphql/BUILD.plz deleted file mode 100644 index b4536b2a..00000000 --- a/graphql/BUILD.plz +++ /dev/null @@ -1,46 +0,0 @@ -subinclude("//build/rules/codegen:defs") - -# Generates Go code from the GraphQL schema -# using the gqlgen tool. -generated( - name = "go", - srcs = [ - "gqlgen.yml", - "schema.graphql", - ], - outs = [ - "exec.go", - "models_gen.go", - ], - cmd = """ -export GOROOT="$($TOOLS_GO env GOROOT)" -export PATH="$PATH:${GOROOT%/share/go}/bin" -cd $PKG -$TOOLS_GQLGEN generate -""", - out_dir = "//backend/graphql/internal/generated", - tools = [ - "//build/nix:go", - "//build/tools:gqlgen", - ], -) - -# Generates TypeScript code from the GraphQL schema. -generated( - name = "js", - srcs = [ - "codegen.yml", - "schema.graphql", - ], - outs = [ - "types.ts", - ], - cmd = """ -cd $PKG -$TOOLS_GRAPHQL_CODEGEN -""", - out_dir = "//frontend/packages/shared/src/client/.generated", - tools = [ - "//build/tools:graphql-codegen", - ], -) diff --git a/graphql/README.md b/graphql/README.md deleted file mode 100644 index 80936e04..00000000 --- a/graphql/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Seed Daemon GraphQL API - -This is the schema of the GraphQL API exposed by the Seed Daemon. - -It contains some Go-specific directives, and eventually we might want to split -the schema into different files, so it's easier to work with. - -Eventually we'd probably want to do some transformation to strip away some -directives, or even generate some types on the fly and what not, which could -make the final schema easier to consume by clients, generate documentation, etc. - -## Play Around - -On the configured HTTP port the Daemon exposes two routes: - -1. `/playground` - the GraphQL Playground UI. Useful to test the API in the - browser. -2. `/graphql` - the actual API endpoint for GraphQL. - -## Typescript Codegen - -Based on the [GraphQL Schema](./schema.graphql) we generate all the Typescript -Types using -[graphql-codegen](https://github.com/dotansimha/graphql-code-generator). - -The above command generates a `types.d.ts` file in -`frontend/packages/shared/src/client/.generated` (checkout -[codegen.yml](../codegen.yml) for more info about the config.) - -### Additional Resources - -- https://egghead.io/lessons/graphql-generate-typescript-types-from-a-graphql-schema -- https://github.com/dotansimha/graphql-code-generator diff --git a/graphql/codegen.yml b/graphql/codegen.yml deleted file mode 100644 index 3af8f0a9..00000000 --- a/graphql/codegen.yml +++ /dev/null @@ -1,11 +0,0 @@ -# This is a configuration file for graphql-codegen tool that generates TypeScript -# code based on the GraphQL schema. - -overwrite: true -schema: - - ./schema.graphql - -generates: - ../frontend/packages/shared/src/client/.generated/types.ts: - plugins: - - typescript diff --git a/graphql/go.gensum b/graphql/go.gensum deleted file mode 100644 index 5b370cf8..00000000 --- a/graphql/go.gensum +++ /dev/null @@ -1,2 +0,0 @@ -srcs: 27f484e64af30a4b201129948eaed8dd -outs: bdbe446475e51033b3128884a4f526b4 diff --git a/graphql/gqlgen.yml b/graphql/gqlgen.yml deleted file mode 100644 index dccc9e40..00000000 --- a/graphql/gqlgen.yml +++ /dev/null @@ -1,52 +0,0 @@ -# This is a configuration file for github.com/99designs/gqlgen. -# It generates Go code based on the GraphQL schema. - -# Where are all the schema files located? globs are supported eg src/**/*.graphqls -schema: - - ./schema.graphql - -# Where should the generated server code go? -exec: - filename: ../backend/graphql/internal/generated/exec.go - package: generated - -# Where should any generated models go? -model: - filename: ../backend/graphql/internal/generated/models_gen.go - package: generated - -# Where should the resolver implementations go? -resolver: - layout: follow-schema - dir: ../backend/graphql/internal/resolver - package: resolver - -struct_tag: json - -omit_slice_element_pointers: true - -# Optional: set to speed up generation time by not performing a final validation pass. -# skip_validation: true - -# gqlgen will search for any type names in the schema in these go packages -# if they match it will use them, otherwise it will generate them. -autobind: - - 'seed/backend/graphql/internal/model' - -# This section declares type mapping between the GraphQL and go type systems -# -# The first line in each type will be used as defaults for resolver arguments and -# modelgen, the others will be allowed when binding to fields. Configure them to -# your liking -models: - ID: - model: - - github.com/99designs/gqlgen/graphql.ID - - github.com/99designs/gqlgen/graphql.Int - - github.com/99designs/gqlgen/graphql.Int64 - - github.com/99designs/gqlgen/graphql.Int32 - Int: - model: - - github.com/99designs/gqlgen/graphql.Int - - github.com/99designs/gqlgen/graphql.Int64 - - github.com/99designs/gqlgen/graphql.Int32 diff --git a/graphql/js.gensum b/graphql/js.gensum deleted file mode 100644 index f52d1fa0..00000000 --- a/graphql/js.gensum +++ /dev/null @@ -1,2 +0,0 @@ -srcs: b2ee36fcdb779faf8c36b395c4df9531 -outs: b0acd071beb6a00048c3d4d23caa0f43 diff --git a/graphql/schema.graphql b/graphql/schema.graphql deleted file mode 100644 index 74912f99..00000000 --- a/graphql/schema.graphql +++ /dev/null @@ -1,439 +0,0 @@ -""" -Built-in directive for Go's gqlgen library. -""" -directive @goModel( - model: String - models: [String!] -) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION - -""" -Built-in directive for Go's gqlgen library. -""" -directive @goField( - forceResolver: Boolean - name: String -) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION - -""" -Lightning Network payment request encoded as a string. -Ready to be encoded as a QR code for wallets to scan and pay. -""" -scalar LightningPaymentRequest - -""" -Bitcoin amount in sats. -Should be interpreted as a large-enough unsigned integer type. -""" -scalar Satoshis - -""" -Top-level queries. -""" -type Query { - """ - Information about the current user. - """ - me: Me! - - """ - Information about payments. - """ - payments( - walletID: ID! - excludeUnpaid: Boolean - excludeKeysend: Boolean - excludeExpired: Boolean - ): Payments! -} - -""" -Information about the current user. -""" -type Me { - """ - List configured Lightning wallets. - """ - wallets: [LightningWallet!] @goField(forceResolver: true) - - """ - Account-wide Lightning addres (lnaddress) - """ - lnaddress: String @goField(forceResolver: true) -} - -""" -Information about payments -""" -type Payments { - """ - Payments made. They can be unconfirmed - """ - sent: [Invoice] - """ - Payments received. They can be unconfirmed - """ - received: [Invoice] -} - -""" -Top-level mutations. -""" -type Mutation { - """ - Set an existing wallet to be the default one. Initially, the first configured wallet - automatically becomes the default one. - """ - setDefaultWallet(input: SetDefaultWalletInput!): SetDefaultWalletPayload! - - """ - Update existing wallet. - """ - updateWallet(input: UpdateWalletInput!): UpdateWalletPayload! - - """ - Delete existing wallet. - """ - deleteWallet(input: DeleteWalletInput!): DeleteWalletPayload! - - """ - Export wallet to use it with an external application. - """ - exportWallet(input: ExportWalletInput!): ExportWalletPayload! - - """ - Import wallet to use it in seed. - """ - importWallet(input: ImportWalletInput!): ImportWalletPayload! - - """ - Request an invoice from a user. The user can be either a Seed Account ID or a ln address. - """ - requestInvoice(input: RequestInvoiceInput!): RequestInvoicePayload! - - """ - Pay invoice with a previously configured wallet. - """ - payInvoice(input: PayInvoiceInput!): PayInvoicePayload! - - """ - Update lnaddress' nickname. - """ - updateNickname(input: UpdateNicknameInput!): UpdateNicknamePayload! -} - -""" -Input for setting the default wallet. -""" -input SetDefaultWalletInput { - """ - ID of the wallet to become the default one. - """ - id: ID! -} - -""" -Response after setting default wallet. -""" -type SetDefaultWalletPayload { - """ - The new default wallet. - """ - wallet: LightningWallet! -} - -""" -Input to update Lightning wallets. -""" -input UpdateWalletInput { - """ - ID of the wallet to be updated. - """ - id: ID! - - """ - New name for the wallet. - """ - name: String! -} - -""" -Response with the updated wallet. -""" -type UpdateWalletPayload { - """ - Updated wallet. - """ - wallet: LightningWallet! -} - -""" -Input to delete a wallet. -""" -input DeleteWalletInput { - """ - ID of the wallet to be deleted. - """ - id: ID! -} - -""" -Response after deleting a wallet. -""" -type DeleteWalletPayload { - """ - ID of the deleted wallet. - """ - id: ID! -} - -""" -Input to export a wallet. -""" -input ExportWalletInput { - """ - ID of the wallet to be exported. If empty, the built-in wallet will be exported. - """ - id: ID! -} - -""" -Response after exporting a wallet. -""" -type ExportWalletPayload { - """ - credentials of the exported wallet. - """ - credentials: String! -} - - -""" -Input to export a wallet. -""" -input ImportWalletInput { - """ - Local name for this wallet. - """ - name: String! - - """ - Credential string to connect to imported wallet service. - """ - url: String! -} - -""" -Response after exporting a wallet. -""" -type ImportWalletPayload { - """ - Stored wallet. - """ - wallet: LightningWallet! -} - -""" -Input for requesting an invoice. -""" -input RequestInvoiceInput { - """ - Seed Account ID or lnaddress we want the invoice from. Can be ourselves. - """ - user: String! - - """ - Amount in Satoshis the invoice should be created for. - """ - amountSats: Satoshis! - - """ - Optional description for the invoice. - """ - memo: String -} - -""" -Response with the invoice to pay. -""" -type RequestInvoicePayload { - """ - Payment request is a string-encoded Lightning Network Payment Request. - It's ready to be used in a wallet app to pay. - """ - paymentRequest: LightningPaymentRequest! -} - -""" -Input to pay an invoice. -""" -input PayInvoiceInput { - """ - Previously obtained payment request we want to pay for. - """ - paymentRequest: LightningPaymentRequest! - - """ - Optional amount in satoshis to pay. In case this is not defined, - The amount showed in the invoice will be paid. If amountSats is - provided, then the invoice amount will be override. This will cause - an error unless both amounts are the same or the invoice amount is 0. - """ - amountSats: Satoshis - - """ - Optional ID of the wallet to pay with. Otherwise the default one will be used. - """ - walletID: ID -} - -""" -Response after paying an invoice. -""" -type PayInvoicePayload { - """ - Wallet ID that was used to pay the invoice. - """ - walletID: ID! -} - -""" -Input to update lnaddress' nickname. -""" -input UpdateNicknameInput { - """ - New nickname to update. - """ - nickname: String! -} - -""" -Response after updating the nickname. -""" -type UpdateNicknamePayload { - """ - Updated Nickname. - """ - nickname: String! -} - -""" -Common interface for Lightning wallets. We support different types. -""" -interface LightningWallet { - """ - Globally unique ID of the wallet. Public key. - """ - id: ID! - - """ - Local-only name of the wallet. For user's convenience. - """ - name: String! - - """ - Balance in Satoshis. - """ - balanceSats: Satoshis! - - """ - If this wallet is the default wallet to send/receive automatic payments - """ - isDefault: Boolean! -} - -""" -Lightning wallet compatible with LndHub. -""" -type LndHubWallet implements LightningWallet { - """ - Globally unique ID of the wallet. Since this type of wallet doesn't have unique addresses - we decided to use the cryptographic hash of the credentials URL as an ID. - """ - id: ID! - - """ - URL of the LndHub server this wallet is connected to. - """ - apiURL: String! - - """ - Name of the wallet. - """ - name: String! - - """ - Balance in Satoshis. - """ - balanceSats: Satoshis! - - """ - If this wallet is the default wallet to send/receive automatic payments - """ - isDefault: Boolean! -} - -""" -Lightning Invoices -""" -type Invoice { - """ - Preimage hash of the payment. - """ - PaymentHash: String - """ - Bolt-11 encoded invoice. - """ - PaymentRequest: String - """ - Memo field of the invoice. - """ - Description: String - """ - Memo hash in case its too long - """ - DescriptionHash: String - """ - Invoice secret known at settlement. Proof of payment - """ - PaymentPreimage: String - """ - Payee lightning node ID. - """ - Destination: String - """ - Invoice quantity in satoshis. - """ - Amount: Satoshis! - """ - Fees incurred by the payer when paying the invoice - """ - Fee: Satoshis - """ - Status of the invoice. (Settled, in-flight, expired, ...) - """ - Status: String - """ - Invoice tyoe - """ - Type: String - """ - Error of the invoice - """ - ErrorMessage: String - """ - Settlement date - """ - SettledAt: String - """ - Expiring date. - """ - ExpiresAt: String - """ - If the invoice has been paid or not. - """ - IsPaid: Boolean - """ - Whether or not this is a made up invoice corrensponding with a keysend payment - """ - Keysend: Boolean -} diff --git a/proto/p2p/v1alpha/go.gensum b/proto/p2p/v1alpha/go.gensum index aa37bff3..6eb66e2a 100644 --- a/proto/p2p/v1alpha/go.gensum +++ b/proto/p2p/v1alpha/go.gensum @@ -1,2 +1,2 @@ -srcs: 03712aac78ed2b19699e26ddf9f6fbbd -outs: a54b248c2fcd8a9945be770fff300dc3 +srcs: 54e96b9b1f20d169a4ddd6b69b5b501e +outs: dc12a9edc7a4a83b30f2ae55ee8a4bc4 diff --git a/proto/p2p/v1alpha/p2p.proto b/proto/p2p/v1alpha/p2p.proto index 05558b89..be43f294 100644 --- a/proto/p2p/v1alpha/p2p.proto +++ b/proto/p2p/v1alpha/p2p.proto @@ -42,14 +42,17 @@ message RequestInvoiceRequest { // The invoice amount in satoshis int64 amount_sats = 1; + // Required. The account we request this invoice from + string account = 2; + // Optional requested memo to be attached in the invoice - string memo = 2; + string memo = 3; // True to request a hold invoice instead of a regular one. If true, then preimage_hash should be filled - bool hold_invoice = 3; + bool hold_invoice = 4; // Preimage hash of the requested hold invoice. If hold_invoice is set to false this field is skipped - bytes preimage_hash = 4; + bytes preimage_hash = 5; } // Request invoice response diff --git a/proto/payments/v1alpha/BUILD.plz b/proto/payments/v1alpha/BUILD.plz new file mode 100644 index 00000000..e36594c8 --- /dev/null +++ b/proto/payments/v1alpha/BUILD.plz @@ -0,0 +1,9 @@ +subinclude("//build/rules/seed:defs") + +mtt_proto_codegen( + srcs = glob(["*.proto"]), + languages = [ + "go", + "js", + ], +) diff --git a/proto/payments/v1alpha/go.gensum b/proto/payments/v1alpha/go.gensum new file mode 100644 index 00000000..45344e4f --- /dev/null +++ b/proto/payments/v1alpha/go.gensum @@ -0,0 +1,2 @@ +srcs: af26ed34bae8cb124dfa183ff780d460 +outs: dc65c778793d3980e490d2cac0292148 diff --git a/proto/payments/v1alpha/invoices.proto b/proto/payments/v1alpha/invoices.proto new file mode 100644 index 00000000..f25c8368 --- /dev/null +++ b/proto/payments/v1alpha/invoices.proto @@ -0,0 +1,182 @@ +syntax = "proto3"; + +package com.seed.payments.v1alpha; + +import "google/protobuf/empty.proto"; + +option go_package = "seed/backend/genproto/payments/v1alpha;payments"; + +// Invoices service deals with invoices and payments of invoices. +service Invoices { + // CreateInvoice creates a local invoice. Used to get paid. Typicaly + // seed users will call this remotely bc they don't know the lnaddress + // of the receiver, just their seed account. The local node, upon the + // request, issues an invoice. + rpc CreateInvoice(CreateInvoiceRequest) returns (Payreq); + + // PayInvoice Pays a bolt11 invoice. + rpc PayInvoice(PayInvoiceRequest) returns (google.protobuf.Empty); + + // PayInvoice Pays a bolt11 invoice. + rpc ListPaidInvoices(ListInvoicesRequest) returns (ListInvoicesResponse); + + // PayInvoice Pays a bolt11 invoice. + rpc ListReceivednvoices(ListInvoicesRequest) returns (ListInvoicesResponse); + +} + +// LNURL service provides LNURL (https://github.com/lnurl) compatibility. +service LNURL { + // Request an invoice following the LNURL lud6 protocol + // (https://github.com/lnurl/luds/blob/luds/06.md). This does not require the + // caller to log in anywhere. Used to pay. + rpc RequestLud6Invoice(RequestLud6InvoiceRequest) returns (Payreq); + + // GetLnAddress gets the lnaddress (https://lightningaddress.com/) associated + // with a wallet. Not all wallets are lnaddress compatible. + rpc GetLnAddress(GetLnAddressRequest) returns (LNAddress); + + // UpdateLNAddress change the lnaddress of a specific wallet. + // LNaddress must be globally unique (like email addresses). + rpc UpdateLNAddress(UpdateLNAddressRequest) returns (LNAddress); +} + +// String representation of a bolt11 invoice payment request. +message Payreq{ + // Bolt11 invoice payment request. + string payreq = 1; +} + +// The request to create a local invoice. Used to be paid. +message CreateInvoiceRequest { + // Optional. The account we are creating the invoice from. The default wallet + // from that account will be used to issue the invoice. If the user wants to + // select an espedific wallet, then account must be blank and the user must + // provide a wallet id. + string account = 1; + + // Optional. In case account is not provided, the especific walletID + // to issue an invoice from. + string id = 2; + + // Required. The amount in satoshis we want the invoice. + int64 amount = 3; + + // Optional. Description we want to include in the invoice. + string memo = 4; +} + +// To pay an invoice +message PayInvoiceRequest { + // Required. The payment request in plaintext representing the bolt-11 invoice to be paid + string payreq = 1; + + // Optional. The account used to pay this invoice. The default wallet of this account will + // be used. If not provided, then an specific wallet ID must be provided + string account = 2; + + // Optional. Wallet id to pay the invoice with + string id = 3; + + // Optional. Amount in satoshis to pay. This should match the amount in the invoice. + // For zero-amount invoices, the user can put whatever amount it wants. + int64 amount = 4; +} + +// Request to pay. +message RequestLud6InvoiceRequest { + // Required. URL associated with the ln server. + string URL = 1; + + // Required. User to pay. + string user = 2; + + // Required. Amount in satohis. + int64 amount = 3; + + // Optional. String to be attached in the invoice. + string memo = 4; +} + +// Get the LNAddress of a wallet. +message GetLnAddressRequest { + // Required. The wallet ID we want to know the lnaddress from. + string id = 1; +} + +// The LNAddress of a wallet. +message LNAddress { + // Required. The account we want to know the lnaddress from. + string address = 1; +} + +// Changes the lnaddress associated with a wallet. +message UpdateLNAddressRequest { + // Required. The wallet we want to change its lnaddress. Not all wallets + // support lnaddresses + string id = 1; + + // Required. The nickname of the new lnadress. The resultin lnaddress would be + // @ + string nickname = 2; +} + +// List all invoices that has been paid with a wallet +message ListInvoicesRequest { + // Required. The wallet id from where we want the list of paid invoices + string id = 1; +} + +// Bolt11 Invoice +message Invoice{ + // The hash of the invoice. Unique identifier of the invoice + string payment_hash = 1; + + // The string representation of the invoice + string payment_request = 2; + + // The description/memo/purpose of the invoice + string description = 3; + + // The description hash + string description_hash = 4; + + // The preimage revealed upon settlement. Proof of payment. + string payment_preimage = 5; + + // The destination node of the payment. + string destination = 6; + + // The amount in satoshis of the payment. + int64 amount = 7; + + // The fees paid in satoshis. + int64 fee = 8; + + // The satus of the invoice. + string status = 9; + + // The type of invoice. + string type = 10; + + // Error message (if any) of the transaction. + string error_message = 11; + + // When the invoice was settled + string settled_at = 12; + + // When the invoice expires (if unpaid). + string expires_at = 13; + + // Whether or not the invoice has been paid. + bool is_paid = 14; + + // Whether or not this is a keysed payment. + bool keysend = 15; +} + +// List all invoices that has been paid with a wallet +message ListInvoicesResponse { + // Required. The wallet id from where we want the list of paid invoices + repeated Invoice invoices = 1; +} \ No newline at end of file diff --git a/proto/payments/v1alpha/js.gensum b/proto/payments/v1alpha/js.gensum new file mode 100644 index 00000000..c51e92f4 --- /dev/null +++ b/proto/payments/v1alpha/js.gensum @@ -0,0 +1,2 @@ +srcs: af26ed34bae8cb124dfa183ff780d460 +outs: 4731f48a176008a1c5e06c891e231987 diff --git a/proto/payments/v1alpha/wallets.proto b/proto/payments/v1alpha/wallets.proto new file mode 100644 index 00000000..978ee1e7 --- /dev/null +++ b/proto/payments/v1alpha/wallets.proto @@ -0,0 +1,143 @@ +syntax = "proto3"; + +package com.seed.payments.v1alpha; + +import "google/protobuf/empty.proto"; + +option go_package = "seed/backend/genproto/payments/v1alpha;payments"; + +// Wallet service provides wallet management functionality. + +service Wallets { + // CreateWallet Created a seed wallet based on mnemonics. + rpc CreateWallet(CreateWalletRequest) returns (Wallet); + + // RemoveWallet deletes a wallet locally. It can be later imported + // with the necessary credentials and no funds will be lost. + rpc RemoveWallet(WalletRequest) returns (google.protobuf.Empty); + + // ImportWallet Imports a 3rd party (compatible) wallet with credentials. + rpc ImportWallet(ImportWalletRequest) returns (Wallet); + + // ExportWallet Export the wallet credentials so they can be imported and + // used with a 3rd party compatible app. + rpc ExportWallet(WalletRequest) returns (ExportWalletResponse); + + // ListWallets lists all available wallets for the account. + rpc GetWalletBalance(WalletRequest) returns (GetWalletBalanceResponse); + + // ListWallets lists all available wallets for the account. + rpc ListWallets(ListWalletsRequest) returns (ListWalletsResponse); + + // GetWallet gets a specific wallet. + rpc GetWallet(WalletRequest) returns (Wallet); + + // UpdateWalletName changes the name of the wallet. This does not have any + // implications on payments. Name is just for user convenience. + rpc UpdateWalletName(UpdateWalletNameRequest) returns (Wallet); + + // GetDefaultWallet returns the default wallet where payments are going + // to be collected at. Also, this wallet will be used to make payments. + rpc GetDefaultWallet(GetDefaultWalletRequest) returns (Wallet); + + // SetDefaultWallet changes the default wallet where payments are going + // to be collected at. Also, this wallet will be used to make payments. + rpc SetDefaultWallet(SetDefaultWalletRequest) returns (Wallet); +} + + +// Representation of a wallet +message Wallet { + // Unique wallet identificator. Automatically generated. Unique across accounts. + string id = 1; + + // The account this wallet belongs to. + string account = 2; + + // Address of the LND node backing up this wallet. In case lndhub, this will be the + // URL to connect via rest api. In case LND wallet, this will be the gRPC address. + string address = 3; + + // The name of the wallet. + string name = 4; + + // The type of the wallet. + string type = 5; +} + +// The request to create a wallet. +message CreateWalletRequest { + // Required. The account we are creating the wallet to. + string account = 1; + + // Required. Name of the wallet to be created. + string name = 2; +} + +// The request to import a wallet. +message ImportWalletRequest { + // Required. The credentials to insert the new wallet in the format of + // ://:@https:// + string credentials_url = 1; + + // Required. Account where this wallet will belong to. + string account = 2; + + // Required. The wallet name to be displayed. + string name = 3; +} + +// Exported credentials. +message ExportWalletResponse{ + // The credentials url to be used with a compatible 3rd party app. + string credentials = 1; +} + +// The request to get an lndhub wallet. +message WalletRequest { + // Required. Id of the wallet to operate with + string id = 1; +} + +// The wallet's balance in satohis. +message GetWalletBalanceResponse { + // The wallet's balance in satohis. + uint64 balance = 1; +} + +// The request to list all wallets under a certain account. +message ListWalletsRequest { + // Required. Account to list wallets from. + string account = 1; +} + +// All the wallets under a certain account. +message ListWalletsResponse { + // Wallets under the account. + repeated Wallet wallets = 1; +} + +// The request to update a wallet +message UpdateWalletNameRequest { + // Required. The wallet id to be modified. + string id = 1; + + // Required. The new wallet's name. + string name = 2; +} + +// Gets the account's default wallet. +message GetDefaultWalletRequest { + string account = 1; +} + +// Sets the default wallet used for payments. +message SetDefaultWalletRequest { + // Required. The wallet id to set as default. + string id = 1; + + // Required. The account the provided wallet is going to + // be the default. + string account = 2; +} +