Skip to content

Commit

Permalink
Merge pull request #188 from BuxOrg/BUX-528/RemoveUnreserveUtxos
Browse files Browse the repository at this point in the history
BUX-528: UnreserveUtxos
  • Loading branch information
Nazarii-4chain authored Feb 5, 2024
2 parents 77c98ae + 410762c commit 5cb0d26
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
5 changes: 0 additions & 5 deletions transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,3 @@ func (b *BuxClient) SendToRecipients(ctx context.Context, recipients []*transpor

return b.RecordTransaction(ctx, hex, draft.ID, metadata)
}

// UnreserveUtxos unreserves utxos from draft transaction
func (b *BuxClient) UnreserveUtxos(ctx context.Context, referenceID string) transports.ResponseError {
return b.transport.UnreserveUtxos(ctx, referenceID)
}
7 changes: 4 additions & 3 deletions transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,19 @@ func TestTransactions(t *testing.T) {
assert.Len(t, txDraft.Outputs, len(fixtures.DraftTx.Configuration.Outputs))
})

t.Run("UnreserveUtxos", func(t *testing.T) {
t.Run("CountUtxos", func(t *testing.T) {
// given
transportHandler := testTransportHandler{
Type: fixtures.RequestType,
Path: "/utxo/unreserve",
Path: "/utxo/count",
ClientURL: fixtures.ServerURL,
Result: "0",
Client: WithHTTPClient,
}
client := getTestBuxClient(transportHandler, false)

// when
err := client.UnreserveUtxos(context.Background(), fixtures.DraftTx.Configuration.Outputs[0].PaymailP4.ReferenceID)
_, err := client.GetUtxosCount(context.Background(), map[string]interface{}{}, fixtures.TestMetadata)

// then
assert.NoError(t, err)
Expand Down
12 changes: 0 additions & 12 deletions transports/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,18 +581,6 @@ func (h *TransportHTTP) GetUtxosCount(ctx context.Context, conditions map[string
return count, nil
}

// UnreserveUtxos will unreserve utxos from draft transaction
func (h *TransportHTTP) UnreserveUtxos(ctx context.Context, referenceID string) ResponseError {
jsonStr, err := json.Marshal(map[string]interface{}{
FieldReferenceID: referenceID,
})
if err != nil {
return WrapError(err)
}

return h.doHTTPRequest(ctx, http.MethodPatch, "/utxo/unreserve", jsonStr, h.xPriv, h.signRequest, nil)
}

// createSignatureAccessKey will create a signature for the given access key & body contents
func createSignatureAccessKey(privateKeyHex, bodyString string) (payload *buxmodels.AuthPayload, err error) {
// No key?
Expand Down
1 change: 0 additions & 1 deletion transports/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type TransactionService interface {
GetUtxo(ctx context.Context, txID string, outputIndex uint32) (*buxmodels.Utxo, ResponseError)
GetUtxos(ctx context.Context, conditions map[string]interface{}, metadata *buxmodels.Metadata, queryParams *QueryParams) ([]*buxmodels.Utxo, ResponseError)
GetUtxosCount(ctx context.Context, conditions map[string]interface{}, metadata *buxmodels.Metadata) (int64, ResponseError)
UnreserveUtxos(ctx context.Context, referenceID string) ResponseError
}

// PaymailService is the paymail related requests
Expand Down

0 comments on commit 5cb0d26

Please sign in to comment.