Cleanup comments & removed notes on escrow

This commit is contained in:
Joseph Poon committed 2016-01-16 17:14:35 -08:00
1 parent 84c0f56330
commit f2a1c0368a
36 files changed
+648 -769

No files matched your search

+30 -30
View File
@@ -5,46 +5,46 @@ 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 HTLCAddRequest 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
//ID of this request
// ID of this request
HTLCKey HTLCKey
//When the HTLC expires
// When the HTLC expires
Expiry uint32
//Amount to pay in the hop
//Difference between hop and first item in blob is the fee to complete
// Amount to pay in the hop
// Difference between hop and first item in blob is the fee to complete
Amount CreditsAmount
//RefundContext is for payment cancellation
//TODO (j): not currently in use, add later
// RefundContext is for payment cancellation
// TODO (j): not currently in use, add later
RefundContext HTLCKey
//Contract Type
//first 4 bits is n, second for is m, in n-of-m "multisig"
// Contract Type
// first 4 bits is n, second for is m, in n-of-m "multisig"
ContractType uint8
//Redemption Hashes
// Redemption Hashes
RedemptionHashes []*[20]byte
//Data to parse&pass on to the next node
//Eventually, we need to make this into a group of 2 nested structs?
// Data to parse&pass on to the next node
// Eventually, we need to make this into a group of 2 nested structs?
Blob []byte
}
func (c *HTLCAddRequest) Decode(r io.Reader, pver uint32) error {
//ChannelID(8)
//HTLCKey(8)
//Expiry(4)
//Amount(4)
//ContractType(1)
//RedemptionHashes (numOfHashes * 20 + numOfHashes)
//Blob(2+blobsize)
// ChannelID(8)
// HTLCKey(8)
// Expiry(4)
// Amount(4)
// ContractType(1)
// RedemptionHashes (numOfHashes * 20 + numOfHashes)
// Blob(2+blobsize)
err := readElements(r,
&c.ChannelID,
&c.HTLCKey,
@@ -61,13 +61,13 @@ func (c *HTLCAddRequest) Decode(r io.Reader, pver uint32) error {
return nil
}
//Creates a new HTLCAddRequest
// Creates a new HTLCAddRequest
func NewHTLCAddRequest() *HTLCAddRequest {
return &HTLCAddRequest{}
}
//Serializes the item from the HTLCAddRequest struct
//Writes the data to w
// Serializes the item from the HTLCAddRequest struct
// Writes the data to w
func (c *HTLCAddRequest) Encode(w io.Writer, pver uint32) error {
err := writeElements(w,
c.ChannelID,
@@ -90,19 +90,19 @@ func (c *HTLCAddRequest) Command() uint32 {
}
func (c *HTLCAddRequest) MaxPayloadLength(uint32) uint32 {
//base size ~110, but blob can be variable.
//shouldn't be bigger than 8K though...
// base size ~110, but blob can be variable.
// shouldn't be bigger than 8K though...
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 *HTLCAddRequest) Validate() error {
if c.Amount < 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
}