diff --git a/actions/v2/admin/internal/mapping/transaction.go b/actions/v2/admin/internal/mapping/transaction.go new file mode 100644 index 000000000..a430c3714 --- /dev/null +++ b/actions/v2/admin/internal/mapping/transaction.go @@ -0,0 +1,82 @@ +package mapping + +import ( + "fmt" + + "github.com/bitcoin-sv/spv-wallet/api" + "github.com/bitcoin-sv/spv-wallet/engine/spverrors" + "github.com/bitcoin-sv/spv-wallet/engine/v2/bsv" + "github.com/bitcoin-sv/spv-wallet/engine/v2/transaction" + "github.com/bitcoin-sv/spv-wallet/engine/v2/transaction/outlines" + "github.com/bitcoin-sv/spv-wallet/engine/v2/transaction/txmodels" + "github.com/bitcoin-sv/spv-wallet/lox" + bsvmodel "github.com/bitcoin-sv/spv-wallet/models/bsv" + "github.com/bitcoin-sv/spv-wallet/models/transaction/bucket" + "github.com/samber/lo" +) + +// RecordedOutline maps domain RecordedOutline to api.ModelsRecordedOutline. +func RecordedOutline(r *txmodels.RecordedOutline) api.ModelsRecordedOutline { + return api.ModelsRecordedOutline{ + TxID: r.TxID, + } +} + +// RequestsTransactionOutlineToOutline maps request's AnnotatedTransaction to outlines.Transaction. +func RequestsTransactionOutlineToOutline(req *api.RequestsRecordTransactionOutlineForUser) (*outlines.Transaction, error) { + errorCollector := lox.NewErrorCollector() + + return &outlines.Transaction{ + Hex: bsv.TxHex(req.Hex), + Annotations: transaction.Annotations{ + Outputs: lo. + IfF( + req.Annotations != nil, + lox.CatchFn(errorCollector, func() (transaction.OutputsAnnotations, error) { + return lox.MapEntriesOrError(req.Annotations.Outputs, mapOutputAnnotationEntry) + }), + ).Else(nil), + }, + }, errorCollector.Error() +} + +func mapOutputAnnotationEntry(key string, value api.ModelsOutputAnnotation) (uint32, *transaction.OutputAnnotation, error) { + var vout uint32 + if n, err := fmt.Sscanf(key, "%d", &vout); err != nil { + return 0, nil, spverrors.ErrCannotMapFromModel.Wrap(err) + } else if n != 1 { + return 0, nil, spverrors.ErrCannotMapFromModel.Wrap(spverrors.Newf("failed to parse vout from key %s", key)) + } + return vout, annotatedOutputToOutline(value), nil +} + +func annotatedOutputToOutline(from api.ModelsOutputAnnotation) *transaction.OutputAnnotation { + return &transaction.OutputAnnotation{ + Bucket: bucket.Name(from.Bucket), + Paymail: lo.IfF( + from.Paymail != nil, + func() *transaction.PaymailAnnotation { + return &transaction.PaymailAnnotation{ + Sender: from.Paymail.Sender, + Receiver: from.Paymail.Receiver, + Reference: from.Paymail.Reference, + } + }, + ).Else(nil), + CustomInstructions: lo.IfF( + from.CustomInstructions != nil, + func() *bsvmodel.CustomInstructions { + return lo.ToPtr( + bsvmodel.CustomInstructions(lo.Map(*from.CustomInstructions, lox.MappingFn(requestToCustomResponse))), + ) + }, + ).Else(nil), + } +} + +func requestToCustomResponse(instruction api.ModelsSPVWalletCustomInstruction) bsvmodel.CustomInstruction { + return bsvmodel.CustomInstruction{ + Type: instruction.Type, + Instruction: instruction.Instruction, + } +} diff --git a/actions/v2/admin/server.go b/actions/v2/admin/server.go index 0ef8f08ec..c79c4235f 100644 --- a/actions/v2/admin/server.go +++ b/actions/v2/admin/server.go @@ -1,6 +1,7 @@ package admin import ( + "github.com/bitcoin-sv/spv-wallet/actions/v2/admin/transactions" "github.com/bitcoin-sv/spv-wallet/actions/v2/admin/users" "github.com/bitcoin-sv/spv-wallet/engine" "github.com/rs/zerolog" @@ -9,11 +10,13 @@ import ( // APIAdmin represents server with API endpoints type APIAdmin struct { users.APIAdminUsers + transactions.APIAdminTransactions } // NewAPIAdmin creates a new APIAdmin func NewAPIAdmin(spvWalletEngine engine.ClientInterface, logger *zerolog.Logger) APIAdmin { return APIAdmin{ users.NewAPIAdminUsers(spvWalletEngine, logger), + transactions.NewAPIAdminTransactions(spvWalletEngine, logger), } } diff --git a/actions/v2/admin/transactions/record.go b/actions/v2/admin/transactions/record.go new file mode 100644 index 000000000..11df729cb --- /dev/null +++ b/actions/v2/admin/transactions/record.go @@ -0,0 +1,37 @@ +package transactions + +import ( + "github.com/bitcoin-sv/spv-wallet/actions/v2/admin/internal/mapping" + "github.com/bitcoin-sv/spv-wallet/api" + "github.com/bitcoin-sv/spv-wallet/engine/spverrors" + "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" +) + +// RecordTransactionOutlineForUser records transaction outline for given user +func (s *APIAdminTransactions) RecordTransactionOutlineForUser(c *gin.Context) { + var requestBody api.RequestsRecordTransactionOutlineForUser + err := c.ShouldBindWith(&requestBody, binding.JSON) + if err != nil { + spverrors.ErrorResponse(c, spverrors.ErrCannotBindRequest.Wrap(err), s.logger) + return + } + if requestBody.UserID == "" { + spverrors.ErrorResponse(c, spverrors.Wrapf(spverrors.ErrCannotBindRequest, "userID not provided"), s.logger) + return + } + + outline, err := mapping.RequestsTransactionOutlineToOutline(&requestBody) + if err != nil { + spverrors.ErrorResponse(c, err, s.logger) + return + } + + recorded, err := s.transactionsRecordService.RecordTransactionOutline(c, requestBody.UserID, outline) + if err != nil { + spverrors.ErrorResponse(c, err, s.logger) + return + } + + c.JSON(201, mapping.RecordedOutline(recorded)) +} diff --git a/actions/v2/admin/transactions/record_test.go b/actions/v2/admin/transactions/record_test.go new file mode 100644 index 000000000..4f0ed2413 --- /dev/null +++ b/actions/v2/admin/transactions/record_test.go @@ -0,0 +1,329 @@ +package transactions_test + +import ( + "fmt" + "testing" + + "github.com/bitcoin-sv/go-sdk/script" + "github.com/bitcoin-sv/spv-wallet/actions/testabilities" + chainmodels "github.com/bitcoin-sv/spv-wallet/engine/chain/models" + testengine "github.com/bitcoin-sv/spv-wallet/engine/testabilities" + "github.com/bitcoin-sv/spv-wallet/engine/tester/fixtures" + "github.com/bitcoin-sv/spv-wallet/models/bsv" + "github.com/samber/lo" + "github.com/stretchr/testify/require" +) + +const ( + recordTransactionOutlineForUserURL = "/api/v2/admin/transactions/record" + dataOfOpReturnTx = "hello world" +) + +func TestOutlinesRecordOpReturn(t *testing.T) { + // given: + givenForAllTests := testabilities.Given(t) + cleanup := givenForAllTests.StartedSPVWalletWithConfiguration( + testengine.WithV2(), + ) + defer cleanup() + + // and: + ownedTransaction := givenForAllTests.Faucet(fixtures.Sender).TopUp(1000) + + // and: + txSpec := givenForAllTests.Tx(). + WithSender(fixtures.Sender). + WithInputFromUTXO(ownedTransaction.TX(), 0). + WithOPReturn(dataOfOpReturnTx) + + t.Run("Record op_return data", func(t *testing.T) { + // given: + given, then := testabilities.NewOf(givenForAllTests, t) + + // and: + client := given.HttpClient().ForAdmin() + + // and: + given.ARC().WillRespondForBroadcast(200, &chainmodels.TXInfo{ + TxID: txSpec.ID(), + TXStatus: chainmodels.SeenOnNetwork, + }) + + // when: + res, _ := client.R(). + SetHeader("Content-Type", "application/json"). + SetBody(map[string]any{ + "hex": txSpec.BEEF(), + "annotations": map[string]any{ + "outputs": map[string]any{ + "0": map[string]any{ + "bucket": "data", + }, + }, + }, + "userID": fixtures.Sender.ID(), + }). + Post(recordTransactionOutlineForUserURL) + + // then: + then.Response(res). + HasStatus(201). + WithJSONMatching(`{ + "txID": "{{ .txID }}" + }`, map[string]any{ + "txID": txSpec.ID(), + }) + }) + + t.Run("get operations", func(t *testing.T) { + // given: + given, then := testabilities.NewOf(givenForAllTests, t) + + // and: + client := given.HttpClient().ForUser() + + // when: + res, _ := client.R().Get("/api/v2/operations/search") + + // then: + then.Response(res).IsOK().WithJSONMatching(`{ + "content": [ + { + "txID": "{{ .txID }}", + "createdAt": "{{ matchTimestamp }}", + "value": {{ .value }}, + "type": "outgoing", + "counterparty": "{{ .sender }}", + "txStatus": "BROADCASTED" + }, + {{ anything }} + ], + "page": { + "number": 1, + "size": 2, + "totalElements": 2, + "totalPages": 1 + } + }`, map[string]any{ + "value": -1000, + "txID": txSpec.ID(), + "sender": "", + }) + }) + + t.Run("Get stored data", func(t *testing.T) { + // given: + given, then := testabilities.NewOf(givenForAllTests, t) + + // and: + outpoint := bsv.Outpoint{TxID: txSpec.ID(), Vout: 0} + + // and: + client := given.HttpClient().ForUser() + + // when: + res, _ := client.R(). + Get("/api/v2/data/" + outpoint.String()) + + // then: + then.Response(res). + IsOK().WithJSONMatching(`{ + "id": "{{ .outpoint }}", + "blob": "{{ .blob }}" + }`, map[string]any{ + "outpoint": outpoint.String(), + "blob": dataOfOpReturnTx, + }) + }) +} + +func TestInternalOutgoingTransaction(t *testing.T) { + // given: + givenForAllTests := testabilities.Given(t) + cleanup := givenForAllTests.StartedSPVWalletWithConfiguration( + testengine.WithV2(), + ) + defer cleanup() + + var testState struct { + reference string + lockingScript *script.Script + } + + // and: + sender := fixtures.Sender + recipient := fixtures.RecipientInternal + + // and: + sourceTxSpec := givenForAllTests.Faucet(sender).TopUp(1201) + + t.Run("During outline preparation - call recipient destination", func(t *testing.T) { + // given: + given, then := testabilities.NewOf(givenForAllTests, t) + + // and: + client := given.HttpClient().ForAnonymous() + + // and: + requestBody := map[string]any{ + "satoshis": 200, + } + + // when: + res, _ := client.R(). + SetHeader("Content-Type", "application/json"). + SetBody(requestBody). + Post( + fmt.Sprintf( + "https://example.com/v1/bsvalias/p2p-payment-destination/%s", + recipient.DefaultPaymail(), + ), + ) + + // then: + then.Response(res).IsOK() + + // update: + getter := then.Response(res).JSONValue() + testState.reference = getter.GetString("reference") + + // and: + lockingScript, err := script.NewFromHex(getter.GetString("outputs[0]/script")) + require.NoError(t, err) + testState.lockingScript = lockingScript + }) + + t.Run("Record new tx outline with change for sender by admin", func(t *testing.T) { + // given: + given, then := testabilities.NewOf(givenForAllTests, t) + + // and: + client := given.HttpClient().ForAdmin() + + // and: + txSpec := given.Tx(). + WithSender(sender). + WithRecipient(recipient). + WithInputFromUTXO(sourceTxSpec.TX(), 0). + WithOutputScript(200, testState.lockingScript) + + // and: + changeOutputs := changeOutputSpecs{ + { + customInstructions: bsv.CustomInstructions{ + { + Type: "type42", + Instruction: "1-destination-1instruction87d3be7bd26cfe2b5996", + }, + { + Type: "type42", + Instruction: "1-destination-2instruction7d3be7bd26cfe2b5996", + }, + { + Type: "type42", + Instruction: "1-destination-3instruction87d3be7bd26cfe2b5996", + }, + }, + satoshis: 200, + }, + { + customInstructions: bsv.CustomInstructions{ + { + Type: "type42", + Instruction: "1-destination-1output4d06387d3be7bd26cfe2b5996", + }, + }, + satoshis: 400, + }, + { + customInstructions: bsv.CustomInstructions{ + { + Type: "type42", + Instruction: "1-destination-1output4d06387d3be7bd26cfe2b5996", + }, + }, + satoshis: 400, + }, + } + for _, changeOutput := range changeOutputs { + txSpec.WithOutputScript(uint64(changeOutput.satoshis), sender.P2PKHLockingScript(changeOutput.customInstructions...)) + } + + // and: + given.ARC().WillRespondForBroadcastWithSeenOnNetwork(txSpec.ID()) + + // when: + res, _ := client.R(). + SetHeader("Content-Type", "application/json"). + SetBody(map[string]any{ + "hex": txSpec.BEEF(), + "format": "BEEF", + "annotations": map[string]any{ + "outputs": lo.Assign( + map[string]any{ + "0": map[string]any{ + "bucket": "bsv", + "paymail": map[string]any{ + "receiver": recipient.DefaultPaymail(), + "reference": testState.reference, + "sender": sender.DefaultPaymail(), + }, + }, + }, + changeOutputs.toAnnotations(1), + ), + }, + "userID": sender.ID(), + }). + Post(recordTransactionOutlineForUserURL) + + // then: + then.Response(res). + IsCreated(). + WithJSONMatching(`{ + "txID": "{{ .txID }}" + }`, map[string]any{ + "txID": txSpec.ID(), + }) + + // and: + then.User(sender).Balance().IsEqualTo(1000) + then.User(sender).Operations().Last(). + WithTxID(txSpec.ID()). + WithTxStatus("BROADCASTED"). + WithValue(-201). + WithType("outgoing"). + WithCounterparty(recipient.DefaultPaymail().Address()) + + // and: + then.User(recipient).Balance().IsEqualTo(200) + then.User(recipient).Operations().Last(). + WithTxID(txSpec.ID()). + WithTxStatus("BROADCASTED"). + WithValue(200). + WithType("incoming"). + WithCounterparty(sender.DefaultPaymail().Address()) + }) +} + +type changeOutputSpec struct { + customInstructions bsv.CustomInstructions + satoshis bsv.Satoshis +} + +func (ch changeOutputSpec) toAnnotation() map[string]any { + return map[string]any{ + "bucket": "bsv", + "customInstructions": ch.customInstructions, + } +} + +type changeOutputSpecs []changeOutputSpec + +func (chs changeOutputSpecs) toAnnotations(startingIndex int) map[string]any { + annotations := make(map[string]any) + for i, ch := range chs { + annotations[fmt.Sprintf("%d", i+startingIndex)] = ch.toAnnotation() + } + return annotations +} diff --git a/actions/v2/admin/transactions/server.go b/actions/v2/admin/transactions/server.go new file mode 100644 index 000000000..470838244 --- /dev/null +++ b/actions/v2/admin/transactions/server.go @@ -0,0 +1,28 @@ +package transactions + +import ( + "context" + + "github.com/bitcoin-sv/spv-wallet/engine" + "github.com/bitcoin-sv/spv-wallet/engine/v2/transaction/outlines" + "github.com/bitcoin-sv/spv-wallet/engine/v2/transaction/txmodels" + "github.com/rs/zerolog" +) + +type transactionsRecordService interface { + RecordTransactionOutline(ctx context.Context, userID string, outline *outlines.Transaction) (*txmodels.RecordedOutline, error) +} + +// APIAdminTransactions represents server with admin API endpoints +type APIAdminTransactions struct { + transactionsRecordService transactionsRecordService + logger *zerolog.Logger +} + +// NewAPIAdminTransactions creates a new APIAdminTransactions +func NewAPIAdminTransactions(engine engine.ClientInterface, logger *zerolog.Logger) APIAdminTransactions { + return APIAdminTransactions{ + transactionsRecordService: engine.TransactionRecordService(), + logger: logger, + } +} diff --git a/api/components/requests.yaml b/api/components/requests.yaml index 470789555..f1263f63a 100644 --- a/api/components/requests.yaml +++ b/api/components/requests.yaml @@ -40,6 +40,18 @@ components: - alias - domain + RecordTransactionOutlineForUser: + allOf: + - $ref: "../components/requests.yaml#/components/schemas/TransactionOutline" + - type: object + properties: + userID: + type: string + description: "User ID for which admin records transaction outline" + example: "1" + required: + - userID + TransactionOutline: allOf: - $ref: "../components/models.yaml#/components/schemas/TransactionHex" diff --git a/api/components/responses.yaml b/api/components/responses.yaml index bb150398b..c3f5d4c99 100644 --- a/api/components/responses.yaml +++ b/api/components/responses.yaml @@ -59,6 +59,36 @@ components: schema: $ref: "./errors.yaml#/components/schemas/GettingUser" + AdminRecordTransactionOutlineForUserSuccess: + description: Transaction outline for user recorded + content: + application/json: + schema: + $ref: "./models.yaml#/components/schemas/RecordedOutline" + + AdminRecordTransactionOutlineForUserBadRequest: + description: Bad request is an error that occurs when the request is malformed. + content: + application/json: + schema: + oneOf: + - $ref: "./errors.yaml#/components/schemas/CannotBindRequest" + - $ref: "./errors.yaml#/components/schemas/InvalidDataID" + - $ref: "./errors.yaml#/components/schemas/AnnotationIndexOutOfRange" + - $ref: "./errors.yaml#/components/schemas/UTXOSpent" + - $ref: "./errors.yaml#/components/schemas/AnnotationIndexConversion" + - $ref: "./errors.yaml#/components/schemas/NoOperations" + + AdminRecordTransactionOutlineForUserInternalServerError: + description: Internal server error + content: + application/json: + schema: + oneOf: + - $ref: "./errors.yaml#/components/schemas/Internal" + - $ref: "./errors.yaml#/components/schemas/GettingOutputs" + - $ref: "./errors.yaml#/components/schemas/TxBroadcast" + NotAuthorized: description: Security requirements failed content: diff --git a/api/endpoints/admin.yaml b/api/endpoints/admin.yaml index a3251054c..294647d22 100644 --- a/api/endpoints/admin.yaml +++ b/api/endpoints/admin.yaml @@ -106,3 +106,30 @@ paths: $ref: "../components/responses.yaml#/components/responses/NotAuthorizedToAdminEndpoint" 422: $ref: "../components/responses.yaml#/components/responses/AdminInvalidAvatarURL" + + /api/v2/admin/transactions/record: + post: + operationId: recordTransactionOutlineForUser + security: + - XPubAuth: + - "admin" + tags: + - Admin endpoints + summary: Record transaction outline for user + description: >- + This endpoint allows for admin to record outline transaction for user with given id. + requestBody: + required: true + content: + application/json: + schema: + $ref: "../components/requests.yaml#/components/schemas/RecordTransactionOutlineForUser" + responses: + 201: + $ref: "../components/responses.yaml#/components/responses/AdminRecordTransactionOutlineForUserSuccess" + 400: + $ref: "../components/responses.yaml#/components/responses/AdminRecordTransactionOutlineForUserBadRequest" + 401: + $ref: "../components/responses.yaml#/components/responses/NotAuthorizedToAdminEndpoint" + 500: + $ref: "../components/responses.yaml#/components/responses/AdminRecordTransactionOutlineForUserInternalServerError" diff --git a/api/gen.api.go b/api/gen.api.go index 9cd33c609..db80f126c 100644 --- a/api/gen.api.go +++ b/api/gen.api.go @@ -16,6 +16,9 @@ type ServerInterface interface { // Get admin status // (GET /api/v2/admin/status) AdminStatus(c *gin.Context) + // Record transaction outline for user + // (POST /api/v2/admin/transactions/record) + RecordTransactionOutlineForUser(c *gin.Context) // Create user // (POST /api/v2/admin/users) CreateUser(c *gin.Context) @@ -72,6 +75,21 @@ func (siw *ServerInterfaceWrapper) AdminStatus(c *gin.Context) { siw.Handler.AdminStatus(c) } +// RecordTransactionOutlineForUser operation middleware +func (siw *ServerInterfaceWrapper) RecordTransactionOutlineForUser(c *gin.Context) { + + c.Set(XPubAuthScopes, []string{"admin"}) + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.RecordTransactionOutlineForUser(c) +} + // CreateUser operation middleware func (siw *ServerInterfaceWrapper) CreateUser(c *gin.Context) { @@ -354,6 +372,7 @@ func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options } router.GET(options.BaseURL+"/api/v2/admin/status", wrapper.AdminStatus) + router.POST(options.BaseURL+"/api/v2/admin/transactions/record", wrapper.RecordTransactionOutlineForUser) router.POST(options.BaseURL+"/api/v2/admin/users", wrapper.CreateUser) router.GET(options.BaseURL+"/api/v2/admin/users/:id", wrapper.UserById) router.POST(options.BaseURL+"/api/v2/admin/users/:id/paymails", wrapper.AddPaymailToUser) diff --git a/api/gen.api.yaml b/api/gen.api.yaml index ce2ac833d..4a6d00759 100644 --- a/api/gen.api.yaml +++ b/api/gen.api.yaml @@ -21,6 +21,31 @@ paths: summary: Get admin status tags: - Admin endpoints + /api/v2/admin/transactions/record: + post: + description: This endpoint allows for admin to record outline transaction for user with given id. + operationId: recordTransactionOutlineForUser + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/requests_RecordTransactionOutlineForUser' + required: true + responses: + "201": + $ref: '#/components/responses/responses_AdminRecordTransactionOutlineForUserSuccess' + "400": + $ref: '#/components/responses/responses_AdminRecordTransactionOutlineForUserBadRequest' + "401": + $ref: '#/components/responses/responses_NotAuthorizedToAdminEndpoint' + "500": + $ref: '#/components/responses/responses_AdminRecordTransactionOutlineForUserInternalServerError' + security: + - XPubAuth: + - admin + summary: Record transaction outline for user + tags: + - Admin endpoints /api/v2/admin/users: post: description: This endpoint creates a new user. @@ -358,6 +383,33 @@ components: oneOf: - $ref: '#/components/schemas/errors_InvalidAvatarURL' description: Unprocessable entity is an error that occurs when the request cannot be fulfilled. + responses_AdminRecordTransactionOutlineForUserBadRequest: + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/errors_CannotBindRequest' + - $ref: '#/components/schemas/errors_InvalidDataID' + - $ref: '#/components/schemas/errors_AnnotationIndexOutOfRange' + - $ref: '#/components/schemas/errors_UTXOSpent' + - $ref: '#/components/schemas/errors_AnnotationIndexConversion' + - $ref: '#/components/schemas/errors_NoOperations' + description: Bad request is an error that occurs when the request is malformed. + responses_AdminRecordTransactionOutlineForUserInternalServerError: + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/errors_Internal' + - $ref: '#/components/schemas/errors_GettingOutputs' + - $ref: '#/components/schemas/errors_TxBroadcast' + description: Internal server error + responses_AdminRecordTransactionOutlineForUserSuccess: + content: + application/json: + schema: + $ref: '#/components/schemas/models_RecordedOutline' + description: Transaction outline for user recorded responses_AdminUserBadRequest: content: application/json: @@ -1388,6 +1440,17 @@ components: - to - satoshis type: object + requests_RecordTransactionOutlineForUser: + allOf: + - $ref: '#/components/schemas/requests_TransactionOutline' + - properties: + userID: + description: User ID for which admin records transaction outline + example: "1" + type: string + required: + - userID + type: object requests_TransactionOutline: allOf: - $ref: '#/components/schemas/models_TransactionHex' diff --git a/api/gen.models.go b/api/gen.models.go index aebde3e9d..c08d87af7 100644 --- a/api/gen.models.go +++ b/api/gen.models.go @@ -73,10 +73,16 @@ const ( Paymail RequestsPaymailOutputSpecificationType = "paymail" ) +// Defines values for RequestsRecordTransactionOutlineForUserFormat. +const ( + RequestsRecordTransactionOutlineForUserFormatBEEF RequestsRecordTransactionOutlineForUserFormat = "BEEF" + RequestsRecordTransactionOutlineForUserFormatRAW RequestsRecordTransactionOutlineForUserFormat = "RAW" +) + // Defines values for RequestsTransactionOutlineFormat. const ( - BEEF RequestsTransactionOutlineFormat = "BEEF" - RAW RequestsTransactionOutlineFormat = "RAW" + RequestsTransactionOutlineFormatBEEF RequestsTransactionOutlineFormat = "BEEF" + RequestsTransactionOutlineFormatRAW RequestsTransactionOutlineFormat = "RAW" ) // Defines values for CreateTransactionOutlineParamsFormat. @@ -643,6 +649,23 @@ type RequestsPaymailOutputSpecification struct { // RequestsPaymailOutputSpecificationType defines model for RequestsPaymailOutputSpecification.Type. type RequestsPaymailOutputSpecificationType string +// RequestsRecordTransactionOutlineForUser defines model for requests_RecordTransactionOutlineForUser. +type RequestsRecordTransactionOutlineForUser struct { + Annotations *ModelsOutputsAnnotations `json:"annotations,omitempty"` + + // Format Transaction format + Format RequestsRecordTransactionOutlineForUserFormat `json:"format"` + + // Hex Transaction hex + Hex string `json:"hex"` + + // UserID User ID for which admin records transaction outline + UserID string `json:"userID"` +} + +// RequestsRecordTransactionOutlineForUserFormat Transaction format +type RequestsRecordTransactionOutlineForUserFormat string + // RequestsTransactionOutline defines model for requests_TransactionOutline. type RequestsTransactionOutline struct { Annotations *ModelsOutputsAnnotations `json:"annotations,omitempty"` @@ -699,6 +722,19 @@ type ResponsesAdminInvalidAvatarURL struct { union json.RawMessage } +// ResponsesAdminRecordTransactionOutlineForUserBadRequest defines model for responses_AdminRecordTransactionOutlineForUserBadRequest. +type ResponsesAdminRecordTransactionOutlineForUserBadRequest struct { + union json.RawMessage +} + +// ResponsesAdminRecordTransactionOutlineForUserInternalServerError defines model for responses_AdminRecordTransactionOutlineForUserInternalServerError. +type ResponsesAdminRecordTransactionOutlineForUserInternalServerError struct { + union json.RawMessage +} + +// ResponsesAdminRecordTransactionOutlineForUserSuccess defines model for responses_AdminRecordTransactionOutlineForUserSuccess. +type ResponsesAdminRecordTransactionOutlineForUserSuccess = ModelsRecordedOutline + // ResponsesAdminUserBadRequest defines model for responses_AdminUserBadRequest. type ResponsesAdminUserBadRequest struct { union json.RawMessage @@ -815,6 +851,9 @@ type CreateTransactionOutlineParams struct { // CreateTransactionOutlineParamsFormat defines parameters for CreateTransactionOutline. type CreateTransactionOutlineParamsFormat string +// RecordTransactionOutlineForUserJSONRequestBody defines body for RecordTransactionOutlineForUser for application/json ContentType. +type RecordTransactionOutlineForUserJSONRequestBody = RequestsRecordTransactionOutlineForUser + // CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType. type CreateUserJSONRequestBody = RequestsCreateUser @@ -1288,6 +1327,260 @@ func (t *ResponsesAdminInvalidAvatarURL) UnmarshalJSON(b []byte) error { return err } +// AsErrorsCannotBindRequest returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsCannotBindRequest +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsCannotBindRequest() (ErrorsCannotBindRequest, error) { + var body ErrorsCannotBindRequest + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsCannotBindRequest overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsCannotBindRequest +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsCannotBindRequest(v ErrorsCannotBindRequest) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsCannotBindRequest performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsCannotBindRequest +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsCannotBindRequest(v ErrorsCannotBindRequest) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsInvalidDataID returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsInvalidDataID +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsInvalidDataID() (ErrorsInvalidDataID, error) { + var body ErrorsInvalidDataID + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsInvalidDataID overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsInvalidDataID +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsInvalidDataID(v ErrorsInvalidDataID) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsInvalidDataID performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsInvalidDataID +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsInvalidDataID(v ErrorsInvalidDataID) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsAnnotationIndexOutOfRange returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsAnnotationIndexOutOfRange +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsAnnotationIndexOutOfRange() (ErrorsAnnotationIndexOutOfRange, error) { + var body ErrorsAnnotationIndexOutOfRange + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsAnnotationIndexOutOfRange overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsAnnotationIndexOutOfRange +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsAnnotationIndexOutOfRange(v ErrorsAnnotationIndexOutOfRange) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsAnnotationIndexOutOfRange performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsAnnotationIndexOutOfRange +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsAnnotationIndexOutOfRange(v ErrorsAnnotationIndexOutOfRange) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsUTXOSpent returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsUTXOSpent +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsUTXOSpent() (ErrorsUTXOSpent, error) { + var body ErrorsUTXOSpent + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsUTXOSpent overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsUTXOSpent +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsUTXOSpent(v ErrorsUTXOSpent) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsUTXOSpent performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsUTXOSpent +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsUTXOSpent(v ErrorsUTXOSpent) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsAnnotationIndexConversion returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsAnnotationIndexConversion +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsAnnotationIndexConversion() (ErrorsAnnotationIndexConversion, error) { + var body ErrorsAnnotationIndexConversion + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsAnnotationIndexConversion overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsAnnotationIndexConversion +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsAnnotationIndexConversion(v ErrorsAnnotationIndexConversion) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsAnnotationIndexConversion performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsAnnotationIndexConversion +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsAnnotationIndexConversion(v ErrorsAnnotationIndexConversion) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsNoOperations returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsNoOperations +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsNoOperations() (ErrorsNoOperations, error) { + var body ErrorsNoOperations + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsNoOperations overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsNoOperations +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsNoOperations(v ErrorsNoOperations) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsNoOperations performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsNoOperations +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsNoOperations(v ErrorsNoOperations) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsErrorsInternal returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as a ErrorsInternal +func (t ResponsesAdminRecordTransactionOutlineForUserInternalServerError) AsErrorsInternal() (ErrorsInternal, error) { + var body ErrorsInternal + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsInternal overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as the provided ErrorsInternal +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) FromErrorsInternal(v ErrorsInternal) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsInternal performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError, using the provided ErrorsInternal +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) MergeErrorsInternal(v ErrorsInternal) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsGettingOutputs returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as a ErrorsGettingOutputs +func (t ResponsesAdminRecordTransactionOutlineForUserInternalServerError) AsErrorsGettingOutputs() (ErrorsGettingOutputs, error) { + var body ErrorsGettingOutputs + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsGettingOutputs overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as the provided ErrorsGettingOutputs +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) FromErrorsGettingOutputs(v ErrorsGettingOutputs) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsGettingOutputs performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError, using the provided ErrorsGettingOutputs +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) MergeErrorsGettingOutputs(v ErrorsGettingOutputs) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsTxBroadcast returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as a ErrorsTxBroadcast +func (t ResponsesAdminRecordTransactionOutlineForUserInternalServerError) AsErrorsTxBroadcast() (ErrorsTxBroadcast, error) { + var body ErrorsTxBroadcast + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsTxBroadcast overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as the provided ErrorsTxBroadcast +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) FromErrorsTxBroadcast(v ErrorsTxBroadcast) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsTxBroadcast performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError, using the provided ErrorsTxBroadcast +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) MergeErrorsTxBroadcast(v ErrorsTxBroadcast) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t ResponsesAdminRecordTransactionOutlineForUserInternalServerError) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + // AsErrorsCannotBindRequest returns the union data inside the ResponsesAdminUserBadRequest as a ErrorsCannotBindRequest func (t ResponsesAdminUserBadRequest) AsErrorsCannotBindRequest() (ErrorsCannotBindRequest, error) { var body ErrorsCannotBindRequest diff --git a/api/manualtests/client/client.gen.go b/api/manualtests/client/client.gen.go index b1645aa4c..4d9321a74 100644 --- a/api/manualtests/client/client.gen.go +++ b/api/manualtests/client/client.gen.go @@ -80,10 +80,16 @@ const ( Paymail RequestsPaymailOutputSpecificationType = "paymail" ) +// Defines values for RequestsRecordTransactionOutlineForUserFormat. +const ( + RequestsRecordTransactionOutlineForUserFormatBEEF RequestsRecordTransactionOutlineForUserFormat = "BEEF" + RequestsRecordTransactionOutlineForUserFormatRAW RequestsRecordTransactionOutlineForUserFormat = "RAW" +) + // Defines values for RequestsTransactionOutlineFormat. const ( - BEEF RequestsTransactionOutlineFormat = "BEEF" - RAW RequestsTransactionOutlineFormat = "RAW" + RequestsTransactionOutlineFormatBEEF RequestsTransactionOutlineFormat = "BEEF" + RequestsTransactionOutlineFormatRAW RequestsTransactionOutlineFormat = "RAW" ) // Defines values for CreateTransactionOutlineParamsFormat. @@ -650,6 +656,23 @@ type RequestsPaymailOutputSpecification struct { // RequestsPaymailOutputSpecificationType defines model for RequestsPaymailOutputSpecification.Type. type RequestsPaymailOutputSpecificationType string +// RequestsRecordTransactionOutlineForUser defines model for requests_RecordTransactionOutlineForUser. +type RequestsRecordTransactionOutlineForUser struct { + Annotations *ModelsOutputsAnnotations `json:"annotations,omitempty"` + + // Format Transaction format + Format RequestsRecordTransactionOutlineForUserFormat `json:"format"` + + // Hex Transaction hex + Hex string `json:"hex"` + + // UserID User ID for which admin records transaction outline + UserID string `json:"userID"` +} + +// RequestsRecordTransactionOutlineForUserFormat Transaction format +type RequestsRecordTransactionOutlineForUserFormat string + // RequestsTransactionOutline defines model for requests_TransactionOutline. type RequestsTransactionOutline struct { Annotations *ModelsOutputsAnnotations `json:"annotations,omitempty"` @@ -706,6 +729,19 @@ type ResponsesAdminInvalidAvatarURL struct { union json.RawMessage } +// ResponsesAdminRecordTransactionOutlineForUserBadRequest defines model for responses_AdminRecordTransactionOutlineForUserBadRequest. +type ResponsesAdminRecordTransactionOutlineForUserBadRequest struct { + union json.RawMessage +} + +// ResponsesAdminRecordTransactionOutlineForUserInternalServerError defines model for responses_AdminRecordTransactionOutlineForUserInternalServerError. +type ResponsesAdminRecordTransactionOutlineForUserInternalServerError struct { + union json.RawMessage +} + +// ResponsesAdminRecordTransactionOutlineForUserSuccess defines model for responses_AdminRecordTransactionOutlineForUserSuccess. +type ResponsesAdminRecordTransactionOutlineForUserSuccess = ModelsRecordedOutline + // ResponsesAdminUserBadRequest defines model for responses_AdminUserBadRequest. type ResponsesAdminUserBadRequest struct { union json.RawMessage @@ -822,6 +858,9 @@ type CreateTransactionOutlineParams struct { // CreateTransactionOutlineParamsFormat defines parameters for CreateTransactionOutline. type CreateTransactionOutlineParamsFormat string +// RecordTransactionOutlineForUserJSONRequestBody defines body for RecordTransactionOutlineForUser for application/json ContentType. +type RecordTransactionOutlineForUserJSONRequestBody = RequestsRecordTransactionOutlineForUser + // CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType. type CreateUserJSONRequestBody = RequestsCreateUser @@ -1295,6 +1334,260 @@ func (t *ResponsesAdminInvalidAvatarURL) UnmarshalJSON(b []byte) error { return err } +// AsErrorsCannotBindRequest returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsCannotBindRequest +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsCannotBindRequest() (ErrorsCannotBindRequest, error) { + var body ErrorsCannotBindRequest + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsCannotBindRequest overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsCannotBindRequest +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsCannotBindRequest(v ErrorsCannotBindRequest) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsCannotBindRequest performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsCannotBindRequest +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsCannotBindRequest(v ErrorsCannotBindRequest) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsInvalidDataID returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsInvalidDataID +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsInvalidDataID() (ErrorsInvalidDataID, error) { + var body ErrorsInvalidDataID + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsInvalidDataID overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsInvalidDataID +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsInvalidDataID(v ErrorsInvalidDataID) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsInvalidDataID performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsInvalidDataID +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsInvalidDataID(v ErrorsInvalidDataID) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsAnnotationIndexOutOfRange returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsAnnotationIndexOutOfRange +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsAnnotationIndexOutOfRange() (ErrorsAnnotationIndexOutOfRange, error) { + var body ErrorsAnnotationIndexOutOfRange + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsAnnotationIndexOutOfRange overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsAnnotationIndexOutOfRange +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsAnnotationIndexOutOfRange(v ErrorsAnnotationIndexOutOfRange) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsAnnotationIndexOutOfRange performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsAnnotationIndexOutOfRange +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsAnnotationIndexOutOfRange(v ErrorsAnnotationIndexOutOfRange) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsUTXOSpent returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsUTXOSpent +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsUTXOSpent() (ErrorsUTXOSpent, error) { + var body ErrorsUTXOSpent + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsUTXOSpent overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsUTXOSpent +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsUTXOSpent(v ErrorsUTXOSpent) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsUTXOSpent performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsUTXOSpent +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsUTXOSpent(v ErrorsUTXOSpent) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsAnnotationIndexConversion returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsAnnotationIndexConversion +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsAnnotationIndexConversion() (ErrorsAnnotationIndexConversion, error) { + var body ErrorsAnnotationIndexConversion + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsAnnotationIndexConversion overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsAnnotationIndexConversion +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsAnnotationIndexConversion(v ErrorsAnnotationIndexConversion) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsAnnotationIndexConversion performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsAnnotationIndexConversion +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsAnnotationIndexConversion(v ErrorsAnnotationIndexConversion) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsNoOperations returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as a ErrorsNoOperations +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) AsErrorsNoOperations() (ErrorsNoOperations, error) { + var body ErrorsNoOperations + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsNoOperations overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest as the provided ErrorsNoOperations +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) FromErrorsNoOperations(v ErrorsNoOperations) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsNoOperations performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserBadRequest, using the provided ErrorsNoOperations +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) MergeErrorsNoOperations(v ErrorsNoOperations) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t ResponsesAdminRecordTransactionOutlineForUserBadRequest) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *ResponsesAdminRecordTransactionOutlineForUserBadRequest) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsErrorsInternal returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as a ErrorsInternal +func (t ResponsesAdminRecordTransactionOutlineForUserInternalServerError) AsErrorsInternal() (ErrorsInternal, error) { + var body ErrorsInternal + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsInternal overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as the provided ErrorsInternal +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) FromErrorsInternal(v ErrorsInternal) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsInternal performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError, using the provided ErrorsInternal +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) MergeErrorsInternal(v ErrorsInternal) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsGettingOutputs returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as a ErrorsGettingOutputs +func (t ResponsesAdminRecordTransactionOutlineForUserInternalServerError) AsErrorsGettingOutputs() (ErrorsGettingOutputs, error) { + var body ErrorsGettingOutputs + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsGettingOutputs overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as the provided ErrorsGettingOutputs +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) FromErrorsGettingOutputs(v ErrorsGettingOutputs) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsGettingOutputs performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError, using the provided ErrorsGettingOutputs +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) MergeErrorsGettingOutputs(v ErrorsGettingOutputs) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorsTxBroadcast returns the union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as a ErrorsTxBroadcast +func (t ResponsesAdminRecordTransactionOutlineForUserInternalServerError) AsErrorsTxBroadcast() (ErrorsTxBroadcast, error) { + var body ErrorsTxBroadcast + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorsTxBroadcast overwrites any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError as the provided ErrorsTxBroadcast +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) FromErrorsTxBroadcast(v ErrorsTxBroadcast) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorsTxBroadcast performs a merge with any union data inside the ResponsesAdminRecordTransactionOutlineForUserInternalServerError, using the provided ErrorsTxBroadcast +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) MergeErrorsTxBroadcast(v ErrorsTxBroadcast) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t ResponsesAdminRecordTransactionOutlineForUserInternalServerError) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *ResponsesAdminRecordTransactionOutlineForUserInternalServerError) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + // AsErrorsCannotBindRequest returns the union data inside the ResponsesAdminUserBadRequest as a ErrorsCannotBindRequest func (t ResponsesAdminUserBadRequest) AsErrorsCannotBindRequest() (ErrorsCannotBindRequest, error) { var body ErrorsCannotBindRequest @@ -2169,6 +2462,11 @@ type ClientInterface interface { // AdminStatus request AdminStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + // RecordTransactionOutlineForUserWithBody request with any body + RecordTransactionOutlineForUserWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + RecordTransactionOutlineForUser(ctx context.Context, body RecordTransactionOutlineForUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // CreateUserWithBody request with any body CreateUserWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -2220,6 +2518,30 @@ func (c *Client) AdminStatus(ctx context.Context, reqEditors ...RequestEditorFn) return c.Client.Do(req) } +func (c *Client) RecordTransactionOutlineForUserWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRecordTransactionOutlineForUserRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) RecordTransactionOutlineForUser(ctx context.Context, body RecordTransactionOutlineForUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRecordTransactionOutlineForUserRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) CreateUserWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewCreateUserRequestWithBody(c.Server, contentType, body) if err != nil { @@ -2415,6 +2737,46 @@ func NewAdminStatusRequest(server string) (*http.Request, error) { return req, nil } +// NewRecordTransactionOutlineForUserRequest calls the generic RecordTransactionOutlineForUser builder with application/json body +func NewRecordTransactionOutlineForUserRequest(server string, body RecordTransactionOutlineForUserJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRecordTransactionOutlineForUserRequestWithBody(server, "application/json", bodyReader) +} + +// NewRecordTransactionOutlineForUserRequestWithBody generates requests for RecordTransactionOutlineForUser with any type of body +func NewRecordTransactionOutlineForUserRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/v2/admin/transactions/record") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewCreateUserRequest calls the generic CreateUser builder with application/json body func NewCreateUserRequest(server string, body CreateUserJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -2934,6 +3296,11 @@ type ClientWithResponsesInterface interface { // AdminStatusWithResponse request AdminStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AdminStatusResponse, error) + // RecordTransactionOutlineForUserWithBodyWithResponse request with any body + RecordTransactionOutlineForUserWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RecordTransactionOutlineForUserResponse, error) + + RecordTransactionOutlineForUserWithResponse(ctx context.Context, body RecordTransactionOutlineForUserJSONRequestBody, reqEditors ...RequestEditorFn) (*RecordTransactionOutlineForUserResponse, error) + // CreateUserWithBodyWithResponse request with any body CreateUserWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateUserResponse, error) @@ -3005,6 +3372,41 @@ func (r AdminStatusResponse) Bytes() []byte { return r.Body } +type RecordTransactionOutlineForUserResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *ResponsesAdminRecordTransactionOutlineForUserSuccess + JSON400 *ResponsesAdminRecordTransactionOutlineForUserBadRequest + JSON401 *ResponsesNotAuthorizedToAdminEndpoint + JSON500 *ResponsesAdminRecordTransactionOutlineForUserInternalServerError +} + +// Status returns HTTPResponse.Status +func (r RecordTransactionOutlineForUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RecordTransactionOutlineForUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// HTTPResponse returns http.Response from which this response was parsed. +func (r RecordTransactionOutlineForUserResponse) Response() *http.Response { + return r.HTTPResponse +} + +// Bytes is a convenience method to retrieve the raw bytes from the HTTP response +func (r RecordTransactionOutlineForUserResponse) Bytes() []byte { + return r.Body +} + type CreateUserResponse struct { Body []byte HTTPResponse *http.Response @@ -3364,6 +3766,23 @@ func (c *ClientWithResponses) AdminStatusWithResponse(ctx context.Context, reqEd return ParseAdminStatusResponse(rsp) } +// RecordTransactionOutlineForUserWithBodyWithResponse request with arbitrary body returning *RecordTransactionOutlineForUserResponse +func (c *ClientWithResponses) RecordTransactionOutlineForUserWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RecordTransactionOutlineForUserResponse, error) { + rsp, err := c.RecordTransactionOutlineForUserWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRecordTransactionOutlineForUserResponse(rsp) +} + +func (c *ClientWithResponses) RecordTransactionOutlineForUserWithResponse(ctx context.Context, body RecordTransactionOutlineForUserJSONRequestBody, reqEditors ...RequestEditorFn) (*RecordTransactionOutlineForUserResponse, error) { + rsp, err := c.RecordTransactionOutlineForUser(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRecordTransactionOutlineForUserResponse(rsp) +} + // CreateUserWithBodyWithResponse request with arbitrary body returning *CreateUserResponse func (c *ClientWithResponses) CreateUserWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateUserResponse, error) { rsp, err := c.CreateUserWithBody(ctx, contentType, body, reqEditors...) @@ -3512,6 +3931,53 @@ func ParseAdminStatusResponse(rsp *http.Response) (*AdminStatusResponse, error) return response, nil } +// ParseRecordTransactionOutlineForUserResponse parses an HTTP response from a RecordTransactionOutlineForUserWithResponse call +func ParseRecordTransactionOutlineForUserResponse(rsp *http.Response) (*RecordTransactionOutlineForUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RecordTransactionOutlineForUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest ResponsesAdminRecordTransactionOutlineForUserSuccess + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest ResponsesAdminRecordTransactionOutlineForUserBadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ResponsesNotAuthorizedToAdminEndpoint + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ResponsesAdminRecordTransactionOutlineForUserInternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + // ParseCreateUserResponse parses an HTTP response from a CreateUserWithResponse call func ParseCreateUserResponse(rsp *http.Response) (*CreateUserResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body)