contractcourt: add resolver handlers in htlcSuccessResolver

This commit refactors the `Resolve` method by adding two resolver
handlers to handle waiting for spending confirmations.
This commit is contained in:
yyforyongyu
2024-11-14 21:59:55 +08:00
parent fb499bc4cc
commit c92d7f0fd0
2 changed files with 150 additions and 89 deletions

View File

@@ -548,9 +548,9 @@ func (h *htlcTimeoutResolver) sweepSecondLevelTx() error {
return err
}
// sendSecondLevelTxLegacy sends a second level timeout transaction to the utxo
// nursery. This transaction uses the legacy SIGHASH_ALL flag.
func (h *htlcTimeoutResolver) sendSecondLevelTxLegacy() error {
// resolveSecondLevelTxLegacy sends a second level timeout transaction to the
// utxo nursery. This transaction uses the legacy SIGHASH_ALL flag.
func (h *htlcTimeoutResolver) resolveSecondLevelTxLegacy() error {
log.Debugf("%T(%v): incubating htlc output", h,
h.htlcResolution.ClaimOutpoint)
@@ -654,7 +654,7 @@ func (h *htlcTimeoutResolver) spendHtlcOutput() (
// commitment for a non-anchor channel, so we'll send it to the utxo
// nursery.
case h.isLegacyOutput() && !h.outputIncubating:
if err := h.sendSecondLevelTxLegacy(); err != nil {
if err := h.resolveSecondLevelTxLegacy(); err != nil {
log.Errorf("Sending timeout tx to nursery: %v", err)
return nil, err