File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ impl PartiallySignedTransaction {
178178 /// Remove the output at `index` and return it if any, otherwise returns None
179179 /// This also updates the pset global output count
180180 pub fn remove_output ( & mut self , index : usize ) -> Option < Output > {
181- if self . inputs . get ( index) . is_some ( ) {
181+ if self . outputs . get ( index) . is_some ( ) {
182182 self . global . tx_data . output_count -= 1 ;
183183 return Some ( self . outputs . remove ( index) ) ;
184184 }
@@ -955,4 +955,19 @@ mod tests {
955955 let pset = encode:: deserialize :: < PartiallySignedTransaction > ( & bytes) . unwrap ( ) ;
956956 assert_eq ! ( & back_hex, & encode:: serialize( & pset) . to_hex( ) ) ;
957957 }
958+
959+ #[ test]
960+ fn pset_remove_in_out ( ) {
961+ let pset_str = include_str ! ( "../../tests/data/pset_swap_tutorial.hex" ) ;
962+
963+ let bytes = Vec :: < u8 > :: from_hex ( pset_str) . unwrap ( ) ;
964+ let mut pset = encode:: deserialize :: < PartiallySignedTransaction > ( & bytes) . unwrap ( ) ;
965+
966+ let n_inputs = pset. n_inputs ( ) ;
967+ let n_outputs = pset. n_outputs ( ) ;
968+ pset. remove_input ( n_inputs - 1 ) . unwrap ( ) ;
969+ pset. remove_output ( n_outputs - 1 ) . unwrap ( ) ;
970+ assert_eq ! ( pset. n_inputs( ) , n_inputs - 1 ) ;
971+ assert_eq ! ( pset. n_outputs( ) , n_outputs - 1 ) ;
972+ }
958973}
You can’t perform that action at this time.
0 commit comments