multi: surface may add outgoing hltc
This commit is contained in:
4 files changed
+38
No files matched your search
@@ -4934,6 +4934,33 @@ func (lc *LightningChannel) AddHTLC(htlc *lnwire.UpdateAddHTLC,
|
||||
return pd.HtlcIndex, nil
|
||||
}
|
||||
|
||||
// MayAddOutgoingHtlc validates whether we can add an outgoing htlc to this
|
||||
// channel. We don't have a value or circuit for this htlc, because we just
|
||||
// want to test that we have slots for a potential htlc so we use a "mock"
|
||||
// htlc to validate a potential commitment state with one more outgoing htlc.
|
||||
func (lc *LightningChannel) MayAddOutgoingHtlc() error {
|
||||
lc.Lock()
|
||||
defer lc.Unlock()
|
||||
|
||||
// Create a "mock" outgoing htlc, using the smallest amount we can add
|
||||
// to the commitment so that we validate commitment slots rather than
|
||||
// available balance, since our actual htlc amount is unknown at this
|
||||
// stage.
|
||||
pd := lc.htlcAddDescriptor(
|
||||
&lnwire.UpdateAddHTLC{
|
||||
Amount: lc.channelState.LocalChanCfg.MinHTLC,
|
||||
},
|
||||
&channeldb.CircuitKey{},
|
||||
)
|
||||
|
||||
if err := lc.validateAddHtlc(pd); err != nil {
|
||||
lc.log.Debugf("May add outgoing htlc rejected: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// htlcAddDescriptor returns a payment descriptor for the htlc and open key
|
||||
// provided to add to our local update log.
|
||||
func (lc *LightningChannel) htlcAddDescriptor(htlc *lnwire.UpdateAddHTLC,
|
||||
|
||||
Reference in new issue
Block a user