Cleanup comments & removed notes on escrow

This commit is contained in:
Joseph Poon
2016-01-16 17:14:35 -08:00
parent 84c0f56330
commit f2a1c0368a
36 changed files with 648 additions and 769 deletions

View File

@@ -7,40 +7,40 @@ import (
"io"
)
//Multiple Clearing Requests are possible by putting this inside an array of
//clearing requests
// Multiple Clearing Requests are possible by putting this inside an array of
// clearing requests
type CommitSignature struct {
//We can use a different data type for this if necessary...
// 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.
// 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.
CommitmentHeight uint64
//List of HTLC Keys which are updated from all parties
// List of HTLC Keys which are updated from all parties
UpdatedHTLCKeys []uint64
//Hash of the revocation to use
// Hash of the revocation to use
RevocationHash [20]byte
//Total miners' fee that was used
// Total miners' fee that was used
Fee btcutil.Amount
//Signature for the new Commitment
CommitSig *btcec.Signature //Requester's Commitment
// Signature for the new Commitment
CommitSig *btcec.Signature // Requester's Commitment
}
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)
// ChannelID(8)
// CommitmentHeight(8)
// c.UpdatedHTLCKeys(8*1000max)
// RevocationHash(20)
// Fee(8)
// RequesterCommitSig(73max+2)
err := readElements(r,
&c.ChannelID,
&c.CommitmentHeight,
@@ -56,13 +56,13 @@ func (c *CommitSignature) Decode(r io.Reader, pver uint32) error {
return nil
}
//Creates a new CommitSignature
// Creates a new CommitSignature
func NewCommitSignature() *CommitSignature {
return &CommitSignature{}
}
//Serializes the item from the CommitSignature struct
//Writes the data to w
// Serializes the item from the CommitSignature struct
// Writes the data to w
func (c *CommitSignature) Encode(w io.Writer, pver uint32) error {
err := writeElements(w,
c.ChannelID,
@@ -87,24 +87,24 @@ func (c *CommitSignature) MaxPayloadLength(uint32) uint32 {
return 8192
}
//Makes sure the struct data is valid (e.g. no negatives or invalid pkscripts)
// Makes sure the struct data is valid (e.g. no negatives or invalid pkscripts)
func (c *CommitSignature) Validate() error {
if c.Fee < 0 {
//While fees can be negative, it's too confusing to allow
//negative payments. Maybe for some wallets, but not this one!
// While fees can be negative, it's too confusing to allow
// negative payments. Maybe for some wallets, but not this one!
return fmt.Errorf("Amount paid cannot be negative.")
}
//We're good!
// We're good!
return nil
}
func (c *CommitSignature) String() string {
//c.ChannelID,
//c.CommitmentHeight,
//c.RevocationHash,
//c.UpdatedHTLCKeys,
//c.Fee,
//c.CommitSig,
// c.ChannelID,
// c.CommitmentHeight,
// c.RevocationHash,
// c.UpdatedHTLCKeys,
// c.Fee,
// c.CommitSig,
var serializedSig []byte
if &c.CommitSig != nil && c.CommitSig.R != nil {
serializedSig = c.CommitSig.Serialize()