Skip to content

Commit

Permalink
feat(SPV-805): adjust code to new spv-wallet-go-client (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 authored May 24, 2024
1 parent 37c879a commit 3710bdf
Show file tree
Hide file tree
Showing 18 changed files with 1,153 additions and 312 deletions.
486 changes: 398 additions & 88 deletions docs/docs.go

Large diffs are not rendered by default.

486 changes: 398 additions & 88 deletions docs/swagger.json

Large diffs are not rendered by default.

348 changes: 278 additions & 70 deletions docs/swagger.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion domain/config/config_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *ConfigService) makePublicConfig(shared *models.SharedConfig) *PublicCon
}

return &PublicConfig{
PaymilDomain: configuredPaymailDomain,
PaymailDomain: configuredPaymailDomain,
ExperimentalFeatures: shared.ExperimentalFeatures,
}
}
2 changes: 1 addition & 1 deletion domain/config/public_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package config

// PublicConfig represents a config that is exposed to the public.
type PublicConfig struct {
PaymilDomain string `json:"paymail_domain"`
PaymailDomain string `json:"paymail_domain"`
ExperimentalFeatures map[string]bool `json:"experimental_features"`
}
2 changes: 1 addition & 1 deletion domain/contacts/contacts_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (s *ContactsService) ConfirmContact(ctx context.Context, xPriv string, cont
return userWalletClient.ConfirmContact(ctx, contact, passcode, requesterPaymail, getConfPeriod(), getConfDigits())
}

func (s *ContactsService) GetContacts(ctx context.Context, accessKey string, conditions map[string]interface{}, metadata *models.Metadata, queryParams *walletclient.QueryParams) ([]*models.Contact, error) {
func (s *ContactsService) GetContacts(ctx context.Context, accessKey string, conditions map[string]interface{}, metadata *models.Metadata, queryParams *walletclient.QueryParams) (*models.SearchContactsResponse, error) {
userWalletClient, err := s.walletClientFactory.CreateWithAccessKey(accessKey)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion domain/transactions/transactions_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (s *TransactionService) GetTransaction(accessKey, id, userPaymail string) (
}

// GetTransactions returns transactions by access key.
func (s *TransactionService) GetTransactions(accessKey, userPaymail string, queryParam walletclient.QueryParams) (*PaginatedTransactions, error) {
func (s *TransactionService) GetTransactions(accessKey, userPaymail string, queryParam *walletclient.QueryParams) (*PaginatedTransactions, error) {
// Try to generate user-client with decrypted xpriv.
userWalletClient, err := s.walletClientFactory.CreateWithAccessKey(accessKey)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions domain/users/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type (
GetXPub() (PubKey, error)
// Transaction methods
SendToRecipients(recipients []*walletclient.Recipients, senderPaymail string) (Transaction, error)
GetTransactions(queryParam walletclient.QueryParams, userPaymail string) ([]Transaction, error)
GetTransactions(queryParam *walletclient.QueryParams, userPaymail string) ([]Transaction, error)
GetTransaction(transactionId, userPaymail string) (FullTransaction, error)
GetTransactionsCount() (int64, error)
CreateAndFinalizeTransaction(recipients []*walletclient.Recipients, metadata *models.Metadata) (DraftTransaction, error)
Expand All @@ -75,7 +75,7 @@ type (
AcceptContact(ctx context.Context, paymail string) walletclient.ResponseError
RejectContact(ctx context.Context, paymail string) walletclient.ResponseError
ConfirmContact(ctx context.Context, contact *models.Contact, passcode, requesterPaymail string, period, digits uint) walletclient.ResponseError
GetContacts(ctx context.Context, conditions map[string]interface{}, metadata *models.Metadata, queryParams *walletclient.QueryParams) ([]*models.Contact, walletclient.ResponseError)
GetContacts(ctx context.Context, conditions map[string]interface{}, metadata *models.Metadata, queryParams *walletclient.QueryParams) (*models.SearchContactsResponse, walletclient.ResponseError)
GenerateTotpForContact(contact *models.Contact, period, digits uint) (string, error)
}

Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.21.5

require (
github.com/avast/retry-go/v4 v4.5.1
github.com/bitcoin-sv/spv-wallet-go-client v1.0.0-beta.2.0.20240517103917-ab378a15bfea
github.com/bitcoin-sv/spv-wallet/models v1.0.0-beta.4
github.com/bitcoin-sv/spv-wallet-go-client v1.0.0-beta.3
github.com/bitcoin-sv/spv-wallet/models v1.0.0-beta.6
github.com/brianvoe/gofakeit/v6 v6.28.0
github.com/centrifugal/centrifuge v0.31.0
github.com/gin-contrib/sessions v0.0.5
Expand All @@ -28,7 +28,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitcoinschema/go-bitcoin/v2 v2.0.5 // indirect
github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173 // indirect
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
github.com/boombuler/barcode v1.0.1 // indirect
github.com/bytedance/sonic v1.11.2 // indirect
github.com/centrifugal/protocol v0.12.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down Expand Up @@ -80,7 +80,7 @@ require (
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
Expand All @@ -102,8 +102,8 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
27 changes: 12 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh
github.com/avast/retry-go/v4 v4.5.1/go.mod h1:/sipNsvNB3RRuT5iNcb6h73nw3IBmXJ/H3XrCQYSOpc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bitcoin-sv/spv-wallet-go-client v0.9.0 h1:ncSEaFsCcTYWN4toD5BvVQ8rTdIeNpYCH1DCZZO3VqE=
github.com/bitcoin-sv/spv-wallet-go-client v0.9.0/go.mod h1:thz4lwT/Sx1ag5o0IWhMcQoGobt26wemKRgx5uL/7V8=
github.com/bitcoin-sv/spv-wallet-go-client v1.0.0-beta.2.0.20240517103917-ab378a15bfea h1:4+O9v+bJA7vr7Zct2xUKCRTtCpfzJFtTZNVZeRkWx0c=
github.com/bitcoin-sv/spv-wallet-go-client v1.0.0-beta.2.0.20240517103917-ab378a15bfea/go.mod h1:ZcQGjwMZDkRsjuZpK4gYZPWxtMpJVXNBnetwClyXKPc=
github.com/bitcoin-sv/spv-wallet/models v0.24.0 h1:cIfi2noDfRWaFt0VMOECwF8H9OsJFdP0T03XK4BULe0=
github.com/bitcoin-sv/spv-wallet/models v0.24.0/go.mod h1:P8vXF1mPg1Zh3xSvB9yqwuPJfOR8Tt/SAG2FYztwENI=
github.com/bitcoin-sv/spv-wallet/models v1.0.0-beta.4 h1:fACGH8VLz3iiwBLeI091Tz05xmvUlXgpX/UPR0gYHlA=
github.com/bitcoin-sv/spv-wallet/models v1.0.0-beta.4/go.mod h1:i3txysriHpprqYd3u97wEQsC4/jn+KHcyFOmuFYMw8M=
github.com/bitcoin-sv/spv-wallet-go-client v1.0.0-beta.3 h1:QmRcfQ5PHfUUfL0yquDzU1s4hJmrH0PeMnPPVVTvMzw=
github.com/bitcoin-sv/spv-wallet-go-client v1.0.0-beta.3/go.mod h1:hNy5mUafqIPnHUkGi/LblVM+t6dck8MNblvV7zhvJWQ=
github.com/bitcoin-sv/spv-wallet/models v1.0.0-beta.6 h1:KKWtlfhqQ9fdza+ZZ5YraPy3KTqJq/hRhAuJTDDTLfQ=
github.com/bitcoin-sv/spv-wallet/models v1.0.0-beta.6/go.mod h1:i3txysriHpprqYd3u97wEQsC4/jn+KHcyFOmuFYMw8M=
github.com/bitcoinschema/go-bitcoin/v2 v2.0.5 h1:Sgh5Eb746Zck/46rFDrZZEXZWyO53fMuWYhNoZa1tck=
github.com/bitcoinschema/go-bitcoin/v2 v2.0.5/go.mod h1:JjO1ivfZv6vhK0uAXzyH08AAHlzNMAfnyK1Fiv9r4ZA=
github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173 h1:2yTIV9u7H0BhRDGXH5xrAwAz7XibWJtX2dNezMeNsUo=
github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173/go.mod h1:BZ1UcC9+tmcDEcdVXgpt13hMczwJxWzpAn68wNs7zRA=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyXcs=
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4=
github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
Expand Down Expand Up @@ -252,8 +249,8 @@ golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
Expand Down Expand Up @@ -286,17 +283,17 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
Expand Down
6 changes: 3 additions & 3 deletions tests/mocks/users_interfaces_mq.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions transports/http/endpoints/api/config/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"github.com/bitcoin-sv/spv-wallet-web-backend/domain"
"github.com/bitcoin-sv/spv-wallet-web-backend/domain/config"
router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes"
"github.com/gin-gonic/gin"
)
Expand All @@ -10,6 +11,9 @@ type handler struct {
services *domain.Services
}

// PublicConfig is used for swagger generation
type PublicConfig = config.PublicConfig

// NewHandler creates new endpoint handler.
func NewHandler(s *domain.Services) router.RootEndpoints {
return &handler{
Expand Down
12 changes: 6 additions & 6 deletions transports/http/endpoints/api/contacts/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (h *handler) RegisterApiEndpoints(router *gin.RouterGroup) {
user.PATCH("/accepted/:paymail", h.acceptContact)
user.PATCH("/rejected/:paymail", h.rejectContact)
user.PATCH("/confirmed", h.confirmContact)
user.GET("/search", h.getContacts)
user.POST("/search", h.getContacts)
user.POST("/totp", h.generateTotp)
}

Expand All @@ -42,8 +42,8 @@ func (h *handler) RegisterApiEndpoints(router *gin.RouterGroup) {
// @Summary Get all contacts.
// @Tags contact
// @Produce json
// @Success 200 {object} []models.Contact
// @Router /api/v1/contacts/search [get]
// @Success 200 {object} models.SearchContactsResponse
// @Router /api/v1/contacts/search [POST]
// @Param data body SearchContact true "Conditions for filtering contacts"
func (h *handler) getContacts(c *gin.Context) {
var req SearchContact
Expand All @@ -54,15 +54,15 @@ func (h *handler) getContacts(c *gin.Context) {
return
}

// Get user transactions.
txs, err := h.cService.GetContacts(c.Request.Context(), c.GetString(auth.SessionAccessKey), req.Conditions, &req.Metadata, nil)
// Get user contacts.
paginatedContacts, err := h.cService.GetContacts(c.Request.Context(), c.GetString(auth.SessionAccessKey), req.Conditions, &req.Metadata, req.QueryParams)
if err != nil {
h.log.Error().Msgf("An error occurred while trying to get a list of contacts: %s", err)
c.JSON(http.StatusInternalServerError, "An error occurred while trying to get a list of contacts")
return
}

c.JSON(http.StatusOK, txs)
c.JSON(http.StatusOK, paginatedContacts)
}

// Upsert contact.
Expand Down
10 changes: 7 additions & 3 deletions transports/http/endpoints/api/contacts/model.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package contacts

import "github.com/bitcoin-sv/spv-wallet/models"
import (
walletclient "github.com/bitcoin-sv/spv-wallet-go-client"
"github.com/bitcoin-sv/spv-wallet/models"
)

// UpsertContact represents a request for creating or updating new contact.
type UpsertContact struct {
Expand All @@ -9,8 +12,9 @@ type UpsertContact struct {
}

type SearchContact struct {
Conditions map[string]interface{} `json:"conditions,omitempty"`
Metadata models.Metadata `json:"metadata,omitempty"`
Conditions map[string]interface{} `json:"conditions,omitempty"`
Metadata models.Metadata `json:"metadata,omitempty"`
QueryParams *walletclient.QueryParams `json:"params,omitempty"`
}

// ConfirmContact represents a request for confirming a contact.
Expand Down
43 changes: 20 additions & 23 deletions transports/http/endpoints/api/transactions/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/bitcoin-sv/spv-wallet-web-backend/notification"
"github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/auth"
router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes"
"github.com/bitcoin-sv/spv-wallet-web-backend/transports/spvwallet"
"github.com/bitcoin-sv/spv-wallet-web-backend/transports/websocket"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog"
Expand All @@ -23,6 +24,9 @@ type handler struct {
ws websocket.Server
}

// FullTransaction is used for swagger generation
type FullTransaction = spvwallet.FullTransaction

// NewHandler creates new endpoint handler.
func NewHandler(s *domain.Services, log *zerolog.Logger, ws websocket.Server) router.ApiEndpoints {
return &handler{
Expand All @@ -37,8 +41,8 @@ func NewHandler(s *domain.Services, log *zerolog.Logger, ws websocket.Server) ro
func (h *handler) RegisterApiEndpoints(router *gin.RouterGroup) {
user := router.Group("/transaction")
{
user.GET("", h.getTransactions)
user.POST("", h.createTransaction)
user.POST("/search", h.getTransactions)
user.GET("/:id", h.getTransaction)
}
}
Expand All @@ -48,33 +52,26 @@ func (h *handler) RegisterApiEndpoints(router *gin.RouterGroup) {
// @Summary Get all transactions.
// @Tags transaction
// @Produce json
// @Success 200 {object} []spvwallet.Transaction
// @Router /api/v1/transaction [get]
// @Success 200 {object} transactions.PaginatedTransactions
// @Router /api/v1/transaction/search [post]
func (h *handler) getTransactions(c *gin.Context) {
page := c.Query("page")
pageSize := c.Query("page_size")
orderBy := c.Query("order")
sort := c.Query("sort")

pageNumber, err := strconv.Atoi(page)
var req SearchTransaction
err := c.Bind(&req)
if err != nil {
pageNumber = 1
}

pageSizeNumber, err := strconv.Atoi(pageSize)
if err != nil {
pageSizeNumber = 10
h.log.Error().Msgf("Invalid payload: %s", err)
c.JSON(http.StatusBadRequest, "Invalid request. Please check conditions and metadata")
return
}

queryParam := walletclient.QueryParams{
Page: pageNumber,
PageSize: pageSizeNumber,
OrderByField: orderBy,
SortDirection: sort,
if req.QueryParams == nil {
req.QueryParams = &walletclient.QueryParams{
Page: 1,
PageSize: 10,
}
}

// Get user transactions.
txs, err := h.tService.GetTransactions(c.GetString(auth.SessionAccessKey), c.GetString(auth.SessionUserPaymail), queryParam)
txs, err := h.tService.GetTransactions(c.GetString(auth.SessionAccessKey), c.GetString(auth.SessionUserPaymail), req.QueryParams)
if err != nil {
h.log.Error().Msgf("An error occurred while trying to get a list of transactions: %s", err)
c.JSON(http.StatusInternalServerError, "An error occurred while trying to get a list of transactions")
Expand All @@ -89,7 +86,7 @@ func (h *handler) getTransactions(c *gin.Context) {
// @Summary Get transaction by id.
// @Tags transaction
// @Produce json
// @Success 200 {object} spvwallet.FullTransaction
// @Success 200 {object} FullTransaction
// @Router /api/v1/transaction/{id} [get]
// @Param id path string true "Transaction id"
func (h *handler) getTransaction(c *gin.Context) {
Expand All @@ -111,7 +108,7 @@ func (h *handler) getTransaction(c *gin.Context) {
// @Summary Create transaction.
// @Tags transaction
// @Produce json
// @Success 200 {object} spvwallet.FullTransaction
// @Success 200 {object} FullTransaction
// @Router /api/v1/transaction [post]
// @Param data body CreateTransaction true "Create transaction data"
func (h *handler) createTransaction(c *gin.Context) {
Expand Down
11 changes: 11 additions & 0 deletions transports/http/endpoints/api/transactions/model.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
package transactions

import (
walletclient "github.com/bitcoin-sv/spv-wallet-go-client"
"github.com/bitcoin-sv/spv-wallet/models"
)

// CreateTransaction represents request for creating new transaction.
type CreateTransaction struct {
Password string `json:"password"`
Recipient string `json:"recipient"`
Satoshis uint64 `json:"satoshis"`
}

type SearchTransaction struct {
Conditions map[string]interface{} `json:"conditions,omitempty"`
Metadata models.Metadata `json:"metadata,omitempty"`
QueryParams *walletclient.QueryParams `json:"params,omitempty"`
}
Loading

0 comments on commit 3710bdf

Please sign in to comment.