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

// TreeNodeCreate is the builder for creating a TreeNode entity.
type TreeNodeCreate struct {
	config
	mutation *TreeNodeMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

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

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

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

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

// SetValue sets the "value" field.
func (tnc *TreeNodeCreate) SetValue(u uint64) *TreeNodeCreate {
	tnc.mutation.SetValue(u)
	return tnc
}

// SetStatus sets the "status" field.
func (tnc *TreeNodeCreate) SetStatus(sns schematype.TreeNodeStatus) *TreeNodeCreate {
	tnc.mutation.SetStatus(sns)
	return tnc
}

// SetVerifyingPubkey sets the "verifying_pubkey" field.
func (tnc *TreeNodeCreate) SetVerifyingPubkey(k keys.Public) *TreeNodeCreate {
	tnc.mutation.SetVerifyingPubkey(k)
	return tnc
}

// SetOwnerIdentityPubkey sets the "owner_identity_pubkey" field.
func (tnc *TreeNodeCreate) SetOwnerIdentityPubkey(k keys.Public) *TreeNodeCreate {
	tnc.mutation.SetOwnerIdentityPubkey(k)
	return tnc
}

// SetOwnerSigningPubkey sets the "owner_signing_pubkey" field.
func (tnc *TreeNodeCreate) SetOwnerSigningPubkey(k keys.Public) *TreeNodeCreate {
	tnc.mutation.SetOwnerSigningPubkey(k)
	return tnc
}

// SetVout sets the "vout" field.
func (tnc *TreeNodeCreate) SetVout(i int16) *TreeNodeCreate {
	tnc.mutation.SetVout(i)
	return tnc
}

// SetNodeConfirmationHeight sets the "node_confirmation_height" field.
func (tnc *TreeNodeCreate) SetNodeConfirmationHeight(u uint64) *TreeNodeCreate {
	tnc.mutation.SetNodeConfirmationHeight(u)
	return tnc
}

// SetNillableNodeConfirmationHeight sets the "node_confirmation_height" field if the given value is not nil.
func (tnc *TreeNodeCreate) SetNillableNodeConfirmationHeight(u *uint64) *TreeNodeCreate {
	if u != nil {
		tnc.SetNodeConfirmationHeight(*u)
	}
	return tnc
}

// SetRefundConfirmationHeight sets the "refund_confirmation_height" field.
func (tnc *TreeNodeCreate) SetRefundConfirmationHeight(u uint64) *TreeNodeCreate {
	tnc.mutation.SetRefundConfirmationHeight(u)
	return tnc
}

// SetNillableRefundConfirmationHeight sets the "refund_confirmation_height" field if the given value is not nil.
func (tnc *TreeNodeCreate) SetNillableRefundConfirmationHeight(u *uint64) *TreeNodeCreate {
	if u != nil {
		tnc.SetRefundConfirmationHeight(*u)
	}
	return tnc
}

// SetRawTx sets the "raw_tx" field.
func (tnc *TreeNodeCreate) SetRawTx(b []byte) *TreeNodeCreate {
	tnc.mutation.SetRawTx(b)
	return tnc
}

// SetDirectTx sets the "direct_tx" field.
func (tnc *TreeNodeCreate) SetDirectTx(b []byte) *TreeNodeCreate {
	tnc.mutation.SetDirectTx(b)
	return tnc
}

// SetDirectFromCpfpRefundTx sets the "direct_from_cpfp_refund_tx" field.
func (tnc *TreeNodeCreate) SetDirectFromCpfpRefundTx(b []byte) *TreeNodeCreate {
	tnc.mutation.SetDirectFromCpfpRefundTx(b)
	return tnc
}

// SetRawTxid sets the "raw_txid" field.
func (tnc *TreeNodeCreate) SetRawTxid(b []byte) *TreeNodeCreate {
	tnc.mutation.SetRawTxid(b)
	return tnc
}

// SetDirectTxid sets the "direct_txid" field.
func (tnc *TreeNodeCreate) SetDirectTxid(b []byte) *TreeNodeCreate {
	tnc.mutation.SetDirectTxid(b)
	return tnc
}

// SetDirectFromCpfpRefundTxid sets the "direct_from_cpfp_refund_txid" field.
func (tnc *TreeNodeCreate) SetDirectFromCpfpRefundTxid(b []byte) *TreeNodeCreate {
	tnc.mutation.SetDirectFromCpfpRefundTxid(b)
	return tnc
}

// SetRawRefundTx sets the "raw_refund_tx" field.
func (tnc *TreeNodeCreate) SetRawRefundTx(b []byte) *TreeNodeCreate {
	tnc.mutation.SetRawRefundTx(b)
	return tnc
}

// SetDirectRefundTx sets the "direct_refund_tx" field.
func (tnc *TreeNodeCreate) SetDirectRefundTx(b []byte) *TreeNodeCreate {
	tnc.mutation.SetDirectRefundTx(b)
	return tnc
}

// SetRawRefundTxid sets the "raw_refund_txid" field.
func (tnc *TreeNodeCreate) SetRawRefundTxid(b []byte) *TreeNodeCreate {
	tnc.mutation.SetRawRefundTxid(b)
	return tnc
}

// SetDirectRefundTxid sets the "direct_refund_txid" field.
func (tnc *TreeNodeCreate) SetDirectRefundTxid(b []byte) *TreeNodeCreate {
	tnc.mutation.SetDirectRefundTxid(b)
	return tnc
}

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

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

// SetTreeID sets the "tree" edge to the Tree entity by ID.
func (tnc *TreeNodeCreate) SetTreeID(id uuid.UUID) *TreeNodeCreate {
	tnc.mutation.SetTreeID(id)
	return tnc
}

// SetTree sets the "tree" edge to the Tree entity.
func (tnc *TreeNodeCreate) SetTree(t *Tree) *TreeNodeCreate {
	return tnc.SetTreeID(t.ID)
}

// SetParentID sets the "parent" edge to the TreeNode entity by ID.
func (tnc *TreeNodeCreate) SetParentID(id uuid.UUID) *TreeNodeCreate {
	tnc.mutation.SetParentID(id)
	return tnc
}

// SetNillableParentID sets the "parent" edge to the TreeNode entity by ID if the given value is not nil.
func (tnc *TreeNodeCreate) SetNillableParentID(id *uuid.UUID) *TreeNodeCreate {
	if id != nil {
		tnc = tnc.SetParentID(*id)
	}
	return tnc
}

// SetParent sets the "parent" edge to the TreeNode entity.
func (tnc *TreeNodeCreate) SetParent(t *TreeNode) *TreeNodeCreate {
	return tnc.SetParentID(t.ID)
}

// SetSigningKeyshareID sets the "signing_keyshare" edge to the SigningKeyshare entity by ID.
func (tnc *TreeNodeCreate) SetSigningKeyshareID(id uuid.UUID) *TreeNodeCreate {
	tnc.mutation.SetSigningKeyshareID(id)
	return tnc
}

// SetSigningKeyshare sets the "signing_keyshare" edge to the SigningKeyshare entity.
func (tnc *TreeNodeCreate) SetSigningKeyshare(s *SigningKeyshare) *TreeNodeCreate {
	return tnc.SetSigningKeyshareID(s.ID)
}

// AddChildIDs adds the "children" edge to the TreeNode entity by IDs.
func (tnc *TreeNodeCreate) AddChildIDs(ids ...uuid.UUID) *TreeNodeCreate {
	tnc.mutation.AddChildIDs(ids...)
	return tnc
}

// AddChildren adds the "children" edges to the TreeNode entity.
func (tnc *TreeNodeCreate) AddChildren(t ...*TreeNode) *TreeNodeCreate {
	ids := make([]uuid.UUID, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tnc.AddChildIDs(ids...)
}

// Mutation returns the TreeNodeMutation object of the builder.
func (tnc *TreeNodeCreate) Mutation() *TreeNodeMutation {
	return tnc.mutation
}

// Save creates the TreeNode in the database.
func (tnc *TreeNodeCreate) Save(ctx context.Context) (*TreeNode, error) {
	if err := tnc.defaults(); err != nil {
		return nil, err
	}
	return withHooks(ctx, tnc.sqlSave, tnc.mutation, tnc.hooks)
}

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

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

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

// defaults sets the default values of the builder before save.
func (tnc *TreeNodeCreate) defaults() error {
	if _, ok := tnc.mutation.CreateTime(); !ok {
		if treenode.DefaultCreateTime == nil {
			return fmt.Errorf("ent: uninitialized treenode.DefaultCreateTime (forgotten import ent/runtime?)")
		}
		v := treenode.DefaultCreateTime()
		tnc.mutation.SetCreateTime(v)
	}
	if _, ok := tnc.mutation.UpdateTime(); !ok {
		if treenode.DefaultUpdateTime == nil {
			return fmt.Errorf("ent: uninitialized treenode.DefaultUpdateTime (forgotten import ent/runtime?)")
		}
		v := treenode.DefaultUpdateTime()
		tnc.mutation.SetUpdateTime(v)
	}
	if _, ok := tnc.mutation.ID(); !ok {
		if treenode.DefaultID == nil {
			return fmt.Errorf("ent: uninitialized treenode.DefaultID (forgotten import ent/runtime?)")
		}
		v := treenode.DefaultID()
		tnc.mutation.SetID(v)
	}
	return nil
}

// check runs all checks and user-defined validators on the builder.
func (tnc *TreeNodeCreate) check() error {
	if _, ok := tnc.mutation.CreateTime(); !ok {
		return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "TreeNode.create_time"`)}
	}
	if _, ok := tnc.mutation.UpdateTime(); !ok {
		return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "TreeNode.update_time"`)}
	}
	if _, ok := tnc.mutation.Value(); !ok {
		return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "TreeNode.value"`)}
	}
	if _, ok := tnc.mutation.Status(); !ok {
		return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "TreeNode.status"`)}
	}
	if v, ok := tnc.mutation.Status(); ok {
		if err := treenode.StatusValidator(v); err != nil {
			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "TreeNode.status": %w`, err)}
		}
	}
	if _, ok := tnc.mutation.VerifyingPubkey(); !ok {
		return &ValidationError{Name: "verifying_pubkey", err: errors.New(`ent: missing required field "TreeNode.verifying_pubkey"`)}
	}
	if _, ok := tnc.mutation.OwnerIdentityPubkey(); !ok {
		return &ValidationError{Name: "owner_identity_pubkey", err: errors.New(`ent: missing required field "TreeNode.owner_identity_pubkey"`)}
	}
	if _, ok := tnc.mutation.OwnerSigningPubkey(); !ok {
		return &ValidationError{Name: "owner_signing_pubkey", err: errors.New(`ent: missing required field "TreeNode.owner_signing_pubkey"`)}
	}
	if _, ok := tnc.mutation.Vout(); !ok {
		return &ValidationError{Name: "vout", err: errors.New(`ent: missing required field "TreeNode.vout"`)}
	}
	if _, ok := tnc.mutation.RawTx(); !ok {
		return &ValidationError{Name: "raw_tx", err: errors.New(`ent: missing required field "TreeNode.raw_tx"`)}
	}
	if v, ok := tnc.mutation.RawTx(); ok {
		if err := treenode.RawTxValidator(v); err != nil {
			return &ValidationError{Name: "raw_tx", err: fmt.Errorf(`ent: validator failed for field "TreeNode.raw_tx": %w`, err)}
		}
	}
	if len(tnc.mutation.TreeIDs()) == 0 {
		return &ValidationError{Name: "tree", err: errors.New(`ent: missing required edge "TreeNode.tree"`)}
	}
	if len(tnc.mutation.SigningKeyshareIDs()) == 0 {
		return &ValidationError{Name: "signing_keyshare", err: errors.New(`ent: missing required edge "TreeNode.signing_keyshare"`)}
	}
	return nil
}

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

func (tnc *TreeNodeCreate) createSpec() (*TreeNode, *sqlgraph.CreateSpec) {
	var (
		_node = &TreeNode{config: tnc.config}
		_spec = sqlgraph.NewCreateSpec(treenode.Table, sqlgraph.NewFieldSpec(treenode.FieldID, field.TypeUUID))
	)
	_spec.OnConflict = tnc.conflict
	if id, ok := tnc.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = &id
	}
	if value, ok := tnc.mutation.CreateTime(); ok {
		_spec.SetField(treenode.FieldCreateTime, field.TypeTime, value)
		_node.CreateTime = value
	}
	if value, ok := tnc.mutation.UpdateTime(); ok {
		_spec.SetField(treenode.FieldUpdateTime, field.TypeTime, value)
		_node.UpdateTime = value
	}
	if value, ok := tnc.mutation.Value(); ok {
		_spec.SetField(treenode.FieldValue, field.TypeUint64, value)
		_node.Value = value
	}
	if value, ok := tnc.mutation.Status(); ok {
		_spec.SetField(treenode.FieldStatus, field.TypeEnum, value)
		_node.Status = value
	}
	if value, ok := tnc.mutation.VerifyingPubkey(); ok {
		_spec.SetField(treenode.FieldVerifyingPubkey, field.TypeBytes, value)
		_node.VerifyingPubkey = value
	}
	if value, ok := tnc.mutation.OwnerIdentityPubkey(); ok {
		_spec.SetField(treenode.FieldOwnerIdentityPubkey, field.TypeBytes, value)
		_node.OwnerIdentityPubkey = value
	}
	if value, ok := tnc.mutation.OwnerSigningPubkey(); ok {
		_spec.SetField(treenode.FieldOwnerSigningPubkey, field.TypeBytes, value)
		_node.OwnerSigningPubkey = value
	}
	if value, ok := tnc.mutation.Vout(); ok {
		_spec.SetField(treenode.FieldVout, field.TypeInt16, value)
		_node.Vout = value
	}
	if value, ok := tnc.mutation.NodeConfirmationHeight(); ok {
		_spec.SetField(treenode.FieldNodeConfirmationHeight, field.TypeUint64, value)
		_node.NodeConfirmationHeight = value
	}
	if value, ok := tnc.mutation.RefundConfirmationHeight(); ok {
		_spec.SetField(treenode.FieldRefundConfirmationHeight, field.TypeUint64, value)
		_node.RefundConfirmationHeight = value
	}
	if value, ok := tnc.mutation.RawTx(); ok {
		_spec.SetField(treenode.FieldRawTx, field.TypeBytes, value)
		_node.RawTx = value
	}
	if value, ok := tnc.mutation.DirectTx(); ok {
		_spec.SetField(treenode.FieldDirectTx, field.TypeBytes, value)
		_node.DirectTx = value
	}
	if value, ok := tnc.mutation.DirectFromCpfpRefundTx(); ok {
		_spec.SetField(treenode.FieldDirectFromCpfpRefundTx, field.TypeBytes, value)
		_node.DirectFromCpfpRefundTx = value
	}
	if value, ok := tnc.mutation.RawTxid(); ok {
		_spec.SetField(treenode.FieldRawTxid, field.TypeBytes, value)
		_node.RawTxid = value
	}
	if value, ok := tnc.mutation.DirectTxid(); ok {
		_spec.SetField(treenode.FieldDirectTxid, field.TypeBytes, value)
		_node.DirectTxid = value
	}
	if value, ok := tnc.mutation.DirectFromCpfpRefundTxid(); ok {
		_spec.SetField(treenode.FieldDirectFromCpfpRefundTxid, field.TypeBytes, value)
		_node.DirectFromCpfpRefundTxid = value
	}
	if value, ok := tnc.mutation.RawRefundTx(); ok {
		_spec.SetField(treenode.FieldRawRefundTx, field.TypeBytes, value)
		_node.RawRefundTx = value
	}
	if value, ok := tnc.mutation.DirectRefundTx(); ok {
		_spec.SetField(treenode.FieldDirectRefundTx, field.TypeBytes, value)
		_node.DirectRefundTx = value
	}
	if value, ok := tnc.mutation.RawRefundTxid(); ok {
		_spec.SetField(treenode.FieldRawRefundTxid, field.TypeBytes, value)
		_node.RawRefundTxid = value
	}
	if value, ok := tnc.mutation.DirectRefundTxid(); ok {
		_spec.SetField(treenode.FieldDirectRefundTxid, field.TypeBytes, value)
		_node.DirectRefundTxid = value
	}
	if nodes := tnc.mutation.TreeIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   treenode.TreeTable,
			Columns: []string{treenode.TreeColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(tree.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.tree_node_tree = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := tnc.mutation.ParentIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   treenode.ParentTable,
			Columns: []string{treenode.ParentColumn},
			Bidi:    true,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(treenode.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.tree_node_parent = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := tnc.mutation.SigningKeyshareIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   treenode.SigningKeyshareTable,
			Columns: []string{treenode.SigningKeyshareColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(signingkeyshare.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.tree_node_signing_keyshare = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := tnc.mutation.ChildrenIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: true,
			Table:   treenode.ChildrenTable,
			Columns: []string{treenode.ChildrenColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(treenode.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_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.TreeNode.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.TreeNodeUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (tnc *TreeNodeCreate) OnConflict(opts ...sql.ConflictOption) *TreeNodeUpsertOne {
	tnc.conflict = opts
	return &TreeNodeUpsertOne{
		create: tnc,
	}
}

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

type (
	// TreeNodeUpsertOne is the builder for "upsert"-ing
	//  one TreeNode node.
	TreeNodeUpsertOne struct {
		create *TreeNodeCreate
	}

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

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

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

// SetStatus sets the "status" field.
func (u *TreeNodeUpsert) SetStatus(v schematype.TreeNodeStatus) *TreeNodeUpsert {
	u.Set(treenode.FieldStatus, v)
	return u
}

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

// SetOwnerIdentityPubkey sets the "owner_identity_pubkey" field.
func (u *TreeNodeUpsert) SetOwnerIdentityPubkey(v keys.Public) *TreeNodeUpsert {
	u.Set(treenode.FieldOwnerIdentityPubkey, v)
	return u
}

// UpdateOwnerIdentityPubkey sets the "owner_identity_pubkey" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateOwnerIdentityPubkey() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldOwnerIdentityPubkey)
	return u
}

// SetOwnerSigningPubkey sets the "owner_signing_pubkey" field.
func (u *TreeNodeUpsert) SetOwnerSigningPubkey(v keys.Public) *TreeNodeUpsert {
	u.Set(treenode.FieldOwnerSigningPubkey, v)
	return u
}

// UpdateOwnerSigningPubkey sets the "owner_signing_pubkey" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateOwnerSigningPubkey() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldOwnerSigningPubkey)
	return u
}

// SetVout sets the "vout" field.
func (u *TreeNodeUpsert) SetVout(v int16) *TreeNodeUpsert {
	u.Set(treenode.FieldVout, v)
	return u
}

// UpdateVout sets the "vout" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateVout() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldVout)
	return u
}

// AddVout adds v to the "vout" field.
func (u *TreeNodeUpsert) AddVout(v int16) *TreeNodeUpsert {
	u.Add(treenode.FieldVout, v)
	return u
}

// SetNodeConfirmationHeight sets the "node_confirmation_height" field.
func (u *TreeNodeUpsert) SetNodeConfirmationHeight(v uint64) *TreeNodeUpsert {
	u.Set(treenode.FieldNodeConfirmationHeight, v)
	return u
}

// UpdateNodeConfirmationHeight sets the "node_confirmation_height" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateNodeConfirmationHeight() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldNodeConfirmationHeight)
	return u
}

// AddNodeConfirmationHeight adds v to the "node_confirmation_height" field.
func (u *TreeNodeUpsert) AddNodeConfirmationHeight(v uint64) *TreeNodeUpsert {
	u.Add(treenode.FieldNodeConfirmationHeight, v)
	return u
}

// ClearNodeConfirmationHeight clears the value of the "node_confirmation_height" field.
func (u *TreeNodeUpsert) ClearNodeConfirmationHeight() *TreeNodeUpsert {
	u.SetNull(treenode.FieldNodeConfirmationHeight)
	return u
}

// SetRefundConfirmationHeight sets the "refund_confirmation_height" field.
func (u *TreeNodeUpsert) SetRefundConfirmationHeight(v uint64) *TreeNodeUpsert {
	u.Set(treenode.FieldRefundConfirmationHeight, v)
	return u
}

// UpdateRefundConfirmationHeight sets the "refund_confirmation_height" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateRefundConfirmationHeight() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldRefundConfirmationHeight)
	return u
}

// AddRefundConfirmationHeight adds v to the "refund_confirmation_height" field.
func (u *TreeNodeUpsert) AddRefundConfirmationHeight(v uint64) *TreeNodeUpsert {
	u.Add(treenode.FieldRefundConfirmationHeight, v)
	return u
}

// ClearRefundConfirmationHeight clears the value of the "refund_confirmation_height" field.
func (u *TreeNodeUpsert) ClearRefundConfirmationHeight() *TreeNodeUpsert {
	u.SetNull(treenode.FieldRefundConfirmationHeight)
	return u
}

// SetRawTx sets the "raw_tx" field.
func (u *TreeNodeUpsert) SetRawTx(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldRawTx, v)
	return u
}

// UpdateRawTx sets the "raw_tx" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateRawTx() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldRawTx)
	return u
}

// SetDirectTx sets the "direct_tx" field.
func (u *TreeNodeUpsert) SetDirectTx(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldDirectTx, v)
	return u
}

// UpdateDirectTx sets the "direct_tx" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateDirectTx() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldDirectTx)
	return u
}

// ClearDirectTx clears the value of the "direct_tx" field.
func (u *TreeNodeUpsert) ClearDirectTx() *TreeNodeUpsert {
	u.SetNull(treenode.FieldDirectTx)
	return u
}

// SetDirectFromCpfpRefundTx sets the "direct_from_cpfp_refund_tx" field.
func (u *TreeNodeUpsert) SetDirectFromCpfpRefundTx(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldDirectFromCpfpRefundTx, v)
	return u
}

// UpdateDirectFromCpfpRefundTx sets the "direct_from_cpfp_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateDirectFromCpfpRefundTx() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldDirectFromCpfpRefundTx)
	return u
}

// ClearDirectFromCpfpRefundTx clears the value of the "direct_from_cpfp_refund_tx" field.
func (u *TreeNodeUpsert) ClearDirectFromCpfpRefundTx() *TreeNodeUpsert {
	u.SetNull(treenode.FieldDirectFromCpfpRefundTx)
	return u
}

// SetRawTxid sets the "raw_txid" field.
func (u *TreeNodeUpsert) SetRawTxid(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldRawTxid, v)
	return u
}

// UpdateRawTxid sets the "raw_txid" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateRawTxid() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldRawTxid)
	return u
}

// ClearRawTxid clears the value of the "raw_txid" field.
func (u *TreeNodeUpsert) ClearRawTxid() *TreeNodeUpsert {
	u.SetNull(treenode.FieldRawTxid)
	return u
}

// SetDirectTxid sets the "direct_txid" field.
func (u *TreeNodeUpsert) SetDirectTxid(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldDirectTxid, v)
	return u
}

// UpdateDirectTxid sets the "direct_txid" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateDirectTxid() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldDirectTxid)
	return u
}

// ClearDirectTxid clears the value of the "direct_txid" field.
func (u *TreeNodeUpsert) ClearDirectTxid() *TreeNodeUpsert {
	u.SetNull(treenode.FieldDirectTxid)
	return u
}

// SetDirectFromCpfpRefundTxid sets the "direct_from_cpfp_refund_txid" field.
func (u *TreeNodeUpsert) SetDirectFromCpfpRefundTxid(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldDirectFromCpfpRefundTxid, v)
	return u
}

// UpdateDirectFromCpfpRefundTxid sets the "direct_from_cpfp_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateDirectFromCpfpRefundTxid() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldDirectFromCpfpRefundTxid)
	return u
}

// ClearDirectFromCpfpRefundTxid clears the value of the "direct_from_cpfp_refund_txid" field.
func (u *TreeNodeUpsert) ClearDirectFromCpfpRefundTxid() *TreeNodeUpsert {
	u.SetNull(treenode.FieldDirectFromCpfpRefundTxid)
	return u
}

// SetRawRefundTx sets the "raw_refund_tx" field.
func (u *TreeNodeUpsert) SetRawRefundTx(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldRawRefundTx, v)
	return u
}

// UpdateRawRefundTx sets the "raw_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateRawRefundTx() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldRawRefundTx)
	return u
}

// ClearRawRefundTx clears the value of the "raw_refund_tx" field.
func (u *TreeNodeUpsert) ClearRawRefundTx() *TreeNodeUpsert {
	u.SetNull(treenode.FieldRawRefundTx)
	return u
}

// SetDirectRefundTx sets the "direct_refund_tx" field.
func (u *TreeNodeUpsert) SetDirectRefundTx(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldDirectRefundTx, v)
	return u
}

// UpdateDirectRefundTx sets the "direct_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateDirectRefundTx() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldDirectRefundTx)
	return u
}

// ClearDirectRefundTx clears the value of the "direct_refund_tx" field.
func (u *TreeNodeUpsert) ClearDirectRefundTx() *TreeNodeUpsert {
	u.SetNull(treenode.FieldDirectRefundTx)
	return u
}

// SetRawRefundTxid sets the "raw_refund_txid" field.
func (u *TreeNodeUpsert) SetRawRefundTxid(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldRawRefundTxid, v)
	return u
}

// UpdateRawRefundTxid sets the "raw_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateRawRefundTxid() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldRawRefundTxid)
	return u
}

// ClearRawRefundTxid clears the value of the "raw_refund_txid" field.
func (u *TreeNodeUpsert) ClearRawRefundTxid() *TreeNodeUpsert {
	u.SetNull(treenode.FieldRawRefundTxid)
	return u
}

// SetDirectRefundTxid sets the "direct_refund_txid" field.
func (u *TreeNodeUpsert) SetDirectRefundTxid(v []byte) *TreeNodeUpsert {
	u.Set(treenode.FieldDirectRefundTxid, v)
	return u
}

// UpdateDirectRefundTxid sets the "direct_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsert) UpdateDirectRefundTxid() *TreeNodeUpsert {
	u.SetExcluded(treenode.FieldDirectRefundTxid)
	return u
}

// ClearDirectRefundTxid clears the value of the "direct_refund_txid" field.
func (u *TreeNodeUpsert) ClearDirectRefundTxid() *TreeNodeUpsert {
	u.SetNull(treenode.FieldDirectRefundTxid)
	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.TreeNode.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(treenode.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *TreeNodeUpsertOne) UpdateNewValues() *TreeNodeUpsertOne {
	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(treenode.FieldID)
		}
		if _, exists := u.create.mutation.CreateTime(); exists {
			s.SetIgnore(treenode.FieldCreateTime)
		}
		if _, exists := u.create.mutation.Value(); exists {
			s.SetIgnore(treenode.FieldValue)
		}
		if _, exists := u.create.mutation.VerifyingPubkey(); exists {
			s.SetIgnore(treenode.FieldVerifyingPubkey)
		}
	}))
	return u
}

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

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

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

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

// SetStatus sets the "status" field.
func (u *TreeNodeUpsertOne) SetStatus(v schematype.TreeNodeStatus) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetStatus(v)
	})
}

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

// SetOwnerIdentityPubkey sets the "owner_identity_pubkey" field.
func (u *TreeNodeUpsertOne) SetOwnerIdentityPubkey(v keys.Public) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetOwnerIdentityPubkey(v)
	})
}

// UpdateOwnerIdentityPubkey sets the "owner_identity_pubkey" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateOwnerIdentityPubkey() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateOwnerIdentityPubkey()
	})
}

// SetOwnerSigningPubkey sets the "owner_signing_pubkey" field.
func (u *TreeNodeUpsertOne) SetOwnerSigningPubkey(v keys.Public) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetOwnerSigningPubkey(v)
	})
}

// UpdateOwnerSigningPubkey sets the "owner_signing_pubkey" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateOwnerSigningPubkey() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateOwnerSigningPubkey()
	})
}

// SetVout sets the "vout" field.
func (u *TreeNodeUpsertOne) SetVout(v int16) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetVout(v)
	})
}

// AddVout adds v to the "vout" field.
func (u *TreeNodeUpsertOne) AddVout(v int16) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.AddVout(v)
	})
}

// UpdateVout sets the "vout" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateVout() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateVout()
	})
}

// SetNodeConfirmationHeight sets the "node_confirmation_height" field.
func (u *TreeNodeUpsertOne) SetNodeConfirmationHeight(v uint64) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetNodeConfirmationHeight(v)
	})
}

// AddNodeConfirmationHeight adds v to the "node_confirmation_height" field.
func (u *TreeNodeUpsertOne) AddNodeConfirmationHeight(v uint64) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.AddNodeConfirmationHeight(v)
	})
}

// UpdateNodeConfirmationHeight sets the "node_confirmation_height" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateNodeConfirmationHeight() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateNodeConfirmationHeight()
	})
}

// ClearNodeConfirmationHeight clears the value of the "node_confirmation_height" field.
func (u *TreeNodeUpsertOne) ClearNodeConfirmationHeight() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearNodeConfirmationHeight()
	})
}

// SetRefundConfirmationHeight sets the "refund_confirmation_height" field.
func (u *TreeNodeUpsertOne) SetRefundConfirmationHeight(v uint64) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRefundConfirmationHeight(v)
	})
}

// AddRefundConfirmationHeight adds v to the "refund_confirmation_height" field.
func (u *TreeNodeUpsertOne) AddRefundConfirmationHeight(v uint64) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.AddRefundConfirmationHeight(v)
	})
}

// UpdateRefundConfirmationHeight sets the "refund_confirmation_height" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateRefundConfirmationHeight() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRefundConfirmationHeight()
	})
}

// ClearRefundConfirmationHeight clears the value of the "refund_confirmation_height" field.
func (u *TreeNodeUpsertOne) ClearRefundConfirmationHeight() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearRefundConfirmationHeight()
	})
}

// SetRawTx sets the "raw_tx" field.
func (u *TreeNodeUpsertOne) SetRawTx(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRawTx(v)
	})
}

// UpdateRawTx sets the "raw_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateRawTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRawTx()
	})
}

// SetDirectTx sets the "direct_tx" field.
func (u *TreeNodeUpsertOne) SetDirectTx(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectTx(v)
	})
}

// UpdateDirectTx sets the "direct_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateDirectTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectTx()
	})
}

// ClearDirectTx clears the value of the "direct_tx" field.
func (u *TreeNodeUpsertOne) ClearDirectTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectTx()
	})
}

// SetDirectFromCpfpRefundTx sets the "direct_from_cpfp_refund_tx" field.
func (u *TreeNodeUpsertOne) SetDirectFromCpfpRefundTx(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectFromCpfpRefundTx(v)
	})
}

// UpdateDirectFromCpfpRefundTx sets the "direct_from_cpfp_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateDirectFromCpfpRefundTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectFromCpfpRefundTx()
	})
}

// ClearDirectFromCpfpRefundTx clears the value of the "direct_from_cpfp_refund_tx" field.
func (u *TreeNodeUpsertOne) ClearDirectFromCpfpRefundTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectFromCpfpRefundTx()
	})
}

// SetRawTxid sets the "raw_txid" field.
func (u *TreeNodeUpsertOne) SetRawTxid(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRawTxid(v)
	})
}

// UpdateRawTxid sets the "raw_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateRawTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRawTxid()
	})
}

// ClearRawTxid clears the value of the "raw_txid" field.
func (u *TreeNodeUpsertOne) ClearRawTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearRawTxid()
	})
}

// SetDirectTxid sets the "direct_txid" field.
func (u *TreeNodeUpsertOne) SetDirectTxid(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectTxid(v)
	})
}

// UpdateDirectTxid sets the "direct_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateDirectTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectTxid()
	})
}

// ClearDirectTxid clears the value of the "direct_txid" field.
func (u *TreeNodeUpsertOne) ClearDirectTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectTxid()
	})
}

// SetDirectFromCpfpRefundTxid sets the "direct_from_cpfp_refund_txid" field.
func (u *TreeNodeUpsertOne) SetDirectFromCpfpRefundTxid(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectFromCpfpRefundTxid(v)
	})
}

// UpdateDirectFromCpfpRefundTxid sets the "direct_from_cpfp_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateDirectFromCpfpRefundTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectFromCpfpRefundTxid()
	})
}

// ClearDirectFromCpfpRefundTxid clears the value of the "direct_from_cpfp_refund_txid" field.
func (u *TreeNodeUpsertOne) ClearDirectFromCpfpRefundTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectFromCpfpRefundTxid()
	})
}

// SetRawRefundTx sets the "raw_refund_tx" field.
func (u *TreeNodeUpsertOne) SetRawRefundTx(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRawRefundTx(v)
	})
}

// UpdateRawRefundTx sets the "raw_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateRawRefundTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRawRefundTx()
	})
}

// ClearRawRefundTx clears the value of the "raw_refund_tx" field.
func (u *TreeNodeUpsertOne) ClearRawRefundTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearRawRefundTx()
	})
}

// SetDirectRefundTx sets the "direct_refund_tx" field.
func (u *TreeNodeUpsertOne) SetDirectRefundTx(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectRefundTx(v)
	})
}

// UpdateDirectRefundTx sets the "direct_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateDirectRefundTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectRefundTx()
	})
}

// ClearDirectRefundTx clears the value of the "direct_refund_tx" field.
func (u *TreeNodeUpsertOne) ClearDirectRefundTx() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectRefundTx()
	})
}

// SetRawRefundTxid sets the "raw_refund_txid" field.
func (u *TreeNodeUpsertOne) SetRawRefundTxid(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRawRefundTxid(v)
	})
}

// UpdateRawRefundTxid sets the "raw_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateRawRefundTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRawRefundTxid()
	})
}

// ClearRawRefundTxid clears the value of the "raw_refund_txid" field.
func (u *TreeNodeUpsertOne) ClearRawRefundTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearRawRefundTxid()
	})
}

// SetDirectRefundTxid sets the "direct_refund_txid" field.
func (u *TreeNodeUpsertOne) SetDirectRefundTxid(v []byte) *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectRefundTxid(v)
	})
}

// UpdateDirectRefundTxid sets the "direct_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertOne) UpdateDirectRefundTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectRefundTxid()
	})
}

// ClearDirectRefundTxid clears the value of the "direct_refund_txid" field.
func (u *TreeNodeUpsertOne) ClearDirectRefundTxid() *TreeNodeUpsertOne {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectRefundTxid()
	})
}

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

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

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

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

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

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

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

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

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

// TreeNodeUpsertBulk is the builder for "upsert"-ing
// a bulk of TreeNode nodes.
type TreeNodeUpsertBulk struct {
	create *TreeNodeCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.TreeNode.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(treenode.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *TreeNodeUpsertBulk) UpdateNewValues() *TreeNodeUpsertBulk {
	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(treenode.FieldID)
			}
			if _, exists := b.mutation.CreateTime(); exists {
				s.SetIgnore(treenode.FieldCreateTime)
			}
			if _, exists := b.mutation.Value(); exists {
				s.SetIgnore(treenode.FieldValue)
			}
			if _, exists := b.mutation.VerifyingPubkey(); exists {
				s.SetIgnore(treenode.FieldVerifyingPubkey)
			}
		}
	}))
	return u
}

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

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

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

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

// SetStatus sets the "status" field.
func (u *TreeNodeUpsertBulk) SetStatus(v schematype.TreeNodeStatus) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetStatus(v)
	})
}

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

// SetOwnerIdentityPubkey sets the "owner_identity_pubkey" field.
func (u *TreeNodeUpsertBulk) SetOwnerIdentityPubkey(v keys.Public) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetOwnerIdentityPubkey(v)
	})
}

// UpdateOwnerIdentityPubkey sets the "owner_identity_pubkey" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateOwnerIdentityPubkey() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateOwnerIdentityPubkey()
	})
}

// SetOwnerSigningPubkey sets the "owner_signing_pubkey" field.
func (u *TreeNodeUpsertBulk) SetOwnerSigningPubkey(v keys.Public) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetOwnerSigningPubkey(v)
	})
}

// UpdateOwnerSigningPubkey sets the "owner_signing_pubkey" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateOwnerSigningPubkey() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateOwnerSigningPubkey()
	})
}

// SetVout sets the "vout" field.
func (u *TreeNodeUpsertBulk) SetVout(v int16) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetVout(v)
	})
}

// AddVout adds v to the "vout" field.
func (u *TreeNodeUpsertBulk) AddVout(v int16) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.AddVout(v)
	})
}

// UpdateVout sets the "vout" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateVout() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateVout()
	})
}

// SetNodeConfirmationHeight sets the "node_confirmation_height" field.
func (u *TreeNodeUpsertBulk) SetNodeConfirmationHeight(v uint64) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetNodeConfirmationHeight(v)
	})
}

// AddNodeConfirmationHeight adds v to the "node_confirmation_height" field.
func (u *TreeNodeUpsertBulk) AddNodeConfirmationHeight(v uint64) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.AddNodeConfirmationHeight(v)
	})
}

// UpdateNodeConfirmationHeight sets the "node_confirmation_height" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateNodeConfirmationHeight() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateNodeConfirmationHeight()
	})
}

// ClearNodeConfirmationHeight clears the value of the "node_confirmation_height" field.
func (u *TreeNodeUpsertBulk) ClearNodeConfirmationHeight() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearNodeConfirmationHeight()
	})
}

// SetRefundConfirmationHeight sets the "refund_confirmation_height" field.
func (u *TreeNodeUpsertBulk) SetRefundConfirmationHeight(v uint64) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRefundConfirmationHeight(v)
	})
}

// AddRefundConfirmationHeight adds v to the "refund_confirmation_height" field.
func (u *TreeNodeUpsertBulk) AddRefundConfirmationHeight(v uint64) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.AddRefundConfirmationHeight(v)
	})
}

// UpdateRefundConfirmationHeight sets the "refund_confirmation_height" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateRefundConfirmationHeight() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRefundConfirmationHeight()
	})
}

// ClearRefundConfirmationHeight clears the value of the "refund_confirmation_height" field.
func (u *TreeNodeUpsertBulk) ClearRefundConfirmationHeight() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearRefundConfirmationHeight()
	})
}

// SetRawTx sets the "raw_tx" field.
func (u *TreeNodeUpsertBulk) SetRawTx(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRawTx(v)
	})
}

// UpdateRawTx sets the "raw_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateRawTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRawTx()
	})
}

// SetDirectTx sets the "direct_tx" field.
func (u *TreeNodeUpsertBulk) SetDirectTx(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectTx(v)
	})
}

// UpdateDirectTx sets the "direct_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateDirectTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectTx()
	})
}

// ClearDirectTx clears the value of the "direct_tx" field.
func (u *TreeNodeUpsertBulk) ClearDirectTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectTx()
	})
}

// SetDirectFromCpfpRefundTx sets the "direct_from_cpfp_refund_tx" field.
func (u *TreeNodeUpsertBulk) SetDirectFromCpfpRefundTx(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectFromCpfpRefundTx(v)
	})
}

// UpdateDirectFromCpfpRefundTx sets the "direct_from_cpfp_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateDirectFromCpfpRefundTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectFromCpfpRefundTx()
	})
}

// ClearDirectFromCpfpRefundTx clears the value of the "direct_from_cpfp_refund_tx" field.
func (u *TreeNodeUpsertBulk) ClearDirectFromCpfpRefundTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectFromCpfpRefundTx()
	})
}

// SetRawTxid sets the "raw_txid" field.
func (u *TreeNodeUpsertBulk) SetRawTxid(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRawTxid(v)
	})
}

// UpdateRawTxid sets the "raw_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateRawTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRawTxid()
	})
}

// ClearRawTxid clears the value of the "raw_txid" field.
func (u *TreeNodeUpsertBulk) ClearRawTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearRawTxid()
	})
}

// SetDirectTxid sets the "direct_txid" field.
func (u *TreeNodeUpsertBulk) SetDirectTxid(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectTxid(v)
	})
}

// UpdateDirectTxid sets the "direct_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateDirectTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectTxid()
	})
}

// ClearDirectTxid clears the value of the "direct_txid" field.
func (u *TreeNodeUpsertBulk) ClearDirectTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectTxid()
	})
}

// SetDirectFromCpfpRefundTxid sets the "direct_from_cpfp_refund_txid" field.
func (u *TreeNodeUpsertBulk) SetDirectFromCpfpRefundTxid(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectFromCpfpRefundTxid(v)
	})
}

// UpdateDirectFromCpfpRefundTxid sets the "direct_from_cpfp_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateDirectFromCpfpRefundTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectFromCpfpRefundTxid()
	})
}

// ClearDirectFromCpfpRefundTxid clears the value of the "direct_from_cpfp_refund_txid" field.
func (u *TreeNodeUpsertBulk) ClearDirectFromCpfpRefundTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectFromCpfpRefundTxid()
	})
}

// SetRawRefundTx sets the "raw_refund_tx" field.
func (u *TreeNodeUpsertBulk) SetRawRefundTx(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRawRefundTx(v)
	})
}

// UpdateRawRefundTx sets the "raw_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateRawRefundTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRawRefundTx()
	})
}

// ClearRawRefundTx clears the value of the "raw_refund_tx" field.
func (u *TreeNodeUpsertBulk) ClearRawRefundTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearRawRefundTx()
	})
}

// SetDirectRefundTx sets the "direct_refund_tx" field.
func (u *TreeNodeUpsertBulk) SetDirectRefundTx(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectRefundTx(v)
	})
}

// UpdateDirectRefundTx sets the "direct_refund_tx" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateDirectRefundTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectRefundTx()
	})
}

// ClearDirectRefundTx clears the value of the "direct_refund_tx" field.
func (u *TreeNodeUpsertBulk) ClearDirectRefundTx() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectRefundTx()
	})
}

// SetRawRefundTxid sets the "raw_refund_txid" field.
func (u *TreeNodeUpsertBulk) SetRawRefundTxid(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetRawRefundTxid(v)
	})
}

// UpdateRawRefundTxid sets the "raw_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateRawRefundTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateRawRefundTxid()
	})
}

// ClearRawRefundTxid clears the value of the "raw_refund_txid" field.
func (u *TreeNodeUpsertBulk) ClearRawRefundTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearRawRefundTxid()
	})
}

// SetDirectRefundTxid sets the "direct_refund_txid" field.
func (u *TreeNodeUpsertBulk) SetDirectRefundTxid(v []byte) *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.SetDirectRefundTxid(v)
	})
}

// UpdateDirectRefundTxid sets the "direct_refund_txid" field to the value that was provided on create.
func (u *TreeNodeUpsertBulk) UpdateDirectRefundTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.UpdateDirectRefundTxid()
	})
}

// ClearDirectRefundTxid clears the value of the "direct_refund_txid" field.
func (u *TreeNodeUpsertBulk) ClearDirectRefundTxid() *TreeNodeUpsertBulk {
	return u.Update(func(s *TreeNodeUpsert) {
		s.ClearDirectRefundTxid()
	})
}

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

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