lnwire: remove deprecated single funding wire messages

This commit removes the original single funder wire messages as they’ve
now been deprecated by the new commitment and HTLC structure within the
latest draft of the specification.
This commit is contained in:
Olaoluwa Osuntokun 2017-07-28 16:18:15 -07:00
parent 78f6caf5d2
commit b2d86bffc5
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
4 changed files with 0 additions and 537 deletions

View File

@ -1,103 +0,0 @@
package lnwire
import (
"io"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/wire"
)
// SingleFundingComplete is the message Alice sends to Bob once she is able to
// fully assemble the funding transaction, and both versions of the commitment
// transaction. The purpose of this message is to present Bob with the items
// required for him to generate a signature for Alice's version of the
// commitment transaction.
type SingleFundingComplete struct {
// PendingChannelID serves to uniquely identify the future channel
// created by the initiated single funder workflow.
PendingChannelID [32]byte
// FundingOutPoint is the outpoint (txid:index) of the funding
// transaction. With this value, Bob will be able to generate a
// signature for Alice's version of the commitment transaction.
FundingOutPoint wire.OutPoint
// CommitSignature is Alice's signature for Bob's version of the
// commitment transaction.
CommitSignature *btcec.Signature
// RevocationKey is the initial key to be used for the revocation
// clause within the self-output of the initiators's commitment
// transaction. Once an initial new state is created, the initiator
// will send a preimage which will allow the initiator to sweep the
// initiator's funds if the violate the contract.
RevocationKey *btcec.PublicKey
// StateHintObsfucator is the set of bytes used by the initiator to
// obsfucate the state number encoded within the sequence number for
// the commitment transaction's only input. The initiator generates
// this value by hashing the 0th' state derived from the revocation PRF
// an additional time.
StateHintObsfucator [6]byte
}
// NewSingleFundingComplete creates, and returns a new empty
// SingleFundingResponse.
func NewSingleFundingComplete(pChanID [32]byte, fundingPoint wire.OutPoint,
commitSig *btcec.Signature, revokeKey *btcec.PublicKey,
obsfucator [6]byte) *SingleFundingComplete {
return &SingleFundingComplete{
PendingChannelID: pChanID,
FundingOutPoint: fundingPoint,
CommitSignature: commitSig,
RevocationKey: revokeKey,
StateHintObsfucator: obsfucator,
}
}
// Decode deserializes the serialized SingleFundingComplete stored in the passed
// io.Reader into the target SingleFundingComplete using the deserialization
// rules defined by the passed protocol version.
//
// This is part of the lnwire.Message interface.
func (s *SingleFundingComplete) Decode(r io.Reader, pver uint32) error {
return readElements(r,
s.PendingChannelID[:],
&s.FundingOutPoint,
&s.CommitSignature,
&s.RevocationKey,
s.StateHintObsfucator[:])
}
// Encode serializes the target SingleFundingComplete into the passed io.Writer
// implementation. Serialization will observe the rules defined by the passed
// protocol version.
//
// This is part of the lnwire.Message interface.
func (s *SingleFundingComplete) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
s.PendingChannelID[:],
s.FundingOutPoint,
s.CommitSignature,
s.RevocationKey,
s.StateHintObsfucator[:])
}
// MsgType returns the uint32 code which uniquely identifies this message as a
// SingleFundingComplete on the wire.
//
// This is part of the lnwire.Message interface.
func (s *SingleFundingComplete) MsgType() MessageType {
return MsgSingleFundingComplete
}
// MaxPayloadLength returns the maximum allowed payload length for a
// SingleFundingComplete. This is calculated by summing the max length of all
// the fields within a SingleFundingComplete.
//
// This is part of the lnwire.Message interface.
func (s *SingleFundingComplete) MaxPayloadLength(uint32) uint32 {
// 32 + 36 + 64 + 33 + 6
return 171
}

View File

@ -1,204 +0,0 @@
package lnwire
import (
"io"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcutil"
)
// SingleFundingRequest is the message Alice sends to Bob if we should like
// to create a channel with Bob where she's the sole provider of funds to the
// channel. Single funder channels simplify the initial funding workflow, are
// supported by nodes backed by SPV Bitcoin clients, and have a simpler
// security models than dual funded channels.
//
// NOTE: In order to avoid a slow loris like resource exhaustion attack, the
// responder of a single funding channel workflow *should not* watch the
// blockchain for the funding transaction. Instead, it is the initiator's job
// to provide the responder with an SPV proof of funding transaction inclusion
// after a sufficient number of confirmations.
type SingleFundingRequest struct {
// PendingChannelID serves to uniquely identify the future channel
// created by the initiated single funder workflow.
PendingChannelID [32]byte
// ChannelType represents the type of channel this request would like
// to open. At this point, the only supported channels are type 0
// channels, which are channels with regular commitment transactions
// utilizing HTLCs for payments.
ChannelType uint8
// CoinType represents which blockchain the channel will be opened
// using. By default, this field should be set to 0, indicating usage
// of the Bitcoin blockchain.
CoinType uint64
// FeePerKw is the required number of satoshis per kilo-weight that the
// requester will pay at all timers, for both the funding transaction
// and commitment transaction. This value can later be updated once the
// channel is open.
FeePerKw btcutil.Amount
// FundingAmount is the number of satoshis the initiator would like
// to commit to the channel.
FundingAmount btcutil.Amount
// PushSatoshis is the number of satoshis that will be pushed to the
// responder as a part of the first commitment state.
PushSatoshis btcutil.Amount
// CsvDelay is the number of blocks to use for the relative time lock
// in the pay-to-self output of both commitment transactions.
CsvDelay uint32
// CommitmentKey is key the initiator of the funding workflow wishes to
// use within their versino of the commitment transaction for any
// delayed (CSV) or immediate outputs to them.
CommitmentKey *btcec.PublicKey
// ChannelDerivationPoint is an secp256k1 point which will be used to
// derive the public key the initiator will use for the half of the
// 2-of-2 multi-sig. Using the channel derivation point (CDP), and the
// initiators identity public key (A), the channel public key is
// computed as: C = A + CDP. In order to be valid all CDP's MUST have
// an odd y-coordinate.
ChannelDerivationPoint *btcec.PublicKey
// DeliveryPkScript defines the public key script that the initiator
// would like to use to receive their balance in the case of a
// cooperative close. Only the following script templates are
// supported: P2PKH, P2WKH, P2SH, and P2WSH.
DeliveryPkScript PkScript
// DustLimit is the threshold below which no HTLC output should be
// generated for our commitment transaction; ie. HTLCs below
// this amount are not enforceable onchain from our point view.
DustLimit btcutil.Amount
// ConfirmationDepth is the number of confirmations that the initiator
// of a funding workflow is requesting be required before the channel
// is considered fully open.
ConfirmationDepth uint32
}
// NewSingleFundingRequest creates, and returns a new empty SingleFundingRequest.
func NewSingleFundingRequest(chanID [32]byte, chanType uint8, coinType uint64,
feePerKw btcutil.Amount, amt btcutil.Amount, delay uint32, ck,
cdp *btcec.PublicKey, deliveryScript PkScript,
dustLimit btcutil.Amount, pushSat btcutil.Amount,
confDepth uint32) *SingleFundingRequest {
return &SingleFundingRequest{
PendingChannelID: chanID,
ChannelType: chanType,
CoinType: coinType,
FeePerKw: feePerKw,
FundingAmount: amt,
CsvDelay: delay,
CommitmentKey: ck,
ChannelDerivationPoint: cdp,
DeliveryPkScript: deliveryScript,
DustLimit: dustLimit,
PushSatoshis: pushSat,
ConfirmationDepth: confDepth,
}
}
// Decode deserializes the serialized SingleFundingRequest stored in the passed
// io.Reader into the target SingleFundingRequest using the deserialization
// rules defined by the passed protocol version.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingRequest) Decode(r io.Reader, pver uint32) error {
return readElements(r,
c.PendingChannelID[:],
&c.ChannelType,
&c.CoinType,
&c.FeePerKw,
&c.FundingAmount,
&c.PushSatoshis,
&c.CsvDelay,
&c.CommitmentKey,
&c.ChannelDerivationPoint,
&c.DeliveryPkScript,
&c.DustLimit,
&c.ConfirmationDepth)
}
// Encode serializes the target SingleFundingRequest into the passed io.Writer
// implementation. Serialization will observe the rules defined by the passed
// protocol version.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingRequest) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
c.PendingChannelID[:],
c.ChannelType,
c.CoinType,
c.FeePerKw,
c.FundingAmount,
c.PushSatoshis,
c.CsvDelay,
c.CommitmentKey,
c.ChannelDerivationPoint,
c.DeliveryPkScript,
c.DustLimit,
c.ConfirmationDepth)
}
// MsgType returns the uint32 code which uniquely identifies this message as a
// SingleFundingRequest on the wire.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingRequest) MsgType() MessageType {
return MsgSingleFundingRequest
}
// MaxPayloadLength returns the maximum allowed payload length for a
// SingleFundingRequest. This is calculated by summing the max length of all
// the fields within a SingleFundingRequest. To enforce a maximum
// DeliveryPkScript size, the size of a P2PKH public key script is used.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingRequest) MaxPayloadLength(uint32) uint32 {
var length uint32
// PendingChannelID - 32 bytes
length += 32
// ChannelType - 1 byte
length++
// CoinType - 8 bytes
length += 8
// FeePerKw - 8 bytes
length += 8
// FundingAmount - 8 bytes
length += 8
// PushSatoshis - 8 bytes
length += 8
// CsvDelay - 4 bytes
length += 4
// CommitmentKey - 33 bytes
length += 33
// ChannelDerivationPoint - 33 bytes
length += 33
// DeliveryPkScript - 34 bytes + 1 byte varInt
length += 35
// DustLimit - 8 bytes
length += 8
// ConfirmationDepth - 4 bytes
length += 4
return length
}

View File

@ -1,158 +0,0 @@
package lnwire
import (
"io"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcutil"
)
// SingleFundingResponse is the message Bob sends to Alice after she initiates
// the single funder channel workflow via a SingleFundingRequest message. Once
// Alice receives Bob's response, then she has all the items necessary to
// construct the funding transaction, and both commitment transactions.
type SingleFundingResponse struct {
// PendingChannelID serves to uniquely identify the future channel
// created by the initiated single funder workflow.
PendingChannelID [32]byte
// ChannelDerivationPoint is an secp256k1 point which will be used to
// derive the public key the responder will use for the half of the
// 2-of-2 multi-sig. Using the channel derivation point (CDP), and the
// responder's identity public key (A), the channel public key is
// computed as: C = A + CDP. In order to be valid all CDP's MUST have
// an odd y-coordinate.
ChannelDerivationPoint *btcec.PublicKey
// CommitmentKey is key the responder to the funding workflow wishes to
// use within their versino of the commitment transaction for any
// delayed (CSV) or immediate outputs to them.
CommitmentKey *btcec.PublicKey
// RevocationKey is the initial key to be used for the revocation
// clause within the self-output of the responder's commitment
// transaction. Once an initial new state is created, the responder
// will send a preimage which will allow the initiator to sweep the
// responder's funds if the violate the contract.
RevocationKey *btcec.PublicKey
// CsvDelay is the number of blocks to use for the relative time lock
// in the pay-to-self output of both commitment transactions.
CsvDelay uint32
// DeliveryPkScript defines the public key script that the initiator
// would like to use to receive their balance in the case of a
// cooperative close. Only the following script templates are
// supported: P2PKH, P2WKH, P2SH, and P2WSH.
DeliveryPkScript PkScript
// DustLimit is the threshold below which no HTLC output should be
// generated for remote commitment transaction; ie. HTLCs below
// this amount are not enforceable onchain for their point of view.
DustLimit btcutil.Amount
// ConfirmationDepth is the number of confirmations that the initiator
// of a funding workflow is requesting be required before the channel
// is considered fully open.
ConfirmationDepth uint32
}
// NewSingleFundingResponse creates, and returns a new empty
// SingleFundingResponse.
func NewSingleFundingResponse(chanID [32]byte, rk, ck, cdp *btcec.PublicKey,
delay uint32, deliveryScript PkScript,
dustLimit btcutil.Amount, confDepth uint32) *SingleFundingResponse {
return &SingleFundingResponse{
PendingChannelID: chanID,
ChannelDerivationPoint: cdp,
CommitmentKey: ck,
RevocationKey: rk,
CsvDelay: delay,
DeliveryPkScript: deliveryScript,
DustLimit: dustLimit,
ConfirmationDepth: confDepth,
}
}
// A compile time check to ensure SingleFundingResponse implements the
// lnwire.Message interface.
var _ Message = (*SingleFundingResponse)(nil)
// Decode deserializes the serialized SingleFundingResponse stored in the passed
// io.Reader into the target SingleFundingResponse using the deserialization
// rules defined by the passed protocol version.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingResponse) Decode(r io.Reader, pver uint32) error {
return readElements(r,
c.PendingChannelID[:],
&c.ChannelDerivationPoint,
&c.CommitmentKey,
&c.RevocationKey,
&c.CsvDelay,
&c.DeliveryPkScript,
&c.DustLimit,
&c.ConfirmationDepth)
}
// Encode serializes the target SingleFundingResponse into the passed io.Writer
// implementation. Serialization will observe the rules defined by the passed
// protocol version.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingResponse) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
c.PendingChannelID[:],
c.ChannelDerivationPoint,
c.CommitmentKey,
c.RevocationKey,
c.CsvDelay,
c.DeliveryPkScript,
c.DustLimit,
c.ConfirmationDepth)
}
// MsgType returns the uint32 code which uniquely identifies this message as a
// SingleFundingResponse on the wire.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingResponse) MsgType() MessageType {
return MsgSingleFundingResponse
}
// MaxPayloadLength returns the maximum allowed payload length for a
// SingleFundingResponse. This is calculated by summing the max length of all
// the fields within a SingleFundingResponse. To enforce a maximum
// DeliveryPkScript size, the size of a P2PKH public key script is used.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingResponse) MaxPayloadLength(uint32) uint32 {
var length uint32
// PendingChannelID - 32 bytes
length += 32
// ChannelDerivationPoint - 33 bytes
length += 33
// CommitmentKey - 33 bytes
length += 33
// RevocationKey - 33 bytes
length += 33
// CsvDelay - 4 bytes
length += 4
// DeliveryPkScript - 34 bytes + 1 varInt
length += 35
// DustLimit - 8 bytes
length += 8
// ConfirmationDepth - 4 bytes
length += 4
return length
}

View File

@ -1,72 +0,0 @@
package lnwire
import (
"io"
"github.com/roasbeef/btcd/btcec"
)
// SingleFundingSignComplete is the message Bob sends to Alice which delivers
// a signature for Alice's version of the commitment transaction. After this
// message is received and processed by Alice, she is free to broadcast the
// funding transaction.
type SingleFundingSignComplete struct {
// PendingChannelID serves to uniquely identify the future channel
// created by the initiated single funder workflow.
PendingChannelID [32]byte
// CommitSignature is Bobs's signature for Alice's version of the
// commitment transaction.
CommitSignature *btcec.Signature
}
// NewSingleFundingSignComplete creates a new empty SingleFundingSignComplete
// message.
func NewSingleFundingSignComplete(chanID [32]byte,
sig *btcec.Signature) *SingleFundingSignComplete {
return &SingleFundingSignComplete{
PendingChannelID: chanID,
CommitSignature: sig,
}
}
// Decode deserializes the serialized SingleFundingSignComplete stored in the
// passed io.Reader into the target SingleFundingComplete using the
// deserialization rules defined by the passed protocol version.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingSignComplete) Decode(r io.Reader, pver uint32) error {
return readElements(r,
c.PendingChannelID[:],
&c.CommitSignature)
}
// Encode serializes the target SingleFundingSignComplete into the passed
// io.Writer implementation. Serialization will observe the rules defined by
// the passed protocol version.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingSignComplete) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
c.PendingChannelID[:],
c.CommitSignature)
}
// MsgType returns the uint32 code which uniquely identifies this message as a
// SingleFundingSignComplete on the wire.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingSignComplete) MsgType() MessageType {
return MsgSingleFundingSignComplete
}
// MaxPayloadLength returns the maximum allowed payload length for a
// SingleFundingSignComplete. This is calculated by summing the max length of
// all the fields within a SingleFundingSignComplete.
//
// This is part of the lnwire.Message interface.
func (c *SingleFundingSignComplete) MaxPayloadLength(uint32) uint32 {
// 32 + 64
return 96
}