@@ -317,7 +317,7 @@ impl HolderCommitment {
317
317
let delayed_payment_key = & tx_keys. broadcaster_delayed_payment_key ;
318
318
let per_commitment_point = & tx_keys. per_commitment_point ;
319
319
320
- let mut nondust_htlcs = self . tx . htlcs ( ) . iter ( ) . zip ( self . tx . counterparty_htlc_sigs . iter ( ) ) ;
320
+ let mut nondust_htlcs = self . tx . nondust_htlcs ( ) . iter ( ) . zip ( self . tx . counterparty_htlc_sigs . iter ( ) ) ;
321
321
let mut sources = self . nondust_htlc_sources . iter ( ) ;
322
322
323
323
// Use an iterator to write `htlc_outputs` to avoid allocations.
@@ -937,7 +937,7 @@ impl TryFrom<(HolderCommitmentTransaction, HolderSignedTx)> for HolderCommitment
937
937
// HTLC sources, separately. All offered, non-dust HTLCs must have a source available.
938
938
939
939
let mut missing_nondust_source = false ;
940
- let mut nondust_htlc_sources = Vec :: with_capacity ( holder_commitment_tx. htlcs ( ) . len ( ) ) ;
940
+ let mut nondust_htlc_sources = Vec :: with_capacity ( holder_commitment_tx. nondust_htlcs ( ) . len ( ) ) ;
941
941
let dust_htlcs = holder_signed_tx. htlc_outputs . into_iter ( ) . filter_map ( |( htlc, _, source) | {
942
942
// Filter our non-dust HTLCs, while at the same time pushing their sources into
943
943
// `nondust_htlc_sources`.
@@ -967,16 +967,16 @@ impl TryFrom<(HolderCommitmentTransaction, HolderSignedTx)> for HolderCommitment
967
967
968
968
impl HolderCommitment {
969
969
fn has_htlcs ( & self ) -> bool {
970
- self . tx . htlcs ( ) . len ( ) > 0 || self . dust_htlcs . len ( ) > 0
970
+ self . tx . nondust_htlcs ( ) . len ( ) > 0 || self . dust_htlcs . len ( ) > 0
971
971
}
972
972
973
973
fn htlcs ( & self ) -> impl Iterator < Item = & HTLCOutputInCommitment > {
974
- self . tx . htlcs ( ) . iter ( ) . chain ( self . dust_htlcs . iter ( ) . map ( |( htlc, _) | htlc) )
974
+ self . tx . nondust_htlcs ( ) . iter ( ) . chain ( self . dust_htlcs . iter ( ) . map ( |( htlc, _) | htlc) )
975
975
}
976
976
977
977
fn htlcs_with_sources ( & self ) -> impl Iterator < Item = ( & HTLCOutputInCommitment , Option < & HTLCSource > ) > {
978
978
let mut sources = self . nondust_htlc_sources . iter ( ) ;
979
- let nondust_htlcs = self . tx . htlcs ( ) . iter ( ) . map ( move |htlc| {
979
+ let nondust_htlcs = self . tx . nondust_htlcs ( ) . iter ( ) . map ( move |htlc| {
980
980
let mut source = None ;
981
981
if htlc. offered && htlc. transaction_output_index . is_some ( ) {
982
982
source = sources. next ( ) ;
@@ -3093,8 +3093,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3093
3093
// If we have non-dust HTLCs in htlc_outputs, ensure they match the HTLCs in the
3094
3094
// `holder_commitment_tx`. In the future, we'll no longer provide the redundant data
3095
3095
// and just pass in source data via `nondust_htlc_sources`.
3096
- debug_assert_eq ! ( htlc_outputs. iter( ) . filter( |( _, s, _) | s. is_some( ) ) . count( ) , holder_commitment_tx. trust( ) . htlcs ( ) . len( ) ) ;
3097
- for ( a, b) in htlc_outputs. iter ( ) . filter ( |( _, s, _) | s. is_some ( ) ) . map ( |( h, _, _) | h) . zip ( holder_commitment_tx. trust ( ) . htlcs ( ) . iter ( ) ) {
3096
+ debug_assert_eq ! ( htlc_outputs. iter( ) . filter( |( _, s, _) | s. is_some( ) ) . count( ) , holder_commitment_tx. trust( ) . nondust_htlcs ( ) . len( ) ) ;
3097
+ for ( a, b) in htlc_outputs. iter ( ) . filter ( |( _, s, _) | s. is_some ( ) ) . map ( |( h, _, _) | h) . zip ( holder_commitment_tx. trust ( ) . nondust_htlcs ( ) . iter ( ) ) {
3098
3098
debug_assert_eq ! ( a, b) ;
3099
3099
}
3100
3100
debug_assert_eq ! ( htlc_outputs. iter( ) . filter( |( _, s, _) | s. is_some( ) ) . count( ) , holder_commitment_tx. counterparty_htlc_sigs. len( ) ) ;
@@ -3104,7 +3104,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3104
3104
3105
3105
// Backfill the non-dust HTLC sources.
3106
3106
debug_assert ! ( nondust_htlc_sources. is_empty( ) ) ;
3107
- nondust_htlc_sources. reserve_exact ( holder_commitment_tx. htlcs ( ) . len ( ) ) ;
3107
+ nondust_htlc_sources. reserve_exact ( holder_commitment_tx. nondust_htlcs ( ) . len ( ) ) ;
3108
3108
let dust_htlcs = htlc_outputs. into_iter ( ) . filter_map ( |( htlc, _, source) | {
3109
3109
// Filter our non-dust HTLCs, while at the same time pushing their sources into
3110
3110
// `nondust_htlc_sources`.
@@ -3124,18 +3124,18 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3124
3124
// `nondust_htlc_sources` and the `holder_commitment_tx`
3125
3125
{
3126
3126
let mut prev = -1 ;
3127
- for htlc in holder_commitment_tx. trust ( ) . htlcs ( ) . iter ( ) {
3127
+ for htlc in holder_commitment_tx. trust ( ) . nondust_htlcs ( ) . iter ( ) {
3128
3128
assert ! ( htlc. transaction_output_index. unwrap( ) as i32 > prev) ;
3129
3129
prev = htlc. transaction_output_index . unwrap ( ) as i32 ;
3130
3130
}
3131
3131
}
3132
3132
3133
3133
debug_assert ! ( htlc_outputs. iter( ) . all( |( htlc, _, _) | htlc. transaction_output_index. is_none( ) ) ) ;
3134
3134
debug_assert ! ( htlc_outputs. iter( ) . all( |( _, sig_opt, _) | sig_opt. is_none( ) ) ) ;
3135
- debug_assert_eq ! ( holder_commitment_tx. trust( ) . htlcs ( ) . len( ) , holder_commitment_tx. counterparty_htlc_sigs. len( ) ) ;
3135
+ debug_assert_eq ! ( holder_commitment_tx. trust( ) . nondust_htlcs ( ) . len( ) , holder_commitment_tx. counterparty_htlc_sigs. len( ) ) ;
3136
3136
3137
3137
let mut sources = nondust_htlc_sources. iter ( ) ;
3138
- for htlc in holder_commitment_tx. trust ( ) . htlcs ( ) . iter ( ) {
3138
+ for htlc in holder_commitment_tx. trust ( ) . nondust_htlcs ( ) . iter ( ) {
3139
3139
if htlc. offered {
3140
3140
let source = sources. next ( ) . expect ( "Non-dust HTLC sources didn't match commitment tx" ) ;
3141
3141
assert ! ( source. possibly_matches_output( htlc) ) ;
@@ -3526,7 +3526,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3526
3526
let counterparty_node_id = self . counterparty_node_id ;
3527
3527
let commitment_txid = commitment_tx. compute_txid ( ) ;
3528
3528
debug_assert_eq ! ( self . funding. current_holder_commitment. tx. trust( ) . txid( ) , commitment_txid) ;
3529
- let pending_htlcs = self . funding . current_holder_commitment . tx . trust ( ) . htlcs ( ) . to_vec ( ) ;
3529
+ let pending_htlcs = self . funding . current_holder_commitment . tx . trust ( ) . nondust_htlcs ( ) . to_vec ( ) ;
3530
3530
let channel_value_satoshis = self . funding . channel_parameters . channel_value_satoshis ;
3531
3531
let commitment_tx_fee_satoshis = channel_value_satoshis -
3532
3532
commitment_tx. output . iter ( ) . fold ( 0u64 , |sum, output| sum + output. value . to_sat ( ) ) ;
@@ -3973,7 +3973,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3973
3973
fn get_broadcasted_holder_claims (
3974
3974
& self , holder_tx : & HolderCommitmentTransaction , conf_height : u32 ,
3975
3975
) -> ( Vec < PackageTemplate > , Option < ( ScriptBuf , PublicKey , RevocationKey ) > ) {
3976
- let mut claim_requests = Vec :: with_capacity ( holder_tx. htlcs ( ) . len ( ) ) ;
3976
+ let mut claim_requests = Vec :: with_capacity ( holder_tx. nondust_htlcs ( ) . len ( ) ) ;
3977
3977
3978
3978
let tx = holder_tx. trust ( ) ;
3979
3979
let keys = tx. keys ( ) ;
@@ -3985,7 +3985,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3985
3985
) ) ;
3986
3986
3987
3987
let txid = tx. txid ( ) ;
3988
- for htlc in holder_tx. htlcs ( ) {
3988
+ for htlc in holder_tx. nondust_htlcs ( ) {
3989
3989
if let Some ( transaction_output_index) = htlc. transaction_output_index {
3990
3990
let ( htlc_output, counterparty_spendable_height) = if htlc. offered {
3991
3991
let htlc_output = HolderHTLCOutput :: build_offered (
@@ -4020,9 +4020,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4020
4020
4021
4021
// Returns holder HTLC outputs to watch and react to in case of spending.
4022
4022
fn get_broadcasted_holder_watch_outputs ( & self , holder_tx : & HolderCommitmentTransaction ) -> Vec < ( u32 , TxOut ) > {
4023
- let mut watch_outputs = Vec :: with_capacity ( holder_tx. htlcs ( ) . len ( ) ) ;
4023
+ let mut watch_outputs = Vec :: with_capacity ( holder_tx. nondust_htlcs ( ) . len ( ) ) ;
4024
4024
let tx = holder_tx. trust ( ) ;
4025
- for htlc in holder_tx. htlcs ( ) {
4025
+ for htlc in holder_tx. nondust_htlcs ( ) {
4026
4026
if let Some ( transaction_output_index) = htlc. transaction_output_index {
4027
4027
watch_outputs. push ( (
4028
4028
transaction_output_index,
@@ -4115,7 +4115,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4115
4115
let txid = self . funding . current_holder_commitment . tx . trust ( ) . txid ( ) ;
4116
4116
log_trace ! ( logger, "Canceling claims for previously broadcast holder commitment {}" , txid) ;
4117
4117
let mut outpoint = BitcoinOutPoint { txid, vout : 0 } ;
4118
- for htlc in self . funding . current_holder_commitment . tx . htlcs ( ) {
4118
+ for htlc in self . funding . current_holder_commitment . tx . nondust_htlcs ( ) {
4119
4119
if let Some ( vout) = htlc. transaction_output_index {
4120
4120
outpoint. vout = vout;
4121
4121
self . onchain_tx_handler . abandon_claim ( & outpoint) ;
@@ -4129,7 +4129,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4129
4129
if txid != * confirmed_commitment_txid {
4130
4130
log_trace ! ( logger, "Canceling claims for previously broadcast holder commitment {}" , txid) ;
4131
4131
let mut outpoint = BitcoinOutPoint { txid, vout : 0 } ;
4132
- for htlc in prev_holder_commitment. tx . htlcs ( ) {
4132
+ for htlc in prev_holder_commitment. tx . nondust_htlcs ( ) {
4133
4133
if let Some ( vout) = htlc. transaction_output_index {
4134
4134
outpoint. vout = vout;
4135
4135
self . onchain_tx_handler . abandon_claim ( & outpoint) ;
@@ -4155,7 +4155,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4155
4155
if self . channel_type_features ( ) . supports_anchors_zero_fee_htlc_tx ( ) {
4156
4156
return holder_transactions;
4157
4157
}
4158
- for htlc in self . funding . current_holder_commitment . tx . htlcs ( ) {
4158
+ for htlc in self . funding . current_holder_commitment . tx . nondust_htlcs ( ) {
4159
4159
if let Some ( vout) = htlc. transaction_output_index {
4160
4160
let preimage = if !htlc. offered {
4161
4161
if let Some ( ( preimage, _) ) = self . payment_preimages . get ( & htlc. payment_hash ) { Some ( preimage. clone ( ) ) } else {
0 commit comments