@@ -73,14 +73,10 @@ fn new_raw_input<'raw>(
7373 inp : & ' raw elements:: TxIn ,
7474 in_utxo : & ' raw ElementsUtxo ,
7575 inp_data : & ' raw RawInputData ,
76+ annex : * const c_elements:: CRawBuffer ,
7677) -> c_elements:: CRawInput < ' raw > {
7778 c_elements:: CRawInput {
78- annex : inp_data
79- . annex
80- . as_ref ( )
81- . map ( |annex| c_elements:: CRawBuffer :: new ( annex) )
82- . as_ref ( )
83- . map_or ( core:: ptr:: null ( ) , |ptr| ptr as * const _ ) ,
79+ annex,
8480 prev_txid : inp. previous_output . txid . as_ref ( ) ,
8581 pegin : inp_data. genesis_hash . as_ref ( ) ,
8682 issuance : if inp. has_issuance ( ) {
@@ -152,10 +148,6 @@ pub(super) fn new_tx(
152148) -> * mut c_elements:: CTransaction {
153149 let mut raw_inputs = Vec :: new ( ) ;
154150 let mut raw_outputs = Vec :: new ( ) ;
155- // Allocate space for the raw annexes. This dumb `Vec::from_iter` construction is
156- // equivalent to `vec![None; tx.input.len()]`, but that won't compile because it
157- // requires Option::<CRawBuffer>::None to be cloneable, which it's not because
158- // CRawBuffer isn't.
159151
160152 // SAFETY: this allocation *must* live until after the `simplicity_mallocTransaction`
161153 // at the bottom of this function. We convert the vector to a boxed slice to ensure
@@ -175,7 +167,10 @@ pub(super) fn new_tx(
175167 . annex
176168 . as_ref ( )
177169 . map ( |annex| c_elements:: CRawBuffer :: new ( annex) ) ;
178- let res = new_raw_input ( inp, in_utxo, inp_data) ;
170+ let annex_ptr = raw_annexes[ n]
171+ . as_ref ( )
172+ . map_or ( core:: ptr:: null ( ) , |b| b as * const _ ) ;
173+ let res = new_raw_input ( inp, in_utxo, inp_data, annex_ptr) ;
179174 raw_inputs. push ( res) ;
180175 }
181176 for ( out, out_data) in tx. output . iter ( ) . zip ( tx_data. outputs . iter ( ) ) {
0 commit comments