lnwire: add a LogIndex
field to CommitSignature
This commit updates the CommitSignature message to match the latest version of the state-machine protocol. The log index specifies up to which index in the receiver’s HTLC log the sender’s signature covers.
This commit is contained in:
parent
bba9b665ef
commit
7c7ed5e638
@ -21,6 +21,12 @@ type CommitSignature struct {
|
|||||||
// CommitSignature applies to.
|
// CommitSignature applies to.
|
||||||
ChannelPoint *wire.OutPoint
|
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
|
// Fee represents the total miner's fee that was used when constructing
|
||||||
// the new commitment transaction.
|
// the new commitment transaction.
|
||||||
// TODO(roasbeef): is the above comment correct?
|
// TODO(roasbeef): is the above comment correct?
|
||||||
@ -49,10 +55,12 @@ var _ Message = (*CommitSignature)(nil)
|
|||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (c *CommitSignature) Decode(r io.Reader, pver uint32) error {
|
func (c *CommitSignature) Decode(r io.Reader, pver uint32) error {
|
||||||
// ChannelPoint(8)
|
// ChannelPoint(8)
|
||||||
|
// LogIndex(8)
|
||||||
// Fee(8)
|
// Fee(8)
|
||||||
// RequesterCommitSig(73max+2)
|
// RequesterCommitSig(73max+2)
|
||||||
err := readElements(r,
|
err := readElements(r,
|
||||||
&c.ChannelPoint,
|
&c.ChannelPoint,
|
||||||
|
&c.LogIndex,
|
||||||
&c.Fee,
|
&c.Fee,
|
||||||
&c.CommitSig,
|
&c.CommitSig,
|
||||||
)
|
)
|
||||||
@ -68,9 +76,16 @@ func (c *CommitSignature) Decode(r io.Reader, pver uint32) error {
|
|||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (c *CommitSignature) Encode(w io.Writer, pver uint32) error {
|
func (c *CommitSignature) Encode(w io.Writer, pver uint32) error {
|
||||||
// TODO(roasbeef): make similar modificaiton to all other encode/decode
|
err := writeElements(w,
|
||||||
// messags
|
c.ChannelPoint,
|
||||||
return writeElements(w, c.ChannelPoint, c.Fee, c.CommitSig)
|
c.LogIndex,
|
||||||
|
c.Fee,
|
||||||
|
c.CommitSig,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command returns the integer uniquely identifying this message type on the
|
// Command returns the integer uniquely identifying this message type on the
|
||||||
|
@ -9,11 +9,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCommitSignatureEncodeDecode(t *testing.T) {
|
func TestCommitSignatureEncodeDecode(t *testing.T) {
|
||||||
copy(revocationHash[:], revocationHashBytes)
|
|
||||||
|
|
||||||
commitSignature := &CommitSignature{
|
commitSignature := &CommitSignature{
|
||||||
ChannelPoint: outpoint1,
|
ChannelPoint: outpoint1,
|
||||||
Fee: btcutil.Amount(10000),
|
Fee: btcutil.Amount(10000),
|
||||||
|
LogIndex: 5,
|
||||||
CommitSig: commitSig,
|
CommitSig: commitSig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user