mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 07:35:07 +02:00
contractcourt: remove the immediate
param used in Resolve
This `immediate` flag was added as a hack so during a restart, the pending resolvers would offer the inputs to the sweeper and ask it to sweep them immediately. This is no longer need due to `blockbeat`, as now during restart, a block is always sent to all subsystems via the flow `ChainArb` -> `ChannelArb` -> resolvers -> sweeper. Thus, when there are pending inputs offered, they will be processed by the sweeper immediately.
This commit is contained in:
@@ -115,9 +115,7 @@ func (h *htlcSuccessResolver) ResolverKey() []byte {
|
||||
// TODO(roasbeef): create multi to batch
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (h *htlcSuccessResolver) Resolve(
|
||||
immediate bool) (ContractResolver, error) {
|
||||
|
||||
func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
||||
// If we're already resolved, then we can exit early.
|
||||
if h.resolved {
|
||||
return nil, nil
|
||||
@@ -126,12 +124,12 @@ func (h *htlcSuccessResolver) Resolve(
|
||||
// If we don't have a success transaction, then this means that this is
|
||||
// an output on the remote party's commitment transaction.
|
||||
if h.htlcResolution.SignedSuccessTx == nil {
|
||||
return h.resolveRemoteCommitOutput(immediate)
|
||||
return h.resolveRemoteCommitOutput()
|
||||
}
|
||||
|
||||
// Otherwise this an output on our own commitment, and we must start by
|
||||
// broadcasting the second-level success transaction.
|
||||
secondLevelOutpoint, err := h.broadcastSuccessTx(immediate)
|
||||
secondLevelOutpoint, err := h.broadcastSuccessTx()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -165,8 +163,8 @@ func (h *htlcSuccessResolver) Resolve(
|
||||
// broadcasting the second-level success transaction. It returns the ultimate
|
||||
// outpoint of the second-level tx, that we must wait to be spent for the
|
||||
// resolver to be fully resolved.
|
||||
func (h *htlcSuccessResolver) broadcastSuccessTx(
|
||||
immediate bool) (*wire.OutPoint, error) {
|
||||
func (h *htlcSuccessResolver) broadcastSuccessTx() (
|
||||
*wire.OutPoint, error) {
|
||||
|
||||
// If we have non-nil SignDetails, this means that have a 2nd level
|
||||
// HTLC transaction that is signed using sighash SINGLE|ANYONECANPAY
|
||||
@@ -175,7 +173,7 @@ func (h *htlcSuccessResolver) broadcastSuccessTx(
|
||||
// the checkpointed outputIncubating field to determine if we already
|
||||
// swept the HTLC output into the second level transaction.
|
||||
if h.htlcResolution.SignDetails != nil {
|
||||
return h.broadcastReSignedSuccessTx(immediate)
|
||||
return h.broadcastReSignedSuccessTx()
|
||||
}
|
||||
|
||||
// Otherwise we'll publish the second-level transaction directly and
|
||||
@@ -225,10 +223,8 @@ func (h *htlcSuccessResolver) broadcastSuccessTx(
|
||||
// broadcastReSignedSuccessTx handles the case where we have non-nil
|
||||
// SignDetails, and offers the second level transaction to the Sweeper, that
|
||||
// will re-sign it and attach fees at will.
|
||||
//
|
||||
//nolint:funlen
|
||||
func (h *htlcSuccessResolver) broadcastReSignedSuccessTx(immediate bool) (
|
||||
*wire.OutPoint, error) {
|
||||
func (h *htlcSuccessResolver) broadcastReSignedSuccessTx() (*wire.OutPoint,
|
||||
error) {
|
||||
|
||||
// Keep track of the tx spending the HTLC output on the commitment, as
|
||||
// this will be the confirmed second-level tx we'll ultimately sweep.
|
||||
@@ -287,7 +283,6 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx(immediate bool) (
|
||||
sweep.Params{
|
||||
Budget: budget,
|
||||
DeadlineHeight: deadline,
|
||||
Immediate: immediate,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -419,7 +414,7 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx(immediate bool) (
|
||||
// resolveRemoteCommitOutput handles sweeping an HTLC output on the remote
|
||||
// commitment with the preimage. In this case we can sweep the output directly,
|
||||
// and don't have to broadcast a second-level transaction.
|
||||
func (h *htlcSuccessResolver) resolveRemoteCommitOutput(immediate bool) (
|
||||
func (h *htlcSuccessResolver) resolveRemoteCommitOutput() (
|
||||
ContractResolver, error) {
|
||||
|
||||
isTaproot := txscript.IsPayToTaproot(
|
||||
@@ -471,7 +466,6 @@ func (h *htlcSuccessResolver) resolveRemoteCommitOutput(immediate bool) (
|
||||
sweep.Params{
|
||||
Budget: budget,
|
||||
DeadlineHeight: deadline,
|
||||
Immediate: immediate,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user