Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
feat(BUX-498): remove block header model (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 authored and jakubmkowalski committed Feb 12, 2024
1 parent e47e22b commit fb366a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
52 changes: 19 additions & 33 deletions action_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package bux

import (
"context"

"github.com/mrz1836/go-datastore"
)

// NewDestination will get a new destination for an existing xPub
//
// xPubKey is the raw public xPub
func (c *Client) NewDestination(ctx context.Context, xPubKey string, chain uint32,
destinationType string, opts ...ModelOps) (*Destination, error) {

destinationType string, opts ...ModelOps,
) (*Destination, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "new_destination")

Expand Down Expand Up @@ -46,8 +47,8 @@ func (c *Client) NewDestination(ctx context.Context, xPubKey string, chain uint3

// NewDestinationForLockingScript will create a new destination based on a locking script
func (c *Client) NewDestinationForLockingScript(ctx context.Context, xPubID, lockingScript string,
opts ...ModelOps) (*Destination, error) {

opts ...ModelOps,
) (*Destination, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "new_destination_for_locking_script")

Expand All @@ -66,18 +67,6 @@ func (c *Client) NewDestinationForLockingScript(ctx context.Context, xPubID, loc
return nil, ErrUnknownLockingScript
}

<<<<<<< HEAD
// set the monitoring, passed down from the initiating function
// this will be set when calling NewDestination from http, but not for instance paymail
if monitor {
destination.Monitor = customTypes.NullTime{NullTime: sql.NullTime{
Valid: true,
Time: time.Now(),
}}
}

=======
>>>>>>> 06feaba (feat(BUX-417): remove monitor, ITC flag and IncomingTransaction (#532))
// Save the destination
if err := destination.Save(ctx); err != nil {
return nil, err
Expand All @@ -89,8 +78,8 @@ 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) ([]*Destination, error) {

conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps,
) ([]*Destination, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_destinations")

Expand All @@ -108,8 +97,8 @@ 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) (int64, error) {

conditions *map[string]interface{}, opts ...ModelOps,
) (int64, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_destinations_count")

Expand All @@ -129,8 +118,8 @@ func (c *Client) GetDestinationsCount(ctx context.Context, metadataConditions *M
//
// metadataConditions are the search criteria used to find destinations
func (c *Client) GetDestinationsByXpubID(ctx context.Context, xPubID string, metadataConditions *Metadata,
conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*Destination, error) {

conditions *map[string]interface{}, queryParams *datastore.QueryParams,
) ([]*Destination, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_destinations")

Expand All @@ -147,8 +136,8 @@ func (c *Client) GetDestinationsByXpubID(ctx context.Context, xPubID string, met

// GetDestinationsByXpubIDCount will get a count of all destinations based on an xPub
func (c *Client) GetDestinationsByXpubIDCount(ctx context.Context, xPubID string, metadataConditions *Metadata,
conditions *map[string]interface{}) (int64, error) {

conditions *map[string]interface{},
) (int64, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_destinations")

Expand All @@ -165,7 +154,6 @@ func (c *Client) GetDestinationsByXpubIDCount(ctx context.Context, xPubID string

// GetDestinationByID will get a destination by id
func (c *Client) GetDestinationByID(ctx context.Context, xPubID, id string) (*Destination, error) {

// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_destination_by_id")

Expand All @@ -187,7 +175,6 @@ func (c *Client) GetDestinationByID(ctx context.Context, xPubID, id string) (*De

// GetDestinationByLockingScript will get a destination for a locking script
func (c *Client) GetDestinationByLockingScript(ctx context.Context, xPubID, lockingScript string) (*Destination, error) {

// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_destination_by_locking_script")

Expand All @@ -209,7 +196,6 @@ func (c *Client) GetDestinationByLockingScript(ctx context.Context, xPubID, lock

// GetDestinationByAddress will get a destination for an address
func (c *Client) GetDestinationByAddress(ctx context.Context, xPubID, address string) (*Destination, error) {

// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_destination_by_address")

Expand All @@ -231,8 +217,8 @@ func (c *Client) GetDestinationByAddress(ctx context.Context, xPubID, address st

// UpdateDestinationMetadataByID will update the metadata in an existing destination by id
func (c *Client) UpdateDestinationMetadataByID(ctx context.Context, xPubID, id string,
metadata Metadata) (*Destination, error) {

metadata Metadata,
) (*Destination, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "update_destination_by_id")

Expand All @@ -253,8 +239,8 @@ func (c *Client) UpdateDestinationMetadataByID(ctx context.Context, xPubID, id s

// UpdateDestinationMetadataByLockingScript will update the metadata in an existing destination by locking script
func (c *Client) UpdateDestinationMetadataByLockingScript(ctx context.Context, xPubID,
lockingScript string, metadata Metadata) (*Destination, error) {

lockingScript string, metadata Metadata,
) (*Destination, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "update_destination_by_locking_script")

Expand All @@ -275,8 +261,8 @@ func (c *Client) UpdateDestinationMetadataByLockingScript(ctx context.Context, x

// UpdateDestinationMetadataByAddress will update the metadata in an existing destination by address
func (c *Client) UpdateDestinationMetadataByAddress(ctx context.Context, xPubID, address string,
metadata Metadata) (*Destination, error) {

metadata Metadata,
) (*Destination, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "update_destination_by_address")

Expand Down
2 changes: 1 addition & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var ErrUtxoNotReserved = errors.New("transaction utxo has not been reserved for
var ErrDraftIDMismatch = errors.New("transaction draft id does not match utxo draft reservation id")

// ErrMissingTxHex is when the hex is missing or invalid and creates an empty id
var ErrMissingTxHex = errors.New("transaction hex is invalid or id is missing")
var ErrMissingTxHex = errors.New("transaction hex is empty or id is missing")

// ErrUtxoAlreadySpent is when the utxo is already spent, but is trying to be used
var ErrUtxoAlreadySpent = errors.New("utxo has already been spent")
Expand Down

0 comments on commit fb366a9

Please sign in to comment.