contracourt: rename broadcastHeight to confirmHeight

The broadcastHeight was misleading because the commit resolver
is only created when the commitment transaction is confirmed.
This commit is contained in:
ziggie committed 2025-11-22 01:17:34 +01:00
1 parent 8c8662c86a
commit 8824244656
2 files changed
+15 -15

No files matched your search

+4 -4
View File
@@ -278,9 +278,9 @@ func assertResolversEqual(t *testing.T, originalResolver ContractResolver,
t.Fatalf("expected %v, got %v", ogRes.resolved.Load(), t.Fatalf("expected %v, got %v", ogRes.resolved.Load(),
diskRes.resolved.Load()) diskRes.resolved.Load())
} }
if ogRes.broadcastHeight != diskRes.broadcastHeight { if ogRes.confirmHeight != diskRes.confirmHeight {
t.Fatalf("expected %v, got %v", t.Fatalf("expected %v, got %v",
ogRes.broadcastHeight, diskRes.broadcastHeight) ogRes.confirmHeight, diskRes.confirmHeight)
} }
if ogRes.chanPoint != diskRes.chanPoint { if ogRes.chanPoint != diskRes.chanPoint {
t.Fatalf("expected %v, got %v", ogRes.chanPoint, t.Fatalf("expected %v, got %v", ogRes.chanPoint,
@@ -341,8 +341,8 @@ func TestContractInsertionRetrieval(t *testing.T) {
SelfOutputSignDesc: testSignDesc, SelfOutputSignDesc: testSignDesc,
MaturityDelay: 99, MaturityDelay: 99,
}, },
broadcastHeight: 109, confirmHeight: 109,
chanPoint: testChanPoint1, chanPoint: testChanPoint1,
} }
commitResolver.resolved.Store(false) commitResolver.resolved.Store(false)
+11 -11
View File
@@ -38,10 +38,10 @@ type commitSweepResolver struct {
// this HTLC on-chain. // this HTLC on-chain.
commitResolution lnwallet.CommitOutputResolution commitResolution lnwallet.CommitOutputResolution
// broadcastHeight is the height that the original contract was // confirmHeight is the block height that the commitment transaction was
// broadcast to the main-chain at. We'll use this value to bound any // confirmed at. We'll use this value to bound any historical queries to
// historical queries to the chain for spends/confirmations. // the chain for spends/confirmations.
broadcastHeight uint32 confirmHeight uint32
// chanPoint is the channel point of the original contract. // chanPoint is the channel point of the original contract.
chanPoint wire.OutPoint chanPoint wire.OutPoint
@@ -74,13 +74,13 @@ type commitSweepResolver struct {
// newCommitSweepResolver instantiates a new direct commit output resolver. // newCommitSweepResolver instantiates a new direct commit output resolver.
func newCommitSweepResolver(res lnwallet.CommitOutputResolution, func newCommitSweepResolver(res lnwallet.CommitOutputResolution,
broadcastHeight uint32, chanPoint wire.OutPoint, confirmHeight uint32, chanPoint wire.OutPoint,
resCfg ResolverConfig) *commitSweepResolver { resCfg ResolverConfig) *commitSweepResolver {
r := &commitSweepResolver{ r := &commitSweepResolver{
contractResolverKit: *newContractResolverKit(resCfg), contractResolverKit: *newContractResolverKit(resCfg),
commitResolution: res, commitResolution: res,
broadcastHeight: broadcastHeight, confirmHeight: confirmHeight,
chanPoint: chanPoint, chanPoint: chanPoint,
} }
@@ -133,7 +133,7 @@ func (c *commitSweepResolver) getCommitTxConfHeight() (uint32, error) {
const confDepth = 1 const confDepth = 1
confChan, err := c.Notifier.RegisterConfirmationsNtfn( confChan, err := c.Notifier.RegisterConfirmationsNtfn(
&txID, pkScript, confDepth, c.broadcastHeight, &txID, pkScript, confDepth, c.confirmHeight,
) )
if err != nil { if err != nil {
return 0, err return 0, err
@@ -268,7 +268,7 @@ func (c *commitSweepResolver) Encode(w io.Writer) error {
if err := binary.Write(w, endian, c.IsResolved()); err != nil { if err := binary.Write(w, endian, c.IsResolved()); err != nil {
return err return err
} }
if err := binary.Write(w, endian, c.broadcastHeight); err != nil { if err := binary.Write(w, endian, c.confirmHeight); err != nil {
return err return err
} }
if _, err := w.Write(c.chanPoint.Hash[:]); err != nil { if _, err := w.Write(c.chanPoint.Hash[:]); err != nil {
@@ -308,7 +308,7 @@ func newCommitSweepResolverFromReader(r io.Reader, resCfg ResolverConfig) (
c.markResolved() c.markResolved()
} }
if err := binary.Read(r, endian, &c.broadcastHeight); err != nil { if err := binary.Read(r, endian, &c.confirmHeight); err != nil {
return nil, err return nil, err
} }
_, err := io.ReadFull(r, c.chanPoint.Hash[:]) _, err := io.ReadFull(r, c.chanPoint.Hash[:])
@@ -412,7 +412,7 @@ func (c *commitSweepResolver) Launch() error {
inp = input.NewCsvInputWithCltv( inp = input.NewCsvInputWithCltv(
&c.commitResolution.SelfOutPoint, witnessType, &c.commitResolution.SelfOutPoint, witnessType,
&c.commitResolution.SelfOutputSignDesc, &c.commitResolution.SelfOutputSignDesc,
c.broadcastHeight, c.commitResolution.MaturityDelay, c.confirmHeight, c.commitResolution.MaturityDelay,
c.leaseExpiry, input.WithResolutionBlob( c.leaseExpiry, input.WithResolutionBlob(
c.commitResolution.ResolutionBlob, c.commitResolution.ResolutionBlob,
), ),
@@ -421,7 +421,7 @@ func (c *commitSweepResolver) Launch() error {
inp = input.NewCsvInput( inp = input.NewCsvInput(
&c.commitResolution.SelfOutPoint, witnessType, &c.commitResolution.SelfOutPoint, witnessType,
&c.commitResolution.SelfOutputSignDesc, &c.commitResolution.SelfOutputSignDesc,
c.broadcastHeight, c.commitResolution.MaturityDelay, c.confirmHeight, c.commitResolution.MaturityDelay,
input.WithResolutionBlob( input.WithResolutionBlob(
c.commitResolution.ResolutionBlob, c.commitResolution.ResolutionBlob,
), ),