@@ -198,7 +198,7 @@ impl Display for AbortReason {
198
198
pub ( crate ) struct ConstructedTransaction {
199
199
holder_is_initiator : bool ,
200
200
201
- inputs : Vec < NegotiatedTxInput > ,
201
+ input_metadata : Vec < TxInMetadata > ,
202
202
outputs : Vec < InteractiveTxOutput > ,
203
203
tx : Transaction ,
204
204
@@ -212,12 +212,12 @@ pub(crate) struct ConstructedTransaction {
212
212
}
213
213
214
214
#[ derive( Clone , Debug , Eq , PartialEq ) ]
215
- pub ( crate ) struct NegotiatedTxInput {
215
+ pub ( crate ) struct TxInMetadata {
216
216
serial_id : SerialId ,
217
217
prev_output : TxOut ,
218
218
}
219
219
220
- impl NegotiatedTxInput {
220
+ impl TxInMetadata {
221
221
pub ( super ) fn is_local ( & self , holder_is_initiator : bool ) -> bool {
222
222
!is_serial_id_valid_for_counterparty ( holder_is_initiator, self . serial_id )
223
223
}
@@ -227,14 +227,14 @@ impl NegotiatedTxInput {
227
227
}
228
228
}
229
229
230
- impl_writeable_tlv_based ! ( NegotiatedTxInput , {
230
+ impl_writeable_tlv_based ! ( TxInMetadata , {
231
231
( 1 , serial_id, required) ,
232
232
( 3 , prev_output, required) ,
233
233
} ) ;
234
234
235
235
impl_writeable_tlv_based ! ( ConstructedTransaction , {
236
236
( 1 , holder_is_initiator, required) ,
237
- ( 3 , inputs , required) ,
237
+ ( 3 , input_metadata , required) ,
238
238
( 5 , outputs, required) ,
239
239
( 7 , tx, required) ,
240
240
( 9 , local_inputs_value_satoshis, required) ,
@@ -279,11 +279,8 @@ impl ConstructedTransaction {
279
279
value. saturating_add ( input. satisfaction_weight ( ) . to_wu ( ) )
280
280
} ) ) ;
281
281
282
- let mut inputs: Vec < ( TxIn , NegotiatedTxInput ) > = context
283
- . inputs
284
- . into_values ( )
285
- . map ( |input| input. into_txin_and_negotiated_input ( ) )
286
- . collect ( ) ;
282
+ let mut inputs: Vec < ( TxIn , TxInMetadata ) > =
283
+ context. inputs . into_values ( ) . map ( |input| input. into_txin_and_metadata ( ) ) . collect ( ) ;
287
284
let mut outputs: Vec < InteractiveTxOutput > = context. outputs . into_values ( ) . collect ( ) ;
288
285
inputs. sort_unstable_by_key ( |( _, input) | input. serial_id ) ;
289
286
outputs. sort_unstable_by_key ( |output| output. serial_id ) ;
@@ -298,7 +295,7 @@ impl ConstructedTransaction {
298
295
. map ( |position| position as u32 )
299
296
} ) ;
300
297
301
- let ( input, inputs ) : ( Vec < TxIn > , Vec < NegotiatedTxInput > ) = inputs. into_iter ( ) . unzip ( ) ;
298
+ let ( input, input_metadata ) : ( Vec < TxIn > , Vec < TxInMetadata > ) = inputs. into_iter ( ) . unzip ( ) ;
302
299
let output = outputs. iter ( ) . map ( |output| output. tx_out ( ) . clone ( ) ) . collect ( ) ;
303
300
304
301
let tx =
@@ -318,7 +315,7 @@ impl ConstructedTransaction {
318
315
remote_inputs_value_satoshis,
319
316
remote_outputs_value_satoshis,
320
317
321
- inputs ,
318
+ input_metadata ,
322
319
outputs,
323
320
tx,
324
321
@@ -334,8 +331,8 @@ impl ConstructedTransaction {
334
331
self . outputs . iter ( )
335
332
}
336
333
337
- pub fn inputs ( & self ) -> impl Iterator < Item = & NegotiatedTxInput > {
338
- self . inputs . iter ( )
334
+ pub fn input_metadata ( & self ) -> impl Iterator < Item = & TxInMetadata > {
335
+ self . input_metadata . iter ( )
339
336
}
340
337
341
338
pub fn compute_txid ( & self ) -> Txid {
@@ -349,7 +346,7 @@ impl ConstructedTransaction {
349
346
self . tx
350
347
. input
351
348
. iter_mut ( )
352
- . zip ( self . inputs . iter ( ) )
349
+ . zip ( self . input_metadata . iter ( ) )
353
350
. enumerate ( )
354
351
. filter ( |( _, ( _, input) ) | input. is_local ( self . holder_is_initiator ) )
355
352
. filter ( |( index, _) | {
@@ -369,7 +366,7 @@ impl ConstructedTransaction {
369
366
self . tx
370
367
. input
371
368
. iter_mut ( )
372
- . zip ( self . inputs . iter ( ) )
369
+ . zip ( self . input_metadata . iter ( ) )
373
370
. enumerate ( )
374
371
. filter ( |( _, ( _, input) ) | !input. is_local ( self . holder_is_initiator ) )
375
372
. filter ( |( index, _) | {
@@ -535,7 +532,7 @@ impl InteractiveTxSigningSession {
535
532
pub fn remote_inputs_count ( & self ) -> usize {
536
533
let shared_index = self . unsigned_tx . shared_input_index . as_ref ( ) ;
537
534
self . unsigned_tx
538
- . inputs
535
+ . input_metadata
539
536
. iter ( )
540
537
. enumerate ( )
541
538
. filter ( |( _, input) | !input. is_local ( self . unsigned_tx . holder_is_initiator ) )
@@ -547,7 +544,7 @@ impl InteractiveTxSigningSession {
547
544
548
545
pub fn local_inputs_count ( & self ) -> usize {
549
546
self . unsigned_tx
550
- . inputs
547
+ . input_metadata
551
548
. iter ( )
552
549
. enumerate ( )
553
550
. filter ( |( _, input) | input. is_local ( self . unsigned_tx . holder_is_initiator ) )
@@ -578,10 +575,10 @@ impl InteractiveTxSigningSession {
578
575
self . local_inputs_count ( ) > 0 || self . local_outputs_count ( ) > 0
579
576
}
580
577
581
- pub fn shared_input ( & self ) -> Option < & NegotiatedTxInput > {
582
- self . unsigned_tx
583
- . shared_input_index
584
- . and_then ( |shared_input_index| self . unsigned_tx . inputs . get ( shared_input_index as usize ) )
578
+ pub fn shared_input ( & self ) -> Option < & TxInMetadata > {
579
+ self . unsigned_tx . shared_input_index . and_then ( |shared_input_index| {
580
+ self . unsigned_tx . input_metadata . get ( shared_input_index as usize )
581
+ } )
585
582
}
586
583
587
584
fn finalize_funding_tx ( & mut self ) -> Transaction {
@@ -629,13 +626,13 @@ impl InteractiveTxSigningSession {
629
626
let unsigned_tx = self . unsigned_tx ( ) ;
630
627
let built_tx = unsigned_tx. tx ( ) ;
631
628
let prev_outputs: Vec < & TxOut > =
632
- unsigned_tx. inputs ( ) . map ( |input| input. prev_output ( ) ) . collect :: < Vec < _ > > ( ) ;
629
+ unsigned_tx. input_metadata ( ) . map ( |input| input. prev_output ( ) ) . collect :: < Vec < _ > > ( ) ;
633
630
let all_prevouts = sighash:: Prevouts :: All ( & prev_outputs[ ..] ) ;
634
631
635
632
let mut cache = SighashCache :: new ( built_tx) ;
636
633
637
634
let script_pubkeys = unsigned_tx
638
- . inputs ( )
635
+ . input_metadata ( )
639
636
. enumerate ( )
640
637
. filter ( |( _, input) | input. is_local ( unsigned_tx. holder_is_initiator ( ) ) )
641
638
. filter ( |( index, _) | {
@@ -1835,9 +1832,9 @@ impl InteractiveTxInput {
1835
1832
self . input . satisfaction_weight ( )
1836
1833
}
1837
1834
1838
- fn into_txin_and_negotiated_input ( self ) -> ( TxIn , NegotiatedTxInput ) {
1835
+ fn into_txin_and_metadata ( self ) -> ( TxIn , TxInMetadata ) {
1839
1836
let ( txin, prev_output) = self . input . into_tx_in_with_prev_output ( ) ;
1840
- ( txin, NegotiatedTxInput { serial_id : self . serial_id , prev_output } )
1837
+ ( txin, TxInMetadata { serial_id : self . serial_id , prev_output } )
1841
1838
}
1842
1839
}
1843
1840
@@ -2228,7 +2225,7 @@ mod tests {
2228
2225
2229
2226
use super :: {
2230
2227
get_output_weight, AddingRole , ConstructedTransaction , InteractiveTxOutput ,
2231
- InteractiveTxSigningSession , NegotiatedTxInput , OutputOwned , P2TR_INPUT_WEIGHT_LOWER_BOUND ,
2228
+ InteractiveTxSigningSession , OutputOwned , TxInMetadata , P2TR_INPUT_WEIGHT_LOWER_BOUND ,
2232
2229
P2WPKH_INPUT_WEIGHT_LOWER_BOUND , P2WSH_INPUT_WEIGHT_LOWER_BOUND , TX_COMMON_FIELDS_WEIGHT ,
2233
2230
} ;
2234
2231
@@ -3301,11 +3298,11 @@ mod tests {
3301
3298
fn do_verify_tx_signatures (
3302
3299
transaction : Transaction , prev_outputs : Vec < TxOut > ,
3303
3300
) -> Result < ( ) , String > {
3304
- let inputs : Vec < NegotiatedTxInput > = prev_outputs
3301
+ let input_metadata : Vec < TxInMetadata > = prev_outputs
3305
3302
. into_iter ( )
3306
3303
. enumerate ( )
3307
3304
. map ( |( idx, prev_output) | {
3308
- NegotiatedTxInput {
3305
+ TxInMetadata {
3309
3306
serial_id : idx as u64 , // even values will be holder (initiator in this test)
3310
3307
prev_output,
3311
3308
}
@@ -3325,7 +3322,7 @@ mod tests {
3325
3322
3326
3323
let unsigned_tx = ConstructedTransaction {
3327
3324
holder_is_initiator : true ,
3328
- inputs ,
3325
+ input_metadata ,
3329
3326
outputs,
3330
3327
tx : transaction. clone ( ) ,
3331
3328
local_inputs_value_satoshis : 0 , // N/A for test
0 commit comments