@@ -529,7 +529,7 @@ pub async fn handle_offline_wallet_subcommand(
529529 }
530530 }
531531 CreateTx {
532- recipients,
532+ mut recipients,
533533 #[ cfg( feature = "dns_payment" ) ]
534534 dns_recipients,
535535 #[ cfg( feature = "dns_payment" ) ]
@@ -547,28 +547,32 @@ pub async fn handle_offline_wallet_subcommand(
547547 } => {
548548 let mut tx_builder = wallet. build_tx ( ) ;
549549
550+ #[ cfg( feature = "dns_payment" ) ]
551+ for recipient in dns_recipients {
552+ log:: info!( "Resolving DNS instructions for recipient {}" , recipient. 0 ) ;
553+ let amount = Amount :: from_sat ( recipient. 1 ) ;
554+ let ( resolver, instructions) =
555+ parse_dns_instructions ( & recipient. 0 , cli_opts. network , & dns_resolver)
556+ . await
557+ . map_err ( |e| Error :: Generic ( format ! ( "Parsing error occured {e:#?}" ) ) ) ?;
558+ let payment = process_instructions ( amount, & instructions, resolver) . await ?;
559+
560+ recipients. push ( ( payment. 0 . into ( ) , payment. 1 . to_sat ( ) ) ) ;
561+ }
562+
563+ if recipients. is_empty ( ) {
564+ return Err ( Error :: Generic (
565+ "Either --to or --to_dns parameters must be specified" . to_string ( ) ,
566+ ) ) ;
567+ }
568+
550569 if send_all {
551570 tx_builder. drain_wallet ( ) . drain_to ( recipients[ 0 ] . 0 . clone ( ) ) ;
552571 } else {
553- #[ allow( unused_mut) ]
554- let mut recipients: Vec < _ > = recipients
572+ let recipients: Vec < _ > = recipients
555573 . into_iter ( )
556574 . map ( |( script, amount) | ( script, Amount :: from_sat ( amount) ) )
557575 . collect ( ) ;
558-
559- #[ cfg( feature = "dns_payment" ) ]
560- for recipient in dns_recipients {
561- println ! ( "Resolving DNS instructions for recipient {}" , recipient. 0 ) ;
562- let amount = Amount :: from_sat ( recipient. 1 ) ;
563- let ( resolver, instructions) =
564- parse_dns_instructions ( & recipient. 0 , cli_opts. network , & dns_resolver)
565- . await
566- . map_err ( |e| Error :: Generic ( format ! ( "Parsing error occured {e:#?}" ) ) ) ?;
567- let payment = process_instructions ( amount, & instructions, resolver) . await ?;
568-
569- recipients. push ( ( payment. 0 . into ( ) , payment. 1 ) ) ;
570- }
571-
572576 tx_builder. set_recipients ( recipients) ;
573577 }
574578
0 commit comments