@@ -446,6 +446,14 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
446446 chainParams ,
447447 )
448448
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+
449457 // If we're running an asset client, we'll log something here.
450458 if d .assetClient != nil {
451459 getInfo , err := d .assetClient .GetInfo (
@@ -580,7 +588,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
580588 ChainParams : d .lnd .ChainParams ,
581589 ChainNotifier : d .lnd .ChainNotifier ,
582590 }
583- staticAddressManager = address .NewManager (addrCfg )
591+ staticAddressManager = address .NewManager (addrCfg , int32 ( blockHeight ) )
584592
585593 // Static address deposit manager setup.
586594 depositStore := deposit .NewSqlStore (baseDb )
@@ -606,7 +614,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
606614 ChainNotifier : d .lnd .ChainNotifier ,
607615 Signer : d .lnd .Signer ,
608616 }
609- withdrawalManager = withdraw .NewManager (withdrawalCfg )
617+ withdrawalManager = withdraw .NewManager (withdrawalCfg , blockHeight )
610618
611619 // Static address loop-in manager setup.
612620 staticAddressLoopInStore := loopin .NewSqlStore (
@@ -631,7 +639,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
631639 ValidateLoopInContract : loop .ValidateLoopInContract ,
632640 MaxStaticAddrHtlcFeePercentage : d .cfg .MaxStaticAddrHtlcFeePercentage ,
633641 MaxStaticAddrHtlcBackupFeePercentage : d .cfg .MaxStaticAddrHtlcBackupFeePercentage ,
634- })
642+ }, blockHeight )
635643
636644 var (
637645 reservationManager * reservation.Manager
@@ -674,7 +682,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
674682 }
675683
676684 instantOutManager = instantout .NewInstantOutManager (
677- instantOutConfig ,
685+ instantOutConfig , int32 ( blockHeight ),
678686 )
679687 }
680688
@@ -769,19 +777,11 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
769777 go func () {
770778 defer d .wg .Done ()
771779
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-
780780 infof ("Starting reservation manager" )
781781 defer infof ("Reservation manager stopped" )
782782
783- err = d .reservationManager .Run (
784- d .mainCtx , int32 (getInfo . BlockHeight ), initChan ,
783+ err : = d .reservationManager .Run (
784+ d .mainCtx , int32 (blockHeight ), initChan ,
785785 )
786786 if err != nil && ! errors .Is (err , context .Canceled ) {
787787 d .internalErrChan <- err
@@ -809,18 +809,10 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
809809 go func () {
810810 defer d .wg .Done ()
811811
812- getInfo , err := d .lnd .Client .GetInfo (d .mainCtx )
813- if err != nil {
814- d .internalErrChan <- err
815- return
816- }
817-
818812 infof ("Starting instantout manager" )
819813 defer infof ("Instantout manager stopped" )
820814
821- err = d .instantOutManager .Run (
822- d .mainCtx , initChan , int32 (getInfo .BlockHeight ),
823- )
815+ err := d .instantOutManager .Run (d .mainCtx , initChan )
824816 if err != nil && ! errors .Is (err , context .Canceled ) {
825817 d .internalErrChan <- err
826818 }
@@ -847,7 +839,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
847839 defer d .wg .Done ()
848840
849841 infof ("Starting static address manager..." )
850- err = staticAddressManager .Run (d .mainCtx )
842+ err : = staticAddressManager .Run (d .mainCtx )
851843 if err != nil && ! errors .Is (context .Canceled , err ) {
852844 d .internalErrChan <- err
853845 }
@@ -862,7 +854,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
862854 defer d .wg .Done ()
863855
864856 infof ("Starting static address deposit manager..." )
865- err = depositManager .Run (d .mainCtx )
857+ err : = depositManager .Run (d .mainCtx )
866858 if err != nil && ! errors .Is (context .Canceled , err ) {
867859 d .internalErrChan <- err
868860 }
@@ -877,17 +869,9 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
877869 go func () {
878870 defer d .wg .Done ()
879871
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-
888872 infof ("Starting static address deposit withdrawal " +
889873 "manager..." )
890- err = withdrawalManager .Run (d .mainCtx , info . BlockHeight )
874+ err : = withdrawalManager .Run (d .mainCtx )
891875 if err != nil && ! errors .Is (context .Canceled , err ) {
892876 d .internalErrChan <- err
893877 }
@@ -903,19 +887,8 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
903887 go func () {
904888 defer d .wg .Done ()
905889
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-
915890 infof ("Starting static address loop-in manager..." )
916- err = staticLoopInManager .Run (
917- d .mainCtx , info .BlockHeight ,
918- )
891+ err := staticLoopInManager .Run (d .mainCtx )
919892 if err != nil && ! errors .Is (context .Canceled , err ) {
920893 d .internalErrChan <- err
921894 }
0 commit comments