multi: fix various typos

This commit is contained in:
Elle Mouton committed 2024-02-21 11:35:10 +02:00
1 parent c398b0cc69
commit 71753af8ee
5 files changed
+90 -82

No files matched your search

+1 -1
View File
@@ -139,7 +139,7 @@ type ChannelUpdateHandler interface {
// the state already allowed those adds. // the state already allowed those adds.
EnableAdds(direction LinkDirection) error EnableAdds(direction LinkDirection) error
// DiableAdds sets the ChannelUpdateHandler state to allow // DisableAdds sets the ChannelUpdateHandler state to allow
// UpdateAddHtlc's in the specified direction. It returns an error if // UpdateAddHtlc's in the specified direction. It returns an error if
// the state already disallowed those adds. // the state already disallowed those adds.
DisableAdds(direction LinkDirection) error DisableAdds(direction LinkDirection) error
+1 -1
View File
@@ -636,7 +636,7 @@ func (l *channelLink) EnableAdds(linkDirection LinkDirection) error {
return nil return nil
} }
// DiableAdds sets the ChannelUpdateHandler state to allow UpdateAddHtlc's in // DisableAdds sets the ChannelUpdateHandler state to allow UpdateAddHtlc's in
// the specified direction. It returns an error if the state already disallowed // the specified direction. It returns an error if the state already disallowed
// those adds. // those adds.
func (l *channelLink) DisableAdds(linkDirection LinkDirection) error { func (l *channelLink) DisableAdds(linkDirection LinkDirection) error {
+6 -6
View File
@@ -11,12 +11,12 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
// testCoopCloseWithHtlcs tests whether or not we can successfully issue a coop // testCoopCloseWithHtlcs tests whether we can successfully issue a coop close
// close request whilt there are still active htlcs on the link. Here we will // request while there are still active htlcs on the link. Here we will set up
// set up an HODL invoice to suspend settlement. Then we will attempt to close // an HODL invoice to suspend settlement. Then we will attempt to close the
// the channel which should appear as a noop for the time being. Then we will // channel which should appear as a noop for the time being. Then we will have
// have the receiver settle the invoice and observe that the channel gets torn // the receiver settle the invoice and observe that the channel gets torn down
// down after settlement. // after settlement.
func testCoopCloseWithHtlcs(ht *lntest.HarnessTest) { func testCoopCloseWithHtlcs(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice, bob := ht.Alice, ht.Bob
+77 -69
View File
@@ -21,13 +21,13 @@ import (
) )
var ( var (
// ErrChanAlreadyClosing is returned when a channel shutdown is attempted // ErrChanAlreadyClosing is returned when a channel shutdown is
// more than once. // attempted more than once.
ErrChanAlreadyClosing = fmt.Errorf("channel shutdown already initiated") ErrChanAlreadyClosing = fmt.Errorf("channel shutdown already initiated")
// ErrChanCloseNotFinished is returned when a caller attempts to access // ErrChanCloseNotFinished is returned when a caller attempts to access
// a field or function that is contingent on the channel closure negotiation // a field or function that is contingent on the channel closure
// already being completed. // negotiation already being completed.
ErrChanCloseNotFinished = fmt.Errorf("close negotiation not finished") ErrChanCloseNotFinished = fmt.Errorf("close negotiation not finished")
// ErrInvalidState is returned when the closing state machine receives a // ErrInvalidState is returned when the closing state machine receives a
@@ -79,16 +79,16 @@ const (
// closeFeeNegotiation is the third, and most persistent state. Both // closeFeeNegotiation is the third, and most persistent state. Both
// parties enter this state after they've sent and received a shutdown // parties enter this state after they've sent and received a shutdown
// message. During this phase, both sides will send monotonically // message. During this phase, both sides will send monotonically
// increasing fee requests until one side accepts the last fee rate offered // increasing fee requests until one side accepts the last fee rate
// by the other party. In this case, the party will broadcast the closing // offered by the other party. In this case, the party will broadcast
// transaction, and send the accepted fee to the remote party. This then // the closing transaction, and send the accepted fee to the remote
// causes a shift into the closeFinished state. // party. This then causes a shift into the closeFinished state.
closeFeeNegotiation closeFeeNegotiation
// closeFinished is the final state of the state machine. In this state, a // closeFinished is the final state of the state machine. In this state,
// side has accepted a fee offer and has broadcast the valid closing // a side has accepted a fee offer and has broadcast the valid closing
// transaction to the network. During this phase, the closing transaction // transaction to the network. During this phase, the closing
// becomes available for examination. // transaction becomes available for examination.
closeFinished closeFinished
) )
@@ -156,8 +156,9 @@ type ChanCloser struct {
// negotiationHeight is the height that the fee negotiation begun at. // negotiationHeight is the height that the fee negotiation begun at.
negotiationHeight uint32 negotiationHeight uint32
// closingTx is the final, fully signed closing transaction. This will only // closingTx is the final, fully signed closing transaction. This will
// be populated once the state machine shifts to the closeFinished state. // only be populated once the state machine shifts to the closeFinished
// state.
closingTx *wire.MsgTx closingTx *wire.MsgTx
// idealFeeSat is the ideal fee that the state machine should initially // idealFeeSat is the ideal fee that the state machine should initially
@@ -173,22 +174,22 @@ type ChanCloser struct {
idealFeeRate chainfee.SatPerKWeight idealFeeRate chainfee.SatPerKWeight
// lastFeeProposal is the last fee that we proposed to the remote party. // lastFeeProposal is the last fee that we proposed to the remote party.
// We'll use this as a pivot point to ratchet our next offer up, down, or // We'll use this as a pivot point to ratchet our next offer up, down,
// simply accept the remote party's prior offer. // or simply accept the remote party's prior offer.
lastFeeProposal btcutil.Amount lastFeeProposal btcutil.Amount
// priorFeeOffers is a map that keeps track of all the proposed fees that // priorFeeOffers is a map that keeps track of all the proposed fees
// we've offered during the fee negotiation. We use this map to cut the // that we've offered during the fee negotiation. We use this map to cut
// negotiation early if the remote party ever sends an offer that we've // the negotiation early if the remote party ever sends an offer that
// sent in the past. Once negotiation terminates, we can extract the prior // we've sent in the past. Once negotiation terminates, we can extract
// signature of our accepted offer from this map. // the prior signature of our accepted offer from this map.
// //
// TODO(roasbeef): need to ensure if they broadcast w/ any of our prior // TODO(roasbeef): need to ensure if they broadcast w/ any of our prior
// sigs, we are aware of // sigs, we are aware of
priorFeeOffers map[btcutil.Amount]*lnwire.ClosingSigned priorFeeOffers map[btcutil.Amount]*lnwire.ClosingSigned
// closeReq is the initial closing request. This will only be populated if // closeReq is the initial closing request. This will only be populated
// we're the initiator of this closing negotiation. // if we're the initiator of this closing negotiation.
// //
// TODO(roasbeef): abstract away // TODO(roasbeef): abstract away
closeReq *htlcswitch.ChanClose closeReq *htlcswitch.ChanClose
@@ -273,8 +274,10 @@ func NewChanCloser(cfg ChanCloseCfg, deliveryScript []byte,
negotiationHeight: negotiationHeight, negotiationHeight: negotiationHeight,
idealFeeRate: idealFeePerKw, idealFeeRate: idealFeePerKw,
localDeliveryScript: deliveryScript, localDeliveryScript: deliveryScript,
priorFeeOffers: make(map[btcutil.Amount]*lnwire.ClosingSigned), priorFeeOffers: make(
locallyInitiated: locallyInitiated, map[btcutil.Amount]*lnwire.ClosingSigned,
),
locallyInitiated: locallyInitiated,
} }
} }
@@ -321,9 +324,9 @@ func (c *ChanCloser) initFeeBaseline() {
// initChanShutdown begins the shutdown process by un-registering the channel, // initChanShutdown begins the shutdown process by un-registering the channel,
// and creating a valid shutdown message to our target delivery address. // and creating a valid shutdown message to our target delivery address.
func (c *ChanCloser) initChanShutdown() (*lnwire.Shutdown, error) { func (c *ChanCloser) initChanShutdown() (*lnwire.Shutdown, error) {
// With both items constructed we'll now send the shutdown message for this // With both items constructed we'll now send the shutdown message for
// particular channel, advertising a shutdown request to our desired // this particular channel, advertising a shutdown request to our
// closing script. // desired closing script.
shutdown := lnwire.NewShutdown(c.cid, c.localDeliveryScript) shutdown := lnwire.NewShutdown(c.cid, c.localDeliveryScript)
// If this is a taproot channel, then we'll need to also generate a // If this is a taproot channel, then we'll need to also generate a
@@ -375,12 +378,12 @@ func (c *ChanCloser) ShutdownChan() (*lnwire.Shutdown, error) {
} }
// With the opening steps complete, we'll transition into the // With the opening steps complete, we'll transition into the
// closeShutdownInitiated state. In this state, we'll wait until the other // closeShutdownInitiated state. In this state, we'll wait until the
// party sends their version of the shutdown message. // other party sends their version of the shutdown message.
c.state = closeShutdownInitiated c.state = closeShutdownInitiated
// Finally, we'll return the shutdown message to the caller so it can send // Finally, we'll return the shutdown message to the caller so it can
// it to the remote peer. // send it to the remote peer.
return shutdownMsg, nil return shutdownMsg, nil
} }
@@ -476,9 +479,8 @@ func validateShutdownScript(disconnect func() error, upfrontScript,
// If appropriate, it will also generate a Shutdown message of its own to send // If appropriate, it will also generate a Shutdown message of its own to send
// out to the peer. It is possible for this method to return None when no error // out to the peer. It is possible for this method to return None when no error
// occurred. // occurred.
func (c *ChanCloser) ReceiveShutdown( func (c *ChanCloser) ReceiveShutdown(msg lnwire.Shutdown) (
msg lnwire.Shutdown, fn.Option[lnwire.Shutdown], error) {
) (fn.Option[lnwire.Shutdown], error) {
noShutdown := fn.None[lnwire.Shutdown]() noShutdown := fn.None[lnwire.Shutdown]()
@@ -610,9 +612,8 @@ func (c *ChanCloser) ReceiveShutdown(
// it will not. In either case it will transition the ChanCloser state machine // it will not. In either case it will transition the ChanCloser state machine
// to the negotiation phase wherein ClosingSigned messages are exchanged until // to the negotiation phase wherein ClosingSigned messages are exchanged until
// a mutually agreeable result is achieved. // a mutually agreeable result is achieved.
func (c *ChanCloser) BeginNegotiation() ( func (c *ChanCloser) BeginNegotiation() (fn.Option[lnwire.ClosingSigned],
fn.Option[lnwire.ClosingSigned], error, error) {
) {
noClosingSigned := fn.None[lnwire.ClosingSigned]() noClosingSigned := fn.None[lnwire.ClosingSigned]()
@@ -673,11 +674,8 @@ func (c *ChanCloser) BeginNegotiation() (
// ReceiveClosingSigned is a method that should be called whenever we receive a // ReceiveClosingSigned is a method that should be called whenever we receive a
// ClosingSigned message from the wire. It may or may not return a ClosingSigned // ClosingSigned message from the wire. It may or may not return a ClosingSigned
// of our own to send back to the remote. // of our own to send back to the remote.
// func (c *ChanCloser) ReceiveClosingSigned(msg lnwire.ClosingSigned) (
//nolint:funlen fn.Option[lnwire.ClosingSigned], error) {
func (c *ChanCloser) ReceiveClosingSigned(
msg lnwire.ClosingSigned,
) (fn.Option[lnwire.ClosingSigned], error) {
noClosing := fn.None[lnwire.ClosingSigned]() noClosing := fn.None[lnwire.ClosingSigned]()
@@ -882,7 +880,9 @@ func (c *ChanCloser) ReceiveClosingSigned(
// proposeCloseSigned attempts to propose a new signature for the closing // proposeCloseSigned attempts to propose a new signature for the closing
// transaction for a channel based on the prior fee negotiations and our current // transaction for a channel based on the prior fee negotiations and our current
// compromise fee. // compromise fee.
func (c *ChanCloser) proposeCloseSigned(fee btcutil.Amount) (*lnwire.ClosingSigned, error) { func (c *ChanCloser) proposeCloseSigned(fee btcutil.Amount) (
*lnwire.ClosingSigned, error) {
var ( var (
closeOpts []lnwallet.ChanCloseOpt closeOpts []lnwallet.ChanCloseOpt
err error err error
@@ -956,8 +956,8 @@ func (c *ChanCloser) proposeCloseSigned(fee btcutil.Amount) (*lnwire.ClosingSign
// compromise and to ensure that the fee negotiation has a stopping point. We // compromise and to ensure that the fee negotiation has a stopping point. We
// consider their fee acceptable if it's within 30% of our fee. // consider their fee acceptable if it's within 30% of our fee.
func feeInAcceptableRange(localFee, remoteFee btcutil.Amount) bool { func feeInAcceptableRange(localFee, remoteFee btcutil.Amount) bool {
// If our offer is lower than theirs, then we'll accept their offer if it's // If our offer is lower than theirs, then we'll accept their offer if
// no more than 30% *greater* than our current offer. // it's no more than 30% *greater* than our current offer.
if localFee < remoteFee { if localFee < remoteFee {
acceptableRange := localFee + ((localFee * 3) / 10) acceptableRange := localFee + ((localFee * 3) / 10)
return remoteFee <= acceptableRange return remoteFee <= acceptableRange
@@ -991,51 +991,59 @@ func calcCompromiseFee(chanPoint wire.OutPoint, ourIdealFee, lastSentFee,
// TODO(roasbeef): take in number of rounds as well? // TODO(roasbeef): take in number of rounds as well?
chancloserLog.Infof("ChannelPoint(%v): computing fee compromise, ideal="+ chancloserLog.Infof("ChannelPoint(%v): computing fee compromise, "+
"%v, last_sent=%v, remote_offer=%v", chanPoint, int64(ourIdealFee), "ideal=%v, last_sent=%v, remote_offer=%v", chanPoint,
int64(lastSentFee), int64(remoteFee)) int64(ourIdealFee), int64(lastSentFee), int64(remoteFee))
// Otherwise, we'll need to attempt to make a fee compromise if this is the // Otherwise, we'll need to attempt to make a fee compromise if this is
// second round, and neither side has agreed on fees. // the second round, and neither side has agreed on fees.
switch { switch {
// If their proposed fee is identical to our ideal fee, then we'll go with // If their proposed fee is identical to our ideal fee, then we'll go
// that as we can short circuit the fee negotiation. Similarly, if we // with that as we can short circuit the fee negotiation. Similarly, if
// haven't sent an offer yet, we'll default to our ideal fee. // we haven't sent an offer yet, we'll default to our ideal fee.
case ourIdealFee == remoteFee || lastSentFee == 0: case ourIdealFee == remoteFee || lastSentFee == 0:
return ourIdealFee return ourIdealFee
// If the last fee we sent, is equal to the fee the remote party is // If the last fee we sent, is equal to the fee the remote party is
// offering, then we can simply return this fee as the negotiation is over. // offering, then we can simply return this fee as the negotiation is
// over.
case remoteFee == lastSentFee: case remoteFee == lastSentFee:
return lastSentFee return lastSentFee
// If the fee the remote party is offering is less than the last one we // If the fee the remote party is offering is less than the last one we
// sent, then we'll need to ratchet down in order to move our offer closer // sent, then we'll need to ratchet down in order to move our offer
// to theirs. // closer to theirs.
case remoteFee < lastSentFee: case remoteFee < lastSentFee:
// If the fee is lower, but still acceptable, then we'll just return // If the fee is lower, but still acceptable, then we'll just
// this fee and end the negotiation. // return this fee and end the negotiation.
if feeInAcceptableRange(lastSentFee, remoteFee) { if feeInAcceptableRange(lastSentFee, remoteFee) {
chancloserLog.Infof("ChannelPoint(%v): proposed remote fee is "+ chancloserLog.Infof("ChannelPoint(%v): proposed "+
"close enough, capitulating", chanPoint) "remote fee is close enough, capitulating",
chanPoint)
return remoteFee return remoteFee
} }
// Otherwise, we'll ratchet the fee *down* using our current algorithm. // Otherwise, we'll ratchet the fee *down* using our current
// algorithm.
return ratchetFee(lastSentFee, false) return ratchetFee(lastSentFee, false)
// If the fee the remote party is offering is greater than the last one we // If the fee the remote party is offering is greater than the last one
// sent, then we'll ratchet up in order to ensure we terminate eventually. // we sent, then we'll ratchet up in order to ensure we terminate
// eventually.
case remoteFee > lastSentFee: case remoteFee > lastSentFee:
// If the fee is greater, but still acceptable, then we'll just return // If the fee is greater, but still acceptable, then we'll just
// this fee in order to put an end to the negotiation. // return this fee in order to put an end to the negotiation.
if feeInAcceptableRange(lastSentFee, remoteFee) { if feeInAcceptableRange(lastSentFee, remoteFee) {
chancloserLog.Infof("ChannelPoint(%v): proposed remote fee is "+ chancloserLog.Infof("ChannelPoint(%v): proposed "+
"close enough, capitulating", chanPoint) "remote fee is close enough, capitulating",
chanPoint)
return remoteFee return remoteFee
} }
// Otherwise, we'll ratchet the fee up using our current algorithm. // Otherwise, we'll ratchet the fee up using our current
// algorithm.
return ratchetFee(lastSentFee, true) return ratchetFee(lastSentFee, true)
default: default:
+5 -5
View File
@@ -975,11 +975,11 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
spew.Sdump(forwardingPolicy)) spew.Sdump(forwardingPolicy))
// If the channel is pending, set the value to nil in the // If the channel is pending, set the value to nil in the
// activeChannels map. This is done to signify that the channel is // activeChannels map. This is done to signify that the channel
// pending. We don't add the link to the switch here - it's the funding // is pending. We don't add the link to the switch here - it's
// manager's responsibility to spin up pending channels. Adding them // the funding manager's responsibility to spin up pending
// here would just be extra work as we'll tear them down when creating // channels. Adding them here would just be extra work as we'll
// + adding the final link. // tear them down when creating + adding the final link.
if lnChan.IsPending() { if lnChan.IsPending() {
p.activeChannels.Store(chanID, nil) p.activeChannels.Store(chanID, nil)