Simplified the commitment messages
This commit is contained in:
parent
10d52611cd
commit
5218dca5b6
@ -8,24 +8,17 @@ import (
|
|||||||
// Multiple Clearing Requests are possible by putting this inside an array of
|
// Multiple Clearing Requests are possible by putting this inside an array of
|
||||||
// clearing requests
|
// clearing requests
|
||||||
type CommitRevocation struct {
|
type CommitRevocation struct {
|
||||||
// We can use a different data type for this if necessary...
|
|
||||||
ChannelID uint64
|
|
||||||
|
|
||||||
// Revocation to use
|
|
||||||
RevocationProof [20]byte
|
|
||||||
|
|
||||||
//Next revocation to use
|
//Next revocation to use
|
||||||
NextRevocationHash [20]byte
|
NextRevocationHash [20]byte
|
||||||
|
Revocation [20]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CommitRevocation) Decode(r io.Reader, pver uint32) error {
|
func (c *CommitRevocation) Decode(r io.Reader, pver uint32) error {
|
||||||
// ChannelID(8)
|
// NextRevocationHash(20)
|
||||||
// CommitmentHeight(8)
|
// Revocation(20)
|
||||||
// RevocationProof(20)
|
|
||||||
err := readElements(r,
|
err := readElements(r,
|
||||||
&c.ChannelID,
|
|
||||||
&c.RevocationProof,
|
|
||||||
&c.NextRevocationHash,
|
&c.NextRevocationHash,
|
||||||
|
&c.Revocation,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -43,9 +36,8 @@ func NewCommitRevocation() *CommitRevocation {
|
|||||||
// Writes the data to w
|
// Writes the data to w
|
||||||
func (c *CommitRevocation) Encode(w io.Writer, pver uint32) error {
|
func (c *CommitRevocation) Encode(w io.Writer, pver uint32) error {
|
||||||
err := writeElements(w,
|
err := writeElements(w,
|
||||||
c.ChannelID,
|
|
||||||
c.RevocationProof,
|
|
||||||
c.NextRevocationHash,
|
c.NextRevocationHash,
|
||||||
|
c.Revocation,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -70,8 +62,7 @@ func (c *CommitRevocation) Validate() error {
|
|||||||
|
|
||||||
func (c *CommitRevocation) String() string {
|
func (c *CommitRevocation) String() string {
|
||||||
return fmt.Sprintf("\n--- Begin CommitRevocation ---\n") +
|
return fmt.Sprintf("\n--- Begin CommitRevocation ---\n") +
|
||||||
fmt.Sprintf("ChannelID:\t\t%d\n", c.ChannelID) +
|
|
||||||
fmt.Sprintf("RevocationProof:\t%x\n", c.RevocationProof) +
|
|
||||||
fmt.Sprintf("NextRevocationHash:\t%x\n", c.NextRevocationHash) +
|
fmt.Sprintf("NextRevocationHash:\t%x\n", c.NextRevocationHash) +
|
||||||
|
fmt.Sprintf("Revocation:\t%x\n", c.Revocation) +
|
||||||
fmt.Sprintf("--- End CommitRevocation ---\n")
|
fmt.Sprintf("--- End CommitRevocation ---\n")
|
||||||
}
|
}
|
||||||
|
@ -10,25 +10,9 @@ import (
|
|||||||
// Multiple Clearing Requests are possible by putting this inside an array of
|
// Multiple Clearing Requests are possible by putting this inside an array of
|
||||||
// clearing requests
|
// clearing requests
|
||||||
type CommitSignature struct {
|
type CommitSignature struct {
|
||||||
// We can use a different data type for this if necessary...
|
|
||||||
ChannelID uint64
|
|
||||||
|
|
||||||
// Height of the commitment
|
|
||||||
// You should have the most recent commitment height stored locally
|
|
||||||
// This should be validated!
|
|
||||||
// This is used for shachain.
|
|
||||||
// Each party increments their own CommitmentHeight, they can differ for
|
|
||||||
// each part of the Commitment.
|
|
||||||
//FIXME This might be superfluous
|
|
||||||
CommitmentHeight uint64
|
|
||||||
|
|
||||||
// List of HTLC Keys which are updated from all parties
|
// List of HTLC Keys which are updated from all parties
|
||||||
//UpdatedHTLCKeys []uint64
|
//UpdatedHTLCKeys []uint64
|
||||||
LastCommittedKeyAlice HTLCKey
|
HighestPosition uint64
|
||||||
LastCommittedKeyBob HTLCKey
|
|
||||||
|
|
||||||
// Hash of the revocation to use
|
|
||||||
RevocationHash [20]byte
|
|
||||||
|
|
||||||
// Total miners' fee that was used
|
// Total miners' fee that was used
|
||||||
Fee btcutil.Amount
|
Fee btcutil.Amount
|
||||||
@ -44,11 +28,7 @@ func (c *CommitSignature) Decode(r io.Reader, pver uint32) error {
|
|||||||
// Fee(8)
|
// Fee(8)
|
||||||
// RequesterCommitSig(73max+2)
|
// RequesterCommitSig(73max+2)
|
||||||
err := readElements(r,
|
err := readElements(r,
|
||||||
&c.ChannelID,
|
&c.HighestPosition,
|
||||||
&c.CommitmentHeight,
|
|
||||||
&c.LastCommittedKeyAlice,
|
|
||||||
&c.LastCommittedKeyBob,
|
|
||||||
&c.RevocationHash,
|
|
||||||
&c.Fee,
|
&c.Fee,
|
||||||
&c.CommitSig,
|
&c.CommitSig,
|
||||||
)
|
)
|
||||||
@ -68,11 +48,7 @@ func NewCommitSignature() *CommitSignature {
|
|||||||
// Writes the data to w
|
// Writes the data to w
|
||||||
func (c *CommitSignature) Encode(w io.Writer, pver uint32) error {
|
func (c *CommitSignature) Encode(w io.Writer, pver uint32) error {
|
||||||
err := writeElements(w,
|
err := writeElements(w,
|
||||||
c.ChannelID,
|
c.HighestPosition,
|
||||||
c.CommitmentHeight,
|
|
||||||
c.LastCommittedKeyAlice,
|
|
||||||
c.LastCommittedKeyBob,
|
|
||||||
c.RevocationHash,
|
|
||||||
c.Fee,
|
c.Fee,
|
||||||
c.CommitSig,
|
c.CommitSig,
|
||||||
)
|
)
|
||||||
@ -115,11 +91,7 @@ func (c *CommitSignature) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("\n--- Begin CommitSignature ---\n") +
|
return fmt.Sprintf("\n--- Begin CommitSignature ---\n") +
|
||||||
fmt.Sprintf("ChannelID:\t\t%d\n", c.ChannelID) +
|
fmt.Sprintf("HighestPosition:\t%d\n", c.HighestPosition) +
|
||||||
fmt.Sprintf("CommitmentHeight:\t%d\n", c.CommitmentHeight) +
|
|
||||||
fmt.Sprintf("LastCommittedKeyAlice:\t%d\n", c.LastCommittedKeyAlice) +
|
|
||||||
fmt.Sprintf("LastCommittedKeyBob:\t%d\n", c.LastCommittedKeyBob) +
|
|
||||||
fmt.Sprintf("RevocationHash:\t\t%x\n", c.RevocationHash) +
|
|
||||||
fmt.Sprintf("Fee:\t\t\t%s\n", c.Fee.String()) +
|
fmt.Sprintf("Fee:\t\t\t%s\n", c.Fee.String()) +
|
||||||
fmt.Sprintf("CommitSig:\t\t%x\n", serializedSig) +
|
fmt.Sprintf("CommitSig:\t\t%x\n", serializedSig) +
|
||||||
fmt.Sprintf("--- End CommitSignature ---\n")
|
fmt.Sprintf("--- End CommitSignature ---\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user