// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"

	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/google/uuid"
	"github.com/lightsparkdev/spark/common/keys"
	"github.com/lightsparkdev/spark/so/ent/schema/schematype"
	"github.com/lightsparkdev/spark/so/ent/transfer"
	"github.com/lightsparkdev/spark/so/ent/utxo"
	"github.com/lightsparkdev/spark/so/ent/utxoswap"
)

// UtxoSwapCreate is the builder for creating a UtxoSwap entity.
type UtxoSwapCreate struct {
	config
	mutation *UtxoSwapMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreateTime sets the "create_time" field.
func (usc *UtxoSwapCreate) SetCreateTime(t time.Time) *UtxoSwapCreate {
	usc.mutation.SetCreateTime(t)
	return usc
}

// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableCreateTime(t *time.Time) *UtxoSwapCreate {
	if t != nil {
		usc.SetCreateTime(*t)
	}
	return usc
}

// SetUpdateTime sets the "update_time" field.
func (usc *UtxoSwapCreate) SetUpdateTime(t time.Time) *UtxoSwapCreate {
	usc.mutation.SetUpdateTime(t)
	return usc
}

// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableUpdateTime(t *time.Time) *UtxoSwapCreate {
	if t != nil {
		usc.SetUpdateTime(*t)
	}
	return usc
}

// SetStatus sets the "status" field.
func (usc *UtxoSwapCreate) SetStatus(sss schematype.UtxoSwapStatus) *UtxoSwapCreate {
	usc.mutation.SetStatus(sss)
	return usc
}

// SetRequestType sets the "request_type" field.
func (usc *UtxoSwapCreate) SetRequestType(ssrt schematype.UtxoSwapRequestType) *UtxoSwapCreate {
	usc.mutation.SetRequestType(ssrt)
	return usc
}

// SetCreditAmountSats sets the "credit_amount_sats" field.
func (usc *UtxoSwapCreate) SetCreditAmountSats(u uint64) *UtxoSwapCreate {
	usc.mutation.SetCreditAmountSats(u)
	return usc
}

// SetNillableCreditAmountSats sets the "credit_amount_sats" field if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableCreditAmountSats(u *uint64) *UtxoSwapCreate {
	if u != nil {
		usc.SetCreditAmountSats(*u)
	}
	return usc
}

// SetMaxFeeSats sets the "max_fee_sats" field.
func (usc *UtxoSwapCreate) SetMaxFeeSats(u uint64) *UtxoSwapCreate {
	usc.mutation.SetMaxFeeSats(u)
	return usc
}

// SetNillableMaxFeeSats sets the "max_fee_sats" field if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableMaxFeeSats(u *uint64) *UtxoSwapCreate {
	if u != nil {
		usc.SetMaxFeeSats(*u)
	}
	return usc
}

// SetSspSignature sets the "ssp_signature" field.
func (usc *UtxoSwapCreate) SetSspSignature(b []byte) *UtxoSwapCreate {
	usc.mutation.SetSspSignature(b)
	return usc
}

// SetSspIdentityPublicKey sets the "ssp_identity_public_key" field.
func (usc *UtxoSwapCreate) SetSspIdentityPublicKey(k keys.Public) *UtxoSwapCreate {
	usc.mutation.SetSspIdentityPublicKey(k)
	return usc
}

// SetNillableSspIdentityPublicKey sets the "ssp_identity_public_key" field if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableSspIdentityPublicKey(k *keys.Public) *UtxoSwapCreate {
	if k != nil {
		usc.SetSspIdentityPublicKey(*k)
	}
	return usc
}

// SetUserSignature sets the "user_signature" field.
func (usc *UtxoSwapCreate) SetUserSignature(b []byte) *UtxoSwapCreate {
	usc.mutation.SetUserSignature(b)
	return usc
}

// SetUserIdentityPublicKey sets the "user_identity_public_key" field.
func (usc *UtxoSwapCreate) SetUserIdentityPublicKey(k keys.Public) *UtxoSwapCreate {
	usc.mutation.SetUserIdentityPublicKey(k)
	return usc
}

// SetNillableUserIdentityPublicKey sets the "user_identity_public_key" field if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableUserIdentityPublicKey(k *keys.Public) *UtxoSwapCreate {
	if k != nil {
		usc.SetUserIdentityPublicKey(*k)
	}
	return usc
}

// SetCoordinatorIdentityPublicKey sets the "coordinator_identity_public_key" field.
func (usc *UtxoSwapCreate) SetCoordinatorIdentityPublicKey(k keys.Public) *UtxoSwapCreate {
	usc.mutation.SetCoordinatorIdentityPublicKey(k)
	return usc
}

// SetRequestedTransferID sets the "requested_transfer_id" field.
func (usc *UtxoSwapCreate) SetRequestedTransferID(u uuid.UUID) *UtxoSwapCreate {
	usc.mutation.SetRequestedTransferID(u)
	return usc
}

// SetNillableRequestedTransferID sets the "requested_transfer_id" field if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableRequestedTransferID(u *uuid.UUID) *UtxoSwapCreate {
	if u != nil {
		usc.SetRequestedTransferID(*u)
	}
	return usc
}

// SetSpendTxSigningResult sets the "spend_tx_signing_result" field.
func (usc *UtxoSwapCreate) SetSpendTxSigningResult(b []byte) *UtxoSwapCreate {
	usc.mutation.SetSpendTxSigningResult(b)
	return usc
}

// SetID sets the "id" field.
func (usc *UtxoSwapCreate) SetID(u uuid.UUID) *UtxoSwapCreate {
	usc.mutation.SetID(u)
	return usc
}

// SetNillableID sets the "id" field if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableID(u *uuid.UUID) *UtxoSwapCreate {
	if u != nil {
		usc.SetID(*u)
	}
	return usc
}

// SetUtxoID sets the "utxo" edge to the Utxo entity by ID.
func (usc *UtxoSwapCreate) SetUtxoID(id uuid.UUID) *UtxoSwapCreate {
	usc.mutation.SetUtxoID(id)
	return usc
}

// SetUtxo sets the "utxo" edge to the Utxo entity.
func (usc *UtxoSwapCreate) SetUtxo(u *Utxo) *UtxoSwapCreate {
	return usc.SetUtxoID(u.ID)
}

// SetTransferID sets the "transfer" edge to the Transfer entity by ID.
func (usc *UtxoSwapCreate) SetTransferID(id uuid.UUID) *UtxoSwapCreate {
	usc.mutation.SetTransferID(id)
	return usc
}

// SetNillableTransferID sets the "transfer" edge to the Transfer entity by ID if the given value is not nil.
func (usc *UtxoSwapCreate) SetNillableTransferID(id *uuid.UUID) *UtxoSwapCreate {
	if id != nil {
		usc = usc.SetTransferID(*id)
	}
	return usc
}

// SetTransfer sets the "transfer" edge to the Transfer entity.
func (usc *UtxoSwapCreate) SetTransfer(t *Transfer) *UtxoSwapCreate {
	return usc.SetTransferID(t.ID)
}

// Mutation returns the UtxoSwapMutation object of the builder.
func (usc *UtxoSwapCreate) Mutation() *UtxoSwapMutation {
	return usc.mutation
}

// Save creates the UtxoSwap in the database.
func (usc *UtxoSwapCreate) Save(ctx context.Context) (*UtxoSwap, error) {
	usc.defaults()
	return withHooks(ctx, usc.sqlSave, usc.mutation, usc.hooks)
}

// SaveX calls Save and panics if Save returns an error.
func (usc *UtxoSwapCreate) SaveX(ctx context.Context) *UtxoSwap {
	v, err := usc.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (usc *UtxoSwapCreate) Exec(ctx context.Context) error {
	_, err := usc.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (usc *UtxoSwapCreate) ExecX(ctx context.Context) {
	if err := usc.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (usc *UtxoSwapCreate) defaults() {
	if _, ok := usc.mutation.CreateTime(); !ok {
		v := utxoswap.DefaultCreateTime()
		usc.mutation.SetCreateTime(v)
	}
	if _, ok := usc.mutation.UpdateTime(); !ok {
		v := utxoswap.DefaultUpdateTime()
		usc.mutation.SetUpdateTime(v)
	}
	if _, ok := usc.mutation.ID(); !ok {
		v := utxoswap.DefaultID()
		usc.mutation.SetID(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (usc *UtxoSwapCreate) check() error {
	if _, ok := usc.mutation.CreateTime(); !ok {
		return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "UtxoSwap.create_time"`)}
	}
	if _, ok := usc.mutation.UpdateTime(); !ok {
		return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "UtxoSwap.update_time"`)}
	}
	if _, ok := usc.mutation.Status(); !ok {
		return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "UtxoSwap.status"`)}
	}
	if v, ok := usc.mutation.Status(); ok {
		if err := utxoswap.StatusValidator(v); err != nil {
			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "UtxoSwap.status": %w`, err)}
		}
	}
	if _, ok := usc.mutation.RequestType(); !ok {
		return &ValidationError{Name: "request_type", err: errors.New(`ent: missing required field "UtxoSwap.request_type"`)}
	}
	if v, ok := usc.mutation.RequestType(); ok {
		if err := utxoswap.RequestTypeValidator(v); err != nil {
			return &ValidationError{Name: "request_type", err: fmt.Errorf(`ent: validator failed for field "UtxoSwap.request_type": %w`, err)}
		}
	}
	if _, ok := usc.mutation.CoordinatorIdentityPublicKey(); !ok {
		return &ValidationError{Name: "coordinator_identity_public_key", err: errors.New(`ent: missing required field "UtxoSwap.coordinator_identity_public_key"`)}
	}
	if len(usc.mutation.UtxoIDs()) == 0 {
		return &ValidationError{Name: "utxo", err: errors.New(`ent: missing required edge "UtxoSwap.utxo"`)}
	}
	return nil
}

func (usc *UtxoSwapCreate) sqlSave(ctx context.Context) (*UtxoSwap, error) {
	if err := usc.check(); err != nil {
		return nil, err
	}
	_node, _spec := usc.createSpec()
	if err := sqlgraph.CreateNode(ctx, usc.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	if _spec.ID.Value != nil {
		if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
			_node.ID = *id
		} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
			return nil, err
		}
	}
	usc.mutation.id = &_node.ID
	usc.mutation.done = true
	return _node, nil
}

func (usc *UtxoSwapCreate) createSpec() (*UtxoSwap, *sqlgraph.CreateSpec) {
	var (
		_node = &UtxoSwap{config: usc.config}
		_spec = sqlgraph.NewCreateSpec(utxoswap.Table, sqlgraph.NewFieldSpec(utxoswap.FieldID, field.TypeUUID))
	)
	_spec.OnConflict = usc.conflict
	if id, ok := usc.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = &id
	}
	if value, ok := usc.mutation.CreateTime(); ok {
		_spec.SetField(utxoswap.FieldCreateTime, field.TypeTime, value)
		_node.CreateTime = value
	}
	if value, ok := usc.mutation.UpdateTime(); ok {
		_spec.SetField(utxoswap.FieldUpdateTime, field.TypeTime, value)
		_node.UpdateTime = value
	}
	if value, ok := usc.mutation.Status(); ok {
		_spec.SetField(utxoswap.FieldStatus, field.TypeEnum, value)
		_node.Status = value
	}
	if value, ok := usc.mutation.RequestType(); ok {
		_spec.SetField(utxoswap.FieldRequestType, field.TypeEnum, value)
		_node.RequestType = value
	}
	if value, ok := usc.mutation.CreditAmountSats(); ok {
		_spec.SetField(utxoswap.FieldCreditAmountSats, field.TypeUint64, value)
		_node.CreditAmountSats = value
	}
	if value, ok := usc.mutation.MaxFeeSats(); ok {
		_spec.SetField(utxoswap.FieldMaxFeeSats, field.TypeUint64, value)
		_node.MaxFeeSats = value
	}
	if value, ok := usc.mutation.SspSignature(); ok {
		_spec.SetField(utxoswap.FieldSspSignature, field.TypeBytes, value)
		_node.SspSignature = value
	}
	if value, ok := usc.mutation.SspIdentityPublicKey(); ok {
		_spec.SetField(utxoswap.FieldSspIdentityPublicKey, field.TypeBytes, value)
		_node.SspIdentityPublicKey = value
	}
	if value, ok := usc.mutation.UserSignature(); ok {
		_spec.SetField(utxoswap.FieldUserSignature, field.TypeBytes, value)
		_node.UserSignature = value
	}
	if value, ok := usc.mutation.UserIdentityPublicKey(); ok {
		_spec.SetField(utxoswap.FieldUserIdentityPublicKey, field.TypeBytes, value)
		_node.UserIdentityPublicKey = value
	}
	if value, ok := usc.mutation.CoordinatorIdentityPublicKey(); ok {
		_spec.SetField(utxoswap.FieldCoordinatorIdentityPublicKey, field.TypeBytes, value)
		_node.CoordinatorIdentityPublicKey = value
	}
	if value, ok := usc.mutation.RequestedTransferID(); ok {
		_spec.SetField(utxoswap.FieldRequestedTransferID, field.TypeUUID, value)
		_node.RequestedTransferID = value
	}
	if value, ok := usc.mutation.SpendTxSigningResult(); ok {
		_spec.SetField(utxoswap.FieldSpendTxSigningResult, field.TypeBytes, value)
		_node.SpendTxSigningResult = value
	}
	if nodes := usc.mutation.UtxoIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   utxoswap.UtxoTable,
			Columns: []string{utxoswap.UtxoColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(utxo.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.utxo_swap_utxo = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := usc.mutation.TransferIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   utxoswap.TransferTable,
			Columns: []string{utxoswap.TransferColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(transfer.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.utxo_swap_transfer = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.UtxoSwap.Create().
//		SetCreateTime(v).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.UtxoSwapUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (usc *UtxoSwapCreate) OnConflict(opts ...sql.ConflictOption) *UtxoSwapUpsertOne {
	usc.conflict = opts
	return &UtxoSwapUpsertOne{
		create: usc,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.UtxoSwap.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (usc *UtxoSwapCreate) OnConflictColumns(columns ...string) *UtxoSwapUpsertOne {
	usc.conflict = append(usc.conflict, sql.ConflictColumns(columns...))
	return &UtxoSwapUpsertOne{
		create: usc,
	}
}

type (
	// UtxoSwapUpsertOne is the builder for "upsert"-ing
	//  one UtxoSwap node.
	UtxoSwapUpsertOne struct {
		create *UtxoSwapCreate
	}

	// UtxoSwapUpsert is the "OnConflict" setter.
	UtxoSwapUpsert struct {
		*sql.UpdateSet
	}
)

// SetUpdateTime sets the "update_time" field.
func (u *UtxoSwapUpsert) SetUpdateTime(v time.Time) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldUpdateTime, v)
	return u
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateUpdateTime() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldUpdateTime)
	return u
}

// SetStatus sets the "status" field.
func (u *UtxoSwapUpsert) SetStatus(v schematype.UtxoSwapStatus) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldStatus, v)
	return u
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateStatus() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldStatus)
	return u
}

// SetRequestType sets the "request_type" field.
func (u *UtxoSwapUpsert) SetRequestType(v schematype.UtxoSwapRequestType) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldRequestType, v)
	return u
}

// UpdateRequestType sets the "request_type" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateRequestType() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldRequestType)
	return u
}

// SetCreditAmountSats sets the "credit_amount_sats" field.
func (u *UtxoSwapUpsert) SetCreditAmountSats(v uint64) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldCreditAmountSats, v)
	return u
}

// UpdateCreditAmountSats sets the "credit_amount_sats" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateCreditAmountSats() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldCreditAmountSats)
	return u
}

// AddCreditAmountSats adds v to the "credit_amount_sats" field.
func (u *UtxoSwapUpsert) AddCreditAmountSats(v uint64) *UtxoSwapUpsert {
	u.Add(utxoswap.FieldCreditAmountSats, v)
	return u
}

// ClearCreditAmountSats clears the value of the "credit_amount_sats" field.
func (u *UtxoSwapUpsert) ClearCreditAmountSats() *UtxoSwapUpsert {
	u.SetNull(utxoswap.FieldCreditAmountSats)
	return u
}

// SetMaxFeeSats sets the "max_fee_sats" field.
func (u *UtxoSwapUpsert) SetMaxFeeSats(v uint64) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldMaxFeeSats, v)
	return u
}

// UpdateMaxFeeSats sets the "max_fee_sats" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateMaxFeeSats() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldMaxFeeSats)
	return u
}

// AddMaxFeeSats adds v to the "max_fee_sats" field.
func (u *UtxoSwapUpsert) AddMaxFeeSats(v uint64) *UtxoSwapUpsert {
	u.Add(utxoswap.FieldMaxFeeSats, v)
	return u
}

// ClearMaxFeeSats clears the value of the "max_fee_sats" field.
func (u *UtxoSwapUpsert) ClearMaxFeeSats() *UtxoSwapUpsert {
	u.SetNull(utxoswap.FieldMaxFeeSats)
	return u
}

// SetSspSignature sets the "ssp_signature" field.
func (u *UtxoSwapUpsert) SetSspSignature(v []byte) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldSspSignature, v)
	return u
}

// UpdateSspSignature sets the "ssp_signature" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateSspSignature() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldSspSignature)
	return u
}

// ClearSspSignature clears the value of the "ssp_signature" field.
func (u *UtxoSwapUpsert) ClearSspSignature() *UtxoSwapUpsert {
	u.SetNull(utxoswap.FieldSspSignature)
	return u
}

// SetSspIdentityPublicKey sets the "ssp_identity_public_key" field.
func (u *UtxoSwapUpsert) SetSspIdentityPublicKey(v keys.Public) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldSspIdentityPublicKey, v)
	return u
}

// UpdateSspIdentityPublicKey sets the "ssp_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateSspIdentityPublicKey() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldSspIdentityPublicKey)
	return u
}

// ClearSspIdentityPublicKey clears the value of the "ssp_identity_public_key" field.
func (u *UtxoSwapUpsert) ClearSspIdentityPublicKey() *UtxoSwapUpsert {
	u.SetNull(utxoswap.FieldSspIdentityPublicKey)
	return u
}

// SetUserSignature sets the "user_signature" field.
func (u *UtxoSwapUpsert) SetUserSignature(v []byte) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldUserSignature, v)
	return u
}

// UpdateUserSignature sets the "user_signature" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateUserSignature() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldUserSignature)
	return u
}

// ClearUserSignature clears the value of the "user_signature" field.
func (u *UtxoSwapUpsert) ClearUserSignature() *UtxoSwapUpsert {
	u.SetNull(utxoswap.FieldUserSignature)
	return u
}

// SetUserIdentityPublicKey sets the "user_identity_public_key" field.
func (u *UtxoSwapUpsert) SetUserIdentityPublicKey(v keys.Public) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldUserIdentityPublicKey, v)
	return u
}

// UpdateUserIdentityPublicKey sets the "user_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateUserIdentityPublicKey() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldUserIdentityPublicKey)
	return u
}

// ClearUserIdentityPublicKey clears the value of the "user_identity_public_key" field.
func (u *UtxoSwapUpsert) ClearUserIdentityPublicKey() *UtxoSwapUpsert {
	u.SetNull(utxoswap.FieldUserIdentityPublicKey)
	return u
}

// SetCoordinatorIdentityPublicKey sets the "coordinator_identity_public_key" field.
func (u *UtxoSwapUpsert) SetCoordinatorIdentityPublicKey(v keys.Public) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldCoordinatorIdentityPublicKey, v)
	return u
}

// UpdateCoordinatorIdentityPublicKey sets the "coordinator_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateCoordinatorIdentityPublicKey() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldCoordinatorIdentityPublicKey)
	return u
}

// SetRequestedTransferID sets the "requested_transfer_id" field.
func (u *UtxoSwapUpsert) SetRequestedTransferID(v uuid.UUID) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldRequestedTransferID, v)
	return u
}

// UpdateRequestedTransferID sets the "requested_transfer_id" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateRequestedTransferID() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldRequestedTransferID)
	return u
}

// ClearRequestedTransferID clears the value of the "requested_transfer_id" field.
func (u *UtxoSwapUpsert) ClearRequestedTransferID() *UtxoSwapUpsert {
	u.SetNull(utxoswap.FieldRequestedTransferID)
	return u
}

// SetSpendTxSigningResult sets the "spend_tx_signing_result" field.
func (u *UtxoSwapUpsert) SetSpendTxSigningResult(v []byte) *UtxoSwapUpsert {
	u.Set(utxoswap.FieldSpendTxSigningResult, v)
	return u
}

// UpdateSpendTxSigningResult sets the "spend_tx_signing_result" field to the value that was provided on create.
func (u *UtxoSwapUpsert) UpdateSpendTxSigningResult() *UtxoSwapUpsert {
	u.SetExcluded(utxoswap.FieldSpendTxSigningResult)
	return u
}

// ClearSpendTxSigningResult clears the value of the "spend_tx_signing_result" field.
func (u *UtxoSwapUpsert) ClearSpendTxSigningResult() *UtxoSwapUpsert {
	u.SetNull(utxoswap.FieldSpendTxSigningResult)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
// Using this option is equivalent to using:
//
//	client.UtxoSwap.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(utxoswap.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *UtxoSwapUpsertOne) UpdateNewValues() *UtxoSwapUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		if _, exists := u.create.mutation.ID(); exists {
			s.SetIgnore(utxoswap.FieldID)
		}
		if _, exists := u.create.mutation.CreateTime(); exists {
			s.SetIgnore(utxoswap.FieldCreateTime)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.UtxoSwap.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *UtxoSwapUpsertOne) Ignore() *UtxoSwapUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *UtxoSwapUpsertOne) DoNothing() *UtxoSwapUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the UtxoSwapCreate.OnConflict
// documentation for more info.
func (u *UtxoSwapUpsertOne) Update(set func(*UtxoSwapUpsert)) *UtxoSwapUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&UtxoSwapUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdateTime sets the "update_time" field.
func (u *UtxoSwapUpsertOne) SetUpdateTime(v time.Time) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetUpdateTime(v)
	})
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateUpdateTime() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateUpdateTime()
	})
}

// SetStatus sets the "status" field.
func (u *UtxoSwapUpsertOne) SetStatus(v schematype.UtxoSwapStatus) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetStatus(v)
	})
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateStatus() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateStatus()
	})
}

// SetRequestType sets the "request_type" field.
func (u *UtxoSwapUpsertOne) SetRequestType(v schematype.UtxoSwapRequestType) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetRequestType(v)
	})
}

// UpdateRequestType sets the "request_type" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateRequestType() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateRequestType()
	})
}

// SetCreditAmountSats sets the "credit_amount_sats" field.
func (u *UtxoSwapUpsertOne) SetCreditAmountSats(v uint64) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetCreditAmountSats(v)
	})
}

// AddCreditAmountSats adds v to the "credit_amount_sats" field.
func (u *UtxoSwapUpsertOne) AddCreditAmountSats(v uint64) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.AddCreditAmountSats(v)
	})
}

// UpdateCreditAmountSats sets the "credit_amount_sats" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateCreditAmountSats() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateCreditAmountSats()
	})
}

// ClearCreditAmountSats clears the value of the "credit_amount_sats" field.
func (u *UtxoSwapUpsertOne) ClearCreditAmountSats() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearCreditAmountSats()
	})
}

// SetMaxFeeSats sets the "max_fee_sats" field.
func (u *UtxoSwapUpsertOne) SetMaxFeeSats(v uint64) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetMaxFeeSats(v)
	})
}

// AddMaxFeeSats adds v to the "max_fee_sats" field.
func (u *UtxoSwapUpsertOne) AddMaxFeeSats(v uint64) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.AddMaxFeeSats(v)
	})
}

// UpdateMaxFeeSats sets the "max_fee_sats" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateMaxFeeSats() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateMaxFeeSats()
	})
}

// ClearMaxFeeSats clears the value of the "max_fee_sats" field.
func (u *UtxoSwapUpsertOne) ClearMaxFeeSats() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearMaxFeeSats()
	})
}

// SetSspSignature sets the "ssp_signature" field.
func (u *UtxoSwapUpsertOne) SetSspSignature(v []byte) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetSspSignature(v)
	})
}

// UpdateSspSignature sets the "ssp_signature" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateSspSignature() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateSspSignature()
	})
}

// ClearSspSignature clears the value of the "ssp_signature" field.
func (u *UtxoSwapUpsertOne) ClearSspSignature() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearSspSignature()
	})
}

// SetSspIdentityPublicKey sets the "ssp_identity_public_key" field.
func (u *UtxoSwapUpsertOne) SetSspIdentityPublicKey(v keys.Public) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetSspIdentityPublicKey(v)
	})
}

// UpdateSspIdentityPublicKey sets the "ssp_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateSspIdentityPublicKey() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateSspIdentityPublicKey()
	})
}

// ClearSspIdentityPublicKey clears the value of the "ssp_identity_public_key" field.
func (u *UtxoSwapUpsertOne) ClearSspIdentityPublicKey() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearSspIdentityPublicKey()
	})
}

// SetUserSignature sets the "user_signature" field.
func (u *UtxoSwapUpsertOne) SetUserSignature(v []byte) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetUserSignature(v)
	})
}

// UpdateUserSignature sets the "user_signature" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateUserSignature() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateUserSignature()
	})
}

// ClearUserSignature clears the value of the "user_signature" field.
func (u *UtxoSwapUpsertOne) ClearUserSignature() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearUserSignature()
	})
}

// SetUserIdentityPublicKey sets the "user_identity_public_key" field.
func (u *UtxoSwapUpsertOne) SetUserIdentityPublicKey(v keys.Public) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetUserIdentityPublicKey(v)
	})
}

// UpdateUserIdentityPublicKey sets the "user_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateUserIdentityPublicKey() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateUserIdentityPublicKey()
	})
}

// ClearUserIdentityPublicKey clears the value of the "user_identity_public_key" field.
func (u *UtxoSwapUpsertOne) ClearUserIdentityPublicKey() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearUserIdentityPublicKey()
	})
}

// SetCoordinatorIdentityPublicKey sets the "coordinator_identity_public_key" field.
func (u *UtxoSwapUpsertOne) SetCoordinatorIdentityPublicKey(v keys.Public) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetCoordinatorIdentityPublicKey(v)
	})
}

// UpdateCoordinatorIdentityPublicKey sets the "coordinator_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateCoordinatorIdentityPublicKey() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateCoordinatorIdentityPublicKey()
	})
}

// SetRequestedTransferID sets the "requested_transfer_id" field.
func (u *UtxoSwapUpsertOne) SetRequestedTransferID(v uuid.UUID) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetRequestedTransferID(v)
	})
}

// UpdateRequestedTransferID sets the "requested_transfer_id" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateRequestedTransferID() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateRequestedTransferID()
	})
}

// ClearRequestedTransferID clears the value of the "requested_transfer_id" field.
func (u *UtxoSwapUpsertOne) ClearRequestedTransferID() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearRequestedTransferID()
	})
}

// SetSpendTxSigningResult sets the "spend_tx_signing_result" field.
func (u *UtxoSwapUpsertOne) SetSpendTxSigningResult(v []byte) *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetSpendTxSigningResult(v)
	})
}

// UpdateSpendTxSigningResult sets the "spend_tx_signing_result" field to the value that was provided on create.
func (u *UtxoSwapUpsertOne) UpdateSpendTxSigningResult() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateSpendTxSigningResult()
	})
}

// ClearSpendTxSigningResult clears the value of the "spend_tx_signing_result" field.
func (u *UtxoSwapUpsertOne) ClearSpendTxSigningResult() *UtxoSwapUpsertOne {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearSpendTxSigningResult()
	})
}

// Exec executes the query.
func (u *UtxoSwapUpsertOne) Exec(ctx context.Context) error {
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for UtxoSwapCreate.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *UtxoSwapUpsertOne) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}

// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *UtxoSwapUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
	if u.create.driver.Dialect() == dialect.MySQL {
		// In case of "ON CONFLICT", there is no way to get back non-numeric ID
		// fields from the database since MySQL does not support the RETURNING clause.
		return id, errors.New("ent: UtxoSwapUpsertOne.ID is not supported by MySQL driver. Use UtxoSwapUpsertOne.Exec instead")
	}
	node, err := u.create.Save(ctx)
	if err != nil {
		return id, err
	}
	return node.ID, nil
}

// IDX is like ID, but panics if an error occurs.
func (u *UtxoSwapUpsertOne) IDX(ctx context.Context) uuid.UUID {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// UtxoSwapCreateBulk is the builder for creating many UtxoSwap entities in bulk.
type UtxoSwapCreateBulk struct {
	config
	err      error
	builders []*UtxoSwapCreate
	conflict []sql.ConflictOption
}

// Save creates the UtxoSwap entities in the database.
func (uscb *UtxoSwapCreateBulk) Save(ctx context.Context) ([]*UtxoSwap, error) {
	if uscb.err != nil {
		return nil, uscb.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(uscb.builders))
	nodes := make([]*UtxoSwap, len(uscb.builders))
	mutators := make([]Mutator, len(uscb.builders))
	for i := range uscb.builders {
		func(i int, root context.Context) {
			builder := uscb.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*UtxoSwapMutation)
				if !ok {
					return nil, fmt.Errorf("unexpected mutation type %T", m)
				}
				if err := builder.check(); err != nil {
					return nil, err
				}
				builder.mutation = mutation
				var err error
				nodes[i], specs[i] = builder.createSpec()
				if i < len(mutators)-1 {
					_, err = mutators[i+1].Mutate(root, uscb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = uscb.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, uscb.driver, spec); err != nil {
						if sqlgraph.IsConstraintError(err) {
							err = &ConstraintError{msg: err.Error(), wrap: err}
						}
					}
				}
				if err != nil {
					return nil, err
				}
				mutation.id = &nodes[i].ID
				mutation.done = true
				return nodes[i], nil
			})
			for i := len(builder.hooks) - 1; i >= 0; i-- {
				mut = builder.hooks[i](mut)
			}
			mutators[i] = mut
		}(i, ctx)
	}
	if len(mutators) > 0 {
		if _, err := mutators[0].Mutate(ctx, uscb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

// SaveX is like Save, but panics if an error occurs.
func (uscb *UtxoSwapCreateBulk) SaveX(ctx context.Context) []*UtxoSwap {
	v, err := uscb.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (uscb *UtxoSwapCreateBulk) Exec(ctx context.Context) error {
	_, err := uscb.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (uscb *UtxoSwapCreateBulk) ExecX(ctx context.Context) {
	if err := uscb.Exec(ctx); err != nil {
		panic(err)
	}
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.UtxoSwap.CreateBulk(builders...).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.UtxoSwapUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (uscb *UtxoSwapCreateBulk) OnConflict(opts ...sql.ConflictOption) *UtxoSwapUpsertBulk {
	uscb.conflict = opts
	return &UtxoSwapUpsertBulk{
		create: uscb,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.UtxoSwap.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (uscb *UtxoSwapCreateBulk) OnConflictColumns(columns ...string) *UtxoSwapUpsertBulk {
	uscb.conflict = append(uscb.conflict, sql.ConflictColumns(columns...))
	return &UtxoSwapUpsertBulk{
		create: uscb,
	}
}

// UtxoSwapUpsertBulk is the builder for "upsert"-ing
// a bulk of UtxoSwap nodes.
type UtxoSwapUpsertBulk struct {
	create *UtxoSwapCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.UtxoSwap.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(utxoswap.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *UtxoSwapUpsertBulk) UpdateNewValues() *UtxoSwapUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		for _, b := range u.create.builders {
			if _, exists := b.mutation.ID(); exists {
				s.SetIgnore(utxoswap.FieldID)
			}
			if _, exists := b.mutation.CreateTime(); exists {
				s.SetIgnore(utxoswap.FieldCreateTime)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.UtxoSwap.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *UtxoSwapUpsertBulk) Ignore() *UtxoSwapUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *UtxoSwapUpsertBulk) DoNothing() *UtxoSwapUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the UtxoSwapCreateBulk.OnConflict
// documentation for more info.
func (u *UtxoSwapUpsertBulk) Update(set func(*UtxoSwapUpsert)) *UtxoSwapUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&UtxoSwapUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdateTime sets the "update_time" field.
func (u *UtxoSwapUpsertBulk) SetUpdateTime(v time.Time) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetUpdateTime(v)
	})
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateUpdateTime() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateUpdateTime()
	})
}

// SetStatus sets the "status" field.
func (u *UtxoSwapUpsertBulk) SetStatus(v schematype.UtxoSwapStatus) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetStatus(v)
	})
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateStatus() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateStatus()
	})
}

// SetRequestType sets the "request_type" field.
func (u *UtxoSwapUpsertBulk) SetRequestType(v schematype.UtxoSwapRequestType) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetRequestType(v)
	})
}

// UpdateRequestType sets the "request_type" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateRequestType() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateRequestType()
	})
}

// SetCreditAmountSats sets the "credit_amount_sats" field.
func (u *UtxoSwapUpsertBulk) SetCreditAmountSats(v uint64) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetCreditAmountSats(v)
	})
}

// AddCreditAmountSats adds v to the "credit_amount_sats" field.
func (u *UtxoSwapUpsertBulk) AddCreditAmountSats(v uint64) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.AddCreditAmountSats(v)
	})
}

// UpdateCreditAmountSats sets the "credit_amount_sats" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateCreditAmountSats() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateCreditAmountSats()
	})
}

// ClearCreditAmountSats clears the value of the "credit_amount_sats" field.
func (u *UtxoSwapUpsertBulk) ClearCreditAmountSats() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearCreditAmountSats()
	})
}

// SetMaxFeeSats sets the "max_fee_sats" field.
func (u *UtxoSwapUpsertBulk) SetMaxFeeSats(v uint64) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetMaxFeeSats(v)
	})
}

// AddMaxFeeSats adds v to the "max_fee_sats" field.
func (u *UtxoSwapUpsertBulk) AddMaxFeeSats(v uint64) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.AddMaxFeeSats(v)
	})
}

// UpdateMaxFeeSats sets the "max_fee_sats" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateMaxFeeSats() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateMaxFeeSats()
	})
}

// ClearMaxFeeSats clears the value of the "max_fee_sats" field.
func (u *UtxoSwapUpsertBulk) ClearMaxFeeSats() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearMaxFeeSats()
	})
}

// SetSspSignature sets the "ssp_signature" field.
func (u *UtxoSwapUpsertBulk) SetSspSignature(v []byte) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetSspSignature(v)
	})
}

// UpdateSspSignature sets the "ssp_signature" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateSspSignature() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateSspSignature()
	})
}

// ClearSspSignature clears the value of the "ssp_signature" field.
func (u *UtxoSwapUpsertBulk) ClearSspSignature() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearSspSignature()
	})
}

// SetSspIdentityPublicKey sets the "ssp_identity_public_key" field.
func (u *UtxoSwapUpsertBulk) SetSspIdentityPublicKey(v keys.Public) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetSspIdentityPublicKey(v)
	})
}

// UpdateSspIdentityPublicKey sets the "ssp_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateSspIdentityPublicKey() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateSspIdentityPublicKey()
	})
}

// ClearSspIdentityPublicKey clears the value of the "ssp_identity_public_key" field.
func (u *UtxoSwapUpsertBulk) ClearSspIdentityPublicKey() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearSspIdentityPublicKey()
	})
}

// SetUserSignature sets the "user_signature" field.
func (u *UtxoSwapUpsertBulk) SetUserSignature(v []byte) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetUserSignature(v)
	})
}

// UpdateUserSignature sets the "user_signature" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateUserSignature() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateUserSignature()
	})
}

// ClearUserSignature clears the value of the "user_signature" field.
func (u *UtxoSwapUpsertBulk) ClearUserSignature() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearUserSignature()
	})
}

// SetUserIdentityPublicKey sets the "user_identity_public_key" field.
func (u *UtxoSwapUpsertBulk) SetUserIdentityPublicKey(v keys.Public) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetUserIdentityPublicKey(v)
	})
}

// UpdateUserIdentityPublicKey sets the "user_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateUserIdentityPublicKey() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateUserIdentityPublicKey()
	})
}

// ClearUserIdentityPublicKey clears the value of the "user_identity_public_key" field.
func (u *UtxoSwapUpsertBulk) ClearUserIdentityPublicKey() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearUserIdentityPublicKey()
	})
}

// SetCoordinatorIdentityPublicKey sets the "coordinator_identity_public_key" field.
func (u *UtxoSwapUpsertBulk) SetCoordinatorIdentityPublicKey(v keys.Public) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetCoordinatorIdentityPublicKey(v)
	})
}

// UpdateCoordinatorIdentityPublicKey sets the "coordinator_identity_public_key" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateCoordinatorIdentityPublicKey() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateCoordinatorIdentityPublicKey()
	})
}

// SetRequestedTransferID sets the "requested_transfer_id" field.
func (u *UtxoSwapUpsertBulk) SetRequestedTransferID(v uuid.UUID) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetRequestedTransferID(v)
	})
}

// UpdateRequestedTransferID sets the "requested_transfer_id" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateRequestedTransferID() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateRequestedTransferID()
	})
}

// ClearRequestedTransferID clears the value of the "requested_transfer_id" field.
func (u *UtxoSwapUpsertBulk) ClearRequestedTransferID() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearRequestedTransferID()
	})
}

// SetSpendTxSigningResult sets the "spend_tx_signing_result" field.
func (u *UtxoSwapUpsertBulk) SetSpendTxSigningResult(v []byte) *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.SetSpendTxSigningResult(v)
	})
}

// UpdateSpendTxSigningResult sets the "spend_tx_signing_result" field to the value that was provided on create.
func (u *UtxoSwapUpsertBulk) UpdateSpendTxSigningResult() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.UpdateSpendTxSigningResult()
	})
}

// ClearSpendTxSigningResult clears the value of the "spend_tx_signing_result" field.
func (u *UtxoSwapUpsertBulk) ClearSpendTxSigningResult() *UtxoSwapUpsertBulk {
	return u.Update(func(s *UtxoSwapUpsert) {
		s.ClearSpendTxSigningResult()
	})
}

// Exec executes the query.
func (u *UtxoSwapUpsertBulk) Exec(ctx context.Context) error {
	if u.create.err != nil {
		return u.create.err
	}
	for i, b := range u.create.builders {
		if len(b.conflict) != 0 {
			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UtxoSwapCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for UtxoSwapCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *UtxoSwapUpsertBulk) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}
