lnwire: add a HtlcSigs field to the CommitSig message

This commit adds a new field to the CommitSig message: HtlcSigs. This
new field will house signatures for each of the HTLC’s on the newly
created commitment state. This addition allows us to implement the new
commitment transaction structure outlined within the specification
which modifies HTLC’s such that the claiming process is now a two-phase
process. The first state transitions an HTLC to the delay+claim state,
and the second state (after the delay has passed) allows the
broadcaster of the commitment transaction to sweep the HTLC’s.

Fixes #61.
This commit is contained in:
Olaoluwa Osuntokun 2017-07-28 16:30:02 -07:00
parent be67bd46cd
commit 364a9a8059
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -23,10 +23,19 @@ type CommitSig struct {
// additional data due to the piggybacking of Bob's next revocation // additional data due to the piggybacking of Bob's next revocation
// hash in his prior RevokeAndAck message, as well as the canonical // hash in his prior RevokeAndAck message, as well as the canonical
// ordering used for all inputs/outputs within commitment transactions. // ordering used for all inputs/outputs within commitment transactions.
// If initiating a new commitment state, this signature shoud ONLY
// cover all of the sending party's pending log updates, and the log
// updates of the remote party that have been ACK'd.
CommitSig *btcec.Signature CommitSig *btcec.Signature
// TODO(roasbeef): add HTLC sigs after state machine is updated to // HtlcSigs is a signature for each relevant HTLC output within the
// support that // created commitment. The order of the signatures is expected to be
// identical to the placement of the HTLC's within the BIP 69 sorted
// commitment transaction. For each outgoing HTLC (from the PoV of the
// sender of this message), a signature for a HTLC timeout transaction
// should be signed, for each incoming HTLC the HTLC timeout
// transaction should be signed.
HtlcSigs []*btcec.Signature
} }
// NewCommitSig creates a new empty CommitSig message. // NewCommitSig creates a new empty CommitSig message.
@ -46,6 +55,7 @@ func (c *CommitSig) Decode(r io.Reader, pver uint32) error {
return readElements(r, return readElements(r,
&c.ChanID, &c.ChanID,
&c.CommitSig, &c.CommitSig,
&c.HtlcSigs,
) )
} }
@ -57,6 +67,7 @@ func (c *CommitSig) Encode(w io.Writer, pver uint32) error {
return writeElements(w, return writeElements(w,
c.ChanID, c.ChanID,
c.CommitSig, c.CommitSig,
c.HtlcSigs,
) )
} }
@ -73,6 +84,6 @@ func (c *CommitSig) MsgType() MessageType {
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *CommitSig) MaxPayloadLength(uint32) uint32 { func (c *CommitSig) MaxPayloadLength(uint32) uint32 {
// 32 + 64 // 32 + 64 + 2 + max_allowed_htlcs
return 96 return MaxMessagePayload
} }