// 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/so/ent/transfer"
	"github.com/lightsparkdev/spark/so/ent/transferleaf"
	"github.com/lightsparkdev/spark/so/ent/treenode"
)

// TransferLeafCreate is the builder for creating a TransferLeaf entity.
type TransferLeafCreate struct {
	config
	mutation *TransferLeafMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

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

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

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

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

// SetSecretCipher sets the "secret_cipher" field.
func (tlc *TransferLeafCreate) SetSecretCipher(b []byte) *TransferLeafCreate {
	tlc.mutation.SetSecretCipher(b)
	return tlc
}

// SetSignature sets the "signature" field.
func (tlc *TransferLeafCreate) SetSignature(b []byte) *TransferLeafCreate {
	tlc.mutation.SetSignature(b)
	return tlc
}

// SetPreviousRefundTx sets the "previous_refund_tx" field.
func (tlc *TransferLeafCreate) SetPreviousRefundTx(b []byte) *TransferLeafCreate {
	tlc.mutation.SetPreviousRefundTx(b)
	return tlc
}

// SetPreviousDirectRefundTx sets the "previous_direct_refund_tx" field.
func (tlc *TransferLeafCreate) SetPreviousDirectRefundTx(b []byte) *TransferLeafCreate {
	tlc.mutation.SetPreviousDirectRefundTx(b)
	return tlc
}

// SetPreviousDirectFromCpfpRefundTx sets the "previous_direct_from_cpfp_refund_tx" field.
func (tlc *TransferLeafCreate) SetPreviousDirectFromCpfpRefundTx(b []byte) *TransferLeafCreate {
	tlc.mutation.SetPreviousDirectFromCpfpRefundTx(b)
	return tlc
}

// SetIntermediateRefundTx sets the "intermediate_refund_tx" field.
func (tlc *TransferLeafCreate) SetIntermediateRefundTx(b []byte) *TransferLeafCreate {
	tlc.mutation.SetIntermediateRefundTx(b)
	return tlc
}

// SetIntermediateDirectRefundTx sets the "intermediate_direct_refund_tx" field.
func (tlc *TransferLeafCreate) SetIntermediateDirectRefundTx(b []byte) *TransferLeafCreate {
	tlc.mutation.SetIntermediateDirectRefundTx(b)
	return tlc
}

// SetIntermediateDirectFromCpfpRefundTx sets the "intermediate_direct_from_cpfp_refund_tx" field.
func (tlc *TransferLeafCreate) SetIntermediateDirectFromCpfpRefundTx(b []byte) *TransferLeafCreate {
	tlc.mutation.SetIntermediateDirectFromCpfpRefundTx(b)
	return tlc
}

// SetKeyTweak sets the "key_tweak" field.
func (tlc *TransferLeafCreate) SetKeyTweak(b []byte) *TransferLeafCreate {
	tlc.mutation.SetKeyTweak(b)
	return tlc
}

// SetSenderKeyTweakProof sets the "sender_key_tweak_proof" field.
func (tlc *TransferLeafCreate) SetSenderKeyTweakProof(b []byte) *TransferLeafCreate {
	tlc.mutation.SetSenderKeyTweakProof(b)
	return tlc
}

// SetReceiverKeyTweak sets the "receiver_key_tweak" field.
func (tlc *TransferLeafCreate) SetReceiverKeyTweak(b []byte) *TransferLeafCreate {
	tlc.mutation.SetReceiverKeyTweak(b)
	return tlc
}

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

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

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

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

// SetLeafID sets the "leaf" edge to the TreeNode entity by ID.
func (tlc *TransferLeafCreate) SetLeafID(id uuid.UUID) *TransferLeafCreate {
	tlc.mutation.SetLeafID(id)
	return tlc
}

// SetLeaf sets the "leaf" edge to the TreeNode entity.
func (tlc *TransferLeafCreate) SetLeaf(t *TreeNode) *TransferLeafCreate {
	return tlc.SetLeafID(t.ID)
}

// Mutation returns the TransferLeafMutation object of the builder.
func (tlc *TransferLeafCreate) Mutation() *TransferLeafMutation {
	return tlc.mutation
}

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

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

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

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

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

// check runs all checks and user-defined validators on the builder.
func (tlc *TransferLeafCreate) check() error {
	if _, ok := tlc.mutation.CreateTime(); !ok {
		return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "TransferLeaf.create_time"`)}
	}
	if _, ok := tlc.mutation.UpdateTime(); !ok {
		return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "TransferLeaf.update_time"`)}
	}
	if _, ok := tlc.mutation.PreviousRefundTx(); !ok {
		return &ValidationError{Name: "previous_refund_tx", err: errors.New(`ent: missing required field "TransferLeaf.previous_refund_tx"`)}
	}
	if v, ok := tlc.mutation.PreviousRefundTx(); ok {
		if err := transferleaf.PreviousRefundTxValidator(v); err != nil {
			return &ValidationError{Name: "previous_refund_tx", err: fmt.Errorf(`ent: validator failed for field "TransferLeaf.previous_refund_tx": %w`, err)}
		}
	}
	if _, ok := tlc.mutation.IntermediateRefundTx(); !ok {
		return &ValidationError{Name: "intermediate_refund_tx", err: errors.New(`ent: missing required field "TransferLeaf.intermediate_refund_tx"`)}
	}
	if v, ok := tlc.mutation.IntermediateRefundTx(); ok {
		if err := transferleaf.IntermediateRefundTxValidator(v); err != nil {
			return &ValidationError{Name: "intermediate_refund_tx", err: fmt.Errorf(`ent: validator failed for field "TransferLeaf.intermediate_refund_tx": %w`, err)}
		}
	}
	if len(tlc.mutation.TransferIDs()) == 0 {
		return &ValidationError{Name: "transfer", err: errors.New(`ent: missing required edge "TransferLeaf.transfer"`)}
	}
	if len(tlc.mutation.LeafIDs()) == 0 {
		return &ValidationError{Name: "leaf", err: errors.New(`ent: missing required edge "TransferLeaf.leaf"`)}
	}
	return nil
}

func (tlc *TransferLeafCreate) sqlSave(ctx context.Context) (*TransferLeaf, error) {
	if err := tlc.check(); err != nil {
		return nil, err
	}
	_node, _spec := tlc.createSpec()
	if err := sqlgraph.CreateNode(ctx, tlc.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
		}
	}
	tlc.mutation.id = &_node.ID
	tlc.mutation.done = true
	return _node, nil
}

func (tlc *TransferLeafCreate) createSpec() (*TransferLeaf, *sqlgraph.CreateSpec) {
	var (
		_node = &TransferLeaf{config: tlc.config}
		_spec = sqlgraph.NewCreateSpec(transferleaf.Table, sqlgraph.NewFieldSpec(transferleaf.FieldID, field.TypeUUID))
	)
	_spec.OnConflict = tlc.conflict
	if id, ok := tlc.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = &id
	}
	if value, ok := tlc.mutation.CreateTime(); ok {
		_spec.SetField(transferleaf.FieldCreateTime, field.TypeTime, value)
		_node.CreateTime = value
	}
	if value, ok := tlc.mutation.UpdateTime(); ok {
		_spec.SetField(transferleaf.FieldUpdateTime, field.TypeTime, value)
		_node.UpdateTime = value
	}
	if value, ok := tlc.mutation.SecretCipher(); ok {
		_spec.SetField(transferleaf.FieldSecretCipher, field.TypeBytes, value)
		_node.SecretCipher = value
	}
	if value, ok := tlc.mutation.Signature(); ok {
		_spec.SetField(transferleaf.FieldSignature, field.TypeBytes, value)
		_node.Signature = value
	}
	if value, ok := tlc.mutation.PreviousRefundTx(); ok {
		_spec.SetField(transferleaf.FieldPreviousRefundTx, field.TypeBytes, value)
		_node.PreviousRefundTx = value
	}
	if value, ok := tlc.mutation.PreviousDirectRefundTx(); ok {
		_spec.SetField(transferleaf.FieldPreviousDirectRefundTx, field.TypeBytes, value)
		_node.PreviousDirectRefundTx = value
	}
	if value, ok := tlc.mutation.PreviousDirectFromCpfpRefundTx(); ok {
		_spec.SetField(transferleaf.FieldPreviousDirectFromCpfpRefundTx, field.TypeBytes, value)
		_node.PreviousDirectFromCpfpRefundTx = value
	}
	if value, ok := tlc.mutation.IntermediateRefundTx(); ok {
		_spec.SetField(transferleaf.FieldIntermediateRefundTx, field.TypeBytes, value)
		_node.IntermediateRefundTx = value
	}
	if value, ok := tlc.mutation.IntermediateDirectRefundTx(); ok {
		_spec.SetField(transferleaf.FieldIntermediateDirectRefundTx, field.TypeBytes, value)
		_node.IntermediateDirectRefundTx = value
	}
	if value, ok := tlc.mutation.IntermediateDirectFromCpfpRefundTx(); ok {
		_spec.SetField(transferleaf.FieldIntermediateDirectFromCpfpRefundTx, field.TypeBytes, value)
		_node.IntermediateDirectFromCpfpRefundTx = value
	}
	if value, ok := tlc.mutation.KeyTweak(); ok {
		_spec.SetField(transferleaf.FieldKeyTweak, field.TypeBytes, value)
		_node.KeyTweak = value
	}
	if value, ok := tlc.mutation.SenderKeyTweakProof(); ok {
		_spec.SetField(transferleaf.FieldSenderKeyTweakProof, field.TypeBytes, value)
		_node.SenderKeyTweakProof = value
	}
	if value, ok := tlc.mutation.ReceiverKeyTweak(); ok {
		_spec.SetField(transferleaf.FieldReceiverKeyTweak, field.TypeBytes, value)
		_node.ReceiverKeyTweak = value
	}
	if nodes := tlc.mutation.TransferIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   transferleaf.TransferTable,
			Columns: []string{transferleaf.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.transfer_leaf_transfer = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := tlc.mutation.LeafIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   transferleaf.LeafTable,
			Columns: []string{transferleaf.LeafColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(treenode.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.transfer_leaf_leaf = &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.TransferLeaf.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.TransferLeafUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (tlc *TransferLeafCreate) OnConflict(opts ...sql.ConflictOption) *TransferLeafUpsertOne {
	tlc.conflict = opts
	return &TransferLeafUpsertOne{
		create: tlc,
	}
}

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

type (
	// TransferLeafUpsertOne is the builder for "upsert"-ing
	//  one TransferLeaf node.
	TransferLeafUpsertOne struct {
		create *TransferLeafCreate
	}

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

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

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

// SetSecretCipher sets the "secret_cipher" field.
func (u *TransferLeafUpsert) SetSecretCipher(v []byte) *TransferLeafUpsert {
	u.Set(transferleaf.FieldSecretCipher, v)
	return u
}

// UpdateSecretCipher sets the "secret_cipher" field to the value that was provided on create.
func (u *TransferLeafUpsert) UpdateSecretCipher() *TransferLeafUpsert {
	u.SetExcluded(transferleaf.FieldSecretCipher)
	return u
}

// ClearSecretCipher clears the value of the "secret_cipher" field.
func (u *TransferLeafUpsert) ClearSecretCipher() *TransferLeafUpsert {
	u.SetNull(transferleaf.FieldSecretCipher)
	return u
}

// SetSignature sets the "signature" field.
func (u *TransferLeafUpsert) SetSignature(v []byte) *TransferLeafUpsert {
	u.Set(transferleaf.FieldSignature, v)
	return u
}

// UpdateSignature sets the "signature" field to the value that was provided on create.
func (u *TransferLeafUpsert) UpdateSignature() *TransferLeafUpsert {
	u.SetExcluded(transferleaf.FieldSignature)
	return u
}

// ClearSignature clears the value of the "signature" field.
func (u *TransferLeafUpsert) ClearSignature() *TransferLeafUpsert {
	u.SetNull(transferleaf.FieldSignature)
	return u
}

// SetIntermediateRefundTx sets the "intermediate_refund_tx" field.
func (u *TransferLeafUpsert) SetIntermediateRefundTx(v []byte) *TransferLeafUpsert {
	u.Set(transferleaf.FieldIntermediateRefundTx, v)
	return u
}

// UpdateIntermediateRefundTx sets the "intermediate_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsert) UpdateIntermediateRefundTx() *TransferLeafUpsert {
	u.SetExcluded(transferleaf.FieldIntermediateRefundTx)
	return u
}

// SetIntermediateDirectRefundTx sets the "intermediate_direct_refund_tx" field.
func (u *TransferLeafUpsert) SetIntermediateDirectRefundTx(v []byte) *TransferLeafUpsert {
	u.Set(transferleaf.FieldIntermediateDirectRefundTx, v)
	return u
}

// UpdateIntermediateDirectRefundTx sets the "intermediate_direct_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsert) UpdateIntermediateDirectRefundTx() *TransferLeafUpsert {
	u.SetExcluded(transferleaf.FieldIntermediateDirectRefundTx)
	return u
}

// ClearIntermediateDirectRefundTx clears the value of the "intermediate_direct_refund_tx" field.
func (u *TransferLeafUpsert) ClearIntermediateDirectRefundTx() *TransferLeafUpsert {
	u.SetNull(transferleaf.FieldIntermediateDirectRefundTx)
	return u
}

// SetIntermediateDirectFromCpfpRefundTx sets the "intermediate_direct_from_cpfp_refund_tx" field.
func (u *TransferLeafUpsert) SetIntermediateDirectFromCpfpRefundTx(v []byte) *TransferLeafUpsert {
	u.Set(transferleaf.FieldIntermediateDirectFromCpfpRefundTx, v)
	return u
}

// UpdateIntermediateDirectFromCpfpRefundTx sets the "intermediate_direct_from_cpfp_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsert) UpdateIntermediateDirectFromCpfpRefundTx() *TransferLeafUpsert {
	u.SetExcluded(transferleaf.FieldIntermediateDirectFromCpfpRefundTx)
	return u
}

// ClearIntermediateDirectFromCpfpRefundTx clears the value of the "intermediate_direct_from_cpfp_refund_tx" field.
func (u *TransferLeafUpsert) ClearIntermediateDirectFromCpfpRefundTx() *TransferLeafUpsert {
	u.SetNull(transferleaf.FieldIntermediateDirectFromCpfpRefundTx)
	return u
}

// SetKeyTweak sets the "key_tweak" field.
func (u *TransferLeafUpsert) SetKeyTweak(v []byte) *TransferLeafUpsert {
	u.Set(transferleaf.FieldKeyTweak, v)
	return u
}

// UpdateKeyTweak sets the "key_tweak" field to the value that was provided on create.
func (u *TransferLeafUpsert) UpdateKeyTweak() *TransferLeafUpsert {
	u.SetExcluded(transferleaf.FieldKeyTweak)
	return u
}

// ClearKeyTweak clears the value of the "key_tweak" field.
func (u *TransferLeafUpsert) ClearKeyTweak() *TransferLeafUpsert {
	u.SetNull(transferleaf.FieldKeyTweak)
	return u
}

// SetSenderKeyTweakProof sets the "sender_key_tweak_proof" field.
func (u *TransferLeafUpsert) SetSenderKeyTweakProof(v []byte) *TransferLeafUpsert {
	u.Set(transferleaf.FieldSenderKeyTweakProof, v)
	return u
}

// UpdateSenderKeyTweakProof sets the "sender_key_tweak_proof" field to the value that was provided on create.
func (u *TransferLeafUpsert) UpdateSenderKeyTweakProof() *TransferLeafUpsert {
	u.SetExcluded(transferleaf.FieldSenderKeyTweakProof)
	return u
}

// ClearSenderKeyTweakProof clears the value of the "sender_key_tweak_proof" field.
func (u *TransferLeafUpsert) ClearSenderKeyTweakProof() *TransferLeafUpsert {
	u.SetNull(transferleaf.FieldSenderKeyTweakProof)
	return u
}

// SetReceiverKeyTweak sets the "receiver_key_tweak" field.
func (u *TransferLeafUpsert) SetReceiverKeyTweak(v []byte) *TransferLeafUpsert {
	u.Set(transferleaf.FieldReceiverKeyTweak, v)
	return u
}

// UpdateReceiverKeyTweak sets the "receiver_key_tweak" field to the value that was provided on create.
func (u *TransferLeafUpsert) UpdateReceiverKeyTweak() *TransferLeafUpsert {
	u.SetExcluded(transferleaf.FieldReceiverKeyTweak)
	return u
}

// ClearReceiverKeyTweak clears the value of the "receiver_key_tweak" field.
func (u *TransferLeafUpsert) ClearReceiverKeyTweak() *TransferLeafUpsert {
	u.SetNull(transferleaf.FieldReceiverKeyTweak)
	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.TransferLeaf.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(transferleaf.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *TransferLeafUpsertOne) UpdateNewValues() *TransferLeafUpsertOne {
	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(transferleaf.FieldID)
		}
		if _, exists := u.create.mutation.CreateTime(); exists {
			s.SetIgnore(transferleaf.FieldCreateTime)
		}
		if _, exists := u.create.mutation.PreviousRefundTx(); exists {
			s.SetIgnore(transferleaf.FieldPreviousRefundTx)
		}
		if _, exists := u.create.mutation.PreviousDirectRefundTx(); exists {
			s.SetIgnore(transferleaf.FieldPreviousDirectRefundTx)
		}
		if _, exists := u.create.mutation.PreviousDirectFromCpfpRefundTx(); exists {
			s.SetIgnore(transferleaf.FieldPreviousDirectFromCpfpRefundTx)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.TransferLeaf.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *TransferLeafUpsertOne) Ignore() *TransferLeafUpsertOne {
	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 *TransferLeafUpsertOne) DoNothing() *TransferLeafUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

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

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

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

// SetSecretCipher sets the "secret_cipher" field.
func (u *TransferLeafUpsertOne) SetSecretCipher(v []byte) *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetSecretCipher(v)
	})
}

// UpdateSecretCipher sets the "secret_cipher" field to the value that was provided on create.
func (u *TransferLeafUpsertOne) UpdateSecretCipher() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateSecretCipher()
	})
}

// ClearSecretCipher clears the value of the "secret_cipher" field.
func (u *TransferLeafUpsertOne) ClearSecretCipher() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearSecretCipher()
	})
}

// SetSignature sets the "signature" field.
func (u *TransferLeafUpsertOne) SetSignature(v []byte) *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetSignature(v)
	})
}

// UpdateSignature sets the "signature" field to the value that was provided on create.
func (u *TransferLeafUpsertOne) UpdateSignature() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateSignature()
	})
}

// ClearSignature clears the value of the "signature" field.
func (u *TransferLeafUpsertOne) ClearSignature() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearSignature()
	})
}

// SetIntermediateRefundTx sets the "intermediate_refund_tx" field.
func (u *TransferLeafUpsertOne) SetIntermediateRefundTx(v []byte) *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetIntermediateRefundTx(v)
	})
}

// UpdateIntermediateRefundTx sets the "intermediate_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsertOne) UpdateIntermediateRefundTx() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateIntermediateRefundTx()
	})
}

// SetIntermediateDirectRefundTx sets the "intermediate_direct_refund_tx" field.
func (u *TransferLeafUpsertOne) SetIntermediateDirectRefundTx(v []byte) *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetIntermediateDirectRefundTx(v)
	})
}

// UpdateIntermediateDirectRefundTx sets the "intermediate_direct_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsertOne) UpdateIntermediateDirectRefundTx() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateIntermediateDirectRefundTx()
	})
}

// ClearIntermediateDirectRefundTx clears the value of the "intermediate_direct_refund_tx" field.
func (u *TransferLeafUpsertOne) ClearIntermediateDirectRefundTx() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearIntermediateDirectRefundTx()
	})
}

// SetIntermediateDirectFromCpfpRefundTx sets the "intermediate_direct_from_cpfp_refund_tx" field.
func (u *TransferLeafUpsertOne) SetIntermediateDirectFromCpfpRefundTx(v []byte) *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetIntermediateDirectFromCpfpRefundTx(v)
	})
}

// UpdateIntermediateDirectFromCpfpRefundTx sets the "intermediate_direct_from_cpfp_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsertOne) UpdateIntermediateDirectFromCpfpRefundTx() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateIntermediateDirectFromCpfpRefundTx()
	})
}

// ClearIntermediateDirectFromCpfpRefundTx clears the value of the "intermediate_direct_from_cpfp_refund_tx" field.
func (u *TransferLeafUpsertOne) ClearIntermediateDirectFromCpfpRefundTx() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearIntermediateDirectFromCpfpRefundTx()
	})
}

// SetKeyTweak sets the "key_tweak" field.
func (u *TransferLeafUpsertOne) SetKeyTweak(v []byte) *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetKeyTweak(v)
	})
}

// UpdateKeyTweak sets the "key_tweak" field to the value that was provided on create.
func (u *TransferLeafUpsertOne) UpdateKeyTweak() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateKeyTweak()
	})
}

// ClearKeyTweak clears the value of the "key_tweak" field.
func (u *TransferLeafUpsertOne) ClearKeyTweak() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearKeyTweak()
	})
}

// SetSenderKeyTweakProof sets the "sender_key_tweak_proof" field.
func (u *TransferLeafUpsertOne) SetSenderKeyTweakProof(v []byte) *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetSenderKeyTweakProof(v)
	})
}

// UpdateSenderKeyTweakProof sets the "sender_key_tweak_proof" field to the value that was provided on create.
func (u *TransferLeafUpsertOne) UpdateSenderKeyTweakProof() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateSenderKeyTweakProof()
	})
}

// ClearSenderKeyTweakProof clears the value of the "sender_key_tweak_proof" field.
func (u *TransferLeafUpsertOne) ClearSenderKeyTweakProof() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearSenderKeyTweakProof()
	})
}

// SetReceiverKeyTweak sets the "receiver_key_tweak" field.
func (u *TransferLeafUpsertOne) SetReceiverKeyTweak(v []byte) *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetReceiverKeyTweak(v)
	})
}

// UpdateReceiverKeyTweak sets the "receiver_key_tweak" field to the value that was provided on create.
func (u *TransferLeafUpsertOne) UpdateReceiverKeyTweak() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateReceiverKeyTweak()
	})
}

// ClearReceiverKeyTweak clears the value of the "receiver_key_tweak" field.
func (u *TransferLeafUpsertOne) ClearReceiverKeyTweak() *TransferLeafUpsertOne {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearReceiverKeyTweak()
	})
}

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

// ExecX is like Exec, but panics if an error occurs.
func (u *TransferLeafUpsertOne) 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 *TransferLeafUpsertOne) 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: TransferLeafUpsertOne.ID is not supported by MySQL driver. Use TransferLeafUpsertOne.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 *TransferLeafUpsertOne) IDX(ctx context.Context) uuid.UUID {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

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

// Save creates the TransferLeaf entities in the database.
func (tlcb *TransferLeafCreateBulk) Save(ctx context.Context) ([]*TransferLeaf, error) {
	if tlcb.err != nil {
		return nil, tlcb.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(tlcb.builders))
	nodes := make([]*TransferLeaf, len(tlcb.builders))
	mutators := make([]Mutator, len(tlcb.builders))
	for i := range tlcb.builders {
		func(i int, root context.Context) {
			builder := tlcb.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*TransferLeafMutation)
				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, tlcb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = tlcb.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, tlcb.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, tlcb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

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

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

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

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.TransferLeaf.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.TransferLeafUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (tlcb *TransferLeafCreateBulk) OnConflict(opts ...sql.ConflictOption) *TransferLeafUpsertBulk {
	tlcb.conflict = opts
	return &TransferLeafUpsertBulk{
		create: tlcb,
	}
}

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

// TransferLeafUpsertBulk is the builder for "upsert"-ing
// a bulk of TransferLeaf nodes.
type TransferLeafUpsertBulk struct {
	create *TransferLeafCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.TransferLeaf.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(transferleaf.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *TransferLeafUpsertBulk) UpdateNewValues() *TransferLeafUpsertBulk {
	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(transferleaf.FieldID)
			}
			if _, exists := b.mutation.CreateTime(); exists {
				s.SetIgnore(transferleaf.FieldCreateTime)
			}
			if _, exists := b.mutation.PreviousRefundTx(); exists {
				s.SetIgnore(transferleaf.FieldPreviousRefundTx)
			}
			if _, exists := b.mutation.PreviousDirectRefundTx(); exists {
				s.SetIgnore(transferleaf.FieldPreviousDirectRefundTx)
			}
			if _, exists := b.mutation.PreviousDirectFromCpfpRefundTx(); exists {
				s.SetIgnore(transferleaf.FieldPreviousDirectFromCpfpRefundTx)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.TransferLeaf.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *TransferLeafUpsertBulk) Ignore() *TransferLeafUpsertBulk {
	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 *TransferLeafUpsertBulk) DoNothing() *TransferLeafUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

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

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

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

// SetSecretCipher sets the "secret_cipher" field.
func (u *TransferLeafUpsertBulk) SetSecretCipher(v []byte) *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetSecretCipher(v)
	})
}

// UpdateSecretCipher sets the "secret_cipher" field to the value that was provided on create.
func (u *TransferLeafUpsertBulk) UpdateSecretCipher() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateSecretCipher()
	})
}

// ClearSecretCipher clears the value of the "secret_cipher" field.
func (u *TransferLeafUpsertBulk) ClearSecretCipher() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearSecretCipher()
	})
}

// SetSignature sets the "signature" field.
func (u *TransferLeafUpsertBulk) SetSignature(v []byte) *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetSignature(v)
	})
}

// UpdateSignature sets the "signature" field to the value that was provided on create.
func (u *TransferLeafUpsertBulk) UpdateSignature() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateSignature()
	})
}

// ClearSignature clears the value of the "signature" field.
func (u *TransferLeafUpsertBulk) ClearSignature() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearSignature()
	})
}

// SetIntermediateRefundTx sets the "intermediate_refund_tx" field.
func (u *TransferLeafUpsertBulk) SetIntermediateRefundTx(v []byte) *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetIntermediateRefundTx(v)
	})
}

// UpdateIntermediateRefundTx sets the "intermediate_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsertBulk) UpdateIntermediateRefundTx() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateIntermediateRefundTx()
	})
}

// SetIntermediateDirectRefundTx sets the "intermediate_direct_refund_tx" field.
func (u *TransferLeafUpsertBulk) SetIntermediateDirectRefundTx(v []byte) *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetIntermediateDirectRefundTx(v)
	})
}

// UpdateIntermediateDirectRefundTx sets the "intermediate_direct_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsertBulk) UpdateIntermediateDirectRefundTx() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateIntermediateDirectRefundTx()
	})
}

// ClearIntermediateDirectRefundTx clears the value of the "intermediate_direct_refund_tx" field.
func (u *TransferLeafUpsertBulk) ClearIntermediateDirectRefundTx() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearIntermediateDirectRefundTx()
	})
}

// SetIntermediateDirectFromCpfpRefundTx sets the "intermediate_direct_from_cpfp_refund_tx" field.
func (u *TransferLeafUpsertBulk) SetIntermediateDirectFromCpfpRefundTx(v []byte) *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetIntermediateDirectFromCpfpRefundTx(v)
	})
}

// UpdateIntermediateDirectFromCpfpRefundTx sets the "intermediate_direct_from_cpfp_refund_tx" field to the value that was provided on create.
func (u *TransferLeafUpsertBulk) UpdateIntermediateDirectFromCpfpRefundTx() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateIntermediateDirectFromCpfpRefundTx()
	})
}

// ClearIntermediateDirectFromCpfpRefundTx clears the value of the "intermediate_direct_from_cpfp_refund_tx" field.
func (u *TransferLeafUpsertBulk) ClearIntermediateDirectFromCpfpRefundTx() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearIntermediateDirectFromCpfpRefundTx()
	})
}

// SetKeyTweak sets the "key_tweak" field.
func (u *TransferLeafUpsertBulk) SetKeyTweak(v []byte) *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetKeyTweak(v)
	})
}

// UpdateKeyTweak sets the "key_tweak" field to the value that was provided on create.
func (u *TransferLeafUpsertBulk) UpdateKeyTweak() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateKeyTweak()
	})
}

// ClearKeyTweak clears the value of the "key_tweak" field.
func (u *TransferLeafUpsertBulk) ClearKeyTweak() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearKeyTweak()
	})
}

// SetSenderKeyTweakProof sets the "sender_key_tweak_proof" field.
func (u *TransferLeafUpsertBulk) SetSenderKeyTweakProof(v []byte) *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetSenderKeyTweakProof(v)
	})
}

// UpdateSenderKeyTweakProof sets the "sender_key_tweak_proof" field to the value that was provided on create.
func (u *TransferLeafUpsertBulk) UpdateSenderKeyTweakProof() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateSenderKeyTweakProof()
	})
}

// ClearSenderKeyTweakProof clears the value of the "sender_key_tweak_proof" field.
func (u *TransferLeafUpsertBulk) ClearSenderKeyTweakProof() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearSenderKeyTweakProof()
	})
}

// SetReceiverKeyTweak sets the "receiver_key_tweak" field.
func (u *TransferLeafUpsertBulk) SetReceiverKeyTweak(v []byte) *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.SetReceiverKeyTweak(v)
	})
}

// UpdateReceiverKeyTweak sets the "receiver_key_tweak" field to the value that was provided on create.
func (u *TransferLeafUpsertBulk) UpdateReceiverKeyTweak() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.UpdateReceiverKeyTweak()
	})
}

// ClearReceiverKeyTweak clears the value of the "receiver_key_tweak" field.
func (u *TransferLeafUpsertBulk) ClearReceiverKeyTweak() *TransferLeafUpsertBulk {
	return u.Update(func(s *TransferLeafUpsert) {
		s.ClearReceiverKeyTweak()
	})
}

// Exec executes the query.
func (u *TransferLeafUpsertBulk) 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 TransferLeafCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for TransferLeafCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

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