@@ -446,6 +446,14 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
446
446
chainParams ,
447
447
)
448
448
449
+ // We need to know the current block height to properly initialize
450
+ // managers.
451
+ getInfo , err := d .lnd .Client .GetInfo (d .mainCtx )
452
+ if err != nil {
453
+ return fmt .Errorf ("failed to get current block height: %w" , err )
454
+ }
455
+ blockHeight := getInfo .BlockHeight
456
+
449
457
// If we're running an asset client, we'll log something here.
450
458
if d .assetClient != nil {
451
459
getInfo , err := d .assetClient .GetInfo (
@@ -580,7 +588,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
580
588
ChainParams : d .lnd .ChainParams ,
581
589
ChainNotifier : d .lnd .ChainNotifier ,
582
590
}
583
- staticAddressManager = address .NewManager (addrCfg )
591
+ staticAddressManager = address .NewManager (addrCfg , int32 ( blockHeight ) )
584
592
585
593
// Static address deposit manager setup.
586
594
depositStore := deposit .NewSqlStore (baseDb )
@@ -606,7 +614,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
606
614
ChainNotifier : d .lnd .ChainNotifier ,
607
615
Signer : d .lnd .Signer ,
608
616
}
609
- withdrawalManager = withdraw .NewManager (withdrawalCfg )
617
+ withdrawalManager = withdraw .NewManager (withdrawalCfg , blockHeight )
610
618
611
619
// Static address loop-in manager setup.
612
620
staticAddressLoopInStore := loopin .NewSqlStore (
@@ -631,7 +639,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
631
639
ValidateLoopInContract : loop .ValidateLoopInContract ,
632
640
MaxStaticAddrHtlcFeePercentage : d .cfg .MaxStaticAddrHtlcFeePercentage ,
633
641
MaxStaticAddrHtlcBackupFeePercentage : d .cfg .MaxStaticAddrHtlcBackupFeePercentage ,
634
- })
642
+ }, blockHeight )
635
643
636
644
var (
637
645
reservationManager * reservation.Manager
@@ -674,7 +682,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
674
682
}
675
683
676
684
instantOutManager = instantout .NewInstantOutManager (
677
- instantOutConfig ,
685
+ instantOutConfig , int32 ( blockHeight ),
678
686
)
679
687
}
680
688
@@ -769,19 +777,11 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
769
777
go func () {
770
778
defer d .wg .Done ()
771
779
772
- // We need to know the current block height to properly
773
- // initialize the reservation manager.
774
- getInfo , err := d .lnd .Client .GetInfo (d .mainCtx )
775
- if err != nil {
776
- d .internalErrChan <- err
777
- return
778
- }
779
-
780
780
infof ("Starting reservation manager" )
781
781
defer infof ("Reservation manager stopped" )
782
782
783
- err = d .reservationManager .Run (
784
- d .mainCtx , int32 (getInfo . BlockHeight ), initChan ,
783
+ err : = d .reservationManager .Run (
784
+ d .mainCtx , int32 (blockHeight ), initChan ,
785
785
)
786
786
if err != nil && ! errors .Is (err , context .Canceled ) {
787
787
d .internalErrChan <- err
@@ -809,18 +809,10 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
809
809
go func () {
810
810
defer d .wg .Done ()
811
811
812
- getInfo , err := d .lnd .Client .GetInfo (d .mainCtx )
813
- if err != nil {
814
- d .internalErrChan <- err
815
- return
816
- }
817
-
818
812
infof ("Starting instantout manager" )
819
813
defer infof ("Instantout manager stopped" )
820
814
821
- err = d .instantOutManager .Run (
822
- d .mainCtx , initChan , int32 (getInfo .BlockHeight ),
823
- )
815
+ err := d .instantOutManager .Run (d .mainCtx , initChan )
824
816
if err != nil && ! errors .Is (err , context .Canceled ) {
825
817
d .internalErrChan <- err
826
818
}
@@ -847,7 +839,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
847
839
defer d .wg .Done ()
848
840
849
841
infof ("Starting static address manager..." )
850
- err = staticAddressManager .Run (d .mainCtx )
842
+ err : = staticAddressManager .Run (d .mainCtx )
851
843
if err != nil && ! errors .Is (context .Canceled , err ) {
852
844
d .internalErrChan <- err
853
845
}
@@ -862,7 +854,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
862
854
defer d .wg .Done ()
863
855
864
856
infof ("Starting static address deposit manager..." )
865
- err = depositManager .Run (d .mainCtx )
857
+ err : = depositManager .Run (d .mainCtx )
866
858
if err != nil && ! errors .Is (context .Canceled , err ) {
867
859
d .internalErrChan <- err
868
860
}
@@ -877,17 +869,9 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
877
869
go func () {
878
870
defer d .wg .Done ()
879
871
880
- // Lnd's GetInfo call supplies us with the current block
881
- // height.
882
- info , err := d .lnd .Client .GetInfo (d .mainCtx )
883
- if err != nil {
884
- d .internalErrChan <- err
885
- return
886
- }
887
-
888
872
infof ("Starting static address deposit withdrawal " +
889
873
"manager..." )
890
- err = withdrawalManager .Run (d .mainCtx , info . BlockHeight )
874
+ err : = withdrawalManager .Run (d .mainCtx )
891
875
if err != nil && ! errors .Is (context .Canceled , err ) {
892
876
d .internalErrChan <- err
893
877
}
@@ -903,19 +887,8 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
903
887
go func () {
904
888
defer d .wg .Done ()
905
889
906
- // Lnd's GetInfo call supplies us with the current block
907
- // height.
908
- info , err := d .lnd .Client .GetInfo (d .mainCtx )
909
- if err != nil {
910
- d .internalErrChan <- err
911
-
912
- return
913
- }
914
-
915
890
infof ("Starting static address loop-in manager..." )
916
- err = staticLoopInManager .Run (
917
- d .mainCtx , info .BlockHeight ,
918
- )
891
+ err := staticLoopInManager .Run (d .mainCtx )
919
892
if err != nil && ! errors .Is (context .Canceled , err ) {
920
893
d .internalErrChan <- err
921
894
}
0 commit comments