Documentation ¶
Overview ¶
Code derived from https:// github.com/btcsuite/btcd/blob/master/wire/message.go
Index ¶
- Constants
- func WriteMessage(w io.Writer, msg Message, pver uint32, btcnet wire.BitcoinNet) (int, error)
- type CancelHTLC
- type CloseComplete
- func (c *CloseComplete) Command() uint32
- func (c *CloseComplete) Decode(r io.Reader, pver uint32) error
- func (c *CloseComplete) Encode(w io.Writer, pver uint32) error
- func (c *CloseComplete) MaxPayloadLength(uint32) uint32
- func (c *CloseComplete) String() string
- func (c *CloseComplete) Validate() error
- type CloseRequest
- func (c *CloseRequest) Command() uint32
- func (c *CloseRequest) Decode(r io.Reader, pver uint32) error
- func (c *CloseRequest) Encode(w io.Writer, pver uint32) error
- func (c *CloseRequest) MaxPayloadLength(pver uint32) uint32
- func (c *CloseRequest) String() string
- func (c *CloseRequest) Validate() error
- type CommitHeight
- type CommitRevocation
- func (c *CommitRevocation) Command() uint32
- func (c *CommitRevocation) Decode(r io.Reader, pver uint32) error
- func (c *CommitRevocation) Encode(w io.Writer, pver uint32) error
- func (c *CommitRevocation) MaxPayloadLength(uint32) uint32
- func (c *CommitRevocation) String() string
- func (c *CommitRevocation) Validate() error
- type CommitSignature
- func (c *CommitSignature) Command() uint32
- func (c *CommitSignature) Decode(r io.Reader, pver uint32) error
- func (c *CommitSignature) Encode(w io.Writer, pver uint32) error
- func (c *CommitSignature) MaxPayloadLength(uint32) uint32
- func (c *CommitSignature) String() string
- func (c *CommitSignature) Validate() error
- type CreditsAmount
- type ErrorGeneric
- type HTLCAddReject
- func (c *HTLCAddReject) Command() uint32
- func (c *HTLCAddReject) Decode(r io.Reader, pver uint32) error
- func (c *HTLCAddReject) Encode(w io.Writer, pver uint32) error
- func (c *HTLCAddReject) MaxPayloadLength(uint32) uint32
- func (c *HTLCAddReject) String() string
- func (c *HTLCAddReject) Validate() error
- type HTLCAddRequest
- func (c *HTLCAddRequest) Command() uint32
- func (c *HTLCAddRequest) Decode(r io.Reader, pver uint32) error
- func (c *HTLCAddRequest) Encode(w io.Writer, pver uint32) error
- func (c *HTLCAddRequest) MaxPayloadLength(uint32) uint32
- func (c *HTLCAddRequest) String() string
- func (c *HTLCAddRequest) Validate() error
- type HTLCKey
- type HTLCSettleRequest
- func (c *HTLCSettleRequest) Command() uint32
- func (c *HTLCSettleRequest) Decode(r io.Reader, pver uint32) error
- func (c *HTLCSettleRequest) Encode(w io.Writer, pver uint32) error
- func (c *HTLCSettleRequest) MaxPayloadLength(uint32) uint32
- func (c *HTLCSettleRequest) String() string
- func (c *HTLCSettleRequest) Validate() error
- type Message
- type NeighborAckMessage
- func (msg *NeighborAckMessage) Command() uint32
- func (msg *NeighborAckMessage) Decode(r io.Reader, pver uint32) error
- func (msg *NeighborAckMessage) Encode(w io.Writer, pver uint32) error
- func (msg *NeighborAckMessage) MaxPayloadLength(uint32) uint32
- func (msg *NeighborAckMessage) String() string
- func (msg *NeighborAckMessage) Validate() error
- type NeighborHelloMessage
- func (msg *NeighborHelloMessage) Command() uint32
- func (msg *NeighborHelloMessage) Decode(r io.Reader, pver uint32) error
- func (msg *NeighborHelloMessage) Encode(w io.Writer, pver uint32) error
- func (msg *NeighborHelloMessage) MaxPayloadLength(uint32) uint32
- func (msg *NeighborHelloMessage) String() string
- func (msg *NeighborHelloMessage) Validate() error
- type NeighborRstMessage
- func (msg *NeighborRstMessage) Command() uint32
- func (msg *NeighborRstMessage) Decode(r io.Reader, pver uint32) error
- func (msg *NeighborRstMessage) Encode(w io.Writer, pver uint32) error
- func (msg *NeighborRstMessage) MaxPayloadLength(uint32) uint32
- func (msg *NeighborRstMessage) String() string
- func (msg *NeighborRstMessage) Validate() error
- type NeighborUpdMessage
- func (msg *NeighborUpdMessage) Command() uint32
- func (msg *NeighborUpdMessage) Decode(r io.Reader, pver uint32) error
- func (msg *NeighborUpdMessage) Encode(w io.Writer, pver uint32) error
- func (msg *NeighborUpdMessage) MaxPayloadLength(uint32) uint32
- func (msg *NeighborUpdMessage) String() string
- func (msg *NeighborUpdMessage) Validate() error
- type PkScript
- type RoutingTableRequestMessage
- func (msg *RoutingTableRequestMessage) Command() uint32
- func (msg *RoutingTableRequestMessage) Decode(r io.Reader, pver uint32) error
- func (msg *RoutingTableRequestMessage) Encode(w io.Writer, pver uint32) error
- func (msg *RoutingTableRequestMessage) MaxPayloadLength(uint32) uint32
- func (msg *RoutingTableRequestMessage) String() string
- func (msg *RoutingTableRequestMessage) Validate() error
- type RoutingTableTransferMessage
- func (msg *RoutingTableTransferMessage) Command() uint32
- func (msg *RoutingTableTransferMessage) Decode(r io.Reader, pver uint32) error
- func (msg *RoutingTableTransferMessage) Encode(w io.Writer, pver uint32) error
- func (msg *RoutingTableTransferMessage) MaxPayloadLength(uint32) uint32
- func (msg *RoutingTableTransferMessage) String() string
- func (msg *RoutingTableTransferMessage) Validate() error
- type SingleFundingComplete
- func (s *SingleFundingComplete) Command() uint32
- func (s *SingleFundingComplete) Decode(r io.Reader, pver uint32) error
- func (s *SingleFundingComplete) Encode(w io.Writer, pver uint32) error
- func (s *SingleFundingComplete) MaxPayloadLength(uint32) uint32
- func (s *SingleFundingComplete) String() string
- func (s *SingleFundingComplete) Validate() error
- type SingleFundingOpenProof
- func (s *SingleFundingOpenProof) Command() uint32
- func (s *SingleFundingOpenProof) Decode(r io.Reader, pver uint32) error
- func (s *SingleFundingOpenProof) Encode(w io.Writer, pver uint32) error
- func (s *SingleFundingOpenProof) MaxPayloadLength(uint32) uint32
- func (s *SingleFundingOpenProof) String() string
- func (s *SingleFundingOpenProof) Validate() error
- type SingleFundingRequest
- func (c *SingleFundingRequest) Command() uint32
- func (c *SingleFundingRequest) Decode(r io.Reader, pver uint32) error
- func (c *SingleFundingRequest) Encode(w io.Writer, pver uint32) error
- func (c *SingleFundingRequest) MaxPayloadLength(uint32) uint32
- func (c *SingleFundingRequest) String() string
- func (c *SingleFundingRequest) Validate() error
- type SingleFundingResponse
- func (c *SingleFundingResponse) Command() uint32
- func (c *SingleFundingResponse) Decode(r io.Reader, pver uint32) error
- func (c *SingleFundingResponse) Encode(w io.Writer, pver uint32) error
- func (c *SingleFundingResponse) MaxPayloadLength(uint32) uint32
- func (c *SingleFundingResponse) String() string
- func (c *SingleFundingResponse) Validate() error
- type SingleFundingSignComplete
- func (c *SingleFundingSignComplete) Command() uint32
- func (c *SingleFundingSignComplete) Decode(r io.Reader, pver uint32) error
- func (c *SingleFundingSignComplete) Encode(w io.Writer, pver uint32) error
- func (c *SingleFundingSignComplete) MaxPayloadLength(uint32) uint32
- func (c *SingleFundingSignComplete) String() string
- func (s *SingleFundingSignComplete) Validate() error
Constants ¶
const ( // Commands for opening a channel funded by one party (single funder). CmdSingleFundingRequest = uint32(100) CmdSingleFundingResponse = uint32(110) CmdSingleFundingComplete = uint32(120) CmdSingleFundingSignComplete = uint32(130) CmdSingleFundingOpenProof = uint32(140) // Commands for the workflow of cooperatively closing an active channel. CmdCloseRequest = uint32(300) CmdCloseComplete = uint32(310) // Commands for negotiating HTLCs. CmdHTLCAddRequest = uint32(1000) CmdHTLCAddAccept = uint32(1010) CmdHTLCAddReject = uint32(1020) CmdHTLCSettleRequest = uint32(1100) CmdCancelHTLC = uint32(1300) // Commands for modifying commitment transactions. CmdCommitSignature = uint32(2000) CmdCommitRevocation = uint32(2010) // Commands for routing CmdNeighborHelloMessage = uint32(3000) CmdNeighborUpdMessage = uint32(3010) CmdNeighborAckMessage = uint32(3020) CmdNeighborRstMessage = uint32(3030) CmdRoutingTableRequestMessage = uint32(3040) CmdRoutingTableTransferMessage = uint32(3050) // Commands for reporting protocol errors. CmdErrorGeneric = uint32(4000) )
Commands used in lightning message headers which detail the type of message.
const MaxMessagePayload = 1024 * 1024 * 32 // 32MB
MaxMessagePayload is the maximum bytes a message can be regardless of other individual limits imposed by messages themselves.
const MaxSliceLength = 65535
MaxSliceLength is the maximum allowed lenth for any opaque byte slices in the wire protocol.
const MessageHeaderSize = 12
MessageHeaderSize is the number of bytes in a lightning message header. The bytes are allocated as follows: network magic 4 bytes + command 4 bytes + payload length 4 bytes. Note that a checksum is omitted as lightning messages are assumed to be transmitted over an AEAD secured connection which provides integrity over the entire message.
Variables ¶
This section is empty.
Functions ¶
func WriteMessage ¶
WriteMessage writes a lightning Message to w including the necessary header information and returns the number of bytes written.
Types ¶
type CancelHTLC ¶
type CancelHTLC struct { // ChannelPoint is the particular active channel that this CancelHTLC // is binded to. ChannelPoint *wire.OutPoint // HTLCKey references which HTLC on the remote node's commitment // transaction has timed out. HTLCKey HTLCKey }
CancelHTLC is sent by Alice to Bob in order to remove a previously added HTLC. Upon receipt of an CancelHTLC the HTLC should be removed from the next commitment transaction, with the CancelHTLC propgated backwards in the route to fully un-clear the HTLC.
func NewHTLCTimeoutRequest ¶
func NewHTLCTimeoutRequest() *CancelHTLC
CancelHTLC creates a new CancelHTLC message.
func (*CancelHTLC) Command ¶
func (c *CancelHTLC) Command() uint32
Command returns the integer uniquely identifying this message type on the wire.
This is part of the lnwire.Message interface.
func (*CancelHTLC) Decode ¶
func (c *CancelHTLC) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized CancelHTLC message stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CancelHTLC) Encode ¶
func (c *CancelHTLC) Encode(w io.Writer, pver uint32) error
Encode serializes the target CancelHTLC into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*CancelHTLC) MaxPayloadLength ¶
func (c *CancelHTLC) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for a CancelHTLC complete message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CancelHTLC) String ¶
func (c *CancelHTLC) String() string
String returns the string representation of the target CancelHTLC. This is part of the lnwire.Message interface.
func (*CancelHTLC) Validate ¶
func (c *CancelHTLC) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the CancelHTLC are valid.
This is part of the lnwire.Message interface.
type CloseComplete ¶
type CloseComplete struct { // ChannelPoint serves to identify which channel is to be closed. ChannelPoint *wire.OutPoint // ResponderCloseSig is the signature of the responder for the // transaction which closes the previously active channel. ResponderCloseSig *btcec.Signature }
CloseComplete is sent by Bob signalling a fufillment and completion of Alice's prior CloseRequest message. After Alice receives Bob's CloseComplete message, she is able to broadcast the fully signed transaction executing a cooperative closure of the channel.
NOTE: The responder is able to only send a signature without any additional message as all transactions are assembled observing BIP 69 which defines a cannonical ordering for input/outputs. Therefore, both sides are able to arrive at an identical closure transaction as they know the order of the inputs/outputs.
func NewCloseComplete ¶
func NewCloseComplete() *CloseComplete
NewCloseComplete creates a new empty CloseComplete message. TODO(roasbeef): add params to all constructors...
func (*CloseComplete) Command ¶
func (c *CloseComplete) Command() uint32
Command returns the integer uniquely identifying this message type on the wire.
This is part of the lnwire.Message interface.
func (*CloseComplete) Decode ¶
func (c *CloseComplete) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized CloseComplete message stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CloseComplete) Encode ¶
func (c *CloseComplete) Encode(w io.Writer, pver uint32) error
Encode serializes the target CloseComplete into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*CloseComplete) MaxPayloadLength ¶
func (c *CloseComplete) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for a CloseComplete complete message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CloseComplete) String ¶
func (c *CloseComplete) String() string
String returns the string representation of the target CloseComplete.
This is part of the lnwire.Message interface.
func (*CloseComplete) Validate ¶
func (c *CloseComplete) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the CloseComplete are valid.
This is part of the lnwire.Message interface.
type CloseRequest ¶
type CloseRequest struct { // ChannelPoint serves to identify which channel is to be closed. ChannelPoint *wire.OutPoint // RequesterCloseSig is the signature of the requester for the fully // assembled closing transaction. RequesterCloseSig *btcec.Signature // Fee is the required fee-per-KB the closing transaction must have. // It is recommended that a "sufficient" fee be paid in order to achieve // timely channel closure. // TODO(roasbeef): if initiator always pays fees, then no longer needed. Fee btcutil.Amount }
CloseRequest is sent by either side in order to initiate the cooperative closure of a channel. This message is rather sparse as both side implicitly know to craft a transaction sending the settled funds of both parties to the final delivery addresses negotiated during the funding workflow.
NOTE: The requester is able to only send a signature to initiate the cooperative channel closure as all transactions are assembled observing BIP 69 which defines a cannonical ordering for input/outputs. Therefore, both sides are able to arrive at an identical closure transaction as they know the order of the inputs/outputs.
func NewCloseRequest ¶
func NewCloseRequest(cp *wire.OutPoint, sig *btcec.Signature) *CloseRequest
NewCloseRequest creates a new CloseRequest.
func (*CloseRequest) Command ¶
func (c *CloseRequest) Command() uint32
Command returns the integer uniquely identifying this message type on the wire.
This is part of the lnwire.Message interface.
func (*CloseRequest) Decode ¶
func (c *CloseRequest) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized CloseRequest stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CloseRequest) Encode ¶
func (c *CloseRequest) Encode(w io.Writer, pver uint32) error
Encode serializes the target CloseRequest into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*CloseRequest) MaxPayloadLength ¶
func (c *CloseRequest) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for this message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CloseRequest) String ¶
func (c *CloseRequest) String() string
String returns the string representation of the target CloseRequest.
This is part of the lnwire.Message interface.
func (*CloseRequest) Validate ¶
func (c *CloseRequest) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the CloseRequest are valid.
This is part of the lnwire.Message interface.
type CommitHeight ¶
type CommitHeight uint64
CommitHeight is an integer which represents the highest HTLCKey seen by either side within their commitment transaction. Any addition to the pending, HTLC lists on either side will increment this height. As a result this value should always be monotonically increasing. Any CommitSignature or CommitRevocation messages will reference a value for the commitment height up to which it covers. HTLC's are only explicltly excluded by sending HTLCReject messages referencing a particular HTLCKey.
type CommitRevocation ¶
type CommitRevocation struct { // ChannelPoint uniquely identifies to which currently active channel this // CommitRevocation applies to. ChannelPoint *wire.OutPoint // Revocation is the pre-image to the revocation hash of the now prior // commitment transaction. // // If the received revocation is the all zeroes hash ('0' * 32), then // this CommitRevocation is being sent in order to build up the // sender's initial revocation window (IRW). In this case, the // CommitRevocation should be added to the receiver's queue of unused // revocations to be used to construct future commitment transactions. Revocation [32]byte // NextRevocationKey is the next revocation key which should be added // to the queue of unused revocation keys for the remote peer. This key // will be used within the revocation clause for any new commitment // transactions created for the remote peer. NextRevocationKey *btcec.PublicKey // NextRevocationHash is the next revocation hash which should be added // to the queue on unused revocation hashes for the remote peer. This // revocation hash will be used within any HTLC's included within this // next commitment transaction. NextRevocationHash [32]byte }
CommitRevocation is sent by either side once a CommitSignature message has been received, and validated. This message serves to revoke the prior commitment transaction, which was the most up to date version until a CommitSignature message referencing the specified ChannelPoint was received. Additionally, this message also piggyback's the next revocation hash that Alice should use when constructing the Bob's version of the next commitment transaction (which would be done before sending a CommitSignature message). This piggybacking allows Alice to send the next CommitSignature message modifying Bob's commitment transaction without first asking for a revocation hash initially. TODO(roasbeef): update docs everywhere
func NewCommitRevocation ¶
func NewCommitRevocation() *CommitRevocation
NewCommitRevocation creates a new CommitRevocation message.
func (*CommitRevocation) Command ¶
func (c *CommitRevocation) Command() uint32
Command returns the integer uniquely identifying this message type on the wire.
This is part of the lnwire.Message interface.
func (*CommitRevocation) Decode ¶
func (c *CommitRevocation) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized CommitRevocation message stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CommitRevocation) Encode ¶
func (c *CommitRevocation) Encode(w io.Writer, pver uint32) error
Encode serializes the target CommitRevocation into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*CommitRevocation) MaxPayloadLength ¶
func (c *CommitRevocation) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for a CommitRevocation complete message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CommitRevocation) String ¶
func (c *CommitRevocation) String() string
String returns the string representation of the target CommitRevocation.
This is part of the lnwire.Message interface. TODO(roasbeef): remote all String() methods...spew should be used instead.
func (*CommitRevocation) Validate ¶
func (c *CommitRevocation) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the CommitRevocation are valid.
This is part of the lnwire.Message interface.
type CommitSignature ¶
type CommitSignature struct { // ChannelPoint uniquely identifies to which currently active channel this // CommitSignature applies to. ChannelPoint *wire.OutPoint // LogIndex is the index into the reciever's HTLC log to which this // commitment signature covers. In order to properly verify this // signature, the receiver should include all the HTLC's within their // log with an index less-than-or-equal to the listed log-index. LogIndex uint64 // Fee represents the total miner's fee that was used when constructing // the new commitment transaction. // TODO(roasbeef): is the above comment correct? Fee btcutil.Amount // CommitSig is Alice's signature for Bob's new commitment transaction. // Alice is able to send this signature without requesting any additional // data due to the piggybacking of Bob's next revocation hash in his // prior CommitRevocation message, as well as the cannonical ordering // used for all inputs/outputs within commitment transactions. CommitSig *btcec.Signature }
CommitSignature is sent by either side to stage any pending HTLC's in the reciever's pending set which has not explcitly been rejected via an HTLCAddReject message. Implictly, the new commitment transaction constructed which has been signed by CommitSig includes all HTLC's in the remote node's pending set. A CommitSignature message may be sent after a series of HTLCAdd messages in order to batch add several HTLC's with a single signature covering all implicitly accepted HTLC's.
func NewCommitSignature ¶
func NewCommitSignature() *CommitSignature
NewCommitSignature creates a new empty CommitSignature message.
func (*CommitSignature) Command ¶
func (c *CommitSignature) Command() uint32
Command returns the integer uniquely identifying this message type on the wire.
This is part of the lnwire.Message interface.
func (*CommitSignature) Decode ¶
func (c *CommitSignature) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized CommitSignature message stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CommitSignature) Encode ¶
func (c *CommitSignature) Encode(w io.Writer, pver uint32) error
Encode serializes the target CommitSignature into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*CommitSignature) MaxPayloadLength ¶
func (c *CommitSignature) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for a CommitSignature complete message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*CommitSignature) String ¶
func (c *CommitSignature) String() string
String returns the string representation of the target CommitSignature.
This is part of the lnwire.Message interface.
func (*CommitSignature) Validate ¶
func (c *CommitSignature) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the CommitSignature are valid.
This is part of the lnwire.Message interface.
type CreditsAmount ¶
type CreditsAmount int64
CreditsAmount are the native currency unit used within the Lightning Network. Credits are denominated in sub-satoshi amounts, so micro-satoshis (1/1000). This value is purposefully signed in order to allow the expression of negative fees.
"In any science-fiction movie, anywhere in the galaxy, currency is referred to as 'credits.'"
--Sam Humphries. Ebert, Roger (1999). Ebert's bigger little movie glossary. Andrews McMeel. p. 172.
https://en.wikipedia.org/wiki/List_of_fictional_currencies https://en.wikipedia.org/wiki/Fictional_currency#Trends_in_the_use_of_fictional_currencies http://tvtropes.org/pmwiki/pmwiki.php/Main/WeWillSpendCreditsInTheFuture US Display format: 1 BTC = 100,000,000'000 XCB Or in BTC = 1.00000000'000 Credits (XCB, accountants should use XCB :^)
func (CreditsAmount) ToSatoshi ¶
func (c CreditsAmount) ToSatoshi() int64
ToSatoshi converts an amount in Credits to the coresponding amount expressed in Satoshis.
NOTE: This function rounds down by default (floor).
type ErrorGeneric ¶
type ErrorGeneric struct { // ChannelPoint references the active channel in which the error occured // within. A ChannelPoint of zeroHash:0 denotes this error applies to // the entire established connection. ChannelPoint *wire.OutPoint // ErrorID quickly defines the nature of the error according to error // type. ErrorID uint16 // Problem is a human-readable string further elaborating upon the // nature of the exact error. The maxmium allowed length of this // message is 8192 bytes. Problem string }
ErrorGeneric represents a generic error bound to an exact channel. The message format is purposefully general in order to allow expressino of a wide array of possible errors. Each ErrorGeneric message is directed at a particular open channel referenced by ChannelPoint.
func NewErrorGeneric ¶
func NewErrorGeneric() *ErrorGeneric
NewErrorGeneric creates a new ErrorGeneric message.
func (*ErrorGeneric) Command ¶
func (c *ErrorGeneric) Command() uint32
Command returns the integer uniquely identifying an ErrorGeneric message on the wire.
This is part of the lnwire.Message interface.
func (*ErrorGeneric) Decode ¶
func (c *ErrorGeneric) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized ErrorGeneric message stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*ErrorGeneric) Encode ¶
func (c *ErrorGeneric) Encode(w io.Writer, pver uint32) error
Encode serializes the target ErrorGeneric into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*ErrorGeneric) MaxPayloadLength ¶
func (c *ErrorGeneric) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for a ErrorGeneric complete message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*ErrorGeneric) String ¶
func (c *ErrorGeneric) String() string
String returns the string representation of the target ErrorGeneric.
This is part of the lnwire.Message interface.
func (*ErrorGeneric) Validate ¶
func (c *ErrorGeneric) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the ErrorGeneric are valid.
This is part of the lnwire.Message interface.
type HTLCAddReject ¶
type HTLCAddReject struct { // ChannelPoint references the particular active channel to which this // HTLCAddReject message is binded to. ChannelPoint *wire.OutPoint // HTLCKey is used to identify which HTLC previously attempted to be // added via an HTLCAddRequest message is being declined. HTLCKey HTLCKey }
HTLCAddReject is sent by Bob when he wishes to reject a particular HTLC that Alice attempted to add via an HTLCAddRequest message. The rejected HTLC is referenced by its unique HTLCKey ID. An HTLCAddReject message is bound to a single active channel, referenced by a unique ChannelPoint. Additionally, the HTLCKey of the rejected HTLC is present
func NewHTLCAddReject ¶
func NewHTLCAddReject() *HTLCAddReject
NewHTLCAddReject returns a new empty HTLCAddReject message.
func (*HTLCAddReject) Command ¶
func (c *HTLCAddReject) Command() uint32
Command returns the integer uniquely identifying this message type on the wire.
This is part of the lnwire.Message interface.
func (*HTLCAddReject) Decode ¶
func (c *HTLCAddReject) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized HTLCAddReject message stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*HTLCAddReject) Encode ¶
func (c *HTLCAddReject) Encode(w io.Writer, pver uint32) error
Encode serializes the target HTLCAddReject into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*HTLCAddReject) MaxPayloadLength ¶
func (c *HTLCAddReject) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for a HTLCAddReject complete message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*HTLCAddReject) String ¶
func (c *HTLCAddReject) String() string
String returns the string representation of the target HTLCAddReject.
This is part of the lnwire.Message interface.
func (*HTLCAddReject) Validate ¶
func (c *HTLCAddReject) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the HTLCAddReject are valid.
This is part of the lnwire.Message interface.
type HTLCAddRequest ¶
type HTLCAddRequest struct { // ChannelPoint is the particular active channel that this HTLCAddRequest // is binded to. ChannelPoint *wire.OutPoint // Expiry is the number of blocks after which this HTLC should expire. // It is the receiver's duty to ensure that the outgoing HTLC has a // sufficient expiry value to allow her to redeem the incmoing HTLC. Expiry uint32 // Amount is the number of credits this HTLC is worth. Amount CreditsAmount // RefundContext is for payment cancellation // TODO(j): not currently in use, add later RefundContext HTLCKey // ContractType defines the particular output script to be used for // this HTLC. This value defaults to zero for regular HTLCs. For // multi-sig HTLCs, then first 4 bit represents N, while the second 4 // bits are M, within the N-of-M multi-sig. ContractType uint8 // RedemptionHashes are the hashes to be used within the HTLC script. // An HTLC is only fufilled once Bob is provided with the required // number of pre-images for each of the listed hashes. For regular HTLC's // this slice only has one hash. However, for "multi-sig" HTLC's, the // length of this slice should be N. RedemptionHashes [][32]byte // OnionBlob is the raw serialized mix header used to route an HTLC in // a privacy-preserving manner. The mix header is defined currently to // be parsed as a 4-tuple: (groupElement, routingInfo, headerMAC, body). // First the receiving node should use the groupElement, and its current // onion key to derive a shared secret with the source. Once the shared // secret has been derived, the headerMAC should be checked FIRST. Note // that the MAC only covers the routingInfo field. If the MAC matches, // and the shared secret is fresh, then the node should stip off a layer // of encryption, exposing the next hop to be used in the subsequent // HTLCAddRequest message. OnionBlob []byte }
HTLCAddRequest is the message sent by Alice to Bob when she wishes to add an HTLC to his remote commitment transaction. In addition to information detailing the value, and contract type of the HTLC, and onion blob is also included which allows Bob to derive the next hop in the route. The HTLC added by this message is to be added to the remote node's "pending" HTLC's. A subsequent CommitSignature message will move the pending HTLC to the newly created commitment transaction, marking them as "staged".
func NewHTLCAddRequest ¶
func NewHTLCAddRequest() *HTLCAddRequest
NewHTLCAddRequest returns a new empty HTLCAddRequest message.
func (*HTLCAddRequest) Command ¶
func (c *HTLCAddRequest) Command() uint32
Command returns the integer uniquely identifying this message type on the wire.
This is part of the lnwire.Message interface.
func (*HTLCAddRequest) Decode ¶
func (c *HTLCAddRequest) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized HTLCAddRequest message stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*HTLCAddRequest) Encode ¶
func (c *HTLCAddRequest) Encode(w io.Writer, pver uint32) error
Encode serializes the target HTLCAddRequest into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*HTLCAddRequest) MaxPayloadLength ¶
func (c *HTLCAddRequest) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for a HTLCAddRequest complete message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*HTLCAddRequest) String ¶
func (c *HTLCAddRequest) String() string
String returns the string representation of the target HTLCAddRequest.
This is part of the lnwire.Message interface.
func (*HTLCAddRequest) Validate ¶
func (c *HTLCAddRequest) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the HTLCAddRequest are valid.
This is part of the lnwire.Message interface.
type HTLCKey ¶
type HTLCKey int64
HTLCKey is an identifier used to uniquely identify any HTLC's transmitted between Alice and Bob. In order to cancel, timeout, or settle HTLC's this identifier should be used to allow either side to easily locate and modify any staged or pending HTLCs. TODO(roasbeef): change to HTLCIdentifier?
type HTLCSettleRequest ¶
type HTLCSettleRequest struct { // ChannelPoint references an active channel which holds the HTLC to be // settled. ChannelPoint *wire.OutPoint // HTLCKey denotes the exact HTLC stage within the receiving node's // commitment transaction to be removed. // TODO(roasbeef): rename to LogIndex HTLCKey HTLCKey // RedemptionProofs are the R-value preimages required to fully settle // an HTLC. The number of preimages in the slice will depend on the // specific ContractType of the referenced HTLC. RedemptionProofs [][32]byte }
HTLCSettleRequest is sent by Alice to Bob when she wishes to settle a particular HTLC referenced by its HTLCKey within a specific active channel referenced by ChannelPoint. The message allows multiple hash preimages to be presented in order to support N-of-M HTLC contracts. A subsequent CommitSignature message will be sent by Alice to "lock-in" the removal of the specified HTLC, possible containing a batch signature covering several settled HTLC's.
func NewHTLCSettleRequest ¶
func NewHTLCSettleRequest(chanPoint *wire.OutPoint, key HTLCKey, redemptionProofs [][32]byte) *HTLCSettleRequest
NewHTLCSettleRequest returns a new empty HTLCSettleRequest.
func (*HTLCSettleRequest) Command ¶
func (c *HTLCSettleRequest) Command() uint32
Command returns the integer uniquely identifying this message type on the wire.
This is part of the lnwire.Message interface.
func (*HTLCSettleRequest) Decode ¶
func (c *HTLCSettleRequest) Decode(r io.Reader, pver uint32) error
Decode deserializes a serialized HTLCSettleRequest message stored in the passed io.Reader observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*HTLCSettleRequest) Encode ¶
func (c *HTLCSettleRequest) Encode(w io.Writer, pver uint32) error
Encode serializes the target HTLCSettleRequest into the passed io.Writer observing the protocol version specified.
This is part of the lnwire.Message interface.
func (*HTLCSettleRequest) MaxPayloadLength ¶
func (c *HTLCSettleRequest) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload size for a HTLCSettleRequest complete message observing the specified protocol version.
This is part of the lnwire.Message interface.
func (*HTLCSettleRequest) String ¶
func (c *HTLCSettleRequest) String() string
String returns the string representation of the target HTLCSettleRequest.
This is part of the lnwire.Message interface.
func (*HTLCSettleRequest) Validate ¶
func (c *HTLCSettleRequest) Validate() error
Validate performs any necessary sanity checks to ensure all fields present on the HTLCSettleRequest are valid.
This is part of the lnwire.Message interface.
type Message ¶
type Message interface { Decode(io.Reader, uint32) error Encode(io.Writer, uint32) error Command() uint32 MaxPayloadLength(uint32) uint32 Validate() error String() string }
Message is an interface that defines a lightning wire protocol message. The interface is general in order to allow implementing types full control over the representation of its data.
func ReadMessage ¶
ReadMessageN reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the number of bytes read in addition to the parsed Message and raw bytes which comprise the message. This function is the same as ReadMessage except it also returns the number of bytes read.
type NeighborAckMessage ¶
type NeighborAckMessage struct { }
func (*NeighborAckMessage) Command ¶
func (msg *NeighborAckMessage) Command() uint32
func (*NeighborAckMessage) Decode ¶
func (msg *NeighborAckMessage) Decode(r io.Reader, pver uint32) error
func (*NeighborAckMessage) Encode ¶
func (msg *NeighborAckMessage) Encode(w io.Writer, pver uint32) error
func (*NeighborAckMessage) MaxPayloadLength ¶
func (msg *NeighborAckMessage) MaxPayloadLength(uint32) uint32
func (*NeighborAckMessage) String ¶
func (msg *NeighborAckMessage) String() string
func (*NeighborAckMessage) Validate ¶
func (msg *NeighborAckMessage) Validate() error
type NeighborHelloMessage ¶
type NeighborHelloMessage struct {
RT *rt.RoutingTable
}
func (*NeighborHelloMessage) Command ¶
func (msg *NeighborHelloMessage) Command() uint32
func (*NeighborHelloMessage) Decode ¶
func (msg *NeighborHelloMessage) Decode(r io.Reader, pver uint32) error
func (*NeighborHelloMessage) Encode ¶
func (msg *NeighborHelloMessage) Encode(w io.Writer, pver uint32) error
func (*NeighborHelloMessage) MaxPayloadLength ¶
func (msg *NeighborHelloMessage) MaxPayloadLength(uint32) uint32
func (*NeighborHelloMessage) String ¶
func (msg *NeighborHelloMessage) String() string
func (*NeighborHelloMessage) Validate ¶
func (msg *NeighborHelloMessage) Validate() error
type NeighborRstMessage ¶
type NeighborRstMessage struct { }
func (*NeighborRstMessage) Command ¶
func (msg *NeighborRstMessage) Command() uint32
func (*NeighborRstMessage) Decode ¶
func (msg *NeighborRstMessage) Decode(r io.Reader, pver uint32) error
func (*NeighborRstMessage) Encode ¶
func (msg *NeighborRstMessage) Encode(w io.Writer, pver uint32) error
func (*NeighborRstMessage) MaxPayloadLength ¶
func (msg *NeighborRstMessage) MaxPayloadLength(uint32) uint32
func (*NeighborRstMessage) String ¶
func (msg *NeighborRstMessage) String() string
func (*NeighborRstMessage) Validate ¶
func (msg *NeighborRstMessage) Validate() error
type NeighborUpdMessage ¶
type NeighborUpdMessage struct {
DiffBuff *rt.DifferenceBuffer
}
func (*NeighborUpdMessage) Command ¶
func (msg *NeighborUpdMessage) Command() uint32
func (*NeighborUpdMessage) Decode ¶
func (msg *NeighborUpdMessage) Decode(r io.Reader, pver uint32) error
func (*NeighborUpdMessage) Encode ¶
func (msg *NeighborUpdMessage) Encode(w io.Writer, pver uint32) error
func (*NeighborUpdMessage) MaxPayloadLength ¶
func (msg *NeighborUpdMessage) MaxPayloadLength(uint32) uint32
func (*NeighborUpdMessage) String ¶
func (msg *NeighborUpdMessage) String() string
func (*NeighborUpdMessage) Validate ¶
func (msg *NeighborUpdMessage) Validate() error
type PkScript ¶
type PkScript []byte
PkScript is simple type definition which represents a raw serialized public key script.
type RoutingTableRequestMessage ¶
type RoutingTableRequestMessage struct { }
func (*RoutingTableRequestMessage) Command ¶
func (msg *RoutingTableRequestMessage) Command() uint32
func (*RoutingTableRequestMessage) Decode ¶
func (msg *RoutingTableRequestMessage) Decode(r io.Reader, pver uint32) error
func (*RoutingTableRequestMessage) Encode ¶
func (msg *RoutingTableRequestMessage) Encode(w io.Writer, pver uint32) error
func (*RoutingTableRequestMessage) MaxPayloadLength ¶
func (msg *RoutingTableRequestMessage) MaxPayloadLength(uint32) uint32
func (*RoutingTableRequestMessage) String ¶
func (msg *RoutingTableRequestMessage) String() string
func (*RoutingTableRequestMessage) Validate ¶
func (msg *RoutingTableRequestMessage) Validate() error
type RoutingTableTransferMessage ¶
type RoutingTableTransferMessage struct {
RT *rt.RoutingTable
}
func (*RoutingTableTransferMessage) Command ¶
func (msg *RoutingTableTransferMessage) Command() uint32
func (*RoutingTableTransferMessage) Decode ¶
func (msg *RoutingTableTransferMessage) Decode(r io.Reader, pver uint32) error
func (*RoutingTableTransferMessage) Encode ¶
func (msg *RoutingTableTransferMessage) Encode(w io.Writer, pver uint32) error
func (*RoutingTableTransferMessage) MaxPayloadLength ¶
func (msg *RoutingTableTransferMessage) MaxPayloadLength(uint32) uint32
func (*RoutingTableTransferMessage) String ¶
func (msg *RoutingTableTransferMessage) String() string
func (*RoutingTableTransferMessage) Validate ¶
func (msg *RoutingTableTransferMessage) Validate() error
type SingleFundingComplete ¶
type SingleFundingComplete struct { // ChannelID serves to uniquely identify the future channel created by // the initiated single funder workflow. // TODO(roasbeef): change all to PendingChannelID, document schema ChannelID uint64 // FundingOutPoint is the outpoint (txid:index) of the funding // transaction. With this value, Bob will be able to generate a // signature for Alice's version of the commitment transaction. FundingOutPoint *wire.OutPoint // CommitSignature is Alice's signature for Bob's version of the // commitment transaction. CommitSignature *btcec.Signature // RevocationKey is the initial key to be used for the revocation // clause within the self-output of the initiators's commitment // transaction. Once an initial new state is created, the initiator // will send a pre-image which will allow the initiator to sweep the // initiator's funds if the violate the contract. RevocationKey *btcec.PublicKey }
SingleFundingComplete is the message Alice sends to Bob once she is able to fully assemble the funding transaction, and both versions of the commitment transaction. The purpose of this message is to present Bob with the items required for him to generate a signature for Alice's version of the commitment transaction.
func NewSingleFundingComplete ¶
func NewSingleFundingComplete(chanID uint64, fundingPoint *wire.OutPoint, commitSig *btcec.Signature, revokeKey *btcec.PublicKey) *SingleFundingComplete
NewSingleFundingComplete creates, and returns a new empty SingleFundingResponse.
func (*SingleFundingComplete) Command ¶
func (s *SingleFundingComplete) Command() uint32
Command returns the uint32 code which uniquely identifies this message as a SingleFundingRequest on the wire.
This is part of the lnwire.Message interface.
func (*SingleFundingComplete) Decode ¶
func (s *SingleFundingComplete) Decode(r io.Reader, pver uint32) error
Decode deserializes the serialized SingleFundingComplete stored in the passed io.Reader into the target SingleFundingComplete using the deserialization rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingComplete) Encode ¶
func (s *SingleFundingComplete) Encode(w io.Writer, pver uint32) error
Encode serializes the target SingleFundingComplete into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingComplete) MaxPayloadLength ¶
func (s *SingleFundingComplete) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload length for a SingleFundingComplete. This is calculated by summing the max length of all the fields within a SingleFundingResponse. Therefore, the final breakdown is: 8 + 36 + 73 = 150
This is part of the lnwire.Message interface.
func (*SingleFundingComplete) String ¶
func (s *SingleFundingComplete) String() string
String returns the string representation of the SingleFundingResponse.
This is part of the lnwire.Message interface.
func (*SingleFundingComplete) Validate ¶
func (s *SingleFundingComplete) Validate() error
Validate examines each populated field within the SingleFundingComplete for field sanity.
This is part of the lnwire.Message interface.
type SingleFundingOpenProof ¶
type SingleFundingOpenProof struct { // ChannelID serves to uniquely identify the future channel created by // the initiated single funder workflow. ChannelID uint64 // SpvProof is an merkle proof of the inclusion of the funding // transaction within a block. // TODO(roasbeef): spec out format for SPV proof, only of single tx so // can be compact SpvProof []byte }
SingleFundingOpenProof is the message sent by the channel initiator to the responder after the previously constructed funding transaction has achieved a sufficient number of confirmations. It is the initiator's duty to present a proof of an open channel to the responder. Otherwise, responding node may be vulernable to a resource exhasution attack wherein the a requesting node repeatedly negotiates funding transactions which are never broadcast. If the responding node commits resources to watch the chain for each funding transaction, then this attack is very cheap for the initiator.
func NewSingleFundingOpenProof ¶
func NewSingleFundingOpenProof(chanID uint64, spvProof []byte) *SingleFundingOpenProof
NewSingleFundingSignComplete creates a new empty SingleFundingOpenProof message.
func (*SingleFundingOpenProof) Command ¶
func (s *SingleFundingOpenProof) Command() uint32
Command returns the uint32 code which uniquely identifies this message as a SingleFundingSignComplete on the wire.
This is part of the lnwire.Message interface.
func (*SingleFundingOpenProof) Decode ¶
func (s *SingleFundingOpenProof) Decode(r io.Reader, pver uint32) error
Decode deserializes the serialized SingleFundingOpenProof stored in the passed io.Reader into the target SingleFundingOpenProof using the deserialization rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingOpenProof) Encode ¶
func (s *SingleFundingOpenProof) Encode(w io.Writer, pver uint32) error
Encode serializes the target SingleFundingOpenProof into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingOpenProof) MaxPayloadLength ¶
func (s *SingleFundingOpenProof) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload length for a SingleFundingComplete. This is calculated by summing the max length of all the fields within a SingleFundingOpenProof.
This is part of the lnwire.Message interface.
func (*SingleFundingOpenProof) String ¶
func (s *SingleFundingOpenProof) String() string
String returns the string representation of the SingleFundingOpenProof.
This is part of the lnwire.Message interface.
func (*SingleFundingOpenProof) Validate ¶
func (s *SingleFundingOpenProof) Validate() error
Validate examines each populated field within the SingleFundingOpenProof for field sanity.
This is part of the lnwire.Message interface.
type SingleFundingRequest ¶
type SingleFundingRequest struct { // ChannelID serves to uniquely identify the future channel created by // the initiated single funder workflow. ChannelID uint64 // ChannelType represents the type of channel this request would like // to open. At this point, the only supported channels are type 0 // channels, which are channels with regular commitment transactions // utilizing HTLC's for payments. ChannelType uint8 // CoinType represents which blockchain the channel will be opened // using. By default, this field should be set to 0, indicating usage // of the Bitcoin blockchain. CoinType uint64 // FeePerKb is the required number of satoshis per KB that the // requester will pay at all timers, for both the funding transaction // and commitment transaction. This value can later be updated once the // channel is open. FeePerKb btcutil.Amount // FundingAmount is the number of satoshis the the initiator would like // to commit to the channel. FundingAmount btcutil.Amount // CsvDelay is the number of blocks to use for the relative time lock // in the pay-to-self output of both commitment transactions. CsvDelay uint32 // CommitmentKey is key the initiator of the funding workflow wishes to // use within their versino of the commitment transaction for any // delayed (CSV) or immediate outputs to them. CommitmentKey *btcec.PublicKey // ChannelDerivationPoint is an secp256k1 point which will be used to // derive the public key the initiator will use for the half of the // 2-of-2 multi-sig. Using the channel derivation point (CDP), and the // initiators identity public key (A), the channel public key is // computed as: C = A + CDP. In order to be valid all CDP's MUST have // an odd y-coordinate. ChannelDerivationPoint *btcec.PublicKey // DeliveryPkScript defines the public key script that the initiator // would like to use to receive their balance in the case of a // cooperative close. Only the following script templates are // supported: P2PKH, P2WKH, P2SH, and P2WSH. DeliveryPkScript PkScript }
SingleFundingRequest is the message Alice sends to Bob if we should like to create a channel with Bob where she's the sole provider of funds to the channel. Single funder channels simplify the initial funding workflow, are supported by nodes backed by SPV Bitcoin clients, and have a simpler security models than dual funded channels.
NOTE: In order to avoid a slow loris like resource exhaustion attack, the responder of a single funding channel workflow *should not* watch the blockchain for the funding transaction. Instead, it is the initiator's job to provide the responder with an SPV proof of funding transaction inclusion after a sufficient number of confirmations.
func NewSingleFundingRequest ¶
func NewSingleFundingRequest(chanID uint64, chanType uint8, coinType uint64, fee btcutil.Amount, amt btcutil.Amount, delay uint32, ck, cdp *btcec.PublicKey, deliveryScript PkScript) *SingleFundingRequest
NewSingleFundingRequest creates, and returns a new empty SingleFundingRequest.
func (*SingleFundingRequest) Command ¶
func (c *SingleFundingRequest) Command() uint32
Command returns the uint32 code which uniquely identifies this message as a SingleFundingRequest on the wire.
This is part of the lnwire.Message interface.
func (*SingleFundingRequest) Decode ¶
func (c *SingleFundingRequest) Decode(r io.Reader, pver uint32) error
Decode deserializes the serialized SingleFundingRequest stored in the passed io.Reader into the target SingleFundingRequest using the deserialization rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingRequest) Encode ¶
func (c *SingleFundingRequest) Encode(w io.Writer, pver uint32) error
Encode serializes the target SingleFundingRequest into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingRequest) MaxPayloadLength ¶
func (c *SingleFundingRequest) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload length for a SingleFundingRequest. This is calculated by summing the max length of all the fields within a SingleFundingRequest. To enforce a maximum DeliveryPkScript size, the size of a P2PKH public key script is used. Therefore, the final breakdown is: 8 + 1 + 8 + 8 + 8 + 4 + 33 + 33 + 25 = 158.
This is part of the lnwire.Message interface.
func (*SingleFundingRequest) String ¶
func (c *SingleFundingRequest) String() string
String returns the string representation of the SingleFundingRequest.
This is part of the lnwire.Message interface.
func (*SingleFundingRequest) Validate ¶
func (c *SingleFundingRequest) Validate() error
Validate examines each populated field within the SingleFundingRequest for field sanity. For example, all fields MUST NOT be negative, and all pkScripts must belong to the allowed set of public key scripts.
This is part of the lnwire.Message interface.
type SingleFundingResponse ¶
type SingleFundingResponse struct { // ChannelID serves to uniquely identify the future channel created by // the initiated single funder workflow. ChannelID uint64 // ChannelDerivationPoint is an secp256k1 point which will be used to // derive the public key the responder will use for the half of the // 2-of-2 multi-sig. Using the channel derivation point (CDP), and the // responder's identity public key (A), the channel public key is // computed as: C = A + CDP. In order to be valid all CDP's MUST have // an odd y-coordinate. ChannelDerivationPoint *btcec.PublicKey // CommitmentKey is key the responder to the funding workflow wishes to // use within their versino of the commitment transaction for any // delayed (CSV) or immediate outputs to them. CommitmentKey *btcec.PublicKey // RevocationKey is the initial key to be used for the revocation // clause within the self-output of the responder's commitment // transaction. Once an initial new state is created, the responder // will send a pre-image which will allow the initiator to sweep the // responder's funds if the violate the contract. RevocationKey *btcec.PublicKey // CsvDelay is the number of blocks to use for the relative time lock // in the pay-to-self output of both commitment transactions. CsvDelay uint32 // DeliveryPkScript defines the public key script that the initiator // would like to use to receive their balance in the case of a // cooperative close. Only the following script templates are // supported: P2PKH, P2WKH, P2SH, and P2WSH. DeliveryPkScript PkScript }
SingleFundingResponse is the message Bob sends to Alice after she initiates the single funder channel workflow via a SingleFundingRequest message. Once Alice receives Bob's reponse, then she has all the items neccessary to construct the funding transaction, and both commitment transactions.
func NewSingleFundingResponse ¶
func NewSingleFundingResponse(chanID uint64, rk, ck, cdp *btcec.PublicKey, delay uint32, deliveryScript PkScript) *SingleFundingResponse
NewSingleFundingResponse creates, and returns a new empty SingleFundingResponse.
func (*SingleFundingResponse) Command ¶
func (c *SingleFundingResponse) Command() uint32
Command returns the uint32 code which uniquely identifies this message as a SingleFundingRequest on the wire.
This is part of the lnwire.Message interface.
func (*SingleFundingResponse) Decode ¶
func (c *SingleFundingResponse) Decode(r io.Reader, pver uint32) error
Decode deserializes the serialized SingleFundingResponse stored in the passed io.Reader into the target SingleFundingResponse using the deserialization rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingResponse) Encode ¶
func (c *SingleFundingResponse) Encode(w io.Writer, pver uint32) error
Encode serializes the target SingleFundingResponse into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingResponse) MaxPayloadLength ¶
func (c *SingleFundingResponse) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload length for a SingleFundingResponse. This is calculated by summing the max length of all the fields within a SingleFundingResponse. To enforce a maximum DeliveryPkScript size, the size of a P2PKH public key script is used. Therefore, the final breakdown is: 8 + (33 * 3) + 8 + 25
This is part of the lnwire.Message interface.
func (*SingleFundingResponse) String ¶
func (c *SingleFundingResponse) String() string
String returns the string representation of the SingleFundingResponse.
This is part of the lnwire.Message interface.
func (*SingleFundingResponse) Validate ¶
func (c *SingleFundingResponse) Validate() error
Validate examines each populated field within the SingleFundingResponse for field sanity. For example, all fields MUST NOT be negative, and all pkScripts must belong to the allowed set of public key scripts.
This is part of the lnwire.Message interface.
type SingleFundingSignComplete ¶
type SingleFundingSignComplete struct { // ChannelID serves to uniquely identify the future channel created by // the initiated single funder workflow. ChannelID uint64 // CommitSignature is Bobs's signature for Alice's version of the // commitment transaction. CommitSignature *btcec.Signature }
SingleFundingSignComplete is the message Bob sends to Alice which delivers a signature for Alice's version of the commitment transaction. After thie message is received and processed by Alice, she is free to broadcast the funding transaction.
func NewSingleFundingSignComplete ¶
func NewSingleFundingSignComplete(chanID uint64, sig *btcec.Signature) *SingleFundingSignComplete
NewSingleFundingSignComplete creates a new empty SingleFundingSignComplete message.
func (*SingleFundingSignComplete) Command ¶
func (c *SingleFundingSignComplete) Command() uint32
Command returns the uint32 code which uniquely identifies this message as a SingleFundingSignComplete on the wire.
This is part of the lnwire.Message interface.
func (*SingleFundingSignComplete) Decode ¶
func (c *SingleFundingSignComplete) Decode(r io.Reader, pver uint32) error
Decode deserializes the serialized SingleFundingSignComplete stored in the passed io.Reader into the target SingleFundingComplete using the deserialization rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingSignComplete) Encode ¶
func (c *SingleFundingSignComplete) Encode(w io.Writer, pver uint32) error
Encode serializes the target SingleFundingSignComplete into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.
This is part of the lnwire.Message interface.
func (*SingleFundingSignComplete) MaxPayloadLength ¶
func (c *SingleFundingSignComplete) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum allowed payload length for a SingleFundingComplete. This is calculated by summing the max length of all the fields within a SingleFundingResponse. The final breakdown is: 8 + 73 = 81
This is part of the lnwire.Message interface.
func (*SingleFundingSignComplete) String ¶
func (c *SingleFundingSignComplete) String() string
String returns the string representation of the SingleFundingSignComplete.
This is part of the lnwire.Message interface.
func (*SingleFundingSignComplete) Validate ¶
func (s *SingleFundingSignComplete) Validate() error
Validate examines each populated field within the SingleFundingComplete for field sanity.
This is part of the lnwire.Message interface.
Source Files ¶
- close_complete.go
- close_request.go
- commit_revocation.go
- commit_signature.go
- error_generic.go
- htlc_addreject.go
- htlc_addrequest.go
- htlc_cancel.go
- htlc_settlerequest.go
- lnwire.go
- message.go
- neighbor_ack.go
- neighbor_hello.go
- neighbor_rst.go
- neighbor_upd.go
- routing_table_request.go
- routing_table_transfer.go
- single_funding_complete.go
- single_funding_open_proof.go
- single_funding_request.go
- single_funding_response.go
- single_funding_signcomplete.go