@@ -75,12 +75,23 @@ contract BatcherPaymentService is
7575 alignedLayerServiceManager = _alignedLayerServiceManager;
7676 batcherWallet = _batcherWallet;
7777 }
78-
78+
7979 // PAYABLE FUNCTIONS
80+ /**
81+ * @notice Fallback function to receive ETH payments
82+ * @dev This function handles two scenarios:
83+ * 1. Direct user deposits: Updates the user's balance and emits an event
84+ * 2. Batcher withdrawals from ServiceManager: Ignores balance updates since they don't apply
85+ */
86+
8087 receive () external payable {
81- userData[msg .sender ].balance += msg .value ;
82- userData[msg .sender ].unlockBlockTime = 0 ;
83- emit PaymentReceived (msg .sender , msg .value );
88+ // Skip balance updates when receiving funds from ServiceManager withdrawals
89+ if (msg .sender != address (alignedLayerServiceManager)) {
90+ // Only update balances for direct user deposits
91+ userData[msg .sender ].balance += msg .value ;
92+ userData[msg .sender ].unlockBlockTime = 0 ;
93+ emit PaymentReceived (msg .sender , msg .value );
94+ }
8495 }
8596
8697 // PUBLIC FUNCTIONS
@@ -178,6 +189,17 @@ contract BatcherPaymentService is
178189 emit FundsWithdrawn (msg .sender , amount);
179190 }
180191
192+
193+ function withdrawFromServiceManager (
194+ uint256 amount ,
195+ address withdrawAddress
196+ ) public payable onlyOwner {
197+ alignedLayerServiceManager.withdraw (amount); // reverts if InsufficientBalance
198+ // money is now in this contract
199+ // we transfer it to the withdraw address
200+ payable (withdrawAddress).transfer (amount); // non-reentrant since .transfer() has low gas limit.
201+ }
202+
181203 function pause () public onlyOwner {
182204 _pause ();
183205 }
0 commit comments