@@ -147,8 +147,10 @@ pub enum PsbtCmd<S: clap::Args> {
147
147
/// Create a new PSBT.
148
148
New {
149
149
/// Amount to send in satoshis
150
+ #[ clap( required = true ) ]
150
151
value : u64 ,
151
152
/// Recipient address
153
+ #[ clap( required = true ) ]
152
154
address : Address < NetworkUnchecked > ,
153
155
/// Set the feerate of the tx (sat/vbyte)
154
156
#[ clap( long, short, default_value = "1.0" ) ]
@@ -168,20 +170,21 @@ pub enum PsbtCmd<S: clap::Args> {
168
170
} ,
169
171
/// Sign with a hot signer
170
172
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) ]
176
175
descriptor : Option < String > ,
176
+ /// PSBT
177
+ #[ clap( long, short, required = true ) ]
178
+ psbt : String ,
177
179
} ,
178
180
/// Extract transaction
179
181
Extract {
180
182
/// PSBT
183
+ #[ clap( long, short, required = true ) ]
181
184
psbt : String ,
182
185
/// Whether to try broadcasting the tx
183
- #[ clap( long, short = 'b' ) ]
184
- try_broadcast : bool ,
186
+ #[ clap( long, short) ]
187
+ broadcast : bool ,
185
188
#[ clap( flatten) ]
186
189
chain_specific : S ,
187
190
} ,
@@ -451,7 +454,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
451
454
chain : & Mutex < LocalChain > ,
452
455
db : & Mutex < Store < ChangeSet > > ,
453
456
network : Network ,
454
- broadcast : impl FnOnce ( S , & Transaction ) -> anyhow:: Result < ( ) > ,
457
+ broadcast_fn : impl FnOnce ( S , & Transaction ) -> anyhow:: Result < ( ) > ,
455
458
cmd : Commands < CS , S > ,
456
459
) -> anyhow:: Result < ( ) > {
457
460
match cmd {
@@ -671,7 +674,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
671
674
Ok ( ( ) )
672
675
}
673
676
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) ?;
675
678
676
679
let desc_str = match descriptor {
677
680
Some ( s) => s,
@@ -709,20 +712,20 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
709
712
Ok ( ( ) )
710
713
}
711
714
PsbtCmd :: Extract {
712
- try_broadcast ,
715
+ broadcast ,
713
716
chain_specific,
714
717
psbt,
715
718
} => {
716
- let mut psbt = Psbt :: from_str ( psbt. as_str ( ) ) ?;
719
+ let mut psbt = Psbt :: from_str ( & psbt) ?;
717
720
psbt. finalize_mut ( & Secp256k1 :: new ( ) )
718
721
. map_err ( |errors| anyhow:: anyhow!( "failed to finalize PSBT {errors:?}" ) ) ?;
719
722
720
723
let tx = psbt. extract_tx ( ) ?;
721
724
722
- if try_broadcast {
725
+ if broadcast {
723
726
let mut graph = graph. lock ( ) . unwrap ( ) ;
724
727
725
- match broadcast ( chain_specific, & tx) {
728
+ match broadcast_fn ( chain_specific, & tx) {
726
729
Ok ( _) => {
727
730
println ! ( "Broadcasted Tx: {}" , tx. compute_txid( ) ) ;
728
731
0 commit comments