Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUX-528: UnreserveUtxos #188

Merged
merged 5 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading