mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 06:21:40 +01:00
lnwallet: update comments
This commit is contained in:
parent
a90939a717
commit
5410725306
2 changed files with 15 additions and 18 deletions
|
@ -58,8 +58,8 @@ type InputScript struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelReservation represents an intent to open a lightning payment channel
|
// ChannelReservation represents an intent to open a lightning payment channel
|
||||||
// a counterparty. The funding processes from reservation to channel opening is
|
// with a counterparty. The funding processes from reservation to channel opening
|
||||||
// a 3-step process. In order to allow for full concurrency during the
|
// is a 3-step process. In order to allow for full concurrency during the
|
||||||
// reservation workflow, resources consumed by a contribution are "locked"
|
// reservation workflow, resources consumed by a contribution are "locked"
|
||||||
// themselves. This prevents a number of race conditions such as two funding
|
// themselves. This prevents a number of race conditions such as two funding
|
||||||
// transactions double-spending the same input. A reservation can also be
|
// transactions double-spending the same input. A reservation can also be
|
||||||
|
@ -69,12 +69,12 @@ type InputScript struct {
|
||||||
// The reservation workflow consists of the following three steps:
|
// The reservation workflow consists of the following three steps:
|
||||||
// 1. lnwallet.InitChannelReservation
|
// 1. lnwallet.InitChannelReservation
|
||||||
// * One requests the wallet to allocate the necessary resources for a
|
// * One requests the wallet to allocate the necessary resources for a
|
||||||
// channel reservation. These resources a put in limbo for the lifetime
|
// channel reservation. These resources are put in limbo for the lifetime
|
||||||
// of a reservation.
|
// of a reservation.
|
||||||
// * Once completed the reservation will have the wallet's contribution
|
// * Once completed the reservation will have the wallet's contribution
|
||||||
// accessible via the .OurContribution() method. This contribution
|
// accessible via the .OurContribution() method. This contribution
|
||||||
// contains the necessary items to allow the remote party to build both
|
// contains the necessary items to allow the remote party to build both
|
||||||
// the funding, and commitment transactions.
|
// the funding, and commitment transactions.
|
||||||
// 2. ChannelReservation.ProcessContribution/ChannelReservation.ProcessSingleContribution
|
// 2. ChannelReservation.ProcessContribution/ChannelReservation.ProcessSingleContribution
|
||||||
// * The counterparty presents their contribution to the payment channel.
|
// * The counterparty presents their contribution to the payment channel.
|
||||||
// This allows us to build the funding, and commitment transactions
|
// This allows us to build the funding, and commitment transactions
|
||||||
|
|
|
@ -52,9 +52,8 @@ func (e *ErrInsufficientFunds) Error() string {
|
||||||
// will be created in order to track the lifetime of this pending channel.
|
// will be created in order to track the lifetime of this pending channel.
|
||||||
// Outputs selected will be 'locked', making them unavailable, for any other
|
// Outputs selected will be 'locked', making them unavailable, for any other
|
||||||
// pending reservations. Therefore, all channels in reservation limbo will be
|
// pending reservations. Therefore, all channels in reservation limbo will be
|
||||||
// periodically after a timeout period in order to avoid "exhaustion" attacks.
|
// periodically timed out after an idle period in order to avoid "exhaustion"
|
||||||
//
|
// attacks.
|
||||||
// TODO(roasbeef): zombie reservation sweeper goroutine.
|
|
||||||
type initFundingReserveMsg struct {
|
type initFundingReserveMsg struct {
|
||||||
// chainHash denotes that chain to be used to ultimately open the
|
// chainHash denotes that chain to be used to ultimately open the
|
||||||
// target channel.
|
// target channel.
|
||||||
|
@ -261,8 +260,6 @@ type LightningWallet struct {
|
||||||
fundingLimbo map[uint64]*ChannelReservation
|
fundingLimbo map[uint64]*ChannelReservation
|
||||||
nextFundingID uint64
|
nextFundingID uint64
|
||||||
limboMtx sync.RWMutex
|
limboMtx sync.RWMutex
|
||||||
// TODO(roasbeef): zombie garbage collection routine to solve
|
|
||||||
// lost-object/starvation problem/attack.
|
|
||||||
|
|
||||||
// lockedOutPoints is a set of the currently locked outpoint. This
|
// lockedOutPoints is a set of the currently locked outpoint. This
|
||||||
// information is kept in order to provide an easy way to unlock all
|
// information is kept in order to provide an easy way to unlock all
|
||||||
|
@ -366,7 +363,7 @@ func (l *LightningWallet) ActiveReservations() []*ChannelReservation {
|
||||||
}
|
}
|
||||||
|
|
||||||
// requestHandler is the primary goroutine(s) responsible for handling, and
|
// requestHandler is the primary goroutine(s) responsible for handling, and
|
||||||
// dispatching relies to all messages.
|
// dispatching replies to all messages.
|
||||||
func (l *LightningWallet) requestHandler() {
|
func (l *LightningWallet) requestHandler() {
|
||||||
out:
|
out:
|
||||||
for {
|
for {
|
||||||
|
@ -403,14 +400,14 @@ out:
|
||||||
// successful, a ChannelReservation containing our completed contribution is
|
// successful, a ChannelReservation containing our completed contribution is
|
||||||
// returned. Our contribution contains all the items necessary to allow the
|
// returned. Our contribution contains all the items necessary to allow the
|
||||||
// counterparty to build the funding transaction, and both versions of the
|
// counterparty to build the funding transaction, and both versions of the
|
||||||
// commitment transaction. Otherwise, an error occurred a nil pointer along with
|
// commitment transaction. Otherwise, an error occurred and a nil pointer along
|
||||||
// an error are returned.
|
// with an error are returned.
|
||||||
//
|
//
|
||||||
// Once a ChannelReservation has been obtained, two additional steps must be
|
// Once a ChannelReservation has been obtained, two additional steps must be
|
||||||
// processed before a payment channel can be considered 'open'. The second step
|
// processed before a payment channel can be considered 'open'. The second step
|
||||||
// validates, and processes the counterparty's channel contribution. The third,
|
// validates, and processes the counterparty's channel contribution. The third,
|
||||||
// and final step verifies all signatures for the inputs of the funding
|
// and final step verifies all signatures for the inputs of the funding
|
||||||
// transaction, and that the signature we records for our version of the
|
// transaction, and that the signature we record for our version of the
|
||||||
// commitment transaction is valid.
|
// commitment transaction is valid.
|
||||||
func (l *LightningWallet) InitChannelReservation(
|
func (l *LightningWallet) InitChannelReservation(
|
||||||
capacity, ourFundAmt btcutil.Amount, pushMSat lnwire.MilliSatoshi,
|
capacity, ourFundAmt btcutil.Amount, pushMSat lnwire.MilliSatoshi,
|
||||||
|
@ -579,7 +576,7 @@ func (l *LightningWallet) handleFundingReserveRequest(req *initFundingReserveMsg
|
||||||
reservation.partialState.RevocationProducer = producer
|
reservation.partialState.RevocationProducer = producer
|
||||||
reservation.ourContribution.ChannelConstraints = l.Cfg.DefaultConstraints
|
reservation.ourContribution.ChannelConstraints = l.Cfg.DefaultConstraints
|
||||||
|
|
||||||
// TODO(roasbeef): turn above into: initContributio()
|
// TODO(roasbeef): turn above into: initContribution()
|
||||||
|
|
||||||
// Create a limbo and record entry for this newly pending funding
|
// Create a limbo and record entry for this newly pending funding
|
||||||
// request.
|
// request.
|
||||||
|
|
Loading…
Add table
Reference in a new issue