@@ -147,8 +147,10 @@ pub enum PsbtCmd<S: clap::Args> {
147147 /// Create a new PSBT.
148148 New {
149149 /// Amount to send in satoshis
150+ #[ clap( required = true ) ]
150151 value : u64 ,
151152 /// Recipient address
153+ #[ clap( required = true ) ]
152154 address : Address < NetworkUnchecked > ,
153155 /// Set the feerate of the tx (sat/vbyte)
154156 #[ clap( long, short, default_value = "1.0" ) ]
@@ -168,20 +170,21 @@ pub enum PsbtCmd<S: clap::Args> {
168170 } ,
169171 /// Sign with a hot signer
170172 Sign {
171- /// PSBT
172- #[ clap( long) ]
173- psbt : Option < String > ,
174- /// Private descriptor
175- #[ clap( long, short = 'd' ) ]
173+ /// Private descriptor [env: DESCRIPTOR=]
174+ #[ clap( long, short) ]
176175 descriptor : Option < String > ,
176+ /// PSBT
177+ #[ clap( long, short, required = true ) ]
178+ psbt : String ,
177179 } ,
178180 /// Extract transaction
179181 Extract {
180182 /// PSBT
183+ #[ clap( long, short, required = true ) ]
181184 psbt : String ,
182185 /// Whether to try broadcasting the tx
183- #[ clap( long, short = 'b' ) ]
184- try_broadcast : bool ,
186+ #[ clap( long, short) ]
187+ broadcast : bool ,
185188 #[ clap( flatten) ]
186189 chain_specific : S ,
187190 } ,
@@ -451,7 +454,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
451454 chain : & Mutex < LocalChain > ,
452455 db : & Mutex < Store < ChangeSet > > ,
453456 network : Network ,
454- broadcast : impl FnOnce ( S , & Transaction ) -> anyhow:: Result < ( ) > ,
457+ broadcast_fn : impl FnOnce ( S , & Transaction ) -> anyhow:: Result < ( ) > ,
455458 cmd : Commands < CS , S > ,
456459) -> anyhow:: Result < ( ) > {
457460 match cmd {
@@ -671,7 +674,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
671674 Ok ( ( ) )
672675 }
673676 PsbtCmd :: Sign { psbt, descriptor } => {
674- let mut psbt = Psbt :: from_str ( psbt. unwrap_or_default ( ) . as_str ( ) ) ?;
677+ let mut psbt = Psbt :: from_str ( & psbt) ?;
675678
676679 let desc_str = match descriptor {
677680 Some ( s) => s,
@@ -709,20 +712,20 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
709712 Ok ( ( ) )
710713 }
711714 PsbtCmd :: Extract {
712- try_broadcast ,
715+ broadcast ,
713716 chain_specific,
714717 psbt,
715718 } => {
716- let mut psbt = Psbt :: from_str ( psbt. as_str ( ) ) ?;
719+ let mut psbt = Psbt :: from_str ( & psbt) ?;
717720 psbt. finalize_mut ( & Secp256k1 :: new ( ) )
718721 . map_err ( |errors| anyhow:: anyhow!( "failed to finalize PSBT {errors:?}" ) ) ?;
719722
720723 let tx = psbt. extract_tx ( ) ?;
721724
722- if try_broadcast {
725+ if broadcast {
723726 let mut graph = graph. lock ( ) . unwrap ( ) ;
724727
725- match broadcast ( chain_specific, & tx) {
728+ match broadcast_fn ( chain_specific, & tx) {
726729 Ok ( _) => {
727730 println ! ( "Broadcasted Tx: {}" , tx. compute_txid( ) ) ;
728731
0 commit comments