Skip to content

Commit c632965

Browse files
committed
contractcourt: make sure output from legacy success tx is swept
This commit fixes an existing issue where the output from a pre-anchor type HTLC success tx is not swept.
1 parent 74e1232 commit c632965

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

contractcourt/htlc_success_resolver.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func (h *htlcSuccessResolver) Encode(w io.Writer) error {
298298
if err := binary.Write(w, endian, h.outputIncubating); err != nil {
299299
return err
300300
}
301-
if err := binary.Write(w, endian, h.resolved); err != nil {
301+
if err := binary.Write(w, endian, h.IsResolved()); err != nil {
302302
return err
303303
}
304304
if err := binary.Write(w, endian, h.broadcastHeight); err != nil {
@@ -337,9 +337,13 @@ func newSuccessResolverFromReader(r io.Reader, resCfg ResolverConfig) (
337337
if err := binary.Read(r, endian, &h.outputIncubating); err != nil {
338338
return nil, err
339339
}
340-
if err := binary.Read(r, endian, &h.resolved); err != nil {
340+
341+
var resolved bool
342+
if err := binary.Read(r, endian, &resolved); err != nil {
341343
return nil, err
342344
}
345+
h.resolved.Store(resolved)
346+
343347
if err := binary.Read(r, endian, &h.broadcastHeight); err != nil {
344348
return nil, err
345349
}
@@ -622,7 +626,7 @@ func (h *htlcSuccessResolver) resolveLegacySuccessTx() error {
622626

623627
// Exit early if the output has already been sent to the UtxoNursery.
624628
if h.outputIncubating {
625-
return nil
629+
return h.resolveSuccessTxOutput(h.htlcResolution.ClaimOutpoint)
626630
}
627631

628632
// Otherwise, this is an output on our commitment transaction. In this
@@ -641,7 +645,12 @@ func (h *htlcSuccessResolver) resolveLegacySuccessTx() error {
641645
}
642646

643647
h.outputIncubating = true
644-
return h.Checkpoint(h)
648+
if err := h.Checkpoint(h); err != nil {
649+
log.Errorf("unable to Checkpoint: %v", err)
650+
return err
651+
}
652+
653+
return h.resolveSuccessTxOutput(h.htlcResolution.ClaimOutpoint)
645654
}
646655

647656
// resolveSuccessTx waits for the sweeping tx of the second-level success tx to

0 commit comments

Comments
 (0)