@@ -63,10 +63,14 @@ import { getDefaultLdkStorageShape } from './utils/helpers';
6363// Step 19: Background Processing
6464
6565class LightningManager {
66- currentBlockHeight : number = 0 ;
66+ currentBlock : THeader = {
67+ hex : '' ,
68+ hash : '' ,
69+ height : 0 ,
70+ } ;
6771 watchTxs : TRegisterTxEvent [ ] = [ ] ;
6872 watchOutputs : TRegisterOutputEvent [ ] = [ ] ;
69- getBestBlock ? : TGetBestBlock = async ( ) : Promise < THeader > => ( {
73+ getBestBlock : TGetBestBlock = async ( ) : Promise < THeader > => ( {
7074 hex : '' ,
7175 hash : '' ,
7276 height : 0 ,
@@ -207,7 +211,7 @@ class LightningManager {
207211 'The getBestBlock method is not providing the appropriate block hex, hash or height.' ,
208212 ) ;
209213 }
210- this . currentBlockHeight = bestBlock . height ;
214+ this . currentBlock = bestBlock ;
211215
212216 const ldkData = await this . getLdkData ( ) ;
213217
@@ -333,7 +337,7 @@ class LightningManager {
333337 const height = bestBlock ?. height ;
334338
335339 //Don't update unnecessarily
336- if ( this . currentBlockHeight !== height ) {
340+ if ( this . currentBlock . hash !== bestBlock ?. hash ) {
337341 const syncToTip = await ldk . syncToTip ( {
338342 header,
339343 height,
@@ -342,7 +346,7 @@ class LightningManager {
342346 return syncToTip ;
343347 }
344348
345- this . currentBlockHeight = height ;
349+ this . currentBlock = bestBlock ;
346350 }
347351
348352 // Iterate over watch transactions and set whether they are confirmed or unconfirmed.
0 commit comments