@@ -386,9 +386,6 @@ pub(super) struct Channel<ChanSigner: ChannelKeys> {
386
386
387
387
their_shutdown_scriptpubkey : Option < Script > ,
388
388
389
- /// Used exclusively to broadcast the latest local state, mostly a historical quirk that this
390
- /// is here:
391
- channel_monitor : Option < ChannelMonitor < ChanSigner > > ,
392
389
commitment_secrets : CounterpartyCommitmentSecrets ,
393
390
394
391
network_sync : UpdateStatus ,
@@ -557,7 +554,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
557
554
558
555
their_shutdown_scriptpubkey : None ,
559
556
560
- channel_monitor : None ,
561
557
commitment_secrets : CounterpartyCommitmentSecrets :: new ( ) ,
562
558
563
559
network_sync : UpdateStatus :: Fresh ,
@@ -786,7 +782,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
786
782
787
783
their_shutdown_scriptpubkey,
788
784
789
- channel_monitor : None ,
790
785
commitment_secrets : CounterpartyCommitmentSecrets :: new ( ) ,
791
786
792
787
network_sync : UpdateStatus :: Fresh ,
@@ -1222,7 +1217,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1222
1217
payment_preimage: payment_preimage_arg. clone( ) ,
1223
1218
} ] ,
1224
1219
} ;
1225
- self . channel_monitor . as_mut ( ) . unwrap ( ) . update_monitor_ooo ( monitor_update. clone ( ) , logger) . unwrap ( ) ;
1226
1220
1227
1221
if ( self . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 | ChannelState :: PeerDisconnected as u32 | ChannelState :: MonitorUpdateFailed as u32 ) ) != 0 {
1228
1222
for pending_update in self . holding_cell_htlc_updates . iter ( ) {
@@ -1552,7 +1546,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1552
1546
} }
1553
1547
}
1554
1548
1555
- self . channel_monitor = Some ( create_monitor ! ( ) ) ;
1556
1549
let channel_monitor = create_monitor ! ( ) ;
1557
1550
1558
1551
self . channel_state = ChannelState :: FundingSent as u32 ;
@@ -1618,7 +1611,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1618
1611
} }
1619
1612
}
1620
1613
1621
- self . channel_monitor = Some ( create_monitor ! ( ) ) ;
1622
1614
let channel_monitor = create_monitor ! ( ) ;
1623
1615
1624
1616
assert_eq ! ( self . channel_state & ( ChannelState :: MonitorUpdateFailed as u32 ) , 0 ) ; // We have no had any monitor(s) yet to fail update!
@@ -2060,7 +2052,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2060
2052
htlc_outputs: htlcs_and_sigs
2061
2053
} ]
2062
2054
} ;
2063
- self . channel_monitor . as_mut ( ) . unwrap ( ) . update_monitor_ooo ( monitor_update. clone ( ) , logger) . unwrap ( ) ;
2064
2055
2065
2056
for htlc in self . pending_inbound_htlcs . iter_mut ( ) {
2066
2057
let new_forward = if let & InboundHTLCState :: RemoteAnnounced ( ref forward_info) = & htlc. state {
@@ -2280,7 +2271,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2280
2271
secret: msg. per_commitment_secret,
2281
2272
} ] ,
2282
2273
} ;
2283
- self . channel_monitor . as_mut ( ) . unwrap ( ) . update_monitor_ooo ( monitor_update. clone ( ) , logger) . unwrap ( ) ;
2284
2274
2285
2275
// Update state now that we've passed all the can-fail calls...
2286
2276
// (note that we may still fail to generate the new commitment_signed message, but that's
@@ -3115,14 +3105,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3115
3105
self . user_id
3116
3106
}
3117
3107
3118
- /// May only be called after funding has been initiated (ie is_funding_initiated() is true)
3119
- pub fn channel_monitor ( & mut self ) -> & mut ChannelMonitor < ChanSigner > {
3120
- if self . channel_state < ChannelState :: FundingSent as u32 {
3121
- panic ! ( "Can't get a channel monitor until funding has been created" ) ;
3122
- }
3123
- self . channel_monitor . as_mut ( ) . unwrap ( )
3124
- }
3125
-
3126
3108
/// Guaranteed to be Some after both FundingLocked messages have been exchanged (and, thus,
3127
3109
/// is_usable() returns true).
3128
3110
/// Allowed in any state (including after shutdown)
@@ -3397,9 +3379,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3397
3379
if header. bitcoin_hash ( ) != self . last_block_connected {
3398
3380
self . last_block_connected = header. bitcoin_hash ( ) ;
3399
3381
self . update_time_counter = cmp:: max ( self . update_time_counter , header. time ) ;
3400
- if let Some ( channel_monitor) = self . channel_monitor . as_mut ( ) {
3401
- channel_monitor. last_block_hash = self . last_block_connected ;
3402
- }
3403
3382
if self . funding_tx_confirmations > 0 {
3404
3383
if self . funding_tx_confirmations == self . minimum_depth as u64 {
3405
3384
let need_commitment_update = if non_shutdown_state == ChannelState :: FundingSent as u32 {
@@ -3458,9 +3437,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3458
3437
self . funding_tx_confirmations = self . minimum_depth as u64 - 1 ;
3459
3438
}
3460
3439
self . last_block_connected = header. bitcoin_hash ( ) ;
3461
- if let Some ( channel_monitor) = self . channel_monitor . as_mut ( ) {
3462
- channel_monitor. last_block_hash = self . last_block_connected ;
3463
- }
3464
3440
false
3465
3441
}
3466
3442
@@ -3871,7 +3847,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3871
3847
their_revocation_point: self . their_cur_commitment_point. unwrap( )
3872
3848
} ]
3873
3849
} ;
3874
- self . channel_monitor . as_mut ( ) . unwrap ( ) . update_monitor_ooo ( monitor_update. clone ( ) , logger) . unwrap ( ) ;
3875
3850
self . channel_state |= ChannelState :: AwaitingRemoteRevoke as u32 ;
3876
3851
Ok ( ( res, monitor_update) )
3877
3852
}
@@ -4242,8 +4217,6 @@ impl<ChanSigner: ChannelKeys + Writeable> Writeable for Channel<ChanSigner> {
4242
4217
self . their_shutdown_scriptpubkey . write ( writer) ?;
4243
4218
4244
4219
self . commitment_secrets . write ( writer) ?;
4245
-
4246
- self . channel_monitor . as_ref ( ) . unwrap ( ) . write_for_disk ( writer) ?;
4247
4220
Ok ( ( ) )
4248
4221
}
4249
4222
}
@@ -4398,13 +4371,6 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for Channel<ChanSigner> {
4398
4371
let their_shutdown_scriptpubkey = Readable :: read ( reader) ?;
4399
4372
let commitment_secrets = Readable :: read ( reader) ?;
4400
4373
4401
- let ( monitor_last_block, channel_monitor) = Readable :: read ( reader) ?;
4402
- // We drop the ChannelMonitor's last block connected hash cause we don't actually bother
4403
- // doing full block connection operations on the internal ChannelMonitor copies
4404
- if monitor_last_block != last_block_connected {
4405
- return Err ( DecodeError :: InvalidValue ) ;
4406
- }
4407
-
4408
4374
Ok ( Channel {
4409
4375
user_id,
4410
4376
@@ -4476,7 +4442,6 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for Channel<ChanSigner> {
4476
4442
4477
4443
their_shutdown_scriptpubkey,
4478
4444
4479
- channel_monitor : Some ( channel_monitor) ,
4480
4445
commitment_secrets,
4481
4446
4482
4447
network_sync : UpdateStatus :: Fresh ,
0 commit comments