Notes on payment amount
This commit is contained in:
1 parent
266c121510
commit
b3f812e5da
4 files changed
+9
-13
No files matched your search
@@ -20,6 +20,9 @@ type FundingRequest struct {
|
|||||||
//which is a payment to the responder
|
//which is a payment to the responder
|
||||||
//(This can be used to fund the Reserve)
|
//(This can be used to fund the Reserve)
|
||||||
//If the responder disagrees, then the funding request fails
|
//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
|
PaymentAmount btcutil.Amount
|
||||||
|
|
||||||
//Minimum number of confirmations to validate transaction
|
//Minimum number of confirmations to validate transaction
|
||||||
@@ -169,10 +172,6 @@ func (c *FundingRequest) Validate() error {
|
|||||||
if c.PaymentAmount < 0 {
|
if c.PaymentAmount < 0 {
|
||||||
return fmt.Errorf("This wallet requieres payment to be greater than zero.")
|
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
|
//Make sure there's not more than 127 inputs
|
||||||
if len(c.Inputs) > 127 {
|
if len(c.Inputs) > 127 {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ type FundingSignAccept struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *FundingSignAccept) Decode(r io.Reader, pver uint32) error {
|
func (c *FundingSignAccept) Decode(r io.Reader, pver uint32) error {
|
||||||
//ReservationID (0/8)
|
//ReservationID (8)
|
||||||
//CommitSig
|
//CommitSig (73)
|
||||||
// First byte length then sig
|
// First byte length then sig
|
||||||
//FundingTXSigs
|
//FundingTXSigs
|
||||||
// First byte is number of FundingTxSigs
|
// First byte is number of FundingTxSigs
|
||||||
@@ -40,7 +40,7 @@ func NewFundingSignAccept() *FundingSignAccept {
|
|||||||
//Serializes the item from the FundingSignAccept struct
|
//Serializes the item from the FundingSignAccept struct
|
||||||
//Writes the data to w
|
//Writes the data to w
|
||||||
func (c *FundingSignAccept) Encode(w io.Writer, pver uint32) error {
|
func (c *FundingSignAccept) Encode(w io.Writer, pver uint32) error {
|
||||||
//ReservationID (8)
|
//ReservationID
|
||||||
//CommitSig
|
//CommitSig
|
||||||
//FundingTxSigs
|
//FundingTxSigs
|
||||||
err := writeElements(w,
|
err := writeElements(w,
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ type FundingSignComplete struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *FundingSignComplete) Decode(r io.Reader, pver uint32) error {
|
func (c *FundingSignComplete) Decode(r io.Reader, pver uint32) error {
|
||||||
//ReservationID (0/8)
|
//ReservationID (8)
|
||||||
//TxID
|
//TxID (32)
|
||||||
//FundingTXSigs
|
//FundingTXSigs
|
||||||
// First byte is number of FundingTxSigs
|
// First byte is number of FundingTxSigs
|
||||||
// Sorted list of the requester's input signatures
|
// Sorted list of the requester's input signatures
|
||||||
@@ -40,9 +40,6 @@ func NewFundingSignComplete() *FundingSignComplete {
|
|||||||
//Serializes the item from the FundingSignComplete struct
|
//Serializes the item from the FundingSignComplete struct
|
||||||
//Writes the data to w
|
//Writes the data to w
|
||||||
func (c *FundingSignComplete) Encode(w io.Writer, pver uint32) error {
|
func (c *FundingSignComplete) Encode(w io.Writer, pver uint32) error {
|
||||||
//ReservationID (8)
|
|
||||||
//CommitSig
|
|
||||||
//FundingTxSigs
|
|
||||||
err := writeElements(w,
|
err := writeElements(w,
|
||||||
c.ReservationID,
|
c.ReservationID,
|
||||||
c.TxID,
|
c.TxID,
|
||||||
|
|||||||
+1
-1
@@ -362,10 +362,10 @@ func readElement(r io.Reader, element interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hash, err := wire.NewShaHash(h[:])
|
hash, err := wire.NewShaHash(h[:])
|
||||||
(*e).PreviousOutPoint.Hash = *hash
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
(*e).PreviousOutPoint.Hash = *hash
|
||||||
//Index
|
//Index
|
||||||
var idxBytes [4]byte
|
var idxBytes [4]byte
|
||||||
_, err = io.ReadFull(r, idxBytes[:])
|
_, err = io.ReadFull(r, idxBytes[:])
|
||||||
|
|||||||
Reference in new issue
Block a user