@@ -78,9 +78,11 @@ contract BatcherPaymentService is
7878
7979 // PAYABLE FUNCTIONS
8080 receive () external payable {
81- userData[msg .sender ].balance += msg .value ;
82- userData[msg .sender ].unlockBlockTime = 0 ;
83- emit PaymentReceived (msg .sender , msg .value );
81+ if (msg .sender != address (alignedLayerServiceManager)) { // `alignedLayerServiceManager.withdraw()` triggers `receive()` (and with only 2300 gas)
82+ userData[msg .sender ].balance += msg .value ;
83+ userData[msg .sender ].unlockBlockTime = 0 ;
84+ emit PaymentReceived (msg .sender , msg .value );
85+ }
8486 }
8587
8688 // PUBLIC FUNCTIONS
@@ -178,14 +180,16 @@ contract BatcherPaymentService is
178180 emit FundsWithdrawn (msg .sender , amount);
179181 }
180182
183+
181184 function withdraw_from_service_manager (
182- uint256 amount
183- ) public onlyOwner { // or onlyBatcher ??
184- alignedLayerServiceManager.withdraw (amount); // reverts on InsufficientBalance
185+ uint256 amount ,
186+ address withdrawAddress
187+ ) public payable onlyOwner {
188+ alignedLayerServiceManager.withdraw (amount); // reverts if InsufficientBalance
185189 // money is now in this contract
186- // now transfer to hardcoded batcher wallet
187- payable (batcherWallet ).transfer (amount);
188- // todo test
190+ // we transfer it to the withdraw address
191+ payable (withdrawAddress ).transfer (amount); // non-reentrant since .transfer() has low gas limit. Also, Owner is a multisig.
192+ // this.balance is unchanged
189193 }
190194
191195 function pause () public onlyOwner {
0 commit comments