@@ -168,6 +168,7 @@ pub async fn validate_tx<T: Transaction>(
168168/// - The bundle can only contain 3 transactions at once
169169/// - Partial transaction dropping is not supported, `dropping_tx_hashes` must be empty
170170/// - extra_fields must be empty
171+ /// - refunds are not initially supported (refund_percent, refund_recipient, refund_tx_hashes must be empty)
171172pub fn validate_bundle ( bundle : & EthSendBundle , bundle_gas : u64 ) -> RpcResult < ( ) > {
172173 // Don't allow bundles to be submitted over 1 hour into the future
173174 // TODO: make the window configurable
@@ -214,6 +215,16 @@ pub fn validate_bundle(bundle: &EthSendBundle, bundle_gas: u64) -> RpcResult<()>
214215 return Err ( EthApiError :: InvalidParams ( "extra_fields must be empty" . into ( ) ) . into_rpc_err ( ) ) ;
215216 }
216217
218+ // refunds are not initially supported
219+ if bundle. refund_percent . is_some ( )
220+ || bundle. refund_recipient . is_some ( )
221+ || !bundle. refund_tx_hashes . is_empty ( )
222+ {
223+ return Err (
224+ EthApiError :: InvalidParams ( "refunds are not initially supported" . into ( ) ) . into_rpc_err ( ) ,
225+ ) ;
226+ }
227+
217228 Ok ( ( ) )
218229}
219230
@@ -665,4 +676,49 @@ mod tests {
665676 Err ( EthApiError :: InvalidParams ( "extra_fields must be empty" . into( ) ) . into_rpc_err( ) )
666677 ) ;
667678 }
679+
680+ #[ tokio:: test]
681+ async fn test_err_bundle_refund_percent_not_empty ( ) {
682+ let bundle = EthSendBundle {
683+ refund_percent : Some ( 100 ) ,
684+ ..Default :: default ( )
685+ } ;
686+ assert_eq ! (
687+ validate_bundle( & bundle, 0 ) ,
688+ Err (
689+ EthApiError :: InvalidParams ( "refunds are not initially supported" . into( ) )
690+ . into_rpc_err( )
691+ )
692+ ) ;
693+ }
694+
695+ #[ tokio:: test]
696+ async fn test_err_bundle_refund_recipient_not_empty ( ) {
697+ let bundle = EthSendBundle {
698+ refund_recipient : Some ( Address :: random ( ) ) ,
699+ ..Default :: default ( )
700+ } ;
701+ assert_eq ! (
702+ validate_bundle( & bundle, 0 ) ,
703+ Err (
704+ EthApiError :: InvalidParams ( "refunds are not initially supported" . into( ) )
705+ . into_rpc_err( )
706+ )
707+ ) ;
708+ }
709+
710+ #[ tokio:: test]
711+ async fn test_err_bundle_refund_tx_hashes_not_empty ( ) {
712+ let bundle = EthSendBundle {
713+ refund_tx_hashes : vec ! [ B256 :: random( ) ] ,
714+ ..Default :: default ( )
715+ } ;
716+ assert_eq ! (
717+ validate_bundle( & bundle, 0 ) ,
718+ Err (
719+ EthApiError :: InvalidParams ( "refunds are not initially supported" . into( ) )
720+ . into_rpc_err( )
721+ )
722+ ) ;
723+ }
668724}
0 commit comments