@@ -38,10 +38,10 @@ type commitSweepResolver struct {
3838 // this HTLC on-chain.
3939 commitResolution lnwallet.CommitOutputResolution
4040
41- // broadcastHeight is the height that the original contract was
42- // broadcast to the main-chain at. We'll use this value to bound any
43- // historical queries to the chain for spends/confirmations.
44- broadcastHeight uint32
41+ // confirmHeight is the block height that the commitment transaction was
42+ // confirmed at. We'll use this value to bound any historical queries to
43+ // the chain for spends/confirmations.
44+ confirmHeight uint32
4545
4646 // chanPoint is the channel point of the original contract.
4747 chanPoint wire.OutPoint
@@ -74,13 +74,13 @@ type commitSweepResolver struct {
7474
7575// newCommitSweepResolver instantiates a new direct commit output resolver.
7676func newCommitSweepResolver (res lnwallet.CommitOutputResolution ,
77- broadcastHeight uint32 , chanPoint wire.OutPoint ,
77+ confirmHeight uint32 , chanPoint wire.OutPoint ,
7878 resCfg ResolverConfig ) * commitSweepResolver {
7979
8080 r := & commitSweepResolver {
8181 contractResolverKit : * newContractResolverKit (resCfg ),
8282 commitResolution : res ,
83- broadcastHeight : broadcastHeight ,
83+ confirmHeight : confirmHeight ,
8484 chanPoint : chanPoint ,
8585 }
8686
@@ -123,37 +123,6 @@ func waitForSpend(op *wire.OutPoint, pkScript []byte, heightHint uint32,
123123 }
124124}
125125
126- // getCommitTxConfHeight waits for confirmation of the commitment tx and
127- // returns the confirmation height.
128- func (c * commitSweepResolver ) getCommitTxConfHeight () (uint32 , error ) {
129- txID := c .commitResolution .SelfOutPoint .Hash
130- signDesc := c .commitResolution .SelfOutputSignDesc
131- pkScript := signDesc .Output .PkScript
132-
133- const confDepth = 1
134-
135- confChan , err := c .Notifier .RegisterConfirmationsNtfn (
136- & txID , pkScript , confDepth , c .broadcastHeight ,
137- )
138- if err != nil {
139- return 0 , err
140- }
141- defer confChan .Cancel ()
142-
143- select {
144- case txConfirmation , ok := <- confChan .Confirmed :
145- if ! ok {
146- return 0 , fmt .Errorf ("cannot get confirmation " +
147- "for commit tx %v" , txID )
148- }
149-
150- return txConfirmation .BlockHeight , nil
151-
152- case <- c .quit :
153- return 0 , errResolverShuttingDown
154- }
155- }
156-
157126// Resolve instructs the contract resolver to resolve the output on-chain. Once
158127// the output has been *fully* resolved, the function should return immediately
159128// with a nil ContractResolver value for the first return value. In the case
@@ -268,7 +237,7 @@ func (c *commitSweepResolver) Encode(w io.Writer) error {
268237 if err := binary .Write (w , endian , c .IsResolved ()); err != nil {
269238 return err
270239 }
271- if err := binary .Write (w , endian , c .broadcastHeight ); err != nil {
240+ if err := binary .Write (w , endian , c .confirmHeight ); err != nil {
272241 return err
273242 }
274243 if _ , err := w .Write (c .chanPoint .Hash [:]); err != nil {
@@ -308,7 +277,7 @@ func newCommitSweepResolverFromReader(r io.Reader, resCfg ResolverConfig) (
308277 c .markResolved ()
309278 }
310279
311- if err := binary .Read (r , endian , & c .broadcastHeight ); err != nil {
280+ if err := binary .Read (r , endian , & c .confirmHeight ); err != nil {
312281 return nil , err
313282 }
314283 _ , err := io .ReadFull (r , c .chanPoint .Hash [:])
@@ -381,19 +350,14 @@ func (c *commitSweepResolver) Launch() error {
381350 return nil
382351 }
383352
384- confHeight , err := c .getCommitTxConfHeight ()
385- if err != nil {
386- return err
387- }
388-
389353 // Wait up until the CSV expires, unless we also have a CLTV that
390354 // expires after.
391- unlockHeight := confHeight + c .commitResolution .MaturityDelay
355+ unlockHeight := c . confirmHeight + c .commitResolution .MaturityDelay
392356 if c .hasCLTV () {
393357 unlockHeight = max (unlockHeight , c .leaseExpiry )
394358 }
395359
396- // Update report now that we learned the confirmation height.
360+ // Update report with the calculated maturity height.
397361 c .reportLock .Lock ()
398362 c .currentReport .MaturityHeight = unlockHeight
399363 c .reportLock .Unlock ()
@@ -412,7 +376,7 @@ func (c *commitSweepResolver) Launch() error {
412376 inp = input .NewCsvInputWithCltv (
413377 & c .commitResolution .SelfOutPoint , witnessType ,
414378 & c .commitResolution .SelfOutputSignDesc ,
415- c .broadcastHeight , c .commitResolution .MaturityDelay ,
379+ c .confirmHeight , c .commitResolution .MaturityDelay ,
416380 c .leaseExpiry , input .WithResolutionBlob (
417381 c .commitResolution .ResolutionBlob ,
418382 ),
@@ -421,7 +385,7 @@ func (c *commitSweepResolver) Launch() error {
421385 inp = input .NewCsvInput (
422386 & c .commitResolution .SelfOutPoint , witnessType ,
423387 & c .commitResolution .SelfOutputSignDesc ,
424- c .broadcastHeight , c .commitResolution .MaturityDelay ,
388+ c .confirmHeight , c .commitResolution .MaturityDelay ,
425389 input .WithResolutionBlob (
426390 c .commitResolution .ResolutionBlob ,
427391 ),
0 commit comments