@@ -74,15 +74,6 @@ use crate::sync::{Mutex, LockTestExt};
74
74
#[ must_use]
75
75
pub struct ChannelMonitorUpdate {
76
76
pub ( crate ) updates : Vec < ChannelMonitorUpdateStep > ,
77
- /// Historically, [`ChannelMonitor`]s didn't know their counterparty node id. However,
78
- /// `ChannelManager` really wants to know it so that it can easily look up the corresponding
79
- /// channel. For now, this results in a temporary map in `ChannelManager` to look up channels
80
- /// by only the funding outpoint.
81
- ///
82
- /// To eventually remove that, we repeat the counterparty node id here so that we can upgrade
83
- /// `ChannelMonitor`s to become aware of the counterparty node id if they were generated prior
84
- /// to when it was stored directly in them.
85
- pub ( crate ) counterparty_node_id : Option < PublicKey > ,
86
77
/// The sequence number of this update. Updates *must* be replayed in-order according to this
87
78
/// sequence number (and updates may panic if they are not). The update_id values are strictly
88
79
/// increasing and increase by one for each new update, with two exceptions specified below.
@@ -117,7 +108,7 @@ impl Writeable for ChannelMonitorUpdate {
117
108
update_step. write ( w) ?;
118
109
}
119
110
write_tlv_fields ! ( w, {
120
- ( 1 , self . counterparty_node_id , option ) ,
111
+ // 1 was previously used to store `counterparty_node_id`
121
112
( 3 , self . channel_id, option) ,
122
113
} ) ;
123
114
Ok ( ( ) )
@@ -134,13 +125,12 @@ impl Readable for ChannelMonitorUpdate {
134
125
updates. push ( upd) ;
135
126
}
136
127
}
137
- let mut counterparty_node_id = None ;
138
128
let mut channel_id = None ;
139
129
read_tlv_fields ! ( r, {
140
- ( 1 , counterparty_node_id , option ) ,
130
+ // 1 was previously used to store `counterparty_node_id`
141
131
( 3 , channel_id, option) ,
142
132
} ) ;
143
- Ok ( Self { update_id, counterparty_node_id , updates, channel_id } )
133
+ Ok ( Self { update_id, updates, channel_id } )
144
134
}
145
135
}
146
136
@@ -1020,7 +1010,7 @@ pub(crate) struct ChannelMonitorImpl<Signer: EcdsaChannelSigner> {
1020
1010
best_block : BestBlock ,
1021
1011
1022
1012
/// The node_id of our counterparty
1023
- counterparty_node_id : Option < PublicKey > ,
1013
+ counterparty_node_id : PublicKey ,
1024
1014
1025
1015
/// Initial counterparty commmitment data needed to recreate the commitment tx
1026
1016
/// in the persistence pipeline for third-party watchtowers. This will only be present on
@@ -1242,7 +1232,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1242
1232
( 3 , self . htlcs_resolved_on_chain, required_vec) ,
1243
1233
( 5 , pending_monitor_events, required_vec) ,
1244
1234
( 7 , self . funding_spend_seen, required) ,
1245
- ( 9 , self . counterparty_node_id, option ) ,
1235
+ ( 9 , self . counterparty_node_id, required ) ,
1246
1236
( 11 , self . confirmed_commitment_tx_counterparty_output, option) ,
1247
1237
( 13 , self . spendable_txids_confirmed, required_vec) ,
1248
1238
( 15 , self . counterparty_fulfilled_htlcs, required) ,
@@ -1338,7 +1328,7 @@ impl<'a, L: Deref> WithChannelMonitor<'a, L> where L::Target: Logger {
1338
1328
}
1339
1329
1340
1330
pub ( crate ) fn from_impl < S : EcdsaChannelSigner > ( logger : & ' a L , monitor_impl : & ChannelMonitorImpl < S > , payment_hash : Option < PaymentHash > ) -> Self {
1341
- let peer_id = monitor_impl. counterparty_node_id ;
1331
+ let peer_id = Some ( monitor_impl. counterparty_node_id ) ;
1342
1332
let channel_id = Some ( monitor_impl. channel_id ( ) ) ;
1343
1333
WithChannelMonitor {
1344
1334
logger, peer_id, channel_id, payment_hash,
@@ -1462,7 +1452,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1462
1452
spendable_txids_confirmed : Vec :: new ( ) ,
1463
1453
1464
1454
best_block,
1465
- counterparty_node_id : Some ( counterparty_node_id) ,
1455
+ counterparty_node_id : counterparty_node_id,
1466
1456
initial_counterparty_commitment_info : None ,
1467
1457
balances_empty_height : None ,
1468
1458
@@ -1788,10 +1778,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1788
1778
}
1789
1779
1790
1780
/// Gets the `node_id` of the counterparty for this channel.
1791
- ///
1792
- /// Will be `None` for channels constructed on LDK versions prior to 0.0.110 and always `Some`
1793
- /// otherwise.
1794
- pub fn get_counterparty_node_id ( & self ) -> Option < PublicKey > {
1781
+ pub fn get_counterparty_node_id ( & self ) -> PublicKey {
1795
1782
self . inner . lock ( ) . unwrap ( ) . counterparty_node_id
1796
1783
}
1797
1784
@@ -3200,14 +3187,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3200
3187
log_funding_info!( self ) , self . latest_update_id, updates. update_id, updates. updates. len( ) ) ;
3201
3188
}
3202
3189
3203
- if updates. counterparty_node_id . is_some ( ) {
3204
- if self . counterparty_node_id . is_none ( ) {
3205
- self . counterparty_node_id = updates. counterparty_node_id ;
3206
- } else {
3207
- debug_assert_eq ! ( self . counterparty_node_id, updates. counterparty_node_id) ;
3208
- }
3209
- }
3210
-
3211
3190
// ChannelMonitor updates may be applied after force close if we receive a preimage for a
3212
3191
// broadcasted commitment transaction HTLC output that we'd like to claim on-chain. If this
3213
3192
// is the case, we no longer have guaranteed access to the monitor's update ID, so we use a
@@ -3376,10 +3355,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3376
3355
package_target_feerate_sat_per_1000_weight, commitment_tx, anchor_output_idx,
3377
3356
} => {
3378
3357
let channel_id = self . channel_id ;
3379
- // unwrap safety: `ClaimEvent`s are only available for Anchor channels,
3380
- // introduced with v0.0.116. counterparty_node_id is guaranteed to be `Some`
3381
- // since v0.0.110.
3382
- let counterparty_node_id = self . counterparty_node_id . unwrap ( ) ;
3358
+ let counterparty_node_id = self . counterparty_node_id ;
3383
3359
let commitment_txid = commitment_tx. compute_txid ( ) ;
3384
3360
debug_assert_eq ! ( self . current_holder_commitment_tx. txid, commitment_txid) ;
3385
3361
let pending_htlcs = self . current_holder_commitment_tx . non_dust_htlcs ( ) ;
@@ -3410,10 +3386,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3410
3386
target_feerate_sat_per_1000_weight, htlcs, tx_lock_time,
3411
3387
} => {
3412
3388
let channel_id = self . channel_id ;
3413
- // unwrap safety: `ClaimEvent`s are only available for Anchor channels,
3414
- // introduced with v0.0.116. counterparty_node_id is guaranteed to be `Some`
3415
- // since v0.0.110.
3416
- let counterparty_node_id = self . counterparty_node_id . unwrap ( ) ;
3389
+ let counterparty_node_id = self . counterparty_node_id ;
3417
3390
let mut htlc_descriptors = Vec :: with_capacity ( htlcs. len ( ) ) ;
3418
3391
for htlc in htlcs {
3419
3392
htlc_descriptors. push ( HTLCDescriptor {
@@ -5129,6 +5102,13 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
5129
5102
chan_utils:: get_to_countersignatory_with_anchors_redeemscript ( & payment_point) . to_p2wsh ( ) ;
5130
5103
}
5131
5104
5105
+ let channel_id = channel_id. unwrap_or ( ChannelId :: v1_from_funding_outpoint ( outpoint) ) ;
5106
+ if counterparty_node_id. is_none ( ) {
5107
+ panic ! ( "Found monitor for channel {} with no updates since v0.0.118.\
5108
+ These monitors are no longer supported.\
5109
+ To continue, run a v0.1 release, send/route a payment over the channel or close it.", channel_id) ;
5110
+ }
5111
+
5132
5112
Ok ( ( best_block. block_hash , ChannelMonitor :: from_impl ( ChannelMonitorImpl {
5133
5113
latest_update_id,
5134
5114
commitment_transaction_number_obscure_factor,
@@ -5140,7 +5120,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
5140
5120
5141
5121
channel_keys_id,
5142
5122
holder_revocation_basepoint,
5143
- channel_id : channel_id . unwrap_or ( ChannelId :: v1_from_funding_outpoint ( outpoint ) ) ,
5123
+ channel_id,
5144
5124
funding_info,
5145
5125
first_confirmed_funding_txo : first_confirmed_funding_txo. 0 . unwrap ( ) ,
5146
5126
current_counterparty_commitment_txid,
@@ -5184,7 +5164,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
5184
5164
spendable_txids_confirmed : spendable_txids_confirmed. unwrap ( ) ,
5185
5165
5186
5166
best_block,
5187
- counterparty_node_id,
5167
+ counterparty_node_id : counterparty_node_id . unwrap ( ) ,
5188
5168
initial_counterparty_commitment_info,
5189
5169
balances_empty_height,
5190
5170
failed_back_htlc_ids : new_hash_set ( ) ,
0 commit comments