lnwire: modify fundingOpen to include channel ID rather than SPV proof
This commit modifies the SingleFundingOpen message to include the compact channel ID of the finalized transaction rather than a “fake” SPV proof. This change is a stop-gap which allows us to implement portions of BOLT07 without yet fully implementing all parts of BOLT[02, 03].
This commit is contained in:
parent
e327ffe954
commit
98471256fa
@ -9,7 +9,7 @@ import (
|
|||||||
// responder after the previously constructed funding transaction has achieved
|
// responder after the previously constructed funding transaction has achieved
|
||||||
// a sufficient number of confirmations. It is the initiator's duty to present
|
// a sufficient number of confirmations. It is the initiator's duty to present
|
||||||
// a proof of an open channel to the responder. Otherwise, responding node may
|
// a proof of an open channel to the responder. Otherwise, responding node may
|
||||||
// be vulnerable to a resource exhaustion attack wherein the a requesting node
|
// be vulnerable to a resource exhaustion attack wherein the requesting node
|
||||||
// repeatedly negotiates funding transactions which are never broadcast. If the
|
// repeatedly negotiates funding transactions which are never broadcast. If the
|
||||||
// responding node commits resources to watch the chain for each funding
|
// responding node commits resources to watch the chain for each funding
|
||||||
// transaction, then this attack is very cheap for the initiator.
|
// transaction, then this attack is very cheap for the initiator.
|
||||||
@ -18,19 +18,18 @@ type SingleFundingOpenProof struct {
|
|||||||
// the initiated single funder workflow.
|
// the initiated single funder workflow.
|
||||||
ChannelID uint64
|
ChannelID uint64
|
||||||
|
|
||||||
// SpvProof is an merkle proof of the inclusion of the funding
|
// ChanChainID is the channel ID of the completed channel which
|
||||||
// transaction within a block.
|
// compactly encodes the location of the channel within the current
|
||||||
// TODO(roasbeef): spec out format for SPV proof, only of single tx so
|
// main chain.
|
||||||
// can be compact
|
ChanChainID ChannelID
|
||||||
SpvProof []byte
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSingleFundingSignComplete creates a new empty SingleFundingOpenProof
|
// NewSingleFundingSignComplete creates a new empty SingleFundingOpenProof
|
||||||
// message.
|
// message.
|
||||||
func NewSingleFundingOpenProof(chanID uint64, spvProof []byte) *SingleFundingOpenProof {
|
func NewSingleFundingOpenProof(chanID uint64, chainID ChannelID) *SingleFundingOpenProof {
|
||||||
return &SingleFundingOpenProof{
|
return &SingleFundingOpenProof{
|
||||||
ChannelID: chanID,
|
ChannelID: chanID,
|
||||||
SpvProof: spvProof,
|
ChanChainID: chainID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,10 +40,10 @@ func NewSingleFundingOpenProof(chanID uint64, spvProof []byte) *SingleFundingOpe
|
|||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (s *SingleFundingOpenProof) Decode(r io.Reader, pver uint32) error {
|
func (s *SingleFundingOpenProof) Decode(r io.Reader, pver uint32) error {
|
||||||
// ChannelID (8)
|
// ChannelID (8)
|
||||||
// SpvProof (?)
|
// ChanChainID (8)
|
||||||
err := readElements(r,
|
err := readElements(r,
|
||||||
&s.ChannelID,
|
&s.ChannelID,
|
||||||
&s.SpvProof)
|
&s.ChanChainID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -60,7 +59,7 @@ func (s *SingleFundingOpenProof) Decode(r io.Reader, pver uint32) error {
|
|||||||
func (s *SingleFundingOpenProof) Encode(w io.Writer, pver uint32) error {
|
func (s *SingleFundingOpenProof) Encode(w io.Writer, pver uint32) error {
|
||||||
err := writeElements(w,
|
err := writeElements(w,
|
||||||
s.ChannelID,
|
s.ChannelID,
|
||||||
s.SpvProof)
|
s.ChanChainID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -99,8 +98,8 @@ func (s *SingleFundingOpenProof) Validate() error {
|
|||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (s *SingleFundingOpenProof) String() string {
|
func (s *SingleFundingOpenProof) String() string {
|
||||||
return fmt.Sprintf("\n--- Begin FundingSignComplete ---\n") +
|
return fmt.Sprintf("\n--- Begin SingleFundingOpenProof ---\n") +
|
||||||
fmt.Sprintf("ChannelID:\t\t%d\n", s.ChannelID) +
|
fmt.Sprintf("ChannelID:\t\t%d\n", s.ChannelID) +
|
||||||
fmt.Sprintf("SpvProof\t\t%s\n", s.SpvProof) +
|
fmt.Sprintf("ChanChainID\t\t%s\n", s.ChanChainID.ToUint64()) +
|
||||||
fmt.Sprintf("--- End FundingSignComplete ---\n")
|
fmt.Sprintf("--- End SingleFundingOpenProof ---\n")
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestSingleFundingOpenProofWire(t *testing.T) {
|
func TestSingleFundingOpenProofWire(t *testing.T) {
|
||||||
// First create a new SFOP message.
|
// First create a new SFOP message.
|
||||||
spvProof := bytes.Repeat([]byte{0x9}, 500)
|
sfop := NewSingleFundingOpenProof(22, someChannelID)
|
||||||
sfop := NewSingleFundingOpenProof(22, spvProof)
|
|
||||||
|
|
||||||
// Next encode the SFOP message into an empty bytes buffer.
|
// Next encode the SFOP message into an empty bytes buffer.
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
|
Loading…
Reference in New Issue
Block a user