@@ -15,7 +15,7 @@ use secp256k1;
15
15
16
16
use ln:: msgs:: DecodeError ;
17
17
use ln:: channelmonitor:: { ANTI_REORG_DELAY , CLTV_SHARED_CLAIM_BUFFER , InputMaterial , ClaimRequest } ;
18
- use ln:: chan_utils:: HTLCType ;
18
+ use ln:: chan_utils:: { HTLCType , LocalCommitmentTransaction } ;
19
19
use chain:: chaininterface:: { FeeEstimator , BroadcasterInterface , ConfirmationTarget , MIN_RELAY_FEE_SAT_PER_1000_WEIGHT } ;
20
20
use chain:: keysinterface:: ChannelKeys ;
21
21
use util:: logger:: Logger ;
@@ -142,6 +142,8 @@ macro_rules! subtract_high_prio_fee {
142
142
pub struct OnchainTxHandler < ChanSigner : ChannelKeys > {
143
143
destination_script : Script ,
144
144
funding_redeemscript : Script ,
145
+ local_commitment : Option < LocalCommitmentTransaction > ,
146
+ prev_local_commitment : Option < LocalCommitmentTransaction > ,
145
147
146
148
key_storage : ChanSigner ,
147
149
@@ -182,6 +184,8 @@ impl<ChanSigner: ChannelKeys + Writeable> OnchainTxHandler<ChanSigner> {
182
184
pub ( crate ) fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
183
185
self . destination_script . write ( writer) ?;
184
186
self . funding_redeemscript . write ( writer) ?;
187
+ self . local_commitment . write ( writer) ?;
188
+ self . prev_local_commitment . write ( writer) ?;
185
189
186
190
self . key_storage . write ( writer) ?;
187
191
@@ -224,6 +228,8 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
224
228
fn read < R : :: std:: io:: Read > ( reader : & mut R , logger : Arc < Logger > ) -> Result < Self , DecodeError > {
225
229
let destination_script = Readable :: read ( reader) ?;
226
230
let funding_redeemscript = Readable :: read ( reader) ?;
231
+ let local_commitment = Readable :: read ( reader) ?;
232
+ let prev_local_commitment = Readable :: read ( reader) ?;
227
233
228
234
let key_storage = Readable :: read ( reader) ?;
229
235
@@ -273,6 +279,8 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
273
279
Ok ( OnchainTxHandler {
274
280
destination_script,
275
281
funding_redeemscript,
282
+ local_commitment,
283
+ prev_local_commitment,
276
284
key_storage,
277
285
claimable_outpoints,
278
286
pending_claim_requests,
@@ -291,6 +299,8 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
291
299
OnchainTxHandler {
292
300
destination_script,
293
301
funding_redeemscript,
302
+ local_commitment : None ,
303
+ prev_local_commitment : None ,
294
304
key_storage,
295
305
pending_claim_requests : HashMap :: new ( ) ,
296
306
claimable_outpoints : HashMap :: new ( ) ,
@@ -714,4 +724,9 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
714
724
self . pending_claim_requests . remove ( & req) ;
715
725
}
716
726
}
727
+
728
+ pub ( super ) fn provide_latest_local_tx ( & mut self , tx : LocalCommitmentTransaction ) {
729
+ self . prev_local_commitment = self . local_commitment . take ( ) ;
730
+ self . local_commitment = Some ( tx) ;
731
+ }
717
732
}
0 commit comments