github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/channel_create_tx.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  	"github.com/go-openapi/validate"
    14  
    15  	utils "github.com/aeternity/aepp-sdk-go/utils"
    16  )
    17  
    18  // ChannelCreateTx channel create tx
    19  // swagger:model ChannelCreateTx
    20  type ChannelCreateTx struct {
    21  
    22  	// channel reserve
    23  	// Required: true
    24  	ChannelReserve utils.BigInt `json:"channel_reserve"`
    25  
    26  	// fee
    27  	// Required: true
    28  	Fee utils.BigInt `json:"fee"`
    29  
    30  	// initiator amount
    31  	// Required: true
    32  	InitiatorAmount utils.BigInt `json:"initiator_amount"`
    33  
    34  	// initiator id
    35  	// Required: true
    36  	InitiatorID *string `json:"initiator_id"`
    37  
    38  	// lock period
    39  	// Required: true
    40  	LockPeriod *uint64 `json:"lock_period"`
    41  
    42  	// nonce
    43  	Nonce uint64 `json:"nonce,omitempty"`
    44  
    45  	// push amount
    46  	// Required: true
    47  	PushAmount utils.BigInt `json:"push_amount"`
    48  
    49  	// responder amount
    50  	// Required: true
    51  	ResponderAmount utils.BigInt `json:"responder_amount"`
    52  
    53  	// responder id
    54  	// Required: true
    55  	ResponderID *string `json:"responder_id"`
    56  
    57  	// Root hash of the channel's internal state tree
    58  	// Required: true
    59  	StateHash *string `json:"state_hash"`
    60  
    61  	// ttl
    62  	TTL uint64 `json:"ttl,omitempty"`
    63  }
    64  
    65  // Validate validates this channel create tx
    66  func (m *ChannelCreateTx) Validate(formats strfmt.Registry) error {
    67  	var res []error
    68  
    69  	if err := m.validateChannelReserve(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	if err := m.validateFee(formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  
    77  	if err := m.validateInitiatorAmount(formats); err != nil {
    78  		res = append(res, err)
    79  	}
    80  
    81  	if err := m.validateInitiatorID(formats); err != nil {
    82  		res = append(res, err)
    83  	}
    84  
    85  	if err := m.validateLockPeriod(formats); err != nil {
    86  		res = append(res, err)
    87  	}
    88  
    89  	if err := m.validatePushAmount(formats); err != nil {
    90  		res = append(res, err)
    91  	}
    92  
    93  	if err := m.validateResponderAmount(formats); err != nil {
    94  		res = append(res, err)
    95  	}
    96  
    97  	if err := m.validateResponderID(formats); err != nil {
    98  		res = append(res, err)
    99  	}
   100  
   101  	if err := m.validateStateHash(formats); err != nil {
   102  		res = append(res, err)
   103  	}
   104  
   105  	if len(res) > 0 {
   106  		return errors.CompositeValidationError(res...)
   107  	}
   108  	return nil
   109  }
   110  
   111  func (m *ChannelCreateTx) validateChannelReserve(formats strfmt.Registry) error {
   112  
   113  	if err := m.ChannelReserve.Validate(formats); err != nil {
   114  		if ve, ok := err.(*errors.Validation); ok {
   115  			return ve.ValidateName("channel_reserve")
   116  		}
   117  		return err
   118  	}
   119  
   120  	return nil
   121  }
   122  
   123  func (m *ChannelCreateTx) validateFee(formats strfmt.Registry) error {
   124  
   125  	if err := m.Fee.Validate(formats); err != nil {
   126  		if ve, ok := err.(*errors.Validation); ok {
   127  			return ve.ValidateName("fee")
   128  		}
   129  		return err
   130  	}
   131  
   132  	return nil
   133  }
   134  
   135  func (m *ChannelCreateTx) validateInitiatorAmount(formats strfmt.Registry) error {
   136  
   137  	if err := m.InitiatorAmount.Validate(formats); err != nil {
   138  		if ve, ok := err.(*errors.Validation); ok {
   139  			return ve.ValidateName("initiator_amount")
   140  		}
   141  		return err
   142  	}
   143  
   144  	return nil
   145  }
   146  
   147  func (m *ChannelCreateTx) validateInitiatorID(formats strfmt.Registry) error {
   148  
   149  	if err := validate.Required("initiator_id", "body", m.InitiatorID); err != nil {
   150  		return err
   151  	}
   152  
   153  	return nil
   154  }
   155  
   156  func (m *ChannelCreateTx) validateLockPeriod(formats strfmt.Registry) error {
   157  
   158  	if err := validate.Required("lock_period", "body", m.LockPeriod); err != nil {
   159  		return err
   160  	}
   161  
   162  	return nil
   163  }
   164  
   165  func (m *ChannelCreateTx) validatePushAmount(formats strfmt.Registry) error {
   166  
   167  	if err := m.PushAmount.Validate(formats); err != nil {
   168  		if ve, ok := err.(*errors.Validation); ok {
   169  			return ve.ValidateName("push_amount")
   170  		}
   171  		return err
   172  	}
   173  
   174  	return nil
   175  }
   176  
   177  func (m *ChannelCreateTx) validateResponderAmount(formats strfmt.Registry) error {
   178  
   179  	if err := m.ResponderAmount.Validate(formats); err != nil {
   180  		if ve, ok := err.(*errors.Validation); ok {
   181  			return ve.ValidateName("responder_amount")
   182  		}
   183  		return err
   184  	}
   185  
   186  	return nil
   187  }
   188  
   189  func (m *ChannelCreateTx) validateResponderID(formats strfmt.Registry) error {
   190  
   191  	if err := validate.Required("responder_id", "body", m.ResponderID); err != nil {
   192  		return err
   193  	}
   194  
   195  	return nil
   196  }
   197  
   198  func (m *ChannelCreateTx) validateStateHash(formats strfmt.Registry) error {
   199  
   200  	if err := validate.Required("state_hash", "body", m.StateHash); err != nil {
   201  		return err
   202  	}
   203  
   204  	return nil
   205  }
   206  
   207  // MarshalBinary interface implementation
   208  func (m *ChannelCreateTx) MarshalBinary() ([]byte, error) {
   209  	if m == nil {
   210  		return nil, nil
   211  	}
   212  	return swag.WriteJSON(m)
   213  }
   214  
   215  // UnmarshalBinary interface implementation
   216  func (m *ChannelCreateTx) UnmarshalBinary(b []byte) error {
   217  	var res ChannelCreateTx
   218  	if err := swag.ReadJSON(b, &res); err != nil {
   219  		return err
   220  	}
   221  	*m = res
   222  	return nil
   223  }