@@ -438,7 +438,7 @@ impl<D: Db> Service<D> {
438438 if !scripts. is_empty ( ) {
439439 match screen_v1_addresses ( body_str, & scripts) {
440440 ScreenResult :: Blocked => {
441- return Err ( HandlerError :: Forbidden ( anyhow:: anyhow!(
441+ return Err ( HandlerError :: V1PsbtRejected ( anyhow:: anyhow!(
442442 "blocked address in V1 PSBT"
443443 ) ) ) ;
444444 }
@@ -651,6 +651,8 @@ enum HandlerError {
651651 SenderGone ( anyhow:: Error ) ,
652652 OhttpKeyRejection ( anyhow:: Error ) ,
653653 BadRequest ( anyhow:: Error ) ,
654+ /// V1 PSBT rejected — returns the BIP78 `original-psbt-rejected` error.
655+ V1PsbtRejected ( anyhow:: Error ) ,
654656 Forbidden ( anyhow:: Error ) ,
655657}
656658
@@ -684,6 +686,11 @@ impl HandlerError {
684686 warn ! ( "Bad request: {}" , e) ;
685687 * res. status_mut ( ) = StatusCode :: BAD_REQUEST
686688 }
689+ HandlerError :: V1PsbtRejected ( e) => {
690+ warn ! ( "PSBT rejected: {}" , e) ;
691+ * res. status_mut ( ) = StatusCode :: BAD_REQUEST ;
692+ * res. body_mut ( ) = full ( V1_REJECT_RES_JSON ) ;
693+ }
687694 HandlerError :: Forbidden ( e) => {
688695 warn ! ( "Forbidden: {}" , e) ;
689696 * res. status_mut ( ) = StatusCode :: FORBIDDEN
@@ -883,7 +890,7 @@ mod tests {
883890 }
884891
885892 #[ tokio:: test]
886- async fn post_v1_with_blocked_address_returns_forbidden ( ) {
893+ async fn post_v1_with_blocked_address_returns_bad_request ( ) {
887894 let blocked_addr = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa" ;
888895 let blocked = BlockedAddresses :: from_address_lines ( blocked_addr) ;
889896 let mut svc = test_service ( Some ( V1 :: new ( Some ( blocked) ) ) ) . await ;
@@ -896,9 +903,10 @@ mod tests {
896903 . unwrap ( ) ;
897904
898905 let res = tower:: Service :: call ( & mut svc, req) . await . unwrap ( ) ;
899- let ( status, _body ) = collect_body ( res) . await ;
906+ let ( status, body ) = collect_body ( res) . await ;
900907
901- assert_eq ! ( status, StatusCode :: FORBIDDEN ) ;
908+ assert_eq ! ( status, StatusCode :: BAD_REQUEST ) ;
909+ assert_eq ! ( body, V1_REJECT_RES_JSON ) ;
902910 }
903911
904912 #[ test]
0 commit comments