From b3f812e5da8e17abbfc400c0a86389484394986b Mon Sep 17 00:00:00 2001 From: Joseph Poon Date: Thu, 31 Dec 2015 00:41:55 -0800 Subject: [PATCH] Notes on payment amount --- lnwire/funding_request.go | 7 +++---- lnwire/funding_signaccept.go | 6 +++--- lnwire/funding_signcomplete.go | 7 ++----- lnwire/lnwire.go | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lnwire/funding_request.go b/lnwire/funding_request.go index cb2d02448..85b36435e 100644 --- a/lnwire/funding_request.go +++ b/lnwire/funding_request.go @@ -20,6 +20,9 @@ type FundingRequest struct { //which is a payment to the responder //(This can be used to fund the Reserve) //If the responder disagrees, then the funding request fails + //THIS VALUE GOES INTO THE RESPONDER'S FUNDING AMOUNT + //total requester input value = RequesterFundingAmount + PaymentAmount + "Total Change" + //RequesterFundingAmount = "Available Balance" - RequesterReserveAmount PaymentAmount btcutil.Amount //Minimum number of confirmations to validate transaction @@ -169,10 +172,6 @@ func (c *FundingRequest) Validate() error { if c.PaymentAmount < 0 { return fmt.Errorf("This wallet requieres payment to be greater than zero.") } - //The payment must be below our own contribution (less reserve kept for ourselves - if c.PaymentAmount > c.RequesterFundingAmount-c.RequesterReserveAmount { - return fmt.Errorf("Payment too large") - } //Make sure there's not more than 127 inputs if len(c.Inputs) > 127 { diff --git a/lnwire/funding_signaccept.go b/lnwire/funding_signaccept.go index 52b01949b..1930c49af 100644 --- a/lnwire/funding_signaccept.go +++ b/lnwire/funding_signaccept.go @@ -14,8 +14,8 @@ type FundingSignAccept struct { } func (c *FundingSignAccept) Decode(r io.Reader, pver uint32) error { - //ReservationID (0/8) - //CommitSig + //ReservationID (8) + //CommitSig (73) // First byte length then sig //FundingTXSigs // First byte is number of FundingTxSigs @@ -40,7 +40,7 @@ func NewFundingSignAccept() *FundingSignAccept { //Serializes the item from the FundingSignAccept struct //Writes the data to w func (c *FundingSignAccept) Encode(w io.Writer, pver uint32) error { - //ReservationID (8) + //ReservationID //CommitSig //FundingTxSigs err := writeElements(w, diff --git a/lnwire/funding_signcomplete.go b/lnwire/funding_signcomplete.go index 86e90c1a2..f42c2d21d 100644 --- a/lnwire/funding_signcomplete.go +++ b/lnwire/funding_signcomplete.go @@ -15,8 +15,8 @@ type FundingSignComplete struct { } func (c *FundingSignComplete) Decode(r io.Reader, pver uint32) error { - //ReservationID (0/8) - //TxID + //ReservationID (8) + //TxID (32) //FundingTXSigs // First byte is number of FundingTxSigs // Sorted list of the requester's input signatures @@ -40,9 +40,6 @@ func NewFundingSignComplete() *FundingSignComplete { //Serializes the item from the FundingSignComplete struct //Writes the data to w func (c *FundingSignComplete) Encode(w io.Writer, pver uint32) error { - //ReservationID (8) - //CommitSig - //FundingTxSigs err := writeElements(w, c.ReservationID, c.TxID, diff --git a/lnwire/lnwire.go b/lnwire/lnwire.go index 25c6bc86a..81400c94f 100644 --- a/lnwire/lnwire.go +++ b/lnwire/lnwire.go @@ -362,10 +362,10 @@ func readElement(r io.Reader, element interface{}) error { return err } hash, err := wire.NewShaHash(h[:]) - (*e).PreviousOutPoint.Hash = *hash if err != nil { return err } + (*e).PreviousOutPoint.Hash = *hash //Index var idxBytes [4]byte _, err = io.ReadFull(r, idxBytes[:])