From 1194719f1586f8d6bc946415b3e18bc8a11156d7 Mon Sep 17 00:00:00 2001 From: chris-4chain <152964795+chris-4chain@users.noreply.github.com> Date: Fri, 10 May 2024 09:00:13 +0200 Subject: [PATCH] feat(SPV-729) filters (#569) * feat(SPV-729): filter for access_keys * feat(SPV-729): just maps instead of *maps for conditions * feat(SPV-729): filters for admin endpoints - partial * feat(SPV-729): filters for UTXOs * feat(SPV-729): filters for paymails * feat(SPV-729): filters for xpubs * feat(SPV-729): filter fileds with camelCase json names * feat(SPV-729): linter * feat(SPV-729): unnecessary commented-out code block * feat(SPV-729): update a comment * feat(SPV-729): some filter fileds only for admin * feat(SPV-729): examples for the fields * fix(SPV-729): paymail filter test * feat(SPV-729): regenerated swagger * feat(SPV-729): swagger descriptions and fixes * feat(SPV-729): swagger after branch update --- actions/access_keys/count.go | 19 +- actions/access_keys/models.go | 12 +- actions/access_keys/search.go | 28 +- actions/admin/access_keys.go | 40 +- actions/admin/contact.go | 15 +- actions/admin/destinations.go | 40 +- actions/admin/models.go | 38 +- actions/admin/paymail_addresses.go | 39 +- actions/admin/transactions.go | 40 +- actions/admin/utxos.go | 44 +- actions/admin/xpubs.go | 43 +- actions/common/search_models.go | 2 +- actions/contacts/models.go | 5 + actions/contacts/search.go | 26 +- actions/destinations/count.go | 2 +- actions/destinations/search.go | 2 +- actions/methods.go | 51 - actions/transactions/count.go | 2 +- actions/transactions/search.go | 2 +- actions/utxos/count.go | 19 +- actions/utxos/models.go | 15 +- actions/utxos/search.go | 17 +- docs/docs.go | 1365 ++++++++++++++++++---- docs/swagger.json | 1365 ++++++++++++++++++---- docs/swagger.yaml | 1006 +++++++++++++--- engine/action_access_key.go | 8 +- engine/action_contact.go | 5 +- engine/action_destination.go | 4 +- engine/action_draft_transaction.go | 4 +- engine/action_paymails.go | 10 +- engine/action_transaction.go | 12 +- engine/action_transaction_test.go | 4 +- engine/action_utxo.go | 6 +- engine/action_xpub.go | 4 +- engine/admin_actions_stats.go | 2 +- engine/client_datastore.go | 34 +- engine/datastore/client.go | 10 +- engine/datastore/client_options.go | 2 +- engine/datastore/interface.go | 2 +- engine/datastore/mongodb.go | 38 +- engine/datastore/mongodb_test.go | 28 +- engine/interface.go | 36 +- engine/model_access_keys.go | 12 +- engine/model_contact.go | 4 +- engine/model_destinations.go | 4 +- engine/model_draft_transactions.go | 6 +- engine/model_get.go | 18 +- engine/model_paymail_addresses.go | 4 +- engine/model_utxos.go | 10 +- engine/model_xpubs.go | 4 +- engine/tx_repository.go | 6 +- models/filter/access_key_filter.go | 36 + models/filter/access_key_filter_test.go | 73 ++ models/filter/contact_filter.go | 18 +- models/filter/destination_filter.go | 4 +- models/filter/destination_filter_test.go | 12 +- models/filter/model_filter.go | 11 +- models/filter/paymail_filter.go | 26 + models/filter/paymail_filter_test.go | 63 + models/filter/transaction_filter.go | 16 +- models/filter/transaction_filter_test.go | 8 +- models/filter/utils.go | 43 +- models/filter/utxo_filter.go | 58 + models/filter/utxo_filter_test.go | 65 ++ models/filter/xpub_filter.go | 20 + models/filter/xpub_filter_test.go | 50 + 66 files changed, 3952 insertions(+), 1065 deletions(-) create mode 100644 models/filter/access_key_filter.go create mode 100644 models/filter/access_key_filter_test.go create mode 100644 models/filter/paymail_filter.go create mode 100644 models/filter/paymail_filter_test.go create mode 100644 models/filter/utxo_filter.go create mode 100644 models/filter/utxo_filter_test.go create mode 100644 models/filter/xpub_filter.go create mode 100644 models/filter/xpub_filter_test.go diff --git a/actions/access_keys/count.go b/actions/access_keys/count.go index 94b9ed25d..b833c432b 100644 --- a/actions/access_keys/count.go +++ b/actions/access_keys/count.go @@ -3,7 +3,6 @@ package accesskeys import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" "github.com/bitcoin-sv/spv-wallet/server/auth" "github.com/gin-gonic/gin" ) @@ -14,28 +13,28 @@ import ( // @Description Count of access keys // @Tags Access-key // @Produce json -// @Param CountRequestParameters body actions.CountRequestParameters false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountAccessKeys body CountAccessKeys false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of access keys" -// @Failure 400 "Bad request - Error while parsing CountRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing CountAccessKeys from request body" // @Failure 500 "Internal Server Error - Error while fetching count of access keys" // @Router /v1/access-key/count [post] // @Security x-auth-xpub func (a *Action) count(c *gin.Context) { reqXPubID := c.GetString(auth.ParamXPubHashKey) - metadata, conditions, err := actions.GetCountQueryParameters(c) - if err != nil { + var reqParams CountAccessKeys + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var count int64 - if count, err = a.Services.SpvWalletEngine.GetAccessKeysByXPubIDCount( + count, err := a.Services.SpvWalletEngine.GetAccessKeysByXPubIDCount( c.Request.Context(), reqXPubID, - metadata, - conditions, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } diff --git a/actions/access_keys/models.go b/actions/access_keys/models.go index 91e7c61e9..ec6c28dfe 100644 --- a/actions/access_keys/models.go +++ b/actions/access_keys/models.go @@ -1,9 +1,19 @@ package accesskeys -import "github.com/bitcoin-sv/spv-wallet/engine" +import ( + "github.com/bitcoin-sv/spv-wallet/actions/common" + "github.com/bitcoin-sv/spv-wallet/engine" + "github.com/bitcoin-sv/spv-wallet/models/filter" +) // CreateAccessKey is the model for creating an access key type CreateAccessKey struct { // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` } + +// SearchAccessKeys is a model for handling searching with filters and metadata +type SearchAccessKeys = common.SearchModel[filter.AccessKeyFilter] + +// CountAccessKeys is a model for handling counting filtered access keys +type CountAccessKeys = common.ConditionsModel[filter.AccessKeyFilter] diff --git a/actions/access_keys/search.go b/actions/access_keys/search.go index 198994423..d094c2880 100644 --- a/actions/access_keys/search.go +++ b/actions/access_keys/search.go @@ -3,8 +3,6 @@ package accesskeys import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" - "github.com/bitcoin-sv/spv-wallet/engine" "github.com/bitcoin-sv/spv-wallet/mappings" "github.com/bitcoin-sv/spv-wallet/models" "github.com/bitcoin-sv/spv-wallet/server/auth" @@ -17,35 +15,29 @@ import ( // @Description Search access key // @Tags Access-key // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchAccessKeys body SearchAccessKeys false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.AccessKey "List of access keys" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while SearchAccessKeys from request body" // @Failure 500 "Internal server error - Error while searching for access keys" // @Router /v1/access-key/search [post] // @Security x-auth-xpub func (a *Action) search(c *gin.Context) { reqXPubID := c.GetString(auth.ParamXPubHashKey) - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) - if err != nil { + var reqParams SearchAccessKeys + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - dbConditions := make(map[string]interface{}) - if conditions != nil { - dbConditions = *conditions - } - dbConditions["xpub_id"] = reqXPubID - - var accessKeys []*engine.AccessKey - if accessKeys, err = a.Services.SpvWalletEngine.GetAccessKeysByXPubID( + accessKeys, err := a.Services.SpvWalletEngine.GetAccessKeysByXPubID( c.Request.Context(), reqXPubID, - metadata, - &dbConditions, - queryParams, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + reqParams.QueryParams, + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } diff --git a/actions/admin/access_keys.go b/actions/admin/access_keys.go index ebb572853..cee5389ca 100644 --- a/actions/admin/access_keys.go +++ b/actions/admin/access_keys.go @@ -3,8 +3,6 @@ package admin import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" - "github.com/bitcoin-sv/spv-wallet/engine" "github.com/bitcoin-sv/spv-wallet/mappings" "github.com/bitcoin-sv/spv-wallet/models" "github.com/gin-gonic/gin" @@ -16,26 +14,26 @@ import ( // @Description Access Keys Search // @Tags Admin // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchAccessKeys body SearchAccessKeys false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.AccessKey "List of access keys" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchAccessKeys from request body" // @Failure 500 "Internal server error - Error while searching for access keys" // @Router /v1/admin/access-keys/search [post] // @Security x-auth-xpub func (a *Action) accessKeysSearch(c *gin.Context) { - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) - if err != nil { + var reqParams SearchAccessKeys + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var accessKeys []*engine.AccessKey - if accessKeys, err = a.Services.SpvWalletEngine.GetAccessKeys( + accessKeys, err := a.Services.SpvWalletEngine.GetAccessKeys( c.Request.Context(), - metadata, - conditions, - queryParams, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + reqParams.QueryParams, + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } @@ -54,25 +52,25 @@ func (a *Action) accessKeysSearch(c *gin.Context) { // @Description Access Keys Count // @Tags Admin // @Produce json -// @Param CountRequestParameters body actions.CountRequestParameters false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountAccessKeys body CountAccessKeys false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of access keys" -// @Failure 400 "Bad request - Error while parsing CountRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing CountAccessKeys from request body" // @Failure 500 "Internal Server Error - Error while fetching count of access keys" // @Router /v1/admin/access-keys/count [post] // @Security x-auth-xpub func (a *Action) accessKeysCount(c *gin.Context) { - metadata, conditions, err := actions.GetCountQueryParameters(c) - if err != nil { + var reqParams CountAccessKeys + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var count int64 - if count, err = a.Services.SpvWalletEngine.GetAccessKeysCount( + count, err := a.Services.SpvWalletEngine.GetAccessKeysCount( c.Request.Context(), - metadata, - conditions, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } diff --git a/actions/admin/contact.go b/actions/admin/contact.go index ed871e221..f6040f43d 100644 --- a/actions/admin/contact.go +++ b/actions/admin/contact.go @@ -15,24 +15,30 @@ import ( // @Description Search for contacts // @Tags Admin // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchContacts body SearchContacts false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Contact "List of contacts" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchContacts from request body" // @Failure 500 "Internal server error - Error while searching for contacts" // @Router /v1/admin/contact/search [post] // @Security x-auth-xpub func (a *Action) contactsSearch(c *gin.Context) { - var reqParams SearchTransactions + var reqParams SearchContacts if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } + conditions, err := reqParams.Conditions.ToDbConditions() + if err != nil { + c.JSON(http.StatusBadRequest, err.Error()) + return + } + // Record a new transaction (get the hex from parameters)a contacts, err := a.Services.SpvWalletEngine.GetContacts( c.Request.Context(), reqParams.Metadata, - reqParams.Conditions.ToDbConditions(), + conditions, reqParams.QueryParams, ) if err != nil { @@ -75,7 +81,6 @@ func (a *Action) contactsUpdate(c *gin.Context) { reqParams.FullName, &reqParams.Metadata, ) - if err != nil { handleErrors(err, c) return diff --git a/actions/admin/destinations.go b/actions/admin/destinations.go index d63e55e88..daee77b22 100644 --- a/actions/admin/destinations.go +++ b/actions/admin/destinations.go @@ -3,8 +3,6 @@ package admin import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" - "github.com/bitcoin-sv/spv-wallet/engine" "github.com/bitcoin-sv/spv-wallet/mappings" "github.com/bitcoin-sv/spv-wallet/models" "github.com/gin-gonic/gin" @@ -16,26 +14,26 @@ import ( // @Description Search for destinations // @Tags Admin // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchDestinations body SearchDestinations false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Destination "List of destinations" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchDestinations from request body" // @Failure 500 "Internal server error - Error while searching for destinations" // @Router /v1/admin/destinations/search [post] // @Security x-auth-xpub func (a *Action) destinationsSearch(c *gin.Context) { - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) - if err != nil { + var reqParams SearchDestinations + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var destinations []*engine.Destination - if destinations, err = a.Services.SpvWalletEngine.GetDestinations( + destinations, err := a.Services.SpvWalletEngine.GetDestinations( c.Request.Context(), - metadata, - conditions, - queryParams, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + reqParams.QueryParams, + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } @@ -54,24 +52,24 @@ func (a *Action) destinationsSearch(c *gin.Context) { // @Description Count destinations // @Tags Admin // @Produce json -// @Param CountRequestParameters body actions.CountRequestParameters false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountDestinations body CountDestinations false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of destinations" -// @Failure 400 "Bad request - Error while parsing CountRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing CountDestinations from request body" // @Failure 500 "Internal Server Error - Error while fetching count of destinations" // @Security x-auth-xpub func (a *Action) destinationsCount(c *gin.Context) { - metadata, conditions, err := actions.GetCountQueryParameters(c) - if err != nil { + var reqParams CountDestinations + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var count int64 - if count, err = a.Services.SpvWalletEngine.GetDestinationsCount( + count, err := a.Services.SpvWalletEngine.GetDestinationsCount( c.Request.Context(), - metadata, - conditions, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } diff --git a/actions/admin/models.go b/actions/admin/models.go index aca241ddc..83ff185b2 100644 --- a/actions/admin/models.go +++ b/actions/admin/models.go @@ -48,5 +48,41 @@ type UpdateContact struct { FullName string `json:"fullName" example:"John Doe"` } +// SearchContacts is a model for handling searching with filters and metadata +type SearchContacts = common.SearchModel[filter.ContactFilter] + +// SearchAccessKeys is a model for handling searching with filters and metadata +type SearchAccessKeys = common.SearchModel[filter.AdminAccessKeyFilter] + +// CountAccessKeys is a model for handling counting filtered transactions +type CountAccessKeys = common.ConditionsModel[filter.AdminAccessKeyFilter] + +// SearchDestinations is a model for handling searching with filters and metadata +type SearchDestinations = common.SearchModel[filter.DestinationFilter] + +// CountDestinations is a model for handling counting filtered destinations +type CountDestinations = common.ConditionsModel[filter.DestinationFilter] + // SearchTransactions is a model for handling searching with filters and metadata -type SearchTransactions = common.SearchModel[filter.ContactFilter] +type SearchTransactions = common.SearchModel[filter.TransactionFilter] + +// CountTransactions is a model for handling counting filtered transactions +type CountTransactions = common.ConditionsModel[filter.TransactionFilter] + +// SearchUtxos is a model for handling searching with filters and metadata +type SearchUtxos = common.SearchModel[filter.AdminUtxoFilter] + +// CountUtxos is a model for handling counting filtered UTXOs +type CountUtxos = common.ConditionsModel[filter.AdminUtxoFilter] + +// SearchPaymails is a model for handling searching with filters and metadata +type SearchPaymails = common.SearchModel[filter.AdminPaymailFilter] + +// CountPaymails is a model for handling counting filtered paymails +type CountPaymails = common.ConditionsModel[filter.AdminPaymailFilter] + +// SearchXpubs is a model for handling searching with filters and metadata +type SearchXpubs = common.SearchModel[filter.XpubFilter] + +// CountXpubs is a model for handling counting filtered xPubs +type CountXpubs = common.ConditionsModel[filter.XpubFilter] diff --git a/actions/admin/paymail_addresses.go b/actions/admin/paymail_addresses.go index f47048187..35b9b7f4d 100644 --- a/actions/admin/paymail_addresses.go +++ b/actions/admin/paymail_addresses.go @@ -3,7 +3,6 @@ package admin import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" "github.com/bitcoin-sv/spv-wallet/engine" "github.com/bitcoin-sv/spv-wallet/mappings" "github.com/bitcoin-sv/spv-wallet/models" @@ -54,26 +53,26 @@ func (a *Action) paymailGetAddress(c *gin.Context) { // @Description Paymail addresses search // @Tags Admin // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchPaymails body SearchPaymails false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.PaymailAddress "List of paymail addresses -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchPaymails from request body" // @Failure 500 "Internal server error - Error while searching for paymail addresses" // @Router /v1/admin/paymails/search [post] // @Security x-auth-xpub func (a *Action) paymailAddressesSearch(c *gin.Context) { - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) - if err != nil { + var reqParams SearchPaymails + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var paymailAddresses []*engine.PaymailAddress - if paymailAddresses, err = a.Services.SpvWalletEngine.GetPaymailAddresses( + paymailAddresses, err := a.Services.SpvWalletEngine.GetPaymailAddresses( c.Request.Context(), - metadata, - conditions, - queryParams, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + reqParams.QueryParams, + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } @@ -92,25 +91,25 @@ func (a *Action) paymailAddressesSearch(c *gin.Context) { // @Description Paymail addresses count // @Tags Admin // @Produce json -// @Param CountRequestParameters body actions.CountRequestParameters false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountPaymails body CountPaymails false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of paymail addresses" -// @Failure 400 "Bad request - Error while parsing CountRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing CountPaymails from request body" // @Failure 500 "Internal Server Error - Error while fetching count of paymail addresses" // @Router /v1/admin/paymails/count [post] // @Security x-auth-xpub func (a *Action) paymailAddressesCount(c *gin.Context) { - metadata, conditions, err := actions.GetCountQueryParameters(c) - if err != nil { + var reqParams CountPaymails + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var count int64 - if count, err = a.Services.SpvWalletEngine.GetPaymailAddressesCount( + count, err := a.Services.SpvWalletEngine.GetPaymailAddressesCount( c.Request.Context(), - metadata, - conditions, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } diff --git a/actions/admin/transactions.go b/actions/admin/transactions.go index 927145ee1..9b3a03d4d 100644 --- a/actions/admin/transactions.go +++ b/actions/admin/transactions.go @@ -3,8 +3,6 @@ package admin import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" - "github.com/bitcoin-sv/spv-wallet/engine" "github.com/bitcoin-sv/spv-wallet/mappings" "github.com/bitcoin-sv/spv-wallet/models" "github.com/gin-gonic/gin" @@ -16,26 +14,26 @@ import ( // @Description Search for transactions // @Tags Admin // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchTransactions body SearchTransactions false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Transaction "List of transactions" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchTransactions from request body" // @Failure 500 "Internal server error - Error while searching for transactions" // @Router /v1/admin/transactions/search [post] // @Security x-auth-xpub func (a *Action) transactionsSearch(c *gin.Context) { - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) - if err != nil { + var reqParams SearchTransactions + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var transactions []*engine.Transaction - if transactions, err = a.Services.SpvWalletEngine.GetTransactions( + transactions, err := a.Services.SpvWalletEngine.GetTransactions( c.Request.Context(), - metadata, - conditions, - queryParams, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + reqParams.QueryParams, + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } @@ -54,25 +52,25 @@ func (a *Action) transactionsSearch(c *gin.Context) { // @Description Count transactions // @Tags Admin // @Produce json -// @Param CountRequestParameters body actions.CountRequestParameters false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountTransactions body CountTransactions false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of transactions" -// @Failure 400 "Bad request - Error while parsing CountRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing CountTransactions from request body" // @Failure 500 "Internal Server Error - Error while fetching count of transactions" // @Router /v1/admin/transactions/count [post] // @Security x-auth-xpub func (a *Action) transactionsCount(c *gin.Context) { - metadata, conditions, err := actions.GetCountQueryParameters(c) - if err != nil { + var reqParams CountTransactions + if err := c.Bind(&reqParams); err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var count int64 - if count, err = a.Services.SpvWalletEngine.GetTransactionsCount( + count, err := a.Services.SpvWalletEngine.GetTransactionsCount( c.Request.Context(), - metadata, - conditions, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } diff --git a/actions/admin/utxos.go b/actions/admin/utxos.go index ee7fba889..36c3faf3e 100644 --- a/actions/admin/utxos.go +++ b/actions/admin/utxos.go @@ -3,8 +3,6 @@ package admin import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" - "github.com/bitcoin-sv/spv-wallet/engine" "github.com/gin-gonic/gin" ) @@ -14,26 +12,32 @@ import ( // @Description Search for utxos // @Tags Admin // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchUtxos body SearchUtxos false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Utxo "List of utxos" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchUtxos from request body" // @Failure 500 "Internal server error - Error while searching for utxos" // @Router /v1/admin/utxos/search [post] // @Security x-auth-xpub func (a *Action) utxosSearch(c *gin.Context) { - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) + var reqParams SearchUtxos + if err := c.Bind(&reqParams); err != nil { + c.JSON(http.StatusBadRequest, err.Error()) + return + } + + conditions, err := reqParams.Conditions.ToDbConditions() if err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var utxos []*engine.Utxo - if utxos, err = a.Services.SpvWalletEngine.GetUtxos( + utxos, err := a.Services.SpvWalletEngine.GetUtxos( c.Request.Context(), - metadata, + reqParams.Metadata, conditions, - queryParams, - ); err != nil { + reqParams.QueryParams, + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } @@ -47,25 +51,31 @@ func (a *Action) utxosSearch(c *gin.Context) { // @Description Count utxos // @Tags Admin // @Produce json -// @Param CountRequestParameters body actions.CountRequestParameters false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountUtxos body CountUtxos false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of utxos" -// @Failure 400 "Bad request - Error while parsing CountRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing CountUtxos from request body" // @Failure 500 "Internal Server Error - Error while fetching count of utxos" // @Router /v1/admin/utxos/count [post] // @Security x-auth-xpub func (a *Action) utxosCount(c *gin.Context) { - metadata, conditions, err := actions.GetCountQueryParameters(c) + var reqParams CountUtxos + if err := c.Bind(&reqParams); err != nil { + c.JSON(http.StatusBadRequest, err.Error()) + return + } + + conditions, err := reqParams.Conditions.ToDbConditions() if err != nil { c.JSON(http.StatusBadRequest, err.Error()) return } - var count int64 - if count, err = a.Services.SpvWalletEngine.GetUtxosCount( + count, err := a.Services.SpvWalletEngine.GetUtxosCount( c.Request.Context(), - metadata, + reqParams.Metadata, conditions, - ); err != nil { + ) + if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return } diff --git a/actions/admin/xpubs.go b/actions/admin/xpubs.go index 682b40f6b..9f713b57c 100644 --- a/actions/admin/xpubs.go +++ b/actions/admin/xpubs.go @@ -3,7 +3,6 @@ package admin import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" "github.com/bitcoin-sv/spv-wallet/engine" "github.com/bitcoin-sv/spv-wallet/mappings" "github.com/bitcoin-sv/spv-wallet/models" @@ -48,26 +47,26 @@ func (a *Action) xpubsCreate(c *gin.Context) { // @Description Search for xpubs // @Tags Admin // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchXpubs body SearchXpubs false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Xpub "List of xpubs" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchXpubs from request body" // @Failure 500 "Internal server error - Error while searching for xpubs" // @Router /v1/admin/xpubs/search [post] // @Security x-auth-xpub func (a *Action) xpubsSearch(c *gin.Context) { - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) - if err != nil { - c.JSON(http.StatusExpectationFailed, err.Error()) + var reqParams SearchXpubs + if err := c.Bind(&reqParams); err != nil { + c.JSON(http.StatusBadRequest, err.Error()) return } - var xpubs []*engine.Xpub - if xpubs, err = a.Services.SpvWalletEngine.GetXPubs( + xpubs, err := a.Services.SpvWalletEngine.GetXPubs( c.Request.Context(), - metadata, - conditions, - queryParams, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + reqParams.QueryParams, + ) + if err != nil { c.JSON(http.StatusExpectationFailed, err.Error()) return } @@ -86,25 +85,25 @@ func (a *Action) xpubsSearch(c *gin.Context) { // @Description Count xpubs // @Tags Admin // @Produce json -// @Param CountRequestParameters body actions.CountRequestParameters false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountXpubs body CountXpubs false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of access keys" -// @Failure 400 "Bad request - Error while parsing CountRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing CountXpubs from request body" // @Failure 500 "Internal Server Error - Error while fetching count of xpubs" // @Router /v1/admin/xpubs/count [post] // @Security x-auth-xpub func (a *Action) xpubsCount(c *gin.Context) { - metadata, conditions, err := actions.GetCountQueryParameters(c) - if err != nil { - c.JSON(http.StatusExpectationFailed, err.Error()) + var reqParams CountXpubs + if err := c.Bind(&reqParams); err != nil { + c.JSON(http.StatusBadRequest, err.Error()) return } - var count int64 - if count, err = a.Services.SpvWalletEngine.GetXPubsCount( + count, err := a.Services.SpvWalletEngine.GetXPubsCount( c.Request.Context(), - metadata, - conditions, - ); err != nil { + reqParams.Metadata, + reqParams.Conditions.ToDbConditions(), + ) + if err != nil { c.JSON(http.StatusExpectationFailed, err.Error()) return } diff --git a/actions/common/search_models.go b/actions/common/search_models.go index f37c86e3c..d5830361d 100644 --- a/actions/common/search_models.go +++ b/actions/common/search_models.go @@ -7,7 +7,7 @@ import ( // ConditionsModel is a generic model for handling conditions with metadata type ConditionsModel[TFilter any] struct { - // Custom conditions used for filtering the search results + // Custom conditions used for filtering the search results. Every field within the object is optional. Conditions TFilter `json:"conditions"` // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource Metadata *engine.Metadata `json:"metadata,omitempty" swaggertype:"object,string" example:"key:value,key2:value2"` diff --git a/actions/contacts/models.go b/actions/contacts/models.go index 60c5b4145..fe159422b 100644 --- a/actions/contacts/models.go +++ b/actions/contacts/models.go @@ -3,7 +3,9 @@ package contacts import ( "errors" + "github.com/bitcoin-sv/spv-wallet/actions/common" "github.com/bitcoin-sv/spv-wallet/engine" + "github.com/bitcoin-sv/spv-wallet/models/filter" ) // UpsertContact is the model for creating a contact @@ -23,3 +25,6 @@ func (p *UpsertContact) validate() error { return nil } + +// SearchContacts is a model for handling searching with filters and metadata +type SearchContacts = common.SearchModel[filter.ContactFilter] diff --git a/actions/contacts/search.go b/actions/contacts/search.go index 92ac2f013..e04d7c2ae 100644 --- a/actions/contacts/search.go +++ b/actions/contacts/search.go @@ -3,7 +3,6 @@ package contacts import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" "github.com/bitcoin-sv/spv-wallet/mappings" "github.com/bitcoin-sv/spv-wallet/server/auth" "github.com/gin-gonic/gin" @@ -15,33 +14,34 @@ import ( // @Description Search contacts // @Tags Contact // @Produce json -// @Param page query int false "page" -// @Param page_size query int false "page_size" -// @Param order_by_field query string false "order_by_field" -// @Param sort_direction query string false "sort_direction" -// @Param conditions query string false "conditions" +// @Param SearchContacts body SearchContacts false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Contact "List of contacts" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchContacts from request body" // @Failure 500 "Internal server error - Error while searching for contacts" // @Router /v1/contact/search [POST] // @Security x-auth-xpub func (a *Action) search(c *gin.Context) { reqXPubID := c.GetString(auth.ParamXPubHashKey) - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) + var reqParams SearchContacts + if err := c.Bind(&reqParams); err != nil { + c.JSON(http.StatusBadRequest, err.Error()) + return + } + + conditions, err := reqParams.Conditions.ToDbConditions() if err != nil { - c.JSON(http.StatusExpectationFailed, err.Error()) + c.JSON(http.StatusBadRequest, err.Error()) return } contacts, err := a.Services.SpvWalletEngine.GetContactsByXpubID( c.Request.Context(), reqXPubID, - metadata, - *conditions, - queryParams, + reqParams.Metadata, + conditions, + reqParams.QueryParams, ) - if err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return diff --git a/actions/destinations/count.go b/actions/destinations/count.go index c428904c1..ecd5c3f99 100644 --- a/actions/destinations/count.go +++ b/actions/destinations/count.go @@ -13,7 +13,7 @@ import ( // @Description Count Destinations // @Tags Destinations // @Produce json -// @Param CountDestinations body CountDestinations false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountDestinations body CountDestinations false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of destinations" // @Failure 400 "Bad request - Error while parsing CountDestinations from request body" // @Failure 500 "Internal Server Error - Error while fetching count of destinations" diff --git a/actions/destinations/search.go b/actions/destinations/search.go index 2fdeef022..f171a1c07 100644 --- a/actions/destinations/search.go +++ b/actions/destinations/search.go @@ -15,7 +15,7 @@ import ( // @Description Search for a destination // @Tags Destinations // @Produce json -// @Param SearchDestinations body SearchDestinations false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchDestinations body SearchDestinations false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Destination "List of destinations // @Failure 400 "Bad request - Error while parsing SearchDestinations from request body" // @Failure 500 "Internal server error - Error while searching for destinations" diff --git a/actions/methods.go b/actions/methods.go index 7a814599d..4208957d8 100644 --- a/actions/methods.go +++ b/actions/methods.go @@ -1,33 +1,12 @@ package actions import ( - "fmt" "net/http" "github.com/bitcoin-sv/spv-wallet/dictionary" - "github.com/bitcoin-sv/spv-wallet/engine" - "github.com/bitcoin-sv/spv-wallet/engine/datastore" "github.com/gin-gonic/gin" ) -// SearchRequestParameters is a struct for handling request parameters for search requests -type SearchRequestParameters struct { - // Custom conditions used for filtering the search results - Conditions map[string]interface{} `json:"conditions" swaggertype:"object,string" example:"testColumn:testValue"` - // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource - Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` - // Pagination and sorting options to streamline data exploration and analysis - QueryParams datastore.QueryParams `json:"params" swaggertype:"object,string" example:"page:1,page_size:10,order_by_field:created_at,order_by_direction:desc"` -} - -// CountRequestParameters is a struct for handling request parameters for count requests -type CountRequestParameters struct { - // Custom conditions used for filtering the search results - Conditions map[string]interface{} `json:"conditions" swaggertype:"object,string" example:"testColumn:testValue"` - // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource - Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` -} - // StatusOK is a basic response which sets the status to 200 func StatusOK(c *gin.Context) { c.Status(http.StatusOK) @@ -42,33 +21,3 @@ func NotFound(c *gin.Context) { func MethodNotAllowed(c *gin.Context) { c.JSON(http.StatusMethodNotAllowed, dictionary.GetError(dictionary.ErrorMethodNotAllowed, c.Request.Method, c.Request.RequestURI)) } - -// GetSearchQueryParameters get all filtering parameters related to the db query -func GetSearchQueryParameters(c *gin.Context) (*datastore.QueryParams, *engine.Metadata, *map[string]interface{}, error) { - var requestParameters SearchRequestParameters - if err := c.Bind(&requestParameters); err != nil { - err = fmt.Errorf("error occurred while binding request parameters: %w", err) - return nil, nil, nil, err - } - - if requestParameters.Conditions == nil { - requestParameters.Conditions = make(map[string]interface{}) - } - - return &requestParameters.QueryParams, &requestParameters.Metadata, &requestParameters.Conditions, nil -} - -// GetCountQueryParameters get all filtering parameters related to the db query -func GetCountQueryParameters(c *gin.Context) (*engine.Metadata, *map[string]interface{}, error) { - var requestParameters CountRequestParameters - if err := c.Bind(&requestParameters); err != nil { - err = fmt.Errorf("error occurred while binding request parameters: %w", err) - return nil, nil, err - } - - if requestParameters.Conditions == nil { - requestParameters.Conditions = make(map[string]interface{}) - } - - return &requestParameters.Metadata, &requestParameters.Conditions, nil -} diff --git a/actions/transactions/count.go b/actions/transactions/count.go index cd6a1a6ea..4c707b15a 100644 --- a/actions/transactions/count.go +++ b/actions/transactions/count.go @@ -13,7 +13,7 @@ import ( // @Description Count of transactions // @Tags Transactions // @Produce json -// @Param CountTransactions body CountTransactions false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountTransactions body CountTransactions false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of access keys" // @Failure 400 "Bad request - Error while parsing CountTransactions from request body" // @Failure 500 "Internal Server Error - Error while fetching count of transactions" diff --git a/actions/transactions/search.go b/actions/transactions/search.go index 4de9e2e3e..7be0df0f9 100644 --- a/actions/transactions/search.go +++ b/actions/transactions/search.go @@ -15,7 +15,7 @@ import ( // @Description Search transaction // @Tags Transactions // @Produce json -// @Param SearchTransactions body SearchTransactions false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchTransactions body SearchTransactions false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Transaction "List of transactions" // @Failure 400 "Bad request - Error while parsing SearchTransactions from request body" // @Failure 500 "Internal server error - Error while searching for transactions" diff --git a/actions/utxos/count.go b/actions/utxos/count.go index 0d00396a6..6de2918a6 100644 --- a/actions/utxos/count.go +++ b/actions/utxos/count.go @@ -3,7 +3,6 @@ package utxos import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" "github.com/bitcoin-sv/spv-wallet/server/auth" "github.com/gin-gonic/gin" ) @@ -14,16 +13,22 @@ import ( // @Description Count of UTXOs // @Tags UTXO // @Produce json -// @Param CountRequestParameters body actions.CountRequestParameters false "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs" +// @Param CountUtxos body CountUtxos false "Enables filtering of elements to be counted" // @Success 200 {number} int64 "Count of utxos" -// @Failure 400 "Bad request - Error while parsing CountRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing CountUtxos from request body" // @Failure 500 "Internal Server Error - Error while fetching count of utxos" // @Router /v1/utxo/count [post] // @Security x-auth-xpub func (a *Action) count(c *gin.Context) { reqXPubID := c.GetString(auth.ParamXPubHashKey) - metadata, conditions, err := actions.GetCountQueryParameters(c) + var reqParams CountUtxos + if err := c.Bind(&reqParams); err != nil { + c.JSON(http.StatusBadRequest, err.Error()) + return + } + + conditions, err := reqParams.Conditions.ToDbConditions() if err != nil { c.JSON(http.StatusBadRequest, err.Error()) return @@ -31,7 +36,7 @@ func (a *Action) count(c *gin.Context) { dbConditions := map[string]interface{}{} if conditions != nil { - dbConditions = *conditions + dbConditions = conditions } dbConditions["xpub_id"] = reqXPubID @@ -39,8 +44,8 @@ func (a *Action) count(c *gin.Context) { var count int64 if count, err = a.Services.SpvWalletEngine.GetUtxosCount( c.Request.Context(), - metadata, - &dbConditions, + reqParams.Metadata, + dbConditions, ); err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return diff --git a/actions/utxos/models.go b/actions/utxos/models.go index 5044d2b2d..44390a28d 100644 --- a/actions/utxos/models.go +++ b/actions/utxos/models.go @@ -1,13 +1,12 @@ package utxos import ( - "github.com/bitcoin-sv/spv-wallet/engine" + "github.com/bitcoin-sv/spv-wallet/actions/common" + "github.com/bitcoin-sv/spv-wallet/models/filter" ) -// CountUtxo is the model containing filters for counting utxos -type CountUtxo struct { - // Custom conditions used for filtering the search results - Conditions map[string]interface{} `json:"conditions"` - // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource - Metadata engine.Metadata `json:"metadata"` -} +// SearchUtxos is a model for handling searching with filters and metadata +type SearchUtxos = common.SearchModel[filter.UtxoFilter] + +// CountUtxos is a model for handling counting filtered UTXOs +type CountUtxos = common.ConditionsModel[filter.UtxoFilter] diff --git a/actions/utxos/search.go b/actions/utxos/search.go index 52e7c23f2..df7bb988e 100644 --- a/actions/utxos/search.go +++ b/actions/utxos/search.go @@ -3,7 +3,6 @@ package utxos import ( "net/http" - "github.com/bitcoin-sv/spv-wallet/actions" "github.com/bitcoin-sv/spv-wallet/engine" "github.com/bitcoin-sv/spv-wallet/mappings" "github.com/bitcoin-sv/spv-wallet/models" @@ -17,16 +16,22 @@ import ( // @Description Search UTXO // @Tags UTXO // @Produce json -// @Param SearchRequestParameters body actions.SearchRequestParameters false "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis" +// @Param SearchUtxos body SearchUtxos false "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis" // @Success 200 {object} []models.Utxo "List of utxos" -// @Failure 400 "Bad request - Error while parsing SearchRequestParameters from request body" +// @Failure 400 "Bad request - Error while parsing SearchUtxos from request body" // @Failure 500 "Internal server error - Error while searching for utxos" // @Router /v1/utxo/search [post] // @Security x-auth-xpub func (a *Action) search(c *gin.Context) { reqXPubID := c.GetString(auth.ParamXPubHashKey) - queryParams, metadata, conditions, err := actions.GetSearchQueryParameters(c) + var reqParams SearchUtxos + if err := c.Bind(&reqParams); err != nil { + c.JSON(http.StatusBadRequest, err.Error()) + return + } + + conditions, err := reqParams.Conditions.ToDbConditions() if err != nil { c.JSON(http.StatusBadRequest, err.Error()) return @@ -36,9 +41,9 @@ func (a *Action) search(c *gin.Context) { if utxos, err = a.Services.SpvWalletEngine.GetUtxosByXpubID( c.Request.Context(), reqXPubID, - metadata, + reqParams.Metadata, conditions, - queryParams, + reqParams.QueryParams, ); err != nil { c.JSON(http.StatusInternalServerError, err.Error()) return diff --git a/docs/docs.go b/docs/docs.go index 10ca97e96..8443021a4 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -188,11 +188,11 @@ const docTemplate = `{ "summary": "Count of access keys", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountAccessKeys", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/accesskeys.CountAccessKeys" } } ], @@ -204,7 +204,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountAccessKeys from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of access keys" @@ -229,11 +229,11 @@ const docTemplate = `{ "summary": "Search access key", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchAccessKeys", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/accesskeys.SearchAccessKeys" } } ], @@ -248,7 +248,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while SearchAccessKeys from request body" }, "500": { "description": "Internal server error - Error while searching for access keys" @@ -273,11 +273,11 @@ const docTemplate = `{ "summary": "Access Keys Count", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountAccessKeys", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountAccessKeys" } } ], @@ -289,7 +289,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountAccessKeys from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of access keys" @@ -314,11 +314,11 @@ const docTemplate = `{ "summary": "Access Keys Search", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchAccessKeys", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchAccessKeys" } } ], @@ -333,7 +333,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchAccessKeys from request body" }, "500": { "description": "Internal server error - Error while searching for access keys" @@ -448,11 +448,11 @@ const docTemplate = `{ "summary": "Search for contacts", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchContacts", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchContacts" } } ], @@ -467,7 +467,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchContacts from request body" }, "500": { "description": "Internal server error - Error while searching for contacts" @@ -585,11 +585,11 @@ const docTemplate = `{ "summary": "Search for destinations", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchDestinations", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchDestinations" } } ], @@ -604,7 +604,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchDestinations from request body" }, "500": { "description": "Internal server error - Error while searching for destinations" @@ -749,11 +749,11 @@ const docTemplate = `{ "summary": "Paymail addresses count", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountPaymails", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountPaymails" } } ], @@ -765,7 +765,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountPaymails from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of paymail addresses" @@ -790,11 +790,11 @@ const docTemplate = `{ "summary": "Paymail addresses search", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchPaymails", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchPaymails" } } ], @@ -809,7 +809,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchPaymails from request body" }, "500": { "description": "Internal server error - Error while searching for paymail addresses" @@ -912,11 +912,11 @@ const docTemplate = `{ "summary": "Count transactions", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountTransactions", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountTransactions" } } ], @@ -928,7 +928,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountTransactions from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of transactions" @@ -995,11 +995,11 @@ const docTemplate = `{ "summary": "Search for transactions", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchTransactions", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchTransactions" } } ], @@ -1014,7 +1014,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchTransactions from request body" }, "500": { "description": "Internal server error - Error while searching for transactions" @@ -1039,11 +1039,11 @@ const docTemplate = `{ "summary": "Count utxos", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountUtxos", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountUtxos" } } ], @@ -1055,7 +1055,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountUtxos from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of utxos" @@ -1080,11 +1080,11 @@ const docTemplate = `{ "summary": "Search for utxos", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchUtxos", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchUtxos" } } ], @@ -1099,7 +1099,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchUtxos from request body" }, "500": { "description": "Internal server error - Error while searching for utxos" @@ -1166,11 +1166,11 @@ const docTemplate = `{ "summary": "Count xpubs", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountXpubs", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountXpubs" } } ], @@ -1182,7 +1182,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountXpubs from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of xpubs" @@ -1207,11 +1207,11 @@ const docTemplate = `{ "summary": "Search for xpubs", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchXpubs", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchXpubs" } } ], @@ -1226,7 +1226,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchXpubs from request body" }, "500": { "description": "Internal server error - Error while searching for xpubs" @@ -1371,34 +1371,12 @@ const docTemplate = `{ "summary": "Search contacts", "parameters": [ { - "type": "integer", - "description": "page", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "page_size", - "name": "page_size", - "in": "query" - }, - { - "type": "string", - "description": "order_by_field", - "name": "order_by_field", - "in": "query" - }, - { - "type": "string", - "description": "sort_direction", - "name": "sort_direction", - "in": "query" - }, - { - "type": "string", - "description": "conditions", - "name": "conditions", - "in": "query" + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchContacts", + "in": "body", + "schema": { + "$ref": "#/definitions/contacts.SearchContacts" + } } ], "responses": { @@ -1412,7 +1390,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchContacts from request body" }, "500": { "description": "Internal server error - Error while searching for contacts" @@ -1420,6 +1398,46 @@ const docTemplate = `{ } } }, + "/v1/contact/unconfirmed/{paymail}": { + "patch": { + "security": [ + { + "x-auth-xpub": [] + } + ], + "description": "Unconfirm contact. For contact with status \"confirmed\" change status to \"unconfirmed\"", + "produces": [ + "application/json" + ], + "tags": [ + "Contact" + ], + "summary": "Unconfirm contact", + "parameters": [ + { + "type": "string", + "description": "Paymail address of the contact the user wants to unconfirm", + "name": "paymail", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "404": { + "description": "Contact not found" + }, + "422": { + "description": "Contact status not confirmed" + }, + "500": { + "description": "Internal server error" + } + } + } + }, "/v1/contact/{paymail}": { "put": { "security": [ @@ -1606,7 +1624,7 @@ const docTemplate = `{ "summary": "Count Destinations", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", + "description": "Enables filtering of elements to be counted", "name": "CountDestinations", "in": "body", "schema": { @@ -1647,7 +1665,7 @@ const docTemplate = `{ "summary": "Search for a destination", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", "name": "SearchDestinations", "in": "body", "schema": { @@ -1811,7 +1829,7 @@ const docTemplate = `{ "summary": "Count of transactions", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", + "description": "Enables filtering of elements to be counted", "name": "CountTransactions", "in": "body", "schema": { @@ -1894,7 +1912,7 @@ const docTemplate = `{ "summary": "Search transaction", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", "name": "SearchTransactions", "in": "body", "schema": { @@ -1985,11 +2003,11 @@ const docTemplate = `{ "summary": "Count of UTXOs", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountUtxos", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/utxos.CountUtxos" } } ], @@ -2001,7 +2019,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountUtxos from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of utxos" @@ -2026,11 +2044,11 @@ const docTemplate = `{ "summary": "Search UTXO", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchUtxos", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/utxos.SearchUtxos" } } ], @@ -2045,7 +2063,7 @@ const docTemplate = `{ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchUtxos from request body" }, "500": { "description": "Internal server error - Error while searching for utxos" @@ -2125,6 +2143,30 @@ const docTemplate = `{ } }, "definitions": { + "accesskeys.CountAccessKeys": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AccessKeyFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, "accesskeys.CreateAccessKey": { "type": "object", "properties": { @@ -2141,18 +2183,101 @@ const docTemplate = `{ } } }, - "actions.CountRequestParameters": { + "accesskeys.SearchAccessKeys": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AccessKeyFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.CountAccessKeys": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminAccessKeyFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, + "admin.CountDestinations": { "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.DestinationFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", "type": "object", "additionalProperties": { "type": "string" }, "example": { - "testColumn": "testValue" + "key": "value", + "key2": "value2" } + } + } + }, + "admin.CountPaymails": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminPaymailFilter" + } + ] }, "metadata": { "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", @@ -2167,18 +2292,40 @@ const docTemplate = `{ } } }, - "actions.SearchRequestParameters": { + "admin.CountTransactions": { "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.TransactionFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", "type": "object", "additionalProperties": { "type": "string" }, "example": { - "testColumn": "testValue" + "key": "value", + "key2": "value2" } + } + } + }, + "admin.CountUtxos": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminUtxoFilter" + } + ] }, "metadata": { "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", @@ -2190,18 +2337,29 @@ const docTemplate = `{ "key": "value", "key2": "value2" } + } + } + }, + "admin.CountXpubs": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.XpubFilter" + } + ] }, - "params": { - "description": "Pagination and sorting options to streamline data exploration and analysis", + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", "type": "object", "additionalProperties": { "type": "string" }, "example": { - "order_by_direction": "desc", - "order_by_field": "created_at", - "page": "1", - "page_size": "10" + "key": "value", + "key2": "value2" } } } @@ -2283,13 +2441,16 @@ const docTemplate = `{ } } }, - "admin.UpdateContact": { + "admin.SearchAccessKeys": { "type": "object", "properties": { - "fullName": { - "description": "New name for the contact", - "type": "string", - "example": "John Doe" + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminAccessKeyFilter" + } + ] }, "metadata": { "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", @@ -2301,50 +2462,306 @@ const docTemplate = `{ "key": "value", "key2": "value2" } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } } } }, - "broadcast.SubmittedTx": { + "admin.SearchContacts": { "type": "object", "properties": { - "blockHash": { - "description": "BlockHash is the hash of the block where the transaction was included.", - "type": "string" - }, - "blockHeight": { - "description": "BlockHeight is the height of the block where the transaction was included.", - "type": "integer" - }, - "extraInfo": { - "description": "ExtraInfo provides extra information for given transaction.", - "type": "string" - }, - "merklePath": { - "description": "MerklePath is the Merkle path used to calculate Merkle root of the block in which the transaction was included.", - "type": "string" - }, - "status": { - "description": "Status is the status of the response.", - "type": "integer" - }, - "timestamp": { - "description": "Timestamp is the timestamp of the block where the transaction was included.", - "type": "string" - }, - "title": { - "description": "Title is the title of the response.", - "type": "string" - }, - "txStatus": { - "description": "TxStatus is the status of the transaction.", + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { - "$ref": "#/definitions/broadcast.TxStatus" + "$ref": "#/definitions/filter.ContactFilter" } ] }, - "txid": { - "description": "TxID is the transaction id.", + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchDestinations": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.DestinationFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchPaymails": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminPaymailFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchTransactions": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.TransactionFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchUtxos": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminUtxoFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchXpubs": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.XpubFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.UpdateContact": { + "type": "object", + "properties": { + "fullName": { + "description": "New name for the contact", + "type": "string", + "example": "John Doe" + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, + "broadcast.SubmittedTx": { + "type": "object", + "properties": { + "blockHash": { + "description": "BlockHash is the hash of the block where the transaction was included.", + "type": "string" + }, + "blockHeight": { + "description": "BlockHeight is the height of the block where the transaction was included.", + "type": "integer" + }, + "extraInfo": { + "description": "ExtraInfo provides extra information for given transaction.", + "type": "string" + }, + "merklePath": { + "description": "MerklePath is the Merkle path used to calculate Merkle root of the block in which the transaction was included.", + "type": "string" + }, + "status": { + "description": "Status is the status of the response.", + "type": "integer" + }, + "timestamp": { + "description": "Timestamp is the timestamp of the block where the transaction was included.", + "type": "string" + }, + "title": { + "description": "Title is the title of the response.", + "type": "string" + }, + "txStatus": { + "description": "TxStatus is the status of the transaction.", + "allOf": [ + { + "$ref": "#/definitions/broadcast.TxStatus" + } + ] + }, + "txid": { + "description": "TxID is the transaction id.", "type": "string" } } @@ -2397,6 +2814,43 @@ const docTemplate = `{ "Rejected" ] }, + "contacts.SearchContacts": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.ContactFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, "contacts.UpsertContact": { "type": "object", "properties": { @@ -2425,7 +2879,7 @@ const docTemplate = `{ "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { "$ref": "#/definitions/filter.DestinationFilter" @@ -2465,7 +2919,7 @@ const docTemplate = `{ "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { "$ref": "#/definitions/filter.DestinationFilter" @@ -2483,56 +2937,308 @@ const docTemplate = `{ "key2": "value2" } }, - "params": { - "description": "Pagination and sorting options to streamline data exploration and analysis", - "type": "object", - "additionalProperties": { - "type": "string" - }, - "example": { - "order_by_direction": "desc", - "order_by_field": "created_at", - "page": "1", - "page_size": "10" - } + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "destinations.UpdateDestination": { + "type": "object", + "properties": { + "address": { + "description": "Address of the destination", + "type": "string", + "example": "1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65" + }, + "id": { + "description": "ID of the destination which is the hash of the LockingScript", + "type": "string", + "example": "82a5d848f997819a478b05fb713208d7f3aa66da5ba00953b9845fb1701f9b98" + }, + "locking_script": { + "description": "LockingScript of the destination", + "type": "string", + "example": "76a9147b05764a97f3b4b981471492aa703b188e45979b88ac" + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, + "engine.Metadata": { + "type": "object", + "additionalProperties": true + }, + "filter.AccessKeyFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "revokedRange": { + "description": "RevokedRange specifies the time range when a record was revoked.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + } + } + }, + "filter.AdminAccessKeyFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "revokedRange": { + "description": "RevokedRange specifies the time range when a record was revoked.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "xpubId": { + "type": "string" + } + } + }, + "filter.AdminPaymailFilter": { + "type": "object", + "properties": { + "alias": { + "type": "string", + "example": "alice" + }, + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "domain": { + "type": "string", + "example": "example.com" + }, + "id": { + "type": "string", + "example": "ffb86c103d17d87c15aaf080aab6be5415c9fa885309a79b04c9910e39f2b542" + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "publicName": { + "type": "string", + "example": "Alice" + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "xpubId": { + "type": "string", + "example": "79f90a6bab0a44402fc64828af820e9465645658aea2d138c5205b88e6dabd00" + } + } + }, + "filter.AdminUtxoFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "draftId": { + "type": "string", + "example": "89419d4c7c50810bfe5ff9df9ad5074b749959423782dc91a30f1058b9ad7ef7" + }, + "id": { + "type": "string", + "example": "fe4cbfee0258aa589cbc79963f7c204061fd67d987e32ee5049aa90ce14658ee" + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "outputIndex": { + "type": "integer", + "example": 0 + }, + "reservedRange": { + "description": "ReservedRange specifies the time range when a UTXO was reserved.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "satoshis": { + "type": "integer", + "example": 1 + }, + "scriptPubKey": { + "type": "string", + "example": "76a914a5f271385e75f57bcd9092592dede812f8c466d088ac" + }, + "spendingTxId": { + "type": "string", + "example": "11a7746489a70e9c0170601c2be65558455317a984194eb2791b637f59f8cd6e" + }, + "transactionId": { + "type": "string", + "example": "5e17858ea0ca4155827754ba82bdcfcce108d5bb5b47fbb3aa54bd14540683c6" + }, + "type": { + "type": "string", + "enum": [ + "pubkey", + "pubkeyhash", + "nulldata", + "multisig", + "nonstandard", + "scripthash", + "metanet", + "token_stas", + "token_sensible" + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "xpubId": { + "type": "string" } } }, - "destinations.UpdateDestination": { + "filter.ContactFilter": { "type": "object", "properties": { - "address": { - "description": "Address of the destination", + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "fullName": { "type": "string", - "example": "1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65" + "example": "Alice" }, "id": { - "description": "ID of the destination which is the hash of the LockingScript", "type": "string", - "example": "82a5d848f997819a478b05fb713208d7f3aa66da5ba00953b9845fb1701f9b98" + "example": "ffdbe74e-0700-4710-aac5-611a1f877c7f" }, - "locking_script": { - "description": "LockingScript of the destination", + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "paymail": { "type": "string", - "example": "76a9147b05764a97f3b4b981471492aa703b188e45979b88ac" + "example": "alice@example.com" }, - "metadata": { - "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", - "type": "object", - "additionalProperties": { - "type": "string" - }, - "example": { - "key": "value", - "key2": "value2" - } + "pubKey": { + "type": "string", + "example": "0334f01ecb971e93db179e6fb320cd1466beb0c1ec6c1c6a37aa6cb02e53d5dd1a" + }, + "status": { + "type": "string", + "enum": [ + "unconfirmed", + "awaiting", + "confirmed", + "rejected" + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] } } }, - "engine.Metadata": { - "type": "object", - "additionalProperties": true - }, "filter.DestinationFilter": { "type": "object", "properties": { @@ -2540,65 +3246,96 @@ const docTemplate = `{ "type": "string", "example": "1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65" }, - "created_range": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] }, - "draft_id": { + "draftId": { "type": "string", "example": "b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7" }, - "include_deleted": { + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", "type": "boolean", + "default": false, "example": true }, - "locking_script": { + "lockingScript": { "type": "string", "example": "76a9147b05764a97f3b4b981471492aa703b188e45979b88ac" }, - "updated_range": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + } + } + }, + "filter.TimeRange": { + "type": "object", + "properties": { + "from": { + "description": "From specifies the start time of the range. It's optional and can be nil.", + "type": "string", + "example": "2024-02-26T11:01:28Z" + }, + "to": { + "description": "To specifies the end time of the range. It's optional and can be nil.", + "type": "string", + "example": "2024-02-26T11:01:28Z" } } }, "filter.TransactionFilter": { "type": "object", "properties": { - "block_hash": { - "type": "string" + "blockHash": { + "type": "string", + "example": "0000000000000000031928c28075a82d7a00c2c90b489d1d66dc0afa3f8d26f8" }, - "block_height": { - "type": "integer" + "blockHeight": { + "type": "integer", + "example": 839376 }, - "created_range": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] }, - "draft_id": { - "type": "string" + "draftId": { + "type": "string", + "example": "d425432e0d10a46af1ec6d00f380e9581ebf7907f3486572b3cd561a4c326e14" }, "fee": { - "type": "integer" + "type": "integer", + "example": 1 }, "hex": { "type": "string" }, - "include_deleted": { + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", "type": "boolean", + "default": false, "example": true }, - "number_of_inputs": { - "type": "integer" + "numberOfInputs": { + "type": "integer", + "example": 1 }, - "number_of_outputs": { - "type": "integer" + "numberOfOutputs": { + "type": "integer", + "example": 2 }, "status": { "type": "string", @@ -2618,14 +3355,129 @@ const docTemplate = `{ "REJECTED" ] }, - "total_value": { - "type": "integer" + "totalValue": { + "type": "integer", + "example": 100000000 }, - "updated_range": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + } + } + }, + "filter.UtxoFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "draftId": { + "type": "string", + "example": "89419d4c7c50810bfe5ff9df9ad5074b749959423782dc91a30f1058b9ad7ef7" + }, + "id": { + "type": "string", + "example": "fe4cbfee0258aa589cbc79963f7c204061fd67d987e32ee5049aa90ce14658ee" + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "outputIndex": { + "type": "integer", + "example": 0 + }, + "reservedRange": { + "description": "ReservedRange specifies the time range when a UTXO was reserved.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "satoshis": { + "type": "integer", + "example": 1 + }, + "scriptPubKey": { + "type": "string", + "example": "76a914a5f271385e75f57bcd9092592dede812f8c466d088ac" + }, + "spendingTxId": { + "type": "string", + "example": "11a7746489a70e9c0170601c2be65558455317a984194eb2791b637f59f8cd6e" + }, + "transactionId": { + "type": "string", + "example": "5e17858ea0ca4155827754ba82bdcfcce108d5bb5b47fbb3aa54bd14540683c6" + }, + "type": { + "type": "string", + "enum": [ + "pubkey", + "pubkeyhash", + "nulldata", + "multisig", + "nonstandard", + "scripthash", + "metanet", + "token_stas", + "token_sensible" + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + } + } + }, + "filter.XpubFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "currentBalance": { + "type": "integer", + "example": 1000 + }, + "id": { + "type": "string", + "example": "00b953624f78004a4c727cd28557475d5233c15f17aef545106639f4d71b712d" + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] } } }, @@ -3706,8 +4558,6 @@ const docTemplate = `{ 1000000000, 60000000000, 3600000000000, - -9223372036854775808, - 9223372036854775807, 1, 1000, 1000000, @@ -3732,8 +4582,6 @@ const docTemplate = `{ "Second", "Minute", "Hour", - "minDuration", - "maxDuration", "Nanosecond", "Microsecond", "Millisecond", @@ -3746,7 +4594,7 @@ const docTemplate = `{ "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { "$ref": "#/definitions/filter.TransactionFilter" @@ -3820,7 +4668,7 @@ const docTemplate = `{ "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { "$ref": "#/definitions/filter.TransactionFilter" @@ -3873,6 +4721,67 @@ const docTemplate = `{ } } } + }, + "utxos.CountUtxos": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.UtxoFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, + "utxos.SearchUtxos": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.UtxoFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.json b/docs/swagger.json index d6912ca83..5b7daa0c5 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -179,11 +179,11 @@ "summary": "Count of access keys", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountAccessKeys", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/accesskeys.CountAccessKeys" } } ], @@ -195,7 +195,7 @@ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountAccessKeys from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of access keys" @@ -220,11 +220,11 @@ "summary": "Search access key", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchAccessKeys", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/accesskeys.SearchAccessKeys" } } ], @@ -239,7 +239,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while SearchAccessKeys from request body" }, "500": { "description": "Internal server error - Error while searching for access keys" @@ -264,11 +264,11 @@ "summary": "Access Keys Count", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountAccessKeys", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountAccessKeys" } } ], @@ -280,7 +280,7 @@ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountAccessKeys from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of access keys" @@ -305,11 +305,11 @@ "summary": "Access Keys Search", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchAccessKeys", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchAccessKeys" } } ], @@ -324,7 +324,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchAccessKeys from request body" }, "500": { "description": "Internal server error - Error while searching for access keys" @@ -439,11 +439,11 @@ "summary": "Search for contacts", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchContacts", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchContacts" } } ], @@ -458,7 +458,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchContacts from request body" }, "500": { "description": "Internal server error - Error while searching for contacts" @@ -576,11 +576,11 @@ "summary": "Search for destinations", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchDestinations", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchDestinations" } } ], @@ -595,7 +595,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchDestinations from request body" }, "500": { "description": "Internal server error - Error while searching for destinations" @@ -740,11 +740,11 @@ "summary": "Paymail addresses count", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountPaymails", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountPaymails" } } ], @@ -756,7 +756,7 @@ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountPaymails from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of paymail addresses" @@ -781,11 +781,11 @@ "summary": "Paymail addresses search", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchPaymails", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchPaymails" } } ], @@ -800,7 +800,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchPaymails from request body" }, "500": { "description": "Internal server error - Error while searching for paymail addresses" @@ -903,11 +903,11 @@ "summary": "Count transactions", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountTransactions", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountTransactions" } } ], @@ -919,7 +919,7 @@ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountTransactions from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of transactions" @@ -986,11 +986,11 @@ "summary": "Search for transactions", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchTransactions", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchTransactions" } } ], @@ -1005,7 +1005,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchTransactions from request body" }, "500": { "description": "Internal server error - Error while searching for transactions" @@ -1030,11 +1030,11 @@ "summary": "Count utxos", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountUtxos", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountUtxos" } } ], @@ -1046,7 +1046,7 @@ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountUtxos from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of utxos" @@ -1071,11 +1071,11 @@ "summary": "Search for utxos", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchUtxos", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchUtxos" } } ], @@ -1090,7 +1090,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchUtxos from request body" }, "500": { "description": "Internal server error - Error while searching for utxos" @@ -1157,11 +1157,11 @@ "summary": "Count xpubs", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountXpubs", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/admin.CountXpubs" } } ], @@ -1173,7 +1173,7 @@ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountXpubs from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of xpubs" @@ -1198,11 +1198,11 @@ "summary": "Search for xpubs", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchXpubs", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/admin.SearchXpubs" } } ], @@ -1217,7 +1217,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchXpubs from request body" }, "500": { "description": "Internal server error - Error while searching for xpubs" @@ -1362,34 +1362,12 @@ "summary": "Search contacts", "parameters": [ { - "type": "integer", - "description": "page", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "page_size", - "name": "page_size", - "in": "query" - }, - { - "type": "string", - "description": "order_by_field", - "name": "order_by_field", - "in": "query" - }, - { - "type": "string", - "description": "sort_direction", - "name": "sort_direction", - "in": "query" - }, - { - "type": "string", - "description": "conditions", - "name": "conditions", - "in": "query" + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchContacts", + "in": "body", + "schema": { + "$ref": "#/definitions/contacts.SearchContacts" + } } ], "responses": { @@ -1403,7 +1381,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchContacts from request body" }, "500": { "description": "Internal server error - Error while searching for contacts" @@ -1411,6 +1389,46 @@ } } }, + "/v1/contact/unconfirmed/{paymail}": { + "patch": { + "security": [ + { + "x-auth-xpub": [] + } + ], + "description": "Unconfirm contact. For contact with status \"confirmed\" change status to \"unconfirmed\"", + "produces": [ + "application/json" + ], + "tags": [ + "Contact" + ], + "summary": "Unconfirm contact", + "parameters": [ + { + "type": "string", + "description": "Paymail address of the contact the user wants to unconfirm", + "name": "paymail", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "404": { + "description": "Contact not found" + }, + "422": { + "description": "Contact status not confirmed" + }, + "500": { + "description": "Internal server error" + } + } + } + }, "/v1/contact/{paymail}": { "put": { "security": [ @@ -1597,7 +1615,7 @@ "summary": "Count Destinations", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", + "description": "Enables filtering of elements to be counted", "name": "CountDestinations", "in": "body", "schema": { @@ -1638,7 +1656,7 @@ "summary": "Search for a destination", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", "name": "SearchDestinations", "in": "body", "schema": { @@ -1802,7 +1820,7 @@ "summary": "Count of transactions", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", + "description": "Enables filtering of elements to be counted", "name": "CountTransactions", "in": "body", "schema": { @@ -1885,7 +1903,7 @@ "summary": "Search transaction", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", "name": "SearchTransactions", "in": "body", "schema": { @@ -1976,11 +1994,11 @@ "summary": "Count of UTXOs", "parameters": [ { - "description": "Enables precise filtering of resource counts using custom conditions or metadata, catering to specific business or analysis needs", - "name": "CountRequestParameters", + "description": "Enables filtering of elements to be counted", + "name": "CountUtxos", "in": "body", "schema": { - "$ref": "#/definitions/actions.CountRequestParameters" + "$ref": "#/definitions/utxos.CountUtxos" } } ], @@ -1992,7 +2010,7 @@ } }, "400": { - "description": "Bad request - Error while parsing CountRequestParameters from request body" + "description": "Bad request - Error while parsing CountUtxos from request body" }, "500": { "description": "Internal Server Error - Error while fetching count of utxos" @@ -2017,11 +2035,11 @@ "summary": "Search UTXO", "parameters": [ { - "description": "Supports targeted resource searches with filters for metadata and custom conditions, plus options for pagination and sorting to streamline data exploration and analysis", - "name": "SearchRequestParameters", + "description": "Supports targeted resource searches with filters and metadata, plus options for pagination and sorting to streamline data exploration and analysis", + "name": "SearchUtxos", "in": "body", "schema": { - "$ref": "#/definitions/actions.SearchRequestParameters" + "$ref": "#/definitions/utxos.SearchUtxos" } } ], @@ -2036,7 +2054,7 @@ } }, "400": { - "description": "Bad request - Error while parsing SearchRequestParameters from request body" + "description": "Bad request - Error while parsing SearchUtxos from request body" }, "500": { "description": "Internal server error - Error while searching for utxos" @@ -2116,6 +2134,30 @@ } }, "definitions": { + "accesskeys.CountAccessKeys": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AccessKeyFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, "accesskeys.CreateAccessKey": { "type": "object", "properties": { @@ -2132,18 +2174,101 @@ } } }, - "actions.CountRequestParameters": { + "accesskeys.SearchAccessKeys": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AccessKeyFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.CountAccessKeys": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminAccessKeyFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, + "admin.CountDestinations": { "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.DestinationFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", "type": "object", "additionalProperties": { "type": "string" }, "example": { - "testColumn": "testValue" + "key": "value", + "key2": "value2" } + } + } + }, + "admin.CountPaymails": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminPaymailFilter" + } + ] }, "metadata": { "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", @@ -2158,18 +2283,40 @@ } } }, - "actions.SearchRequestParameters": { + "admin.CountTransactions": { "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.TransactionFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", "type": "object", "additionalProperties": { "type": "string" }, "example": { - "testColumn": "testValue" + "key": "value", + "key2": "value2" } + } + } + }, + "admin.CountUtxos": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminUtxoFilter" + } + ] }, "metadata": { "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", @@ -2181,18 +2328,29 @@ "key": "value", "key2": "value2" } + } + } + }, + "admin.CountXpubs": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.XpubFilter" + } + ] }, - "params": { - "description": "Pagination and sorting options to streamline data exploration and analysis", + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", "type": "object", "additionalProperties": { "type": "string" }, "example": { - "order_by_direction": "desc", - "order_by_field": "created_at", - "page": "1", - "page_size": "10" + "key": "value", + "key2": "value2" } } } @@ -2274,13 +2432,16 @@ } } }, - "admin.UpdateContact": { + "admin.SearchAccessKeys": { "type": "object", "properties": { - "fullName": { - "description": "New name for the contact", - "type": "string", - "example": "John Doe" + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminAccessKeyFilter" + } + ] }, "metadata": { "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", @@ -2292,50 +2453,306 @@ "key": "value", "key2": "value2" } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } } } }, - "broadcast.SubmittedTx": { + "admin.SearchContacts": { "type": "object", "properties": { - "blockHash": { - "description": "BlockHash is the hash of the block where the transaction was included.", - "type": "string" - }, - "blockHeight": { - "description": "BlockHeight is the height of the block where the transaction was included.", - "type": "integer" - }, - "extraInfo": { - "description": "ExtraInfo provides extra information for given transaction.", - "type": "string" - }, - "merklePath": { - "description": "MerklePath is the Merkle path used to calculate Merkle root of the block in which the transaction was included.", - "type": "string" - }, - "status": { - "description": "Status is the status of the response.", - "type": "integer" - }, - "timestamp": { - "description": "Timestamp is the timestamp of the block where the transaction was included.", - "type": "string" - }, - "title": { - "description": "Title is the title of the response.", - "type": "string" - }, - "txStatus": { - "description": "TxStatus is the status of the transaction.", + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { - "$ref": "#/definitions/broadcast.TxStatus" + "$ref": "#/definitions/filter.ContactFilter" } ] }, - "txid": { - "description": "TxID is the transaction id.", + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchDestinations": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.DestinationFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchPaymails": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminPaymailFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchTransactions": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.TransactionFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchUtxos": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.AdminUtxoFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.SearchXpubs": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.XpubFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "admin.UpdateContact": { + "type": "object", + "properties": { + "fullName": { + "description": "New name for the contact", + "type": "string", + "example": "John Doe" + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, + "broadcast.SubmittedTx": { + "type": "object", + "properties": { + "blockHash": { + "description": "BlockHash is the hash of the block where the transaction was included.", + "type": "string" + }, + "blockHeight": { + "description": "BlockHeight is the height of the block where the transaction was included.", + "type": "integer" + }, + "extraInfo": { + "description": "ExtraInfo provides extra information for given transaction.", + "type": "string" + }, + "merklePath": { + "description": "MerklePath is the Merkle path used to calculate Merkle root of the block in which the transaction was included.", + "type": "string" + }, + "status": { + "description": "Status is the status of the response.", + "type": "integer" + }, + "timestamp": { + "description": "Timestamp is the timestamp of the block where the transaction was included.", + "type": "string" + }, + "title": { + "description": "Title is the title of the response.", + "type": "string" + }, + "txStatus": { + "description": "TxStatus is the status of the transaction.", + "allOf": [ + { + "$ref": "#/definitions/broadcast.TxStatus" + } + ] + }, + "txid": { + "description": "TxID is the transaction id.", "type": "string" } } @@ -2388,6 +2805,43 @@ "Rejected" ] }, + "contacts.SearchContacts": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.ContactFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, "contacts.UpsertContact": { "type": "object", "properties": { @@ -2416,7 +2870,7 @@ "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { "$ref": "#/definitions/filter.DestinationFilter" @@ -2456,7 +2910,7 @@ "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { "$ref": "#/definitions/filter.DestinationFilter" @@ -2474,56 +2928,308 @@ "key2": "value2" } }, - "params": { - "description": "Pagination and sorting options to streamline data exploration and analysis", - "type": "object", - "additionalProperties": { - "type": "string" - }, - "example": { - "order_by_direction": "desc", - "order_by_field": "created_at", - "page": "1", - "page_size": "10" - } + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } + }, + "destinations.UpdateDestination": { + "type": "object", + "properties": { + "address": { + "description": "Address of the destination", + "type": "string", + "example": "1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65" + }, + "id": { + "description": "ID of the destination which is the hash of the LockingScript", + "type": "string", + "example": "82a5d848f997819a478b05fb713208d7f3aa66da5ba00953b9845fb1701f9b98" + }, + "locking_script": { + "description": "LockingScript of the destination", + "type": "string", + "example": "76a9147b05764a97f3b4b981471492aa703b188e45979b88ac" + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, + "engine.Metadata": { + "type": "object", + "additionalProperties": true + }, + "filter.AccessKeyFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "revokedRange": { + "description": "RevokedRange specifies the time range when a record was revoked.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + } + } + }, + "filter.AdminAccessKeyFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "revokedRange": { + "description": "RevokedRange specifies the time range when a record was revoked.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "xpubId": { + "type": "string" + } + } + }, + "filter.AdminPaymailFilter": { + "type": "object", + "properties": { + "alias": { + "type": "string", + "example": "alice" + }, + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "domain": { + "type": "string", + "example": "example.com" + }, + "id": { + "type": "string", + "example": "ffb86c103d17d87c15aaf080aab6be5415c9fa885309a79b04c9910e39f2b542" + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "publicName": { + "type": "string", + "example": "Alice" + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "xpubId": { + "type": "string", + "example": "79f90a6bab0a44402fc64828af820e9465645658aea2d138c5205b88e6dabd00" + } + } + }, + "filter.AdminUtxoFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "draftId": { + "type": "string", + "example": "89419d4c7c50810bfe5ff9df9ad5074b749959423782dc91a30f1058b9ad7ef7" + }, + "id": { + "type": "string", + "example": "fe4cbfee0258aa589cbc79963f7c204061fd67d987e32ee5049aa90ce14658ee" + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "outputIndex": { + "type": "integer", + "example": 0 + }, + "reservedRange": { + "description": "ReservedRange specifies the time range when a UTXO was reserved.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "satoshis": { + "type": "integer", + "example": 1 + }, + "scriptPubKey": { + "type": "string", + "example": "76a914a5f271385e75f57bcd9092592dede812f8c466d088ac" + }, + "spendingTxId": { + "type": "string", + "example": "11a7746489a70e9c0170601c2be65558455317a984194eb2791b637f59f8cd6e" + }, + "transactionId": { + "type": "string", + "example": "5e17858ea0ca4155827754ba82bdcfcce108d5bb5b47fbb3aa54bd14540683c6" + }, + "type": { + "type": "string", + "enum": [ + "pubkey", + "pubkeyhash", + "nulldata", + "multisig", + "nonstandard", + "scripthash", + "metanet", + "token_stas", + "token_sensible" + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "xpubId": { + "type": "string" } } }, - "destinations.UpdateDestination": { + "filter.ContactFilter": { "type": "object", "properties": { - "address": { - "description": "Address of the destination", + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "fullName": { "type": "string", - "example": "1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65" + "example": "Alice" }, "id": { - "description": "ID of the destination which is the hash of the LockingScript", "type": "string", - "example": "82a5d848f997819a478b05fb713208d7f3aa66da5ba00953b9845fb1701f9b98" + "example": "ffdbe74e-0700-4710-aac5-611a1f877c7f" }, - "locking_script": { - "description": "LockingScript of the destination", + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "paymail": { "type": "string", - "example": "76a9147b05764a97f3b4b981471492aa703b188e45979b88ac" + "example": "alice@example.com" }, - "metadata": { - "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", - "type": "object", - "additionalProperties": { - "type": "string" - }, - "example": { - "key": "value", - "key2": "value2" - } + "pubKey": { + "type": "string", + "example": "0334f01ecb971e93db179e6fb320cd1466beb0c1ec6c1c6a37aa6cb02e53d5dd1a" + }, + "status": { + "type": "string", + "enum": [ + "unconfirmed", + "awaiting", + "confirmed", + "rejected" + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] } } }, - "engine.Metadata": { - "type": "object", - "additionalProperties": true - }, "filter.DestinationFilter": { "type": "object", "properties": { @@ -2531,65 +3237,96 @@ "type": "string", "example": "1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65" }, - "created_range": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] }, - "draft_id": { + "draftId": { "type": "string", "example": "b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7" }, - "include_deleted": { + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", "type": "boolean", + "default": false, "example": true }, - "locking_script": { + "lockingScript": { "type": "string", "example": "76a9147b05764a97f3b4b981471492aa703b188e45979b88ac" }, - "updated_range": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + } + } + }, + "filter.TimeRange": { + "type": "object", + "properties": { + "from": { + "description": "From specifies the start time of the range. It's optional and can be nil.", + "type": "string", + "example": "2024-02-26T11:01:28Z" + }, + "to": { + "description": "To specifies the end time of the range. It's optional and can be nil.", + "type": "string", + "example": "2024-02-26T11:01:28Z" } } }, "filter.TransactionFilter": { "type": "object", "properties": { - "block_hash": { - "type": "string" + "blockHash": { + "type": "string", + "example": "0000000000000000031928c28075a82d7a00c2c90b489d1d66dc0afa3f8d26f8" }, - "block_height": { - "type": "integer" + "blockHeight": { + "type": "integer", + "example": 839376 }, - "created_range": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] }, - "draft_id": { - "type": "string" + "draftId": { + "type": "string", + "example": "d425432e0d10a46af1ec6d00f380e9581ebf7907f3486572b3cd561a4c326e14" }, "fee": { - "type": "integer" + "type": "integer", + "example": 1 }, "hex": { "type": "string" }, - "include_deleted": { + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", "type": "boolean", + "default": false, "example": true }, - "number_of_inputs": { - "type": "integer" + "numberOfInputs": { + "type": "integer", + "example": 1 }, - "number_of_outputs": { - "type": "integer" + "numberOfOutputs": { + "type": "integer", + "example": 2 }, "status": { "type": "string", @@ -2609,14 +3346,129 @@ "REJECTED" ] }, - "total_value": { - "type": "integer" + "totalValue": { + "type": "integer", + "example": 100000000 }, - "updated_range": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + } + } + }, + "filter.UtxoFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "draftId": { + "type": "string", + "example": "89419d4c7c50810bfe5ff9df9ad5074b749959423782dc91a30f1058b9ad7ef7" + }, + "id": { + "type": "string", + "example": "fe4cbfee0258aa589cbc79963f7c204061fd67d987e32ee5049aa90ce14658ee" + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "outputIndex": { + "type": "integer", + "example": 0 + }, + "reservedRange": { + "description": "ReservedRange specifies the time range when a UTXO was reserved.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "satoshis": { + "type": "integer", + "example": 1 + }, + "scriptPubKey": { + "type": "string", + "example": "76a914a5f271385e75f57bcd9092592dede812f8c466d088ac" + }, + "spendingTxId": { + "type": "string", + "example": "11a7746489a70e9c0170601c2be65558455317a984194eb2791b637f59f8cd6e" + }, + "transactionId": { + "type": "string", + "example": "5e17858ea0ca4155827754ba82bdcfcce108d5bb5b47fbb3aa54bd14540683c6" + }, + "type": { + "type": "string", + "enum": [ + "pubkey", + "pubkeyhash", + "nulldata", + "multisig", + "nonstandard", + "scripthash", + "metanet", + "token_stas", + "token_sensible" + ] + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + } + } + }, + "filter.XpubFilter": { + "type": "object", + "properties": { + "createdRange": { + "description": "CreatedRange specifies the time range when a record was created.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] + }, + "currentBalance": { + "type": "integer", + "example": 1000 + }, + "id": { + "type": "string", + "example": "00b953624f78004a4c727cd28557475d5233c15f17aef545106639f4d71b712d" + }, + "includeDeleted": { + "description": "IncludeDeleted is a flag whether or not to include deleted items in the search results", + "type": "boolean", + "default": false, + "example": true + }, + "updatedRange": { + "description": "UpdatedRange specifies the time range when a record was updated.", + "allOf": [ + { + "$ref": "#/definitions/filter.TimeRange" + } + ] } } }, @@ -3697,8 +4549,6 @@ 1000000000, 60000000000, 3600000000000, - -9223372036854775808, - 9223372036854775807, 1, 1000, 1000000, @@ -3723,8 +4573,6 @@ "Second", "Minute", "Hour", - "minDuration", - "maxDuration", "Nanosecond", "Microsecond", "Millisecond", @@ -3737,7 +4585,7 @@ "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { "$ref": "#/definitions/filter.TransactionFilter" @@ -3811,7 +4659,7 @@ "type": "object", "properties": { "conditions": { - "description": "Custom conditions used for filtering the search results", + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", "allOf": [ { "$ref": "#/definitions/filter.TransactionFilter" @@ -3864,6 +4712,67 @@ } } } + }, + "utxos.CountUtxos": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.UtxoFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + } + } + }, + "utxos.SearchUtxos": { + "type": "object", + "properties": { + "conditions": { + "description": "Custom conditions used for filtering the search results. Every field within the object is optional.", + "allOf": [ + { + "$ref": "#/definitions/filter.UtxoFilter" + } + ] + }, + "metadata": { + "description": "Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "key": "value", + "key2": "value2" + } + }, + "params": { + "description": "Pagination and sorting options to streamline data exploration and analysis", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "order_by_direction": "desc", + "order_by_field": "created_at", + "page": "1", + "page_size": "10" + } + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index ae8661165..f9202c4f9 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,4 +1,21 @@ definitions: + accesskeys.CountAccessKeys: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.AccessKeyFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + type: object accesskeys.CreateAccessKey: properties: metadata: @@ -11,15 +28,41 @@ definitions: key2: value2 type: object type: object - actions.CountRequestParameters: + accesskeys.SearchAccessKeys: properties: conditions: + allOf: + - $ref: '#/definitions/filter.AccessKeyFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: additionalProperties: type: string - description: Custom conditions used for filtering the search results + description: Pagination and sorting options to streamline data exploration + and analysis example: - testColumn: testValue + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" type: object + type: object + admin.CountAccessKeys: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.AdminAccessKeyFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. metadata: additionalProperties: type: string @@ -30,15 +73,30 @@ definitions: key2: value2 type: object type: object - actions.SearchRequestParameters: + admin.CountDestinations: properties: conditions: + allOf: + - $ref: '#/definitions/filter.DestinationFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: additionalProperties: type: string - description: Custom conditions used for filtering the search results + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource example: - testColumn: testValue + key: value + key2: value2 type: object + type: object + admin.CountPaymails: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.AdminPaymailFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. metadata: additionalProperties: type: string @@ -48,16 +106,56 @@ definitions: key: value key2: value2 type: object - params: + type: object + admin.CountTransactions: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.TransactionFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: additionalProperties: type: string - description: Pagination and sorting options to streamline data exploration - and analysis + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource example: - order_by_direction: desc - order_by_field: created_at - page: "1" - page_size: "10" + key: value + key2: value2 + type: object + type: object + admin.CountUtxos: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.AdminUtxoFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + type: object + admin.CountXpubs: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.XpubFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 type: object type: object admin.CreatePaymail: @@ -118,6 +216,202 @@ definitions: example: 0100000002... type: string type: object + admin.SearchAccessKeys: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.AdminAccessKeyFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object + admin.SearchContacts: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.ContactFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object + admin.SearchDestinations: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.DestinationFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object + admin.SearchPaymails: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.AdminPaymailFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object + admin.SearchTransactions: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.TransactionFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object + admin.SearchUtxos: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.AdminUtxoFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object + admin.SearchXpubs: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.XpubFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object admin.UpdateContact: properties: fullName: @@ -213,6 +507,34 @@ definitions: - SeenInOrphanMempool - Confirmed - Rejected + contacts.SearchContacts: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.ContactFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object contacts.UpsertContact: properties: fullName: @@ -238,7 +560,8 @@ definitions: conditions: allOf: - $ref: '#/definitions/filter.DestinationFilter' - description: Custom conditions used for filtering the search results + description: Custom conditions used for filtering the search results. Every + field within the object is optional. metadata: additionalProperties: type: string @@ -266,7 +589,8 @@ definitions: conditions: allOf: - $ref: '#/definitions/filter.DestinationFilter' - description: Custom conditions used for filtering the search results + description: Custom conditions used for filtering the search results. Every + field within the object is optional. metadata: additionalProperties: type: string @@ -315,51 +639,244 @@ definitions: engine.Metadata: additionalProperties: true type: object + filter.AccessKeyFilter: + properties: + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results + example: true + type: boolean + revokedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: RevokedRange specifies the time range when a record was revoked. + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. + type: object + filter.AdminAccessKeyFilter: + properties: + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results + example: true + type: boolean + revokedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: RevokedRange specifies the time range when a record was revoked. + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. + xpubId: + type: string + type: object + filter.AdminPaymailFilter: + properties: + alias: + example: alice + type: string + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + domain: + example: example.com + type: string + id: + example: ffb86c103d17d87c15aaf080aab6be5415c9fa885309a79b04c9910e39f2b542 + type: string + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results + example: true + type: boolean + publicName: + example: Alice + type: string + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. + xpubId: + example: 79f90a6bab0a44402fc64828af820e9465645658aea2d138c5205b88e6dabd00 + type: string + type: object + filter.AdminUtxoFilter: + properties: + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + draftId: + example: 89419d4c7c50810bfe5ff9df9ad5074b749959423782dc91a30f1058b9ad7ef7 + type: string + id: + example: fe4cbfee0258aa589cbc79963f7c204061fd67d987e32ee5049aa90ce14658ee + type: string + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results + example: true + type: boolean + outputIndex: + example: 0 + type: integer + reservedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: ReservedRange specifies the time range when a UTXO was reserved. + satoshis: + example: 1 + type: integer + scriptPubKey: + example: 76a914a5f271385e75f57bcd9092592dede812f8c466d088ac + type: string + spendingTxId: + example: 11a7746489a70e9c0170601c2be65558455317a984194eb2791b637f59f8cd6e + type: string + transactionId: + example: 5e17858ea0ca4155827754ba82bdcfcce108d5bb5b47fbb3aa54bd14540683c6 + type: string + type: + enum: + - pubkey + - pubkeyhash + - nulldata + - multisig + - nonstandard + - scripthash + - metanet + - token_stas + - token_sensible + type: string + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. + xpubId: + type: string + type: object + filter.ContactFilter: + properties: + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + fullName: + example: Alice + type: string + id: + example: ffdbe74e-0700-4710-aac5-611a1f877c7f + type: string + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results + example: true + type: boolean + paymail: + example: alice@example.com + type: string + pubKey: + example: 0334f01ecb971e93db179e6fb320cd1466beb0c1ec6c1c6a37aa6cb02e53d5dd1a + type: string + status: + enum: + - unconfirmed + - awaiting + - confirmed + - rejected + type: string + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. + type: object filter.DestinationFilter: properties: address: example: 1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65 type: string - created_range: - additionalProperties: - type: string - type: object - draft_id: + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + draftId: example: b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7 type: string - include_deleted: + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results example: true type: boolean - locking_script: + lockingScript: example: 76a9147b05764a97f3b4b981471492aa703b188e45979b88ac type: string - updated_range: - additionalProperties: - type: string - type: object + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. + type: object + filter.TimeRange: + properties: + from: + description: From specifies the start time of the range. It's optional and + can be nil. + example: "2024-02-26T11:01:28Z" + type: string + to: + description: To specifies the end time of the range. It's optional and can + be nil. + example: "2024-02-26T11:01:28Z" + type: string type: object filter.TransactionFilter: properties: - block_hash: + blockHash: + example: 0000000000000000031928c28075a82d7a00c2c90b489d1d66dc0afa3f8d26f8 type: string - block_height: + blockHeight: + example: 839376 type: integer - created_range: - additionalProperties: - type: string - type: object - draft_id: + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + draftId: + example: d425432e0d10a46af1ec6d00f380e9581ebf7907f3486572b3cd561a4c326e14 type: string fee: + example: 1 type: integer hex: type: string - include_deleted: + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results example: true type: boolean - number_of_inputs: + numberOfInputs: + example: 1 type: integer - number_of_outputs: + numberOfOutputs: + example: 2 type: integer status: enum: @@ -377,12 +894,90 @@ definitions: - CONFIRMED - REJECTED type: string - total_value: + totalValue: + example: 100000000 type: integer - updated_range: - additionalProperties: - type: string - type: object + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. + type: object + filter.UtxoFilter: + properties: + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + draftId: + example: 89419d4c7c50810bfe5ff9df9ad5074b749959423782dc91a30f1058b9ad7ef7 + type: string + id: + example: fe4cbfee0258aa589cbc79963f7c204061fd67d987e32ee5049aa90ce14658ee + type: string + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results + example: true + type: boolean + outputIndex: + example: 0 + type: integer + reservedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: ReservedRange specifies the time range when a UTXO was reserved. + satoshis: + example: 1 + type: integer + scriptPubKey: + example: 76a914a5f271385e75f57bcd9092592dede812f8c466d088ac + type: string + spendingTxId: + example: 11a7746489a70e9c0170601c2be65558455317a984194eb2791b637f59f8cd6e + type: string + transactionId: + example: 5e17858ea0ca4155827754ba82bdcfcce108d5bb5b47fbb3aa54bd14540683c6 + type: string + type: + enum: + - pubkey + - pubkeyhash + - nulldata + - multisig + - nonstandard + - scripthash + - metanet + - token_stas + - token_sensible + type: string + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. + type: object + filter.XpubFilter: + properties: + createdRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: CreatedRange specifies the time range when a record was created. + currentBalance: + example: 1000 + type: integer + id: + example: 00b953624f78004a4c727cd28557475d5233c15f17aef545106639f4d71b712d + type: string + includeDeleted: + default: false + description: IncludeDeleted is a flag whether or not to include deleted items + in the search results + example: true + type: boolean + updatedRange: + allOf: + - $ref: '#/definitions/filter.TimeRange' + description: UpdatedRange specifies the time range when a record was updated. type: object models.AccessKey: properties: @@ -1195,8 +1790,6 @@ definitions: - 1000000000 - 60000000000 - 3600000000000 - - -9223372036854775808 - - 9223372036854775807 - 1 - 1000 - 1000000 @@ -1221,8 +1814,6 @@ definitions: - Second - Minute - Hour - - minDuration - - maxDuration - Nanosecond - Microsecond - Millisecond @@ -1234,7 +1825,8 @@ definitions: conditions: allOf: - $ref: '#/definitions/filter.TransactionFilter' - description: Custom conditions used for filtering the search results + description: Custom conditions used for filtering the search results. Every + field within the object is optional. metadata: additionalProperties: type: string @@ -1286,7 +1878,8 @@ definitions: conditions: allOf: - $ref: '#/definitions/filter.TransactionFilter' - description: Custom conditions used for filtering the search results + description: Custom conditions used for filtering the search results. Every + field within the object is optional. metadata: additionalProperties: type: string @@ -1324,6 +1917,51 @@ definitions: key2: value2 type: object type: object + utxos.CountUtxos: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.UtxoFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + type: object + utxos.SearchUtxos: + properties: + conditions: + allOf: + - $ref: '#/definitions/filter.UtxoFilter' + description: Custom conditions used for filtering the search results. Every + field within the object is optional. + metadata: + additionalProperties: + type: string + description: Accepts a JSON object for embedding custom metadata, enabling + arbitrary additional information to be associated with the resource + example: + key: value + key2: value2 + type: object + params: + additionalProperties: + type: string + description: Pagination and sorting options to streamline data exploration + and analysis + example: + order_by_direction: desc + order_by_field: created_at + page: "1" + page_size: "10" + type: object + type: object info: contact: {} title: SPV Wallet @@ -1433,12 +2071,11 @@ paths: post: description: Count of access keys parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body - name: CountRequestParameters + name: CountAccessKeys schema: - $ref: '#/definitions/actions.CountRequestParameters' + $ref: '#/definitions/accesskeys.CountAccessKeys' produces: - application/json responses: @@ -1447,8 +2084,8 @@ paths: schema: type: number "400": - description: Bad request - Error while parsing CountRequestParameters from - request body + description: Bad request - Error while parsing CountAccessKeys from request + body "500": description: Internal Server Error - Error while fetching count of access keys @@ -1461,13 +2098,13 @@ paths: post: description: Search access key parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchAccessKeys schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/accesskeys.SearchAccessKeys' produces: - application/json responses: @@ -1478,8 +2115,7 @@ paths: $ref: '#/definitions/models.AccessKey' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while SearchAccessKeys from request body "500": description: Internal server error - Error while searching for access keys security: @@ -1491,12 +2127,11 @@ paths: post: description: Access Keys Count parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body - name: CountRequestParameters + name: CountAccessKeys schema: - $ref: '#/definitions/actions.CountRequestParameters' + $ref: '#/definitions/admin.CountAccessKeys' produces: - application/json responses: @@ -1505,8 +2140,8 @@ paths: schema: type: number "400": - description: Bad request - Error while parsing CountRequestParameters from - request body + description: Bad request - Error while parsing CountAccessKeys from request + body "500": description: Internal Server Error - Error while fetching count of access keys @@ -1519,13 +2154,13 @@ paths: post: description: Access Keys Search parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchAccessKeys schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/admin.SearchAccessKeys' produces: - application/json responses: @@ -1536,8 +2171,8 @@ paths: $ref: '#/definitions/models.AccessKey' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchAccessKeys from request + body "500": description: Internal server error - Error while searching for access keys security: @@ -1665,13 +2300,13 @@ paths: post: description: Search for contacts parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchContacts schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/admin.SearchContacts' produces: - application/json responses: @@ -1682,8 +2317,8 @@ paths: $ref: '#/definitions/models.Contact' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchContacts from request + body "500": description: Internal server error - Error while searching for contacts security: @@ -1695,13 +2330,13 @@ paths: post: description: Search for destinations parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchDestinations schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/admin.SearchDestinations' produces: - application/json responses: @@ -1712,8 +2347,8 @@ paths: $ref: '#/definitions/models.Destination' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchDestinations from request + body "500": description: Internal server error - Error while searching for destinations security: @@ -1801,12 +2436,11 @@ paths: post: description: Paymail addresses count parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body - name: CountRequestParameters + name: CountPaymails schema: - $ref: '#/definitions/actions.CountRequestParameters' + $ref: '#/definitions/admin.CountPaymails' produces: - application/json responses: @@ -1815,8 +2449,8 @@ paths: schema: type: number "400": - description: Bad request - Error while parsing CountRequestParameters from - request body + description: Bad request - Error while parsing CountPaymails from request + body "500": description: Internal Server Error - Error while fetching count of paymail addresses @@ -1829,13 +2463,13 @@ paths: post: description: Paymail addresses search parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchPaymails schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/admin.SearchPaymails' produces: - application/json responses: @@ -1846,8 +2480,8 @@ paths: $ref: '#/definitions/models.PaymailAddress' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchPaymails from request + body "500": description: Internal server error - Error while searching for paymail addresses security: @@ -1906,12 +2540,11 @@ paths: post: description: Count transactions parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body - name: CountRequestParameters + name: CountTransactions schema: - $ref: '#/definitions/actions.CountRequestParameters' + $ref: '#/definitions/admin.CountTransactions' produces: - application/json responses: @@ -1920,8 +2553,8 @@ paths: schema: type: number "400": - description: Bad request - Error while parsing CountRequestParameters from - request body + description: Bad request - Error while parsing CountTransactions from request + body "500": description: Internal Server Error - Error while fetching count of transactions security: @@ -1962,13 +2595,13 @@ paths: post: description: Search for transactions parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchTransactions schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/admin.SearchTransactions' produces: - application/json responses: @@ -1979,8 +2612,8 @@ paths: $ref: '#/definitions/models.Transaction' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchTransactions from request + body "500": description: Internal server error - Error while searching for transactions security: @@ -1992,12 +2625,11 @@ paths: post: description: Count utxos parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body - name: CountRequestParameters + name: CountUtxos schema: - $ref: '#/definitions/actions.CountRequestParameters' + $ref: '#/definitions/admin.CountUtxos' produces: - application/json responses: @@ -2006,8 +2638,7 @@ paths: schema: type: number "400": - description: Bad request - Error while parsing CountRequestParameters from - request body + description: Bad request - Error while parsing CountUtxos from request body "500": description: Internal Server Error - Error while fetching count of utxos security: @@ -2019,13 +2650,13 @@ paths: post: description: Search for utxos parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchUtxos schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/admin.SearchUtxos' produces: - application/json responses: @@ -2036,8 +2667,8 @@ paths: $ref: '#/definitions/models.Utxo' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchUtxos from request + body "500": description: Internal server error - Error while searching for utxos security: @@ -2075,12 +2706,11 @@ paths: post: description: Count xpubs parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body - name: CountRequestParameters + name: CountXpubs schema: - $ref: '#/definitions/actions.CountRequestParameters' + $ref: '#/definitions/admin.CountXpubs' produces: - application/json responses: @@ -2089,8 +2719,7 @@ paths: schema: type: number "400": - description: Bad request - Error while parsing CountRequestParameters from - request body + description: Bad request - Error while parsing CountXpubs from request body "500": description: Internal Server Error - Error while fetching count of xpubs security: @@ -2102,13 +2731,13 @@ paths: post: description: Search for xpubs parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchXpubs schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/admin.SearchXpubs' produces: - application/json responses: @@ -2119,8 +2748,8 @@ paths: $ref: '#/definitions/models.Xpub' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchXpubs from request + body "500": description: Internal server error - Error while searching for xpubs security: @@ -2236,26 +2865,13 @@ paths: post: description: Search contacts parameters: - - description: page - in: query - name: page - type: integer - - description: page_size - in: query - name: page_size - type: integer - - description: order_by_field - in: query - name: order_by_field - type: string - - description: sort_direction - in: query - name: sort_direction - type: string - - description: conditions - in: query - name: conditions - type: string + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis + in: body + name: SearchContacts + schema: + $ref: '#/definitions/contacts.SearchContacts' produces: - application/json responses: @@ -2266,8 +2882,8 @@ paths: $ref: '#/definitions/models.Contact' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchContacts from request + body "500": description: Internal server error - Error while searching for contacts security: @@ -2275,6 +2891,32 @@ paths: summary: Search contacts tags: - Contact + /v1/contact/unconfirmed/{paymail}: + patch: + description: Unconfirm contact. For contact with status "confirmed" change status + to "unconfirmed" + parameters: + - description: Paymail address of the contact the user wants to unconfirm + in: path + name: paymail + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + "404": + description: Contact not found + "422": + description: Contact status not confirmed + "500": + description: Internal server error + security: + - x-auth-xpub: [] + summary: Unconfirm contact + tags: + - Contact /v1/destination: get: description: Get a destination @@ -2361,8 +3003,7 @@ paths: post: description: Count Destinations parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body name: CountDestinations schema: @@ -2388,9 +3029,9 @@ paths: post: description: Search for a destination parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body name: SearchDestinations schema: @@ -2496,8 +3137,7 @@ paths: post: description: Count of transactions parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body name: CountTransactions schema: @@ -2550,9 +3190,9 @@ paths: post: description: Search transaction parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body name: SearchTransactions schema: @@ -2610,12 +3250,11 @@ paths: post: description: Count of UTXOs parameters: - - description: Enables precise filtering of resource counts using custom conditions - or metadata, catering to specific business or analysis needs + - description: Enables filtering of elements to be counted in: body - name: CountRequestParameters + name: CountUtxos schema: - $ref: '#/definitions/actions.CountRequestParameters' + $ref: '#/definitions/utxos.CountUtxos' produces: - application/json responses: @@ -2624,8 +3263,7 @@ paths: schema: type: number "400": - description: Bad request - Error while parsing CountRequestParameters from - request body + description: Bad request - Error while parsing CountUtxos from request body "500": description: Internal Server Error - Error while fetching count of utxos security: @@ -2637,13 +3275,13 @@ paths: post: description: Search UTXO parameters: - - description: Supports targeted resource searches with filters for metadata - and custom conditions, plus options for pagination and sorting to streamline - data exploration and analysis + - description: Supports targeted resource searches with filters and metadata, + plus options for pagination and sorting to streamline data exploration and + analysis in: body - name: SearchRequestParameters + name: SearchUtxos schema: - $ref: '#/definitions/actions.SearchRequestParameters' + $ref: '#/definitions/utxos.SearchUtxos' produces: - application/json responses: @@ -2654,8 +3292,8 @@ paths: $ref: '#/definitions/models.Utxo' type: array "400": - description: Bad request - Error while parsing SearchRequestParameters from - request body + description: Bad request - Error while parsing SearchUtxos from request + body "500": description: Internal server error - Error while searching for utxos security: diff --git a/engine/action_access_key.go b/engine/action_access_key.go index db22bcaa4..26a54c154 100644 --- a/engine/action_access_key.go +++ b/engine/action_access_key.go @@ -73,7 +73,7 @@ func (c *Client) GetAccessKey(ctx context.Context, xPubID, id string) (*AccessKe // GetAccessKeys will get all the access keys from the Datastore func (c *Client) GetAccessKeys(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*AccessKey, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_access_keys") @@ -92,7 +92,7 @@ func (c *Client) GetAccessKeys(ctx context.Context, metadataConditions *Metadata // GetAccessKeysCount will get a count of all the access keys from the Datastore func (c *Client) GetAccessKeysCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_access_keys_count") @@ -113,7 +113,7 @@ func (c *Client) GetAccessKeysCount(ctx context.Context, metadataConditions *Met // // metadataConditions is the metadata to match to the access keys being returned func (c *Client) GetAccessKeysByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*AccessKey, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_access_keys") @@ -139,7 +139,7 @@ func (c *Client) GetAccessKeysByXPubID(ctx context.Context, xPubID string, metad // GetAccessKeysByXPubIDCount will get a count of all existing access keys from the Datastore func (c *Client) GetAccessKeysByXPubIDCount(ctx context.Context, xPubID string, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_access_keys") diff --git a/engine/action_contact.go b/engine/action_contact.go index 513e70802..f3098a949 100644 --- a/engine/action_contact.go +++ b/engine/action_contact.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/bitcoin-sv/go-paymail" "github.com/bitcoin-sv/spv-wallet/engine/datastore" ) @@ -194,7 +195,6 @@ func (c *Client) DeleteContact(ctx context.Context, id string) error { } func (c *Client) AcceptContact(ctx context.Context, xPubID, paymail string) error { - contact, err := getContact(ctx, paymail, xPubID, c.DefaultModelOptions()...) if err != nil { c.logContactError(xPubID, paymail, fmt.Sprintf("unexpected error while geting contact: %s", err.Error())) @@ -302,7 +302,7 @@ func (c *Client) getPaymail(ctx context.Context, xpubID, paymailAddr string) (*P emptyConditions := make(map[string]interface{}) - paymails, err := c.GetPaymailAddressesByXPubID(ctx, xpubID, nil, &emptyConditions, nil) + paymails, err := c.GetPaymailAddressesByXPubID(ctx, xpubID, nil, emptyConditions, nil) if err != nil { return nil, err } @@ -316,7 +316,6 @@ func (c *Client) getPaymail(ctx context.Context, xpubID, paymailAddr string) (*P } func (c *Client) upsertContact(ctx context.Context, pmSrvnt *PaymailServant, reqXPubID, ctcFName string, ctcPaymail *paymail.SanitisedPaymail, opts ...ModelOps) (*Contact, error) { - contactPki, err := pmSrvnt.GetPkiForPaymail(ctx, ctcPaymail) if err != nil { return nil, fmt.Errorf("geting PKI for %s failed. Reason: %w", ctcPaymail.Address, err) diff --git a/engine/action_destination.go b/engine/action_destination.go index b67232383..be3d13f47 100644 --- a/engine/action_destination.go +++ b/engine/action_destination.go @@ -78,7 +78,7 @@ func (c *Client) NewDestinationForLockingScript(ctx context.Context, xPubID, loc // GetDestinations will get all the destinations from the Datastore func (c *Client) GetDestinations(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Destination, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_destinations") @@ -97,7 +97,7 @@ func (c *Client) GetDestinations(ctx context.Context, metadataConditions *Metada // GetDestinationsCount will get a count of all the destinations from the Datastore func (c *Client) GetDestinationsCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_destinations_count") diff --git a/engine/action_draft_transaction.go b/engine/action_draft_transaction.go index 828fa441a..016ea8735 100644 --- a/engine/action_draft_transaction.go +++ b/engine/action_draft_transaction.go @@ -24,7 +24,7 @@ func (c *Client) GetDraftTransactionByID(ctx context.Context, id string, opts .. // GetDraftTransactions will get all the draft transactions from the Datastore func (c *Client) GetDraftTransactions(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*DraftTransaction, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_draft_transactions") @@ -43,7 +43,7 @@ func (c *Client) GetDraftTransactions(ctx context.Context, metadataConditions *M // GetDraftTransactionsCount will get a count of all the draft transactions from the Datastore func (c *Client) GetDraftTransactionsCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_draft_transactions_count") diff --git a/engine/action_paymails.go b/engine/action_paymails.go index f8527810b..9bf1a86da 100644 --- a/engine/action_paymails.go +++ b/engine/action_paymails.go @@ -27,7 +27,7 @@ func (c *Client) GetPaymailAddress(ctx context.Context, address string, opts ... // GetPaymailAddresses will get all the paymail addresses from the Datastore func (c *Client) GetPaymailAddresses(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*PaymailAddress, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_paymail_addresses") @@ -46,7 +46,7 @@ func (c *Client) GetPaymailAddresses(ctx context.Context, metadataConditions *Me // GetPaymailAddressesCount will get a count of all the paymail addresses from the Datastore func (c *Client) GetPaymailAddressesCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_paymail_addresses_count") @@ -65,17 +65,17 @@ func (c *Client) GetPaymailAddressesCount(ctx context.Context, metadataCondition // GetPaymailAddressesByXPubID will get all the paymail addresses for an xPubID from the Datastore func (c *Client) GetPaymailAddressesByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, + conditions map[string]interface{}, queryParams *datastore.QueryParams, ) ([]*PaymailAddress, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_paymail_by_xpub") if conditions == nil { x := make(map[string]interface{}) - conditions = &x + conditions = x } // add the xpub_id to the conditions - (*conditions)["xpub_id"] = xPubID + conditions["xpub_id"] = xPubID // Get the paymail address paymailAddresses, err := getPaymailAddresses( diff --git a/engine/action_transaction.go b/engine/action_transaction.go index d6b390198..8befeaef5 100644 --- a/engine/action_transaction.go +++ b/engine/action_transaction.go @@ -139,7 +139,7 @@ func (c *Client) GetTransactionByHex(ctx context.Context, hex string) (*Transact // GetTransactions will get all the transactions from the Datastore func (c *Client) GetTransactions(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Transaction, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_transactions") @@ -158,7 +158,7 @@ func (c *Client) GetTransactions(ctx context.Context, metadataConditions *Metada // GetTransactionsCount will get a count of all the transactions from the Datastore func (c *Client) GetTransactionsCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_transactions_count") @@ -285,7 +285,7 @@ func (c *Client) RevertTransaction(ctx context.Context, id string) error { // check that the utxos of this transaction have not been spent // this transaction needs to be the tip of the chain - conditions := &map[string]interface{}{ + conditions := map[string]interface{}{ "transaction_id": transaction.ID, } var utxos []*Utxo @@ -415,16 +415,14 @@ func (c *Client) UpdateTransaction(ctx context.Context, callbackResp *broadcast. return processSyncTxSave(ctx, txInfo, syncTx, tx) } -func generateTxIDFilterConditions(txIDs []string) *map[string]interface{} { +func generateTxIDFilterConditions(txIDs []string) map[string]interface{} { orConditions := make([]map[string]interface{}, len(txIDs)) for i, txID := range txIDs { orConditions[i] = map[string]interface{}{"id": txID} } - conditions := &map[string]interface{}{ + return map[string]interface{}{ "$or": orConditions, } - - return conditions } diff --git a/engine/action_transaction_test.go b/engine/action_transaction_test.go index eb36386e5..112a1ec1b 100644 --- a/engine/action_transaction_test.go +++ b/engine/action_transaction_test.go @@ -48,7 +48,7 @@ func Test_RevertTransaction(t *testing.T) { // check utxos where reverted var utxos []*Utxo - conditions := &map[string]interface{}{ + conditions := map[string]interface{}{ xPubIDField: transaction.XPubID, } utxos, err = client.GetUtxos(ctx, nil, conditions, nil, client.DefaultModelOptions()...) @@ -300,7 +300,7 @@ func initRevertTransactionData(t *testing.T) (context.Context, ClientInterface, assert.Equal(t, SyncStatusReady, syncTx.BroadcastStatus) var utxos []*Utxo - conditions := &map[string]interface{}{ + conditions := map[string]interface{}{ xPubIDField: transaction.XPubID, } utxos, err = client.GetUtxos(ctx, nil, conditions, nil, client.DefaultModelOptions()...) diff --git a/engine/action_utxo.go b/engine/action_utxo.go index 844c40a30..b5a0edd03 100644 --- a/engine/action_utxo.go +++ b/engine/action_utxo.go @@ -9,7 +9,7 @@ import ( // GetUtxos will get all the utxos from the Datastore func (c *Client) GetUtxos(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Utxo, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_utxos") @@ -31,7 +31,7 @@ func (c *Client) GetUtxos(ctx context.Context, metadataConditions *Metadata, // GetUtxosCount will get a count of all the utxos from the Datastore func (c *Client) GetUtxosCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_utxos_count") @@ -49,7 +49,7 @@ func (c *Client) GetUtxosCount(ctx context.Context, metadataConditions *Metadata } // GetUtxosByXpubID will get utxos based on an xPub -func (c *Client) GetUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, +func (c *Client) GetUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, ) ([]*Utxo, error) { // Check for existing NewRelic transaction diff --git a/engine/action_xpub.go b/engine/action_xpub.go index 9147cd9f2..2c6ace53d 100644 --- a/engine/action_xpub.go +++ b/engine/action_xpub.go @@ -89,7 +89,7 @@ func (c *Client) UpdateXpubMetadata(ctx context.Context, xPubID string, metadata // GetXPubs gets all xpubs matching the conditions func (c *Client) GetXPubs(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Xpub, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_destinations") @@ -107,7 +107,7 @@ func (c *Client) GetXPubs(ctx context.Context, metadataConditions *Metadata, // GetXPubsCount gets a count of all xpubs matching the conditions func (c *Client) GetXPubsCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { // Check for existing NewRelic transaction ctx = c.GetOrStartTxn(ctx, "get_destinations") diff --git a/engine/admin_actions_stats.go b/engine/admin_actions_stats.go index 44902cc14..bbbec4a85 100644 --- a/engine/admin_actions_stats.go +++ b/engine/admin_actions_stats.go @@ -54,7 +54,7 @@ func (c *Client) GetStats(ctx context.Context, opts ...ModelOps) (*AdminStats, e "deleted_at": nil, } if paymailAddressCount, err = getPaymailAddressesCount( - ctx, nil, &conditions, defaultOpts..., + ctx, nil, conditions, defaultOpts..., ); err != nil { return nil, err } diff --git a/engine/client_datastore.go b/engine/client_datastore.go index abb7e1435..199f90789 100644 --- a/engine/client_datastore.go +++ b/engine/client_datastore.go @@ -12,23 +12,23 @@ const ( ) // processCustomFields will process all custom fields -func processCustomFields(conditions *map[string]interface{}) { +func processCustomFields(conditions map[string]interface{}) { // Process the xpub_output_value - _, ok := (*conditions)["xpub_output_value"] + _, ok := conditions["xpub_output_value"] if ok { processXpubOutputValueConditions(conditions) } // Process the xpub_output_value - _, ok = (*conditions)["xpub_metadata"] + _, ok = conditions["xpub_metadata"] if ok { processXpubMetadataConditions(conditions) } } // processXpubOutputValueConditions will process xpub_output_value -func processXpubOutputValueConditions(conditions *map[string]interface{}) { - m, _ := json.Marshal((*conditions)["xpub_output_value"]) //nolint:errchkjson // this check might break the current code +func processXpubOutputValueConditions(conditions map[string]interface{}) { + m, _ := json.Marshal(conditions["xpub_output_value"]) //nolint:errchkjson // this check might break the current code var r map[string]interface{} _ = json.Unmarshal(m, &r) @@ -40,23 +40,23 @@ func processXpubOutputValueConditions(conditions *map[string]interface{}) { }) } if len(xPubOutputValue) > 0 { - _, ok := (*conditions)[conditionAnd] + _, ok := conditions[conditionAnd] if ok { - and := (*conditions)[conditionAnd].([]map[string]interface{}) + and := conditions[conditionAnd].([]map[string]interface{}) and = append(and, xPubOutputValue...) - (*conditions)[conditionAnd] = and + conditions[conditionAnd] = and } else { - (*conditions)[conditionAnd] = xPubOutputValue + conditions[conditionAnd] = xPubOutputValue } } - delete(*conditions, "xpub_output_value") + delete(conditions, "xpub_output_value") } // processXpubMetadataConditions will process xpub_metadata -func processXpubMetadataConditions(conditions *map[string]interface{}) { +func processXpubMetadataConditions(conditions map[string]interface{}) { // marshal / unmarshal into standard map[string]interface{} - m, _ := json.Marshal((*conditions)["xpub_metadata"]) //nolint:errchkjson // this check might break the current code + m, _ := json.Marshal(conditions["xpub_metadata"]) //nolint:errchkjson // this check might break the current code var r map[string]interface{} _ = json.Unmarshal(m, &r) @@ -70,17 +70,17 @@ func processXpubMetadataConditions(conditions *map[string]interface{}) { }) } if len(xPubMetadata) > 0 { - _, ok := (*conditions)[conditionAnd] + _, ok := conditions[conditionAnd] if ok { - and := (*conditions)[conditionAnd].([]map[string]interface{}) + and := conditions[conditionAnd].([]map[string]interface{}) and = append(and, xPubMetadata...) - (*conditions)[conditionAnd] = and + conditions[conditionAnd] = and } else { - (*conditions)[conditionAnd] = xPubMetadata + conditions[conditionAnd] = xPubMetadata } } } - delete(*conditions, "xpub_metadata") + delete(conditions, "xpub_metadata") } // getMongoIndexes will get indexes from mongo diff --git a/engine/datastore/client.go b/engine/datastore/client.go index 7858dde2e..11e9a453f 100644 --- a/engine/datastore/client.go +++ b/engine/datastore/client.go @@ -39,10 +39,10 @@ type ( // fieldConfig is the configuration for custom fields fieldConfig struct { - arrayFields []string // Fields that are an array (string, string, string) - customMongoConditionProcessor func(conditions *map[string]interface{}) // Function for processing custom conditions (arrays, objects) - customMongoIndexer func() map[string][]mongo.IndexModel // Function for returning custom mongo indexes - objectFields []string // Fields that are objects/JSON (metadata) + arrayFields []string // Fields that are an array (string, string, string) + customMongoConditionProcessor func(conditions map[string]interface{}) // Function for processing custom conditions (arrays, objects) + customMongoIndexer func() map[string][]mongo.IndexModel // Function for returning custom mongo indexes + objectFields []string // Fields that are objects/JSON (metadata) } ) @@ -197,7 +197,7 @@ func (c *Client) GetObjectFields() []string { } // GetMongoConditionProcessor will return a custom mongo condition processor if set -func (c *Client) GetMongoConditionProcessor() func(conditions *map[string]interface{}) { +func (c *Client) GetMongoConditionProcessor() func(conditions map[string]interface{}) { if c.options.fields.customMongoConditionProcessor != nil { return c.options.fields.customMongoConditionProcessor } diff --git a/engine/datastore/client_options.go b/engine/datastore/client_options.go index 27118090c..ee53439af 100644 --- a/engine/datastore/client_options.go +++ b/engine/datastore/client_options.go @@ -227,7 +227,7 @@ func WithCustomFields(arrayFields []string, objectFields []string) ClientOps { } // WithCustomMongoConditionProcessor will add a custom mongo condition processor function -func WithCustomMongoConditionProcessor(f func(conditions *map[string]interface{})) ClientOps { +func WithCustomMongoConditionProcessor(f func(conditions map[string]interface{})) ClientOps { return func(c *clientOptions) { if f != nil { c.fields.customMongoConditionProcessor = f diff --git a/engine/datastore/interface.go b/engine/datastore/interface.go index f474e984e..8858dcb9f 100644 --- a/engine/datastore/interface.go +++ b/engine/datastore/interface.go @@ -38,7 +38,7 @@ type GetterInterface interface { GetDatabaseName() string GetMongoCollection(collectionName string) *mongo.Collection GetMongoCollectionByTableName(tableName string) *mongo.Collection - GetMongoConditionProcessor() func(conditions *map[string]interface{}) + GetMongoConditionProcessor() func(conditions map[string]interface{}) GetMongoIndexer() func() map[string][]mongo.IndexModel GetObjectFields() []string GetTableName(modelName string) string diff --git a/engine/datastore/mongodb.go b/engine/datastore/mongodb.go index 82e4bea08..4997794d0 100644 --- a/engine/datastore/mongodb.go +++ b/engine/datastore/mongodb.go @@ -458,7 +458,7 @@ func setPrefix(prefix, collection string) string { func getMongoQueryConditions( model interface{}, conditions map[string]interface{}, - customProcessor func(conditions *map[string]interface{}), + customProcessor func(conditions map[string]interface{}), ) map[string]interface{} { if conditions == nil { conditions = map[string]interface{}{} @@ -470,7 +470,7 @@ func getMongoQueryConditions( delete(conditions, sqlIDField) } - processMongoConditions(&conditions, customProcessor) + processMongoConditions(conditions, customProcessor) } // add model ID to the query conditions, if set on the model @@ -483,18 +483,18 @@ func getMongoQueryConditions( } // processMongoConditions will process all conditions for Mongo, including custom processing -func processMongoConditions(conditions *map[string]interface{}, - customProcessor func(conditions *map[string]interface{}), -) *map[string]interface{} { +func processMongoConditions(conditions map[string]interface{}, + customProcessor func(conditions map[string]interface{}), +) map[string]interface{} { // Transform the id field to mongo _id field - _, ok := (*conditions)[sqlIDField] + _, ok := conditions[sqlIDField] if ok { - (*conditions)[mongoIDField] = (*conditions)[sqlIDField] - delete(*conditions, sqlIDField) + conditions[mongoIDField] = conditions[sqlIDField] + delete(conditions, sqlIDField) } // Transform the map of metadata to key / value query - _, ok = (*conditions)[metadataField] + _, ok = conditions[metadataField] if ok { processMetadataConditions(conditions) } @@ -505,16 +505,16 @@ func processMongoConditions(conditions *map[string]interface{}, } // Handle all conditions post-processing - for key, condition := range *conditions { + for key, condition := range conditions { if key == conditionAnd || key == conditionOr { var slice []map[string]interface{} a, _ := json.Marshal(condition) //nolint:errchkjson // this check might break the current code _ = json.Unmarshal(a, &slice) var newConditions []map[string]interface{} for _, c := range slice { - newConditions = append(newConditions, *processMongoConditions(&c, customProcessor)) //nolint:scopelint,gosec // ignore for now + newConditions = append(newConditions, processMongoConditions(c, customProcessor)) //nolint:scopelint,gosec // ignore for now } - (*conditions)[key] = newConditions + conditions[key] = newConditions } } @@ -522,9 +522,9 @@ func processMongoConditions(conditions *map[string]interface{}, } // processMetadataConditions will process metadata conditions -func processMetadataConditions(conditions *map[string]interface{}) { +func processMetadataConditions(conditions map[string]interface{}) { // marshal / unmarshal into standard map[string]interface{} - m, _ := json.Marshal((*conditions)[metadataField]) //nolint:errchkjson // this check might break the current code + m, _ := json.Marshal(conditions[metadataField]) //nolint:errchkjson // this check might break the current code var r map[string]interface{} _ = json.Unmarshal(m, &r) @@ -539,18 +539,18 @@ func processMetadataConditions(conditions *map[string]interface{}) { // Found some metadata if len(metadata) > 0 { - _, ok := (*conditions)[conditionAnd] + _, ok := conditions[conditionAnd] if ok { - and := (*conditions)[conditionAnd].([]map[string]interface{}) + and := conditions[conditionAnd].([]map[string]interface{}) and = append(and, metadata...) - (*conditions)[conditionAnd] = and + conditions[conditionAnd] = and } else { - (*conditions)[conditionAnd] = metadata + conditions[conditionAnd] = metadata } } // Remove the field from conditions - delete(*conditions, metadataField) + delete(conditions, metadataField) } // openMongoDatabase will open a new database or use an existing connection diff --git a/engine/datastore/mongodb_test.go b/engine/datastore/mongodb_test.go index 6fcbaf2dc..12a77597a 100644 --- a/engine/datastore/mongodb_test.go +++ b/engine/datastore/mongodb_test.go @@ -409,9 +409,9 @@ func TestClient_getMongoQueryConditions(t *testing.T) { // processObjectMetadataConditions is an example of processing custom object metadata // ObjectID -> Key/Value -func processObjectMetadataConditions(conditions *map[string]interface{}) { +func processObjectMetadataConditions(conditions map[string]interface{}) { // marshal / unmarshal into standard map[string]interface{} - m, _ := json.Marshal((*conditions)[objectMetadataField]) //nolint:errchkjson // this check might break the current code + m, _ := json.Marshal(conditions[objectMetadataField]) //nolint:errchkjson // this check might break the current code var r map[string]interface{} _ = json.Unmarshal(m, &r) @@ -425,25 +425,25 @@ func processObjectMetadataConditions(conditions *map[string]interface{}) { }) } if len(objectMetadata) > 0 { - _, ok := (*conditions)[conditionAnd] + _, ok := conditions[conditionAnd] if ok { - and := (*conditions)[conditionAnd].([]map[string]interface{}) + and := conditions[conditionAnd].([]map[string]interface{}) and = append(and, objectMetadata...) - (*conditions)[conditionAnd] = and + conditions[conditionAnd] = and } else { - (*conditions)[conditionAnd] = objectMetadata + conditions[conditionAnd] = objectMetadata } } } - delete(*conditions, objectMetadataField) + delete(conditions, objectMetadataField) } // processObjectOutputValueConditions is an example of processing custom object value // ObjectID -> Value -func processObjectOutputValueConditions(conditions *map[string]interface{}) { +func processObjectOutputValueConditions(conditions map[string]interface{}) { fieldName := "object_output_value" - m, _ := json.Marshal((*conditions)[fieldName]) //nolint:errchkjson // this check might break the current code + m, _ := json.Marshal(conditions[fieldName]) //nolint:errchkjson // this check might break the current code var r map[string]interface{} _ = json.Unmarshal(m, &r) @@ -455,15 +455,15 @@ func processObjectOutputValueConditions(conditions *map[string]interface{}) { }) } if len(objectOutputValue) > 0 { - _, ok := (*conditions)[conditionAnd] + _, ok := conditions[conditionAnd] if ok { - and := (*conditions)[conditionAnd].([]map[string]interface{}) + and := conditions[conditionAnd].([]map[string]interface{}) and = append(and, objectOutputValue...) - (*conditions)[conditionAnd] = and + conditions[conditionAnd] = and } else { - (*conditions)[conditionAnd] = objectOutputValue + conditions[conditionAnd] = objectOutputValue } } - delete(*conditions, fieldName) + delete(conditions, fieldName) } diff --git a/engine/interface.go b/engine/interface.go index 1c1e98d41..372ff2407 100644 --- a/engine/interface.go +++ b/engine/interface.go @@ -19,14 +19,14 @@ import ( // AccessKeyService is the access key actions type AccessKeyService interface { GetAccessKey(ctx context.Context, xPubID, pubAccessKey string) (*AccessKey, error) - GetAccessKeys(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, + GetAccessKeys(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*AccessKey, error) GetAccessKeysCount(ctx context.Context, metadata *Metadata, - conditions *map[string]interface{}, opts ...ModelOps) (int64, error) - GetAccessKeysByXPubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, + conditions map[string]interface{}, opts ...ModelOps) (int64, error) + GetAccessKeysByXPubID(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*AccessKey, error) GetAccessKeysByXPubIDCount(ctx context.Context, xPubID string, metadata *Metadata, - conditions *map[string]interface{}, opts ...ModelOps) (int64, error) + conditions map[string]interface{}, opts ...ModelOps) (int64, error) NewAccessKey(ctx context.Context, rawXpubKey string, opts ...ModelOps) (*AccessKey, error) RevokeAccessKey(ctx context.Context, rawXpubKey, id string, opts ...ModelOps) (*AccessKey, error) } @@ -34,14 +34,14 @@ type AccessKeyService interface { // AdminService is the SPV Wallet Engine admin service interface comprised of all services available for admins type AdminService interface { GetStats(ctx context.Context, opts ...ModelOps) (*AdminStats, error) - GetPaymailAddresses(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, + GetPaymailAddresses(ctx context.Context, metadataConditions *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*PaymailAddress, error) GetPaymailAddressesCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps) (int64, error) + conditions map[string]interface{}, opts ...ModelOps) (int64, error) GetXPubs(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Xpub, error) + conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Xpub, error) GetXPubsCount(ctx context.Context, metadataConditions *Metadata, - conditions *map[string]interface{}, opts ...ModelOps) (int64, error) + conditions map[string]interface{}, opts ...ModelOps) (int64, error) } // ClientService is the client related services @@ -79,10 +79,10 @@ type DestinationService interface { GetDestinationByID(ctx context.Context, xPubID, id string) (*Destination, error) GetDestinationByAddress(ctx context.Context, xPubID, address string) (*Destination, error) GetDestinationByLockingScript(ctx context.Context, xPubID, lockingScript string) (*Destination, error) - GetDestinations(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, + GetDestinations(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Destination, error) GetDestinationsCount(ctx context.Context, metadata *Metadata, - conditions *map[string]interface{}, opts ...ModelOps) (int64, error) + conditions map[string]interface{}, opts ...ModelOps) (int64, error) GetDestinationsByXpubID(ctx context.Context, xPubID string, usingMetadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams) ([]*Destination, error) GetDestinationsByXpubIDCount(ctx context.Context, xPubID string, usingMetadata *Metadata, @@ -100,10 +100,10 @@ type DestinationService interface { // DraftTransactionService is the draft transactions actions type DraftTransactionService interface { - GetDraftTransactions(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, + GetDraftTransactions(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*DraftTransaction, error) GetDraftTransactionsCount(ctx context.Context, metadata *Metadata, - conditions *map[string]interface{}, opts ...ModelOps) (int64, error) + conditions map[string]interface{}, opts ...ModelOps) (int64, error) } // HTTPInterface is the HTTP client interface @@ -124,7 +124,7 @@ type PaymailService interface { GetPaymailConfig() *PaymailServerOptions GetPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (*PaymailAddress, error) GetPaymailAddressesByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata, - conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*PaymailAddress, error) + conditions map[string]interface{}, queryParams *datastore.QueryParams) ([]*PaymailAddress, error) NewPaymailAddress(ctx context.Context, key, address, publicName, avatar string, opts ...ModelOps) (*PaymailAddress, error) UpdatePaymailAddress(ctx context.Context, address, publicName, @@ -138,10 +138,10 @@ type TransactionService interface { GetTransaction(ctx context.Context, xPubID, txID string) (*Transaction, error) GetTransactionsByIDs(ctx context.Context, txIDs []string) ([]*Transaction, error) GetTransactionByHex(ctx context.Context, hex string) (*Transaction, error) - GetTransactions(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, + GetTransactions(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Transaction, error) GetTransactionsCount(ctx context.Context, metadata *Metadata, - conditions *map[string]interface{}, opts ...ModelOps) (int64, error) + conditions map[string]interface{}, opts ...ModelOps) (int64, error) GetTransactionsByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams) ([]*Transaction, error) GetTransactionsByXpubIDCount(ctx context.Context, xPubID string, metadata *Metadata, @@ -160,11 +160,11 @@ type TransactionService interface { type UTXOService interface { GetUtxo(ctx context.Context, xPubKey, txID string, outputIndex uint32) (*Utxo, error) GetUtxoByTransactionID(ctx context.Context, txID string, outputIndex uint32) (*Utxo, error) - GetUtxos(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, + GetUtxos(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Utxo, error) GetUtxosCount(ctx context.Context, metadata *Metadata, - conditions *map[string]interface{}, opts ...ModelOps) (int64, error) - GetUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, + conditions map[string]interface{}, opts ...ModelOps) (int64, error) + GetUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams) ([]*Utxo, error) UnReserveUtxos(ctx context.Context, xPubID, draftID string) error } diff --git a/engine/model_access_keys.go b/engine/model_access_keys.go index f4caa5b2b..e62b0dcc5 100644 --- a/engine/model_access_keys.go +++ b/engine/model_access_keys.go @@ -69,7 +69,7 @@ func getAccessKey(ctx context.Context, id string, opts ...ModelOps) (*AccessKey, } // getAccessKeys will get all the access keys with the given conditions -func getAccessKeys(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getAccessKeys(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*AccessKey, error) { modelItems := make([]*AccessKey, 0) @@ -81,14 +81,14 @@ func getAccessKeys(ctx context.Context, metadata *Metadata, conditions *map[stri } // getAccessKeysCount will get a count of all the access keys with the given conditions -func getAccessKeysCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getAccessKeysCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { return getModelCountByConditions(ctx, ModelAccessKey, AccessKey{}, metadata, conditions, opts...) } // getAccessKeysByXPubID will get all the access keys that match the metadata search -func getAccessKeysByXPubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, +func getAccessKeysByXPubID(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*AccessKey, error) { // Construct an empty model @@ -96,7 +96,7 @@ func getAccessKeysByXPubID(ctx context.Context, xPubID string, metadata *Metadat dbConditions := map[string]interface{}{} if conditions != nil { - dbConditions = *conditions + dbConditions = conditions } dbConditions[xPubIDField] = xPubID @@ -127,11 +127,11 @@ func getAccessKeysByXPubID(ctx context.Context, xPubID string, metadata *Metadat // getAccessKeysByXPubIDCount will get a count of all the access keys that match the metadata search func getAccessKeysByXPubIDCount(ctx context.Context, xPubID string, metadata *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { dbConditions := map[string]interface{}{} if conditions != nil { - dbConditions = *conditions + dbConditions = conditions } dbConditions[xPubIDField] = xPubID diff --git a/engine/model_contact.go b/engine/model_contact.go index e967a53a2..4a5e6c5dd 100644 --- a/engine/model_contact.go +++ b/engine/model_contact.go @@ -115,7 +115,7 @@ func getContacts(ctx context.Context, metadata *Metadata, conditions map[string] conditions[deletedAtField] = nil contacts := make([]*Contact, 0) - if err := getModelsByConditions(ctx, ModelContact, &contacts, metadata, &conditions, queryParams, opts...); err != nil { + if err := getModelsByConditions(ctx, ModelContact, &contacts, metadata, conditions, queryParams, opts...); err != nil { return nil, err } @@ -130,7 +130,7 @@ func getContactsByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions[deletedAtField] = nil contacts := make([]*Contact, 0) - if err := getModelsByConditions(ctx, ModelContact, &contacts, metadata, &conditions, queryParams, opts...); err != nil { + if err := getModelsByConditions(ctx, ModelContact, &contacts, metadata, conditions, queryParams, opts...); err != nil { return nil, err } diff --git a/engine/model_destinations.go b/engine/model_destinations.go index d6728891c..22460b430 100644 --- a/engine/model_destinations.go +++ b/engine/model_destinations.go @@ -139,7 +139,7 @@ func getDestinationByLockingScript(ctx context.Context, lockingScript string, op } // getDestinations will get all the destinations with the given conditions -func getDestinations(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getDestinations(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Destination, error) { modelItems := make([]*Destination, 0) @@ -151,7 +151,7 @@ func getDestinations(ctx context.Context, metadata *Metadata, conditions *map[st } // getDestinationsCount will get a count of all the destinations with the given conditions -func getDestinationsCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getDestinationsCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { return getModelCountByConditions(ctx, ModelDestination, Destination{}, metadata, conditions, opts...) diff --git a/engine/model_draft_transactions.go b/engine/model_draft_transactions.go index 772a641db..635a75911 100644 --- a/engine/model_draft_transactions.go +++ b/engine/model_draft_transactions.go @@ -95,7 +95,7 @@ func getDraftTransactionID(ctx context.Context, xPubID, id string, } // getDraftTransactions will get all the draft transactions with the given conditions -func getDraftTransactions(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getDraftTransactions(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*DraftTransaction, error) { modelItems := make([]*DraftTransaction, 0) @@ -107,7 +107,7 @@ func getDraftTransactions(ctx context.Context, metadata *Metadata, conditions *m } // getDraftTransactionsCount will get a count of all the access keys with the given conditions -func getDraftTransactionsCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getDraftTransactionsCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { return getModelCountByConditions(ctx, ModelDraftTransaction, DraftTransaction{}, metadata, conditions, opts...) @@ -157,7 +157,7 @@ func (m *DraftTransaction) processConfigOutputs(ctx context.Context) error { conditions := map[string]interface{}{ xPubIDField: m.XpubID, } - paymails, err := c.GetPaymailAddressesByXPubID(ctx, m.XpubID, nil, &conditions, nil) + paymails, err := c.GetPaymailAddressesByXPubID(ctx, m.XpubID, nil, conditions, nil) if err == nil && len(paymails) != 0 { paymailFrom = fmt.Sprintf("%s@%s", paymails[0].Alias, paymails[0].Domain) } diff --git a/engine/model_get.go b/engine/model_get.go index f132d8d4f..9a3c21c5d 100644 --- a/engine/model_get.go +++ b/engine/model_get.go @@ -74,7 +74,7 @@ func getModelCount( // getModelsByConditions will get models by given conditions func getModelsByConditions(ctx context.Context, modelName ModelName, modelItems interface{}, - metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, + metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) error { dbConditions := map[string]interface{}{} @@ -83,12 +83,12 @@ func getModelsByConditions(ctx context.Context, modelName ModelName, modelItems dbConditions[metadataField] = metadata } - if conditions != nil && len(*conditions) > 0 { + if conditions != nil && len(conditions) > 0 { and := make([]map[string]interface{}, 0) if _, ok := dbConditions["$and"]; ok { and = dbConditions["$and"].([]map[string]interface{}) } - and = append(and, *conditions) + and = append(and, conditions) dbConditions["$and"] = and } @@ -108,7 +108,7 @@ func getModelsByConditions(ctx context.Context, modelName ModelName, modelItems // getModelsAggregateByConditions will get aggregates of models by given conditions func getModelsAggregateByConditions(ctx context.Context, modelName ModelName, models interface{}, - metadata *Metadata, conditions *map[string]interface{}, aggregateColumn string, + metadata *Metadata, conditions map[string]interface{}, aggregateColumn string, opts ...ModelOps, ) (map[string]interface{}, error) { dbConditions := map[string]interface{}{} @@ -117,12 +117,12 @@ func getModelsAggregateByConditions(ctx context.Context, modelName ModelName, mo dbConditions[metadataField] = metadata } - if conditions != nil && len(*conditions) > 0 { + if conditions != nil && len(conditions) > 0 { and := make([]map[string]interface{}, 0) if _, ok := dbConditions["$and"]; ok { and = dbConditions["$and"].([]map[string]interface{}) } - and = append(and, *conditions) + and = append(and, conditions) dbConditions["$and"] = and } @@ -143,7 +143,7 @@ func getModelsAggregateByConditions(ctx context.Context, modelName ModelName, mo // getModelCountByConditions will get model counts (sums) from given conditions func getModelCountByConditions(ctx context.Context, modelName ModelName, model interface{}, - metadata *Metadata, conditions *map[string]interface{}, opts ...ModelOps, + metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { dbConditions := map[string]interface{}{} @@ -151,12 +151,12 @@ func getModelCountByConditions(ctx context.Context, modelName ModelName, model i dbConditions[metadataField] = metadata } - if conditions != nil && len(*conditions) > 0 { + if conditions != nil && len(conditions) > 0 { and := make([]map[string]interface{}, 0) if _, ok := dbConditions["$and"]; ok { and = dbConditions["$and"].([]map[string]interface{}) } - and = append(and, *conditions) + and = append(and, conditions) dbConditions["$and"] = and } diff --git a/engine/model_paymail_addresses.go b/engine/model_paymail_addresses.go index 0aa160f6d..8a270c535 100644 --- a/engine/model_paymail_addresses.go +++ b/engine/model_paymail_addresses.go @@ -83,7 +83,7 @@ func getPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (* } // getPaymailAddresses will get all the paymail addresses with the given conditions -func getPaymailAddresses(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getPaymailAddresses(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*PaymailAddress, error) { modelItems := make([]*PaymailAddress, 0) @@ -95,7 +95,7 @@ func getPaymailAddresses(ctx context.Context, metadata *Metadata, conditions *ma } // getPaymailAddressesCount will get all the paymail addresses with the given conditions -func getPaymailAddressesCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getPaymailAddressesCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { return getModelCountByConditions(ctx, ModelPaymailAddress, PaymailAddress{}, metadata, conditions, opts...) diff --git a/engine/model_utxos.go b/engine/model_utxos.go index ae3a4f995..c32474d4c 100644 --- a/engine/model_utxos.go +++ b/engine/model_utxos.go @@ -257,7 +257,7 @@ func newUtxoFromTxID(txID string, index uint32, opts ...ModelOps) *Utxo { } // getUtxos will get all the utxos with the given conditions -func getUtxos(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getUtxos(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Utxo, error) { modelItems := make([]*Utxo, 0) @@ -269,14 +269,14 @@ func getUtxos(ctx context.Context, metadata *Metadata, conditions *map[string]in } // getAccessKeysCount will get a count of all the utxos with the given conditions -func getUtxosCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getUtxosCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { return getModelCountByConditions(ctx, ModelUtxo, Utxo{}, metadata, conditions, opts...) } // getTransactionsAggregate will get a count of all transactions per aggregate column with the given conditions -func getUtxosAggregate(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getUtxosAggregate(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, aggregateColumn string, opts ...ModelOps, ) (map[string]interface{}, error) { modelItems := make([]*Utxo, 0) @@ -291,12 +291,12 @@ func getUtxosAggregate(ctx context.Context, metadata *Metadata, conditions *map[ } // getUtxosByXpubID will return utxos by a given xPub ID -func getUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, +func getUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Utxo, error) { dbConditions := map[string]interface{}{} if conditions != nil { - dbConditions = *conditions + dbConditions = conditions } dbConditions[xPubIDField] = xPubID diff --git a/engine/model_xpubs.go b/engine/model_xpubs.go index 9c1d68eaf..3f197a426 100644 --- a/engine/model_xpubs.go +++ b/engine/model_xpubs.go @@ -124,7 +124,7 @@ func getXpubWithCache(ctx context.Context, client ClientInterface, } // getXPubs will get all the xpubs matching the conditions -func getXPubs(ctx context.Context, usingMetadata *Metadata, conditions *map[string]interface{}, +func getXPubs(ctx context.Context, usingMetadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Xpub, error) { modelItems := make([]*Xpub, 0) @@ -138,7 +138,7 @@ func getXPubs(ctx context.Context, usingMetadata *Metadata, conditions *map[stri // getXPubsCount will get a count of the xpubs matching the conditions func getXPubsCount(ctx context.Context, usingMetadata *Metadata, - conditions *map[string]interface{}, opts ...ModelOps, + conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { return getModelCountByConditions(ctx, ModelXPub, Xpub{}, usingMetadata, conditions, opts...) } diff --git a/engine/tx_repository.go b/engine/tx_repository.go index 194b47072..c9406d9ee 100644 --- a/engine/tx_repository.go +++ b/engine/tx_repository.go @@ -27,7 +27,7 @@ func getTransactionByID(ctx context.Context, xPubID, txID string, opts ...ModelO } // getTransactions will get all the transactions with the given conditions -func getTransactions(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getTransactions(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps, ) ([]*Transaction, error) { modelItems := make([]*Transaction, 0) @@ -39,7 +39,7 @@ func getTransactions(ctx context.Context, metadata *Metadata, conditions *map[st } // getTransactionsAggregate will get a count of all transactions per aggregate column with the given conditions -func getTransactionsAggregate(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getTransactionsAggregate(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, aggregateColumn string, opts ...ModelOps, ) (map[string]interface{}, error) { modelItems := make([]*Transaction, 0) @@ -54,7 +54,7 @@ func getTransactionsAggregate(ctx context.Context, metadata *Metadata, condition } // getTransactionsCount will get a count of all the transactions with the given conditions -func getTransactionsCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, +func getTransactionsCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps, ) (int64, error) { return getModelCountByConditions(ctx, ModelTransaction, Transaction{}, metadata, conditions, opts...) diff --git a/models/filter/access_key_filter.go b/models/filter/access_key_filter.go new file mode 100644 index 000000000..3c4791efb --- /dev/null +++ b/models/filter/access_key_filter.go @@ -0,0 +1,36 @@ +package filter + +// AccessKeyFilter is a struct for handling request parameters for destination search requests +type AccessKeyFilter struct { + ModelFilter `json:",inline"` + + // RevokedRange specifies the time range when a record was revoked. + RevokedRange *TimeRange `json:"revokedRange,omitempty"` +} + +// ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy +func (d *AccessKeyFilter) ToDbConditions() map[string]interface{} { + conditions := d.ModelFilter.ToDbConditions() + + // Column names come from the database model, see: /engine/model_access_keys.go + applyConditionsIfNotNil(conditions, "revoked_at", d.RevokedRange.ToDbConditions()) + + return conditions +} + +// AdminAccessKeyFilter wraps the AccessKeyFilter providing additional fields for admin access key search requests +type AdminAccessKeyFilter struct { + AccessKeyFilter `json:",inline"` + + XpubID *string `json:"xpubId,omitempty"` +} + +// ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy +func (d *AdminAccessKeyFilter) ToDbConditions() map[string]interface{} { + conditions := d.AccessKeyFilter.ToDbConditions() + + // Column names come from the database model, see: /engine/model_access_keys.go + applyIfNotNil(conditions, "xpub_id", d.XpubID) + + return conditions +} diff --git a/models/filter/access_key_filter_test.go b/models/filter/access_key_filter_test.go new file mode 100644 index 000000000..168eeef5f --- /dev/null +++ b/models/filter/access_key_filter_test.go @@ -0,0 +1,73 @@ +package filter + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestAccessKeyFilter(t *testing.T) { + t.Parallel() + + t.Run("default filter", func(t *testing.T) { + filter := AccessKeyFilter{} + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 1, len(dbConditions)) + assert.Nil(t, dbConditions["deleted_at"]) + }) + + t.Run("empty filter with include deleted", func(t *testing.T) { + filter := fromJSON[AccessKeyFilter](`{ + "includeDeleted": true + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 0, len(dbConditions)) + }) + + t.Run("with full RevokedRange", func(t *testing.T) { + filter := fromJSON[AccessKeyFilter](`{ + "includeDeleted": true, + "revokedRange": { + "from": "2024-02-26T11:01:28Z", + "to": "2024-02-25T11:01:28Z" + } + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 2, len(dbConditions["revoked_at"].(map[string]interface{}))) + }) + + t.Run("with empty RevokedRange", func(t *testing.T) { + filter := fromJSON[AccessKeyFilter](`{ + "includeDeleted": true, + "revokedRange": {} + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 0, len(dbConditions)) + }) + + t.Run("with partially filled RevokedRange", func(t *testing.T) { + filter := fromJSON[AccessKeyFilter](`{ + "includeDeleted": true, + "revokedRange": { + "from": "2024-02-26T11:01:28Z" + } + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 1, len(dbConditions["revoked_at"].(map[string]interface{}))) + }) + + t.Run("admin filter with xpubid", func(t *testing.T) { + filter := fromJSON[AdminAccessKeyFilter](`{ + "includeDeleted": true, + "xpubId": "thexpubid" + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, "thexpubid", dbConditions["xpub_id"]) + }) +} diff --git a/models/filter/contact_filter.go b/models/filter/contact_filter.go index be007c0df..f8275c2e5 100644 --- a/models/filter/contact_filter.go +++ b/models/filter/contact_filter.go @@ -3,15 +3,17 @@ package filter // ContactFilter is a struct for handling request parameters for contact search requests type ContactFilter struct { ModelFilter `json:",inline"` - ID *string `json:"id"` - FullName *string `json:"fullName"` - Paymail *string `json:"paymail"` - PubKey *string `json:"pubKey"` + ID *string `json:"id" example:"ffdbe74e-0700-4710-aac5-611a1f877c7f"` + FullName *string `json:"fullName" example:"Alice"` + Paymail *string `json:"paymail" example:"alice@example.com"` + PubKey *string `json:"pubKey" example:"0334f01ecb971e93db179e6fb320cd1466beb0c1ec6c1c6a37aa6cb02e53d5dd1a"` Status *string `json:"status,omitempty" enums:"unconfirmed,awaiting,confirmed,rejected"` } +var validContactStatuses = getEnumValues[ContactFilter]("Status") + // ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy -func (d *ContactFilter) ToDbConditions() map[string]interface{} { +func (d *ContactFilter) ToDbConditions() (map[string]interface{}, error) { conditions := d.ModelFilter.ToDbConditions() // Column names come from the database model, see: /engine/model_contact.go @@ -19,7 +21,9 @@ func (d *ContactFilter) ToDbConditions() map[string]interface{} { applyIfNotNil(conditions, "full_name", d.FullName) applyIfNotNil(conditions, "paymail", d.Paymail) applyIfNotNil(conditions, "pub_key", d.PubKey) - applyIfNotNil(conditions, "status", d.Status) + if err := checkAndApplyStrOption(conditions, "status", d.Status, validContactStatuses...); err != nil { + return nil, err + } - return conditions + return conditions, nil } diff --git a/models/filter/destination_filter.go b/models/filter/destination_filter.go index d219a5ded..4e71567ed 100644 --- a/models/filter/destination_filter.go +++ b/models/filter/destination_filter.go @@ -3,9 +3,9 @@ package filter // DestinationFilter is a struct for handling request parameters for destination search requests type DestinationFilter struct { ModelFilter `json:",inline"` - LockingScript *string `json:"locking_script,omitempty" example:"76a9147b05764a97f3b4b981471492aa703b188e45979b88ac"` + LockingScript *string `json:"lockingScript,omitempty" example:"76a9147b05764a97f3b4b981471492aa703b188e45979b88ac"` Address *string `json:"address,omitempty" example:"1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65"` - DraftID *string `json:"draft_id,omitempty" example:"b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7"` + DraftID *string `json:"draftId,omitempty" example:"b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7"` } // ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy diff --git a/models/filter/destination_filter_test.go b/models/filter/destination_filter_test.go index 9156a3eb2..966b2eef9 100644 --- a/models/filter/destination_filter_test.go +++ b/models/filter/destination_filter_test.go @@ -19,7 +19,7 @@ func TestDestinationFilter(t *testing.T) { t.Run("empty filter with include deleted", func(t *testing.T) { filter := fromJSON[DestinationFilter](`{ - "include_deleted": true + "includeDeleted": true }`) dbConditions := filter.ToDbConditions() @@ -28,11 +28,11 @@ func TestDestinationFilter(t *testing.T) { t.Run("with full CreatedRange", func(t *testing.T) { filter := fromJSON[DestinationFilter](`{ - "created_range": { + "createdRange": { "from": "2024-02-26T11:01:28Z", "to": "2024-02-25T11:01:28Z" }, - "include_deleted": true + "includeDeleted": true }`) dbConditions := filter.ToDbConditions() @@ -43,10 +43,10 @@ func TestDestinationFilter(t *testing.T) { t.Run("with empty CreatedRange", func(t *testing.T) { filter := fromJSON[DestinationFilter](`{ - "locking_script": "test", + "lockingScript": "test", "address": "test", - "draft_id": "test", - "include_deleted": true + "draftId": "test", + "includeDeleted": true }`) dbConditions := filter.ToDbConditions() diff --git a/models/filter/model_filter.go b/models/filter/model_filter.go index 8f6682925..64666d9da 100644 --- a/models/filter/model_filter.go +++ b/models/filter/model_filter.go @@ -2,9 +2,14 @@ package filter // ModelFilter is a common model filter that contains common fields for all model filters. type ModelFilter struct { - IncludeDeleted *bool `json:"include_deleted,omitempty" example:"true"` - CreatedRange *TimeRange `json:"created_range,omitempty" swaggertype:"object,string"` - UpdatedRange *TimeRange `json:"updated_range,omitempty" swaggertype:"object,string"` + // IncludeDeleted is a flag whether or not to include deleted items in the search results + IncludeDeleted *bool `json:"includeDeleted,omitempty" swaggertype:"boolean" default:"false" example:"true"` + + // CreatedRange specifies the time range when a record was created. + CreatedRange *TimeRange `json:"createdRange,omitempty"` + + // UpdatedRange specifies the time range when a record was updated. + UpdatedRange *TimeRange `json:"updatedRange,omitempty"` } // ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy diff --git a/models/filter/paymail_filter.go b/models/filter/paymail_filter.go new file mode 100644 index 000000000..a63122e1c --- /dev/null +++ b/models/filter/paymail_filter.go @@ -0,0 +1,26 @@ +package filter + +// AdminPaymailFilter is a struct for handling request parameters for paymail_addresses search requests +type AdminPaymailFilter struct { + ModelFilter `json:",inline"` + + ID *string `json:"id,omitempty" example:"ffb86c103d17d87c15aaf080aab6be5415c9fa885309a79b04c9910e39f2b542"` + XpubID *string `json:"xpubId,omitempty" example:"79f90a6bab0a44402fc64828af820e9465645658aea2d138c5205b88e6dabd00"` + Alias *string `json:"alias,omitempty" example:"alice"` + Domain *string `json:"domain,omitempty" example:"example.com"` + PublicName *string `json:"publicName,omitempty" example:"Alice"` +} + +// ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy +func (d *AdminPaymailFilter) ToDbConditions() map[string]interface{} { + conditions := d.ModelFilter.ToDbConditions() + + // Column names come from the database model, see: /engine/model_paymail_addresses.go + applyIfNotNil(conditions, "id", d.ID) + applyIfNotNil(conditions, "xpub_id", d.XpubID) + applyIfNotNil(conditions, "alias", d.Alias) + applyIfNotNil(conditions, "domain", d.Domain) + applyIfNotNil(conditions, "public_name", d.PublicName) + + return conditions +} diff --git a/models/filter/paymail_filter_test.go b/models/filter/paymail_filter_test.go new file mode 100644 index 000000000..6097da057 --- /dev/null +++ b/models/filter/paymail_filter_test.go @@ -0,0 +1,63 @@ +package filter + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestPaymailFilter(t *testing.T) { + t.Parallel() + + t.Run("default filter", func(t *testing.T) { + filter := AdminPaymailFilter{} + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 1, len(dbConditions)) + assert.Nil(t, dbConditions["deleted_at"]) + }) + + t.Run("empty filter with include deleted", func(t *testing.T) { + filter := fromJSON[AdminPaymailFilter](`{ + "includeDeleted": true + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 0, len(dbConditions)) + }) + + t.Run("with alias", func(t *testing.T) { + filter := fromJSON[AdminPaymailFilter](`{ + "alias": "example", + "includeDeleted": true + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 1, len(dbConditions)) + assert.Equal(t, "example", dbConditions["alias"]) + }) + + t.Run("with publicName", func(t *testing.T) { + filter := fromJSON[AdminPaymailFilter](`{ + "publicName": "thepubname", + "includeDeleted": true + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 1, len(dbConditions)) + assert.Equal(t, "thepubname", dbConditions["public_name"]) + }) + + t.Run("with publicName", func(t *testing.T) { + filter := fromJSON[AdminPaymailFilter](`{ + "publicName": "thepubname", + "xpubId": "thexpubid", + "includeDeleted": true + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 2, len(dbConditions)) + assert.Equal(t, "thexpubid", dbConditions["xpub_id"]) + assert.Equal(t, "thepubname", dbConditions["public_name"]) + }) +} diff --git a/models/filter/transaction_filter.go b/models/filter/transaction_filter.go index fe9193448..5b36261e0 100644 --- a/models/filter/transaction_filter.go +++ b/models/filter/transaction_filter.go @@ -1,16 +1,16 @@ package filter -// TransactionFilter is a struct for handling request parameters for destination search requests +// TransactionFilter is a struct for handling request parameters for transactions search requests type TransactionFilter struct { ModelFilter `json:",inline"` Hex *string `json:"hex,omitempty"` - BlockHash *string `json:"block_hash,omitempty"` - BlockHeight *uint64 `json:"block_height,omitempty"` - Fee *uint64 `json:"fee,omitempty"` - NumberOfInputs *uint32 `json:"number_of_inputs,omitempty"` - NumberOfOutputs *uint32 `json:"number_of_outputs,omitempty"` - DraftID *string `json:"draft_id,omitempty"` - TotalValue *uint64 `json:"total_value,omitempty"` + BlockHash *string `json:"blockHash,omitempty" example:"0000000000000000031928c28075a82d7a00c2c90b489d1d66dc0afa3f8d26f8"` + BlockHeight *uint64 `json:"blockHeight,omitempty" example:"839376"` + Fee *uint64 `json:"fee,omitempty" example:"1"` + NumberOfInputs *uint32 `json:"numberOfInputs,omitempty" example:"1"` + NumberOfOutputs *uint32 `json:"numberOfOutputs,omitempty" example:"2"` + DraftID *string `json:"draftId,omitempty" example:"d425432e0d10a46af1ec6d00f380e9581ebf7907f3486572b3cd561a4c326e14"` + TotalValue *uint64 `json:"totalValue,omitempty" example:"100000000"` Status *string `json:"status,omitempty" enums:"UNKNOWN,QUEUED,RECEIVED,STORED,ANNOUNCED_TO_NETWORK,REQUESTED_BY_NETWORK,SENT_TO_NETWORK,ACCEPTED_BY_NETWORK,SEEN_ON_NETWORK,MINED,SEEN_IN_ORPHAN_MEMPOOL,CONFIRMED,REJECTED"` } diff --git a/models/filter/transaction_filter_test.go b/models/filter/transaction_filter_test.go index 58b1685ac..dbeb940dd 100644 --- a/models/filter/transaction_filter_test.go +++ b/models/filter/transaction_filter_test.go @@ -19,7 +19,7 @@ func TestTransactionFilter(t *testing.T) { t.Run("empty filter with include deleted", func(t *testing.T) { filter := fromJSON[TransactionFilter](`{ - "include_deleted": true + "includeDeleted": true }`) dbConditions := filter.ToDbConditions() @@ -29,7 +29,7 @@ func TestTransactionFilter(t *testing.T) { t.Run("with hex", func(t *testing.T) { filter := fromJSON[TransactionFilter](`{ "hex": "test", - "include_deleted": true + "includeDeleted": true }`) dbConditions := filter.ToDbConditions() @@ -39,8 +39,8 @@ func TestTransactionFilter(t *testing.T) { t.Run("with block_height", func(t *testing.T) { filter := fromJSON[TransactionFilter](`{ - "block_height": 100, - "include_deleted": true + "blockHeight": 100, + "includeDeleted": true }`) dbConditions := filter.ToDbConditions() diff --git a/models/filter/utils.go b/models/filter/utils.go index fea71bae8..1db1ea599 100644 --- a/models/filter/utils.go +++ b/models/filter/utils.go @@ -2,6 +2,7 @@ package filter import ( "errors" + "reflect" "strings" ) @@ -18,15 +19,41 @@ func applyConditionsIfNotNil(conditions map[string]interface{}, columnName strin } // strOption checks (case-insensitive) if value is in options, if it is, it returns a pointer to the value, otherwise it returns an error -func strOption(value *string, options ...string) (*string, error) { - if value == nil { - return nil, nil - } +func checkStrOption(value string, options ...string) (string, error) { for _, opt := range options { - if strings.EqualFold(*value, opt) { - s := string(opt) - return &s, nil + if strings.EqualFold(value, opt) { + return opt, nil } } - return nil, errors.New("Invalid option: " + *value) + return "", errors.New("Invalid option: " + value) +} + +func checkAndApplyStrOption(conditions map[string]interface{}, columnName string, value *string, options ...string) error { + if value == nil { + return nil + } + opt, err := checkStrOption(*value, options...) + if err != nil { + return err + } + conditions[columnName] = opt + return nil +} + +// getEnumValues gets the tag "enums" of a field by fieldName of a provided struct +func getEnumValues[T any](fieldName string) []string { + t := reflect.TypeOf(*new(T)) + field, found := t.FieldByName(fieldName) + if !found { + return nil + } + enums := field.Tag.Get("enums") + if enums == "" { + return nil + } + options := strings.Split(enums, ",") + for i := 0; i < len(options); i++ { + options[i] = strings.TrimSpace(options[i]) + } + return options } diff --git a/models/filter/utxo_filter.go b/models/filter/utxo_filter.go new file mode 100644 index 000000000..a4f0d2c8b --- /dev/null +++ b/models/filter/utxo_filter.go @@ -0,0 +1,58 @@ +package filter + +// UtxoFilter is a struct for handling request parameters for utxo search requests +type UtxoFilter struct { + ModelFilter `json:",inline"` + + TransactionID *string `json:"transactionId,omitempty" example:"5e17858ea0ca4155827754ba82bdcfcce108d5bb5b47fbb3aa54bd14540683c6"` + OutputIndex *uint32 `json:"outputIndex,omitempty" example:"0"` + + ID *string `json:"id,omitempty" example:"fe4cbfee0258aa589cbc79963f7c204061fd67d987e32ee5049aa90ce14658ee"` + Satoshis *uint64 `json:"satoshis,omitempty" example:"1"` + ScriptPubKey *string `json:"scriptPubKey,omitempty" example:"76a914a5f271385e75f57bcd9092592dede812f8c466d088ac"` + Type *string `json:"type,omitempty" enums:"pubkey,pubkeyhash,nulldata,multisig,nonstandard,scripthash,metanet,token_stas,token_sensible"` + DraftID *string `json:"draftId,omitempty" example:"89419d4c7c50810bfe5ff9df9ad5074b749959423782dc91a30f1058b9ad7ef7"` + ReservedRange *TimeRange `json:"reservedRange,omitempty"` // ReservedRange specifies the time range when a UTXO was reserved. + SpendingTxID *string `json:"spendingTxId,omitempty" example:"11a7746489a70e9c0170601c2be65558455317a984194eb2791b637f59f8cd6e"` +} + +var validUtxoTypes = getEnumValues[UtxoFilter]("Type") + +// ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy +func (d *UtxoFilter) ToDbConditions() (map[string]interface{}, error) { + conditions := d.ModelFilter.ToDbConditions() + + // Column names come from the database model, see: /engine/model_utxos.go + applyIfNotNil(conditions, "transaction_id", d.TransactionID) + applyIfNotNil(conditions, "output_index", d.OutputIndex) + applyIfNotNil(conditions, "id", d.ID) + applyIfNotNil(conditions, "satoshis", d.Satoshis) + applyIfNotNil(conditions, "script_pub_key", d.ScriptPubKey) + if err := checkAndApplyStrOption(conditions, "type", d.Type, validUtxoTypes...); err != nil { + return nil, err + } + applyIfNotNil(conditions, "spending_tx_id", d.SpendingTxID) + + applyConditionsIfNotNil(conditions, "reserved_at", d.ReservedRange.ToDbConditions()) + + return conditions, nil +} + +// AdminUtxoFilter wraps the UtxoFilter providing additional fields for admin utxo search requests +type AdminUtxoFilter struct { + UtxoFilter `json:",inline"` + + XpubID *string `json:"xpubId,omitempty"` +} + +// ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy +func (d *AdminUtxoFilter) ToDbConditions() (map[string]interface{}, error) { + conditions, err := d.UtxoFilter.ToDbConditions() + if err != nil { + return nil, err + } + + applyIfNotNil(conditions, "xpub_id", d.XpubID) + + return conditions, nil +} diff --git a/models/filter/utxo_filter_test.go b/models/filter/utxo_filter_test.go new file mode 100644 index 000000000..4029a2ac5 --- /dev/null +++ b/models/filter/utxo_filter_test.go @@ -0,0 +1,65 @@ +package filter + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestUtxoFilter(t *testing.T) { + t.Parallel() + + t.Run("default filter", func(t *testing.T) { + filter := UtxoFilter{} + dbConditions, err := filter.ToDbConditions() + + assert.NoError(t, err) + assert.Equal(t, 1, len(dbConditions)) + assert.Nil(t, dbConditions["deleted_at"]) + }) + + t.Run("empty filter with include deleted", func(t *testing.T) { + filter := fromJSON[UtxoFilter](`{ + "includeDeleted": true + }`) + dbConditions, err := filter.ToDbConditions() + + assert.NoError(t, err) + assert.Equal(t, 0, len(dbConditions)) + }) + + t.Run("with type", func(t *testing.T) { + filter := fromJSON[UtxoFilter](`{ + "type": "pubkey", + "includeDeleted": true + }`) + dbConditions, err := filter.ToDbConditions() + + assert.NoError(t, err) + assert.Equal(t, 1, len(dbConditions)) + assert.Equal(t, "pubkey", dbConditions["type"]) + }) + + t.Run("with wrong type", func(t *testing.T) { + filter := fromJSON[UtxoFilter](`{ + "type": "wrong_type", + "includeDeleted": true + }`) + dbConditions, err := filter.ToDbConditions() + + assert.Error(t, err) + assert.Nil(t, dbConditions) + }) + + t.Run("admin filter with xpubid", func(t *testing.T) { + filter := fromJSON[AdminUtxoFilter](`{ + "includeDeleted": true, + "id": "theid", + "xpubId": "thexpubid" + }`) + dbConditions, _ := filter.ToDbConditions() + + assert.Equal(t, "thexpubid", dbConditions["xpub_id"]) + assert.Equal(t, "theid", dbConditions["id"]) + }) +} diff --git a/models/filter/xpub_filter.go b/models/filter/xpub_filter.go new file mode 100644 index 000000000..9bcd02bc2 --- /dev/null +++ b/models/filter/xpub_filter.go @@ -0,0 +1,20 @@ +package filter + +// XpubFilter is a struct for handling request parameters for utxo search requests +type XpubFilter struct { + ModelFilter `json:",inline"` + + ID *string `json:"id,omitempty" example:"00b953624f78004a4c727cd28557475d5233c15f17aef545106639f4d71b712d"` + CurrentBalance *uint64 `json:"currentBalance,omitempty" example:"1000"` +} + +// ToDbConditions converts filter fields to the datastore conditions using gorm naming strategy +func (d *XpubFilter) ToDbConditions() map[string]interface{} { + conditions := d.ModelFilter.ToDbConditions() + + // Column names come from the database model, see: /engine/model_xpubs.go + applyIfNotNil(conditions, "id", d.ID) + applyIfNotNil(conditions, "current_balance", d.CurrentBalance) + + return conditions +} diff --git a/models/filter/xpub_filter_test.go b/models/filter/xpub_filter_test.go new file mode 100644 index 000000000..ce20b9342 --- /dev/null +++ b/models/filter/xpub_filter_test.go @@ -0,0 +1,50 @@ +package filter + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestXpubFilter(t *testing.T) { + t.Parallel() + + t.Run("default filter", func(t *testing.T) { + filter := XpubFilter{} + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 1, len(dbConditions)) + assert.Nil(t, dbConditions["deleted_at"]) + }) + + t.Run("empty filter with include deleted", func(t *testing.T) { + filter := fromJSON[XpubFilter](`{ + "includeDeleted": true + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 0, len(dbConditions)) + }) + + t.Run("with id", func(t *testing.T) { + filter := fromJSON[XpubFilter](`{ + "id": "test", + "includeDeleted": true + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 1, len(dbConditions)) + assert.Equal(t, "test", dbConditions["id"]) + }) + + t.Run("with currentBalance", func(t *testing.T) { + filter := fromJSON[XpubFilter](`{ + "currentBalance": 100, + "includeDeleted": true + }`) + dbConditions := filter.ToDbConditions() + + assert.Equal(t, 1, len(dbConditions)) + assert.Equal(t, uint64(100), dbConditions["current_balance"]) + }) +}