mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 15:11:09 +02:00
cnct: define separate broadcast delta for outgoing htlcs
This commits exposes the various parameters around going to chain and
accepting htlcs in a clear way.
In addition to this, it reverts those parameters to what they were
before the merge of commit d107627145
.
This commit is contained in:
@@ -53,13 +53,20 @@ type ChainArbitratorConfig struct {
|
||||
// ChainHash is the chain that this arbitrator is to operate within.
|
||||
ChainHash chainhash.Hash
|
||||
|
||||
// BroadcastDelta is the delta that we'll use to decide when to
|
||||
// broadcast our commitment transaction. This value should be set
|
||||
// based on our current fee estimation of the commitment transaction.
|
||||
// We use this to determine when we should broadcast instead of the
|
||||
// just the HTLC timeout, as we want to ensure that the commitment
|
||||
// transaction is already confirmed, by the time the HTLC expires.
|
||||
BroadcastDelta uint32
|
||||
// IncomingBroadcastDelta is the delta that we'll use to decide when to
|
||||
// broadcast our commitment transaction if we have incoming htlcs. This
|
||||
// value should be set based on our current fee estimation of the
|
||||
// commitment transaction. We use this to determine when we should
|
||||
// broadcast instead of the just the HTLC timeout, as we want to ensure
|
||||
// that the commitment transaction is already confirmed, by the time the
|
||||
// HTLC expires. Otherwise we may end up not settling the htlc on-chain
|
||||
// because the other party managed to time it out.
|
||||
IncomingBroadcastDelta uint32
|
||||
|
||||
// OutgoingBroadcastDelta is the delta that we'll use to decide when to
|
||||
// broadcast our commitment transaction if there are active outgoing
|
||||
// htlcs. This value can be lower than the incoming broadcast delta.
|
||||
OutgoingBroadcastDelta uint32
|
||||
|
||||
// NewSweepAddr is a function that returns a new address under control
|
||||
// by the wallet. We'll use this to sweep any no-delay outputs as a
|
||||
|
@@ -1106,7 +1106,8 @@ func (c *ChannelArbitrator) checkChainActions(height uint32,
|
||||
// We'll need to go on-chain for an outgoing HTLC if it was
|
||||
// never resolved downstream, and it's "close" to timing out.
|
||||
haveChainActions = haveChainActions || c.shouldGoOnChain(
|
||||
htlc.RefundTimeout, c.cfg.BroadcastDelta, height,
|
||||
htlc.RefundTimeout, c.cfg.OutgoingBroadcastDelta,
|
||||
height,
|
||||
)
|
||||
}
|
||||
for _, htlc := range c.activeHTLCs.incomingHTLCs {
|
||||
@@ -1124,7 +1125,8 @@ func (c *ChannelArbitrator) checkChainActions(height uint32,
|
||||
continue
|
||||
}
|
||||
haveChainActions = haveChainActions || c.shouldGoOnChain(
|
||||
htlc.RefundTimeout, c.cfg.BroadcastDelta, height,
|
||||
htlc.RefundTimeout, c.cfg.IncomingBroadcastDelta,
|
||||
height,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1162,7 +1164,8 @@ func (c *ChannelArbitrator) checkChainActions(height uint32,
|
||||
// until the HTLC times out to see if we can also redeem it
|
||||
// on-chain.
|
||||
case !c.shouldGoOnChain(
|
||||
htlc.RefundTimeout, c.cfg.BroadcastDelta, height,
|
||||
htlc.RefundTimeout, c.cfg.OutgoingBroadcastDelta,
|
||||
height,
|
||||
):
|
||||
// TODO(roasbeef): also need to be able to query
|
||||
// circuit map to see if HTLC hasn't been fully
|
||||
|
@@ -165,7 +165,8 @@ func createTestChannelArbitrator(log ArbitratorLog) (*ChannelArbitrator,
|
||||
DeliverResolutionMsg: func(...ResolutionMsg) error {
|
||||
return nil
|
||||
},
|
||||
BroadcastDelta: 5,
|
||||
OutgoingBroadcastDelta: 5,
|
||||
IncomingBroadcastDelta: 5,
|
||||
Notifier: &mockNotifier{
|
||||
epochChan: make(chan *chainntnfs.BlockEpoch),
|
||||
spendChan: make(chan *chainntnfs.SpendDetail),
|
||||
|
Reference in New Issue
Block a user