@@ -438,6 +438,10 @@ fn parse_descriptor_query(
438438
439439 let descriptor = be:: Descriptor :: from_str ( & desc_str, network) ?;
440440
441+ if !descriptor. has_wildcard ( ) {
442+ return Err ( Error :: DescriptorMustHaveWildcard ) ;
443+ }
444+
441445 if is_testnet_or_regtest == descriptor. is_mainnet ( ) {
442446 return Err ( Error :: WrongNetwork ) ;
443447 }
@@ -720,11 +724,11 @@ async fn handle_last_used_index(
720724 let mut internal_last_used: Option < u32 > = None ;
721725
722726 for desc in descriptor. into_single_descriptors ( ) . unwrap ( ) . iter ( ) {
723- let is_single_address = !desc. has_wildcard ( ) ;
724-
725727 // Determine if this is external (0/*) or internal (1/*) chain
726728 let is_internal = desc. to_string ( ) . contains ( "/1/*" ) ;
727729
730+ // we don't need to check for no wildcard, since parse_descriptor_query guarantees we have wildcard
731+
728732 let mut last_used_for_chain: Option < u32 > = None ;
729733
730734 for batch in 0 ..MAX_BATCH {
@@ -746,7 +750,7 @@ async fn handle_last_used_index(
746750 }
747751
748752 // If no activity in this batch and we've checked at least GAP_LIMIT addresses, stop
749- if !batch_has_activity || is_single_address {
753+ if !batch_has_activity {
750754 break ;
751755 }
752756 }
@@ -909,7 +913,13 @@ pub async fn infallible_route(
909913 . status ( StatusCode :: UNPROCESSABLE_ENTITY )
910914 . body ( Full :: new ( e. to_string ( ) . into ( ) ) )
911915 . unwrap ( )
916+ } else if matches ! ( e, Error :: DescriptorMustHaveWildcard ) {
917+ Response :: builder ( )
918+ . status ( StatusCode :: BAD_REQUEST )
919+ . body ( Full :: new ( e. to_string ( ) . into ( ) ) )
920+ . unwrap ( )
912921 } else {
922+ // TODO map many errors to specific status codes
913923 Response :: builder ( )
914924 . status ( StatusCode :: INTERNAL_SERVER_ERROR )
915925 . body ( Full :: new ( e. to_string ( ) . into ( ) ) )
0 commit comments