kickoff_sig.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package lnwire
  2. import (
  3. "bytes"
  4. "io"
  5. )
  6. // KickoffSig is the message used to transmit the signature for a kickoff
  7. // transaction during the execution phase of a dynamic commitment negotiation
  8. // that requires a reanchoring step.
  9. type KickoffSig struct {
  10. // ChanID identifies the channel id for which this signature is
  11. // intended.
  12. ChanID ChannelID
  13. // Signature contains the ECDSA signature that signs the kickoff
  14. // transaction.
  15. Signature Sig
  16. // ExtraData is the set of data that was appended to this message to
  17. // fill out the full maximum transport message size. These fields can
  18. // be used to specify optional data such as custom TLV fields.
  19. ExtraData ExtraOpaqueData
  20. }
  21. // A compile time check to ensure that KickoffSig implements the lnwire.Message
  22. // interface.
  23. var _ Message = (*KickoffSig)(nil)
  24. // Encode serializes the target KickoffSig into the passed bytes.Buffer
  25. // observing the specified protocol version.
  26. //
  27. // This is part of the lnwire.Message interface.
  28. func (ks *KickoffSig) Encode(w *bytes.Buffer, _ uint32) error {
  29. if err := WriteChannelID(w, ks.ChanID); err != nil {
  30. return err
  31. }
  32. if err := WriteSig(w, ks.Signature); err != nil {
  33. return err
  34. }
  35. return WriteBytes(w, ks.ExtraData)
  36. }
  37. // Decode deserializes a serialized KickoffSig message stored in the passed
  38. // io.Reader observing the specified protocol version.
  39. //
  40. // This is part of the lnwire.Message interface.
  41. func (ks *KickoffSig) Decode(r io.Reader, _ uint32) error {
  42. return ReadElements(r, &ks.ChanID, &ks.Signature, &ks.ExtraData)
  43. }
  44. // MsgType returns the integer uniquely identifying KickoffSig on the wire.
  45. //
  46. // This is part of the lnwire.Message interface.
  47. func (ks *KickoffSig) MsgType() MessageType { return MsgKickoffSig }