File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
src/bin/hal-simplicity/cmd/simplicity/pset Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2025 Andrew Poelstra
2+ // SPDX-License-Identifier: CC0-1.0
3+
4+ use elements:: encode:: serialize_hex;
5+
6+ use super :: super :: { Error , ErrorExt as _} ;
7+ use crate :: cmd;
8+
9+ pub fn cmd < ' a > ( ) -> clap:: App < ' a , ' a > {
10+ cmd:: subcommand ( "extract" , "extract a raw transaction from a completed PSET" )
11+ . args ( & cmd:: opts_networks ( ) )
12+ . args ( & [ cmd:: arg ( "pset" , "PSET to update (base64)" ) . takes_value ( true ) . required ( true ) ] )
13+ }
14+
15+ pub fn exec < ' a > ( matches : & clap:: ArgMatches < ' a > ) {
16+ let pset_b64 = matches. value_of ( "pset" ) . expect ( "tx mandatory" ) ;
17+ match exec_inner ( pset_b64) {
18+ Ok ( info) => cmd:: print_output ( matches, & info) ,
19+ Err ( e) => cmd:: print_output ( matches, & e) ,
20+ }
21+ }
22+
23+ fn exec_inner ( pset_b64 : & str ) -> Result < String , Error > {
24+ let pset: elements:: pset:: PartiallySignedTransaction =
25+ pset_b64. parse ( ) . result_context ( "decoding PSET" ) ?;
26+
27+ let tx = pset. extract_tx ( ) . result_context ( "extracting transaction" ) ?;
28+ Ok ( serialize_hex ( & tx) )
29+ }
Original file line number Diff line number Diff line change 11// Copyright 2025 Andrew Poelstra
22// SPDX-License-Identifier: CC0-1.0
33
4+ mod extract;
45mod finalize;
56mod update_input;
67
@@ -15,12 +16,14 @@ struct UpdatedPset {
1516
1617pub fn cmd < ' a > ( ) -> clap:: App < ' a , ' a > {
1718 cmd:: subcommand_group ( "pset" , "manipulate PSETs for spending from Simplicity programs" )
19+ . subcommand ( self :: extract:: cmd ( ) )
1820 . subcommand ( self :: finalize:: cmd ( ) )
1921 . subcommand ( self :: update_input:: cmd ( ) )
2022}
2123
2224pub fn exec < ' a > ( matches : & clap:: ArgMatches < ' a > ) {
2325 match matches. subcommand ( ) {
26+ ( "extract" , Some ( m) ) => self :: extract:: exec ( m) ,
2427 ( "finalize" , Some ( m) ) => self :: finalize:: exec ( m) ,
2528 ( "update-input" , Some ( m) ) => self :: update_input:: exec ( m) ,
2629 ( _, _) => unreachable ! ( "clap prints help" ) ,
You can’t perform that action at this time.
0 commit comments