github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/channel_close_mutual_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  
    14  	utils "github.com/aeternity/aepp-sdk-go/utils"
    15  )
    16  
    17  // ChannelCloseMutualTx channel close mutual tx
    18  // swagger:model ChannelCloseMutualTx
    19  type ChannelCloseMutualTx struct {
    20  
    21  	// channel id
    22  	// Required: true
    23  	ChannelID EncodedPubkey `json:"channel_id"`
    24  
    25  	// fee
    26  	// Required: true
    27  	Fee Uint64 `json:"fee"`
    28  
    29  	// from id
    30  	// Required: true
    31  	FromID EncodedPubkey `json:"from_id"`
    32  
    33  	// initiator amount final
    34  	// Required: true
    35  	InitiatorAmountFinal utils.BigInt `json:"initiator_amount_final"`
    36  
    37  	// nonce
    38  	// Required: true
    39  	Nonce Uint64 `json:"nonce"`
    40  
    41  	// responder amount final
    42  	// Required: true
    43  	ResponderAmountFinal utils.BigInt `json:"responder_amount_final"`
    44  
    45  	// ttl
    46  	TTL Uint64 `json:"ttl,omitempty"`
    47  }
    48  
    49  // Validate validates this channel close mutual tx
    50  func (m *ChannelCloseMutualTx) Validate(formats strfmt.Registry) error {
    51  	var res []error
    52  
    53  	if err := m.validateChannelID(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateFee(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if err := m.validateFromID(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if err := m.validateInitiatorAmountFinal(formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  
    69  	if err := m.validateNonce(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	if err := m.validateResponderAmountFinal(formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  
    77  	if err := m.validateTTL(formats); err != nil {
    78  		res = append(res, err)
    79  	}
    80  
    81  	if len(res) > 0 {
    82  		return errors.CompositeValidationError(res...)
    83  	}
    84  	return nil
    85  }
    86  
    87  func (m *ChannelCloseMutualTx) validateChannelID(formats strfmt.Registry) error {
    88  
    89  	if err := m.ChannelID.Validate(formats); err != nil {
    90  		if ve, ok := err.(*errors.Validation); ok {
    91  			return ve.ValidateName("channel_id")
    92  		}
    93  		return err
    94  	}
    95  
    96  	return nil
    97  }
    98  
    99  func (m *ChannelCloseMutualTx) validateFee(formats strfmt.Registry) error {
   100  
   101  	if err := m.Fee.Validate(formats); err != nil {
   102  		if ve, ok := err.(*errors.Validation); ok {
   103  			return ve.ValidateName("fee")
   104  		}
   105  		return err
   106  	}
   107  
   108  	return nil
   109  }
   110  
   111  func (m *ChannelCloseMutualTx) validateFromID(formats strfmt.Registry) error {
   112  
   113  	if err := m.FromID.Validate(formats); err != nil {
   114  		if ve, ok := err.(*errors.Validation); ok {
   115  			return ve.ValidateName("from_id")
   116  		}
   117  		return err
   118  	}
   119  
   120  	return nil
   121  }
   122  
   123  func (m *ChannelCloseMutualTx) validateInitiatorAmountFinal(formats strfmt.Registry) error {
   124  
   125  	if err := m.InitiatorAmountFinal.Validate(formats); err != nil {
   126  		if ve, ok := err.(*errors.Validation); ok {
   127  			return ve.ValidateName("initiator_amount_final")
   128  		}
   129  		return err
   130  	}
   131  
   132  	return nil
   133  }
   134  
   135  func (m *ChannelCloseMutualTx) validateNonce(formats strfmt.Registry) error {
   136  
   137  	if err := m.Nonce.Validate(formats); err != nil {
   138  		if ve, ok := err.(*errors.Validation); ok {
   139  			return ve.ValidateName("nonce")
   140  		}
   141  		return err
   142  	}
   143  
   144  	return nil
   145  }
   146  
   147  func (m *ChannelCloseMutualTx) validateResponderAmountFinal(formats strfmt.Registry) error {
   148  
   149  	if err := m.ResponderAmountFinal.Validate(formats); err != nil {
   150  		if ve, ok := err.(*errors.Validation); ok {
   151  			return ve.ValidateName("responder_amount_final")
   152  		}
   153  		return err
   154  	}
   155  
   156  	return nil
   157  }
   158  
   159  func (m *ChannelCloseMutualTx) validateTTL(formats strfmt.Registry) error {
   160  
   161  	if swag.IsZero(m.TTL) { // not required
   162  		return nil
   163  	}
   164  
   165  	if err := m.TTL.Validate(formats); err != nil {
   166  		if ve, ok := err.(*errors.Validation); ok {
   167  			return ve.ValidateName("ttl")
   168  		}
   169  		return err
   170  	}
   171  
   172  	return nil
   173  }
   174  
   175  // MarshalBinary interface implementation
   176  func (m *ChannelCloseMutualTx) MarshalBinary() ([]byte, error) {
   177  	if m == nil {
   178  		return nil, nil
   179  	}
   180  	return swag.WriteJSON(m)
   181  }
   182  
   183  // UnmarshalBinary interface implementation
   184  func (m *ChannelCloseMutualTx) UnmarshalBinary(b []byte) error {
   185  	var res ChannelCloseMutualTx
   186  	if err := swag.ReadJSON(b, &res); err != nil {
   187  		return err
   188  	}
   189  	*m = res
   190  	return nil
   191  }