Commit message update
Doesn't need to use a list, only needs to show each party's most recent state.
This commit is contained in:
parent
bf4b43d3f2
commit
4b8a8f410a
@ -19,10 +19,13 @@ type CommitSignature struct {
|
||||
// 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
|
||||
UpdatedHTLCKeys []uint64
|
||||
//UpdatedHTLCKeys []uint64
|
||||
LastCommittedKeyAlice HTLCKey
|
||||
LastCommittedKeyBob HTLCKey
|
||||
|
||||
// Hash of the revocation to use
|
||||
RevocationHash [20]byte
|
||||
@ -37,14 +40,14 @@ type CommitSignature struct {
|
||||
func (c *CommitSignature) Decode(r io.Reader, pver uint32) error {
|
||||
// ChannelID(8)
|
||||
// CommitmentHeight(8)
|
||||
// c.UpdatedHTLCKeys(8*1000max)
|
||||
// RevocationHash(20)
|
||||
// Fee(8)
|
||||
// RequesterCommitSig(73max+2)
|
||||
err := readElements(r,
|
||||
&c.ChannelID,
|
||||
&c.CommitmentHeight,
|
||||
&c.UpdatedHTLCKeys,
|
||||
&c.LastCommittedKeyAlice,
|
||||
&c.LastCommittedKeyBob,
|
||||
&c.RevocationHash,
|
||||
&c.Fee,
|
||||
&c.CommitSig,
|
||||
@ -67,7 +70,8 @@ func (c *CommitSignature) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
c.ChannelID,
|
||||
c.CommitmentHeight,
|
||||
c.UpdatedHTLCKeys,
|
||||
c.LastCommittedKeyAlice,
|
||||
c.LastCommittedKeyBob,
|
||||
c.RevocationHash,
|
||||
c.Fee,
|
||||
c.CommitSig,
|
||||
@ -106,18 +110,15 @@ func (c *CommitSignature) String() string {
|
||||
// c.Fee,
|
||||
// c.CommitSig,
|
||||
var serializedSig []byte
|
||||
if &c.CommitSig != nil && c.CommitSig.R != nil {
|
||||
if c.CommitSig != nil && c.CommitSig.R != nil {
|
||||
serializedSig = c.CommitSig.Serialize()
|
||||
}
|
||||
var items string
|
||||
for i := 0; i < len(c.UpdatedHTLCKeys); i++ {
|
||||
items += fmt.Sprintf("%d ", c.UpdatedHTLCKeys[i])
|
||||
}
|
||||
|
||||
return fmt.Sprintf("\n--- Begin CommitSignature ---\n") +
|
||||
fmt.Sprintf("ChannelID:\t\t%d\n", c.ChannelID) +
|
||||
fmt.Sprintf("CommitmentHeight:\t%d\n", c.CommitmentHeight) +
|
||||
fmt.Sprintf("UpdatedHTLCKeys:\t%s\n", items) +
|
||||
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("CommitSig:\t\t%x\n", serializedSig) +
|
||||
|
@ -10,16 +10,16 @@ var (
|
||||
_ = copy(revocationHash[:], revocationHashBytes)
|
||||
|
||||
commitSignature = &CommitSignature{
|
||||
ChannelID: uint64(12345678),
|
||||
CommitmentHeight: uint64(12345),
|
||||
// CommitterLastStaging: uint64(12345678),
|
||||
UpdatedHTLCKeys: []uint64{1, 2, 3, 4, 5},
|
||||
RevocationHash: revocationHash,
|
||||
Fee: btcutil.Amount(10000),
|
||||
CommitSig: commitSig,
|
||||
ChannelID: uint64(12345678),
|
||||
CommitmentHeight: uint64(12345),
|
||||
LastCommittedKeyAlice: uint64(12345),
|
||||
LastCommittedKeyBob: uint64(54321),
|
||||
RevocationHash: revocationHash,
|
||||
Fee: btcutil.Amount(10000),
|
||||
CommitSig: commitSig,
|
||||
}
|
||||
commitSignatureSerializedString = "0000000000bc614e00000000000030390005000000000000000100000000000000020000000000000003000000000000000400000000000000054132b6b48371f7b022a16eacb9b2b0ebee134d4100000000000027104630440220333835e58e958f5e92b4ff4e6fa2470dac88094c97506b4d6d1f4e23e52cb481022057483ac18d6b9c9c14f0c626694c9ccf8b27b3dbbedfdf6b6c9a9fa9f427a1df"
|
||||
commitSignatureSerializedMessage = "0709110b000007d00000009d0000000000bc614e00000000000030390005000000000000000100000000000000020000000000000003000000000000000400000000000000054132b6b48371f7b022a16eacb9b2b0ebee134d4100000000000027104630440220333835e58e958f5e92b4ff4e6fa2470dac88094c97506b4d6d1f4e23e52cb481022057483ac18d6b9c9c14f0c626694c9ccf8b27b3dbbedfdf6b6c9a9fa9f427a1df"
|
||||
commitSignatureSerializedString = "0000000000bc614e00000000000030390000000000003039000000000000d4314132b6b48371f7b022a16eacb9b2b0ebee134d4100000000000027104630440220333835e58e958f5e92b4ff4e6fa2470dac88094c97506b4d6d1f4e23e52cb481022057483ac18d6b9c9c14f0c626694c9ccf8b27b3dbbedfdf6b6c9a9fa9f427a1df"
|
||||
commitSignatureSerializedMessage = "0709110b000007d0000000830000000000bc614e00000000000030390000000000003039000000000000d4314132b6b48371f7b022a16eacb9b2b0ebee134d4100000000000027104630440220333835e58e958f5e92b4ff4e6fa2470dac88094c97506b4d6d1f4e23e52cb481022057483ac18d6b9c9c14f0c626694c9ccf8b27b3dbbedfdf6b6c9a9fa9f427a1df"
|
||||
)
|
||||
|
||||
func TestCommitSignatureEncodeDecode(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user