@@ -250,7 +250,7 @@ pub struct OnchainTxHandler<ChanSigner: Sign> {
250
250
prev_holder_commitment : Option < HolderCommitmentTransaction > ,
251
251
prev_holder_htlc_sigs : Option < Vec < Option < ( usize , Signature ) > > > ,
252
252
253
- key_storage : ChanSigner ,
253
+ signer : ChanSigner ,
254
254
pub ( crate ) channel_transaction_parameters : ChannelTransactionParameters ,
255
255
256
256
// Used to track claiming requests. If claim tx doesn't confirm before height timer expiration we need to bump
@@ -298,7 +298,7 @@ impl<ChanSigner: Sign> OnchainTxHandler<ChanSigner> {
298
298
self . channel_transaction_parameters . write ( writer) ?;
299
299
300
300
let mut key_data = VecWriter ( Vec :: new ( ) ) ;
301
- self . key_storage . write ( & mut key_data) ?;
301
+ self . signer . write ( & mut key_data) ?;
302
302
assert ! ( key_data. 0 . len( ) < std:: usize :: MAX ) ;
303
303
assert ! ( key_data. 0 . len( ) < std:: u32 :: MAX as usize ) ;
304
304
( key_data. 0 . len ( ) as u32 ) . write ( writer) ?;
@@ -360,7 +360,7 @@ impl<'a, K: KeysInterface> ReadableArgs<&'a K> for OnchainTxHandler<K::Signer> {
360
360
reader. read_exact ( read_slice) ?;
361
361
keys_data. extend_from_slice ( read_slice) ;
362
362
}
363
- let key_storage = keys_manager. read_chan_signer ( & keys_data) ?;
363
+ let signer = keys_manager. read_chan_signer ( & keys_data) ?;
364
364
365
365
let pending_claim_requests_len: u64 = Readable :: read ( reader) ?;
366
366
let mut pending_claim_requests = HashMap :: with_capacity ( cmp:: min ( pending_claim_requests_len as usize , MAX_ALLOC_SIZE / 128 ) ) ;
@@ -412,7 +412,7 @@ impl<'a, K: KeysInterface> ReadableArgs<&'a K> for OnchainTxHandler<K::Signer> {
412
412
holder_htlc_sigs,
413
413
prev_holder_commitment,
414
414
prev_holder_htlc_sigs,
415
- key_storage ,
415
+ signer ,
416
416
channel_transaction_parameters : channel_parameters,
417
417
claimable_outpoints,
418
418
pending_claim_requests,
@@ -424,17 +424,14 @@ impl<'a, K: KeysInterface> ReadableArgs<&'a K> for OnchainTxHandler<K::Signer> {
424
424
}
425
425
426
426
impl < ChanSigner : Sign > OnchainTxHandler < ChanSigner > {
427
- pub ( crate ) fn new ( destination_script : Script , keys : ChanSigner , channel_parameters : ChannelTransactionParameters , holder_commitment : HolderCommitmentTransaction ) -> Self {
428
-
429
- let key_storage = keys;
430
-
427
+ pub ( crate ) fn new ( destination_script : Script , signer : ChanSigner , channel_parameters : ChannelTransactionParameters , holder_commitment : HolderCommitmentTransaction ) -> Self {
431
428
OnchainTxHandler {
432
429
destination_script,
433
430
holder_commitment,
434
431
holder_htlc_sigs : None ,
435
432
prev_holder_commitment : None ,
436
433
prev_holder_htlc_sigs : None ,
437
- key_storage ,
434
+ signer ,
438
435
channel_transaction_parameters : channel_parameters,
439
436
pending_claim_requests : HashMap :: new ( ) ,
440
437
claimable_outpoints : HashMap :: new ( ) ,
@@ -605,15 +602,15 @@ impl<ChanSigner: Sign> OnchainTxHandler<ChanSigner> {
605
602
for ( i, ( outp, per_outp_material) ) in cached_claim_datas. per_input_material . iter ( ) . enumerate ( ) {
606
603
match per_outp_material {
607
604
& InputMaterial :: Revoked { ref per_commitment_point, ref counterparty_delayed_payment_base_key, ref counterparty_htlc_base_key, ref per_commitment_key, ref input_descriptor, ref amount, ref htlc, ref on_counterparty_tx_csv } => {
608
- if let Ok ( chan_keys) = TxCreationKeys :: derive_new ( & self . secp_ctx , & per_commitment_point, counterparty_delayed_payment_base_key, counterparty_htlc_base_key, & self . key_storage . pubkeys ( ) . revocation_basepoint , & self . key_storage . pubkeys ( ) . htlc_basepoint ) {
605
+ if let Ok ( chan_keys) = TxCreationKeys :: derive_new ( & self . secp_ctx , & per_commitment_point, counterparty_delayed_payment_base_key, counterparty_htlc_base_key, & self . signer . pubkeys ( ) . revocation_basepoint , & self . signer . pubkeys ( ) . htlc_basepoint ) {
609
606
610
607
let witness_script = if let Some ( ref htlc) = * htlc {
611
608
chan_utils:: get_htlc_redeemscript_with_explicit_keys ( & htlc, & chan_keys. broadcaster_htlc_key , & chan_keys. countersignatory_htlc_key , & chan_keys. revocation_key )
612
609
} else {
613
610
chan_utils:: get_revokeable_redeemscript ( & chan_keys. revocation_key , * on_counterparty_tx_csv, & chan_keys. broadcaster_delayed_payment_key )
614
611
} ;
615
612
616
- let sig = self . key_storage . sign_justice_transaction ( & bumped_tx, i, * amount, & per_commitment_key, htlc, & self . secp_ctx ) . expect ( "sign justice tx" ) ;
613
+ let sig = self . signer . sign_justice_transaction ( & bumped_tx, i, * amount, & per_commitment_key, htlc, & self . secp_ctx ) . expect ( "sign justice tx" ) ;
617
614
bumped_tx. input [ i] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
618
615
bumped_tx. input [ i] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
619
616
if htlc. is_some ( ) {
@@ -627,11 +624,11 @@ impl<ChanSigner: Sign> OnchainTxHandler<ChanSigner> {
627
624
}
628
625
} ,
629
626
& InputMaterial :: CounterpartyHTLC { ref per_commitment_point, ref counterparty_delayed_payment_base_key, ref counterparty_htlc_base_key, ref preimage, ref htlc } => {
630
- if let Ok ( chan_keys) = TxCreationKeys :: derive_new ( & self . secp_ctx , & per_commitment_point, counterparty_delayed_payment_base_key, counterparty_htlc_base_key, & self . key_storage . pubkeys ( ) . revocation_basepoint , & self . key_storage . pubkeys ( ) . htlc_basepoint ) {
627
+ if let Ok ( chan_keys) = TxCreationKeys :: derive_new ( & self . secp_ctx , & per_commitment_point, counterparty_delayed_payment_base_key, counterparty_htlc_base_key, & self . signer . pubkeys ( ) . revocation_basepoint , & self . signer . pubkeys ( ) . htlc_basepoint ) {
631
628
let witness_script = chan_utils:: get_htlc_redeemscript_with_explicit_keys ( & htlc, & chan_keys. broadcaster_htlc_key , & chan_keys. countersignatory_htlc_key , & chan_keys. revocation_key ) ;
632
629
633
630
if !preimage. is_some ( ) { bumped_tx. lock_time = htlc. cltv_expiry } ; // Right now we don't aggregate time-locked transaction, if we do we should set lock_time before to avoid breaking hash computation
634
- let sig = self . key_storage . sign_counterparty_htlc_transaction ( & bumped_tx, i, & htlc. amount_msat / 1000 , & per_commitment_point, htlc, & self . secp_ctx ) . expect ( "sign counterparty HTLC tx" ) ;
631
+ let sig = self . signer . sign_counterparty_htlc_transaction ( & bumped_tx, i, & htlc. amount_msat / 1000 , & per_commitment_point, htlc, & self . secp_ctx ) . expect ( "sign counterparty HTLC tx" ) ;
635
632
bumped_tx. input [ i] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
636
633
bumped_tx. input [ i] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
637
634
if let & Some ( preimage) = preimage {
@@ -914,7 +911,7 @@ impl<ChanSigner: Sign> OnchainTxHandler<ChanSigner> {
914
911
// ChannelMonitor replica, so we handle that case here.
915
912
fn sign_latest_holder_htlcs ( & mut self ) {
916
913
if self . holder_htlc_sigs . is_none ( ) {
917
- let ( _sig, sigs) = self . key_storage . sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "sign holder commitment" ) ;
914
+ let ( _sig, sigs) = self . signer . sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "sign holder commitment" ) ;
918
915
self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( & self . holder_commitment , sigs) ) ;
919
916
}
920
917
}
@@ -925,7 +922,7 @@ impl<ChanSigner: Sign> OnchainTxHandler<ChanSigner> {
925
922
fn sign_prev_holder_htlcs ( & mut self ) {
926
923
if self . prev_holder_htlc_sigs . is_none ( ) {
927
924
if let Some ( ref holder_commitment) = self . prev_holder_commitment {
928
- let ( _sig, sigs) = self . key_storage . sign_holder_commitment_and_htlcs ( holder_commitment, & self . secp_ctx ) . expect ( "sign previous holder commitment" ) ;
925
+ let ( _sig, sigs) = self . signer . sign_holder_commitment_and_htlcs ( holder_commitment, & self . secp_ctx ) . expect ( "sign previous holder commitment" ) ;
929
926
self . prev_holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( holder_commitment, sigs) ) ;
930
927
}
931
928
}
@@ -946,14 +943,14 @@ impl<ChanSigner: Sign> OnchainTxHandler<ChanSigner> {
946
943
// before providing a initial commitment transaction. For outbound channel, init ChannelMonitor at Channel::funding_signed, there is nothing
947
944
// to monitor before.
948
945
pub ( crate ) fn get_fully_signed_holder_tx ( & mut self , funding_redeemscript : & Script ) -> Transaction {
949
- let ( sig, htlc_sigs) = self . key_storage . sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "signing holder commitment" ) ;
946
+ let ( sig, htlc_sigs) = self . signer . sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "signing holder commitment" ) ;
950
947
self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( & self . holder_commitment , htlc_sigs) ) ;
951
948
self . holder_commitment . add_holder_sig ( funding_redeemscript, sig)
952
949
}
953
950
954
951
#[ cfg( any( test, feature="unsafe_revoked_tx_signing" ) ) ]
955
952
pub ( crate ) fn get_fully_signed_copy_holder_tx ( & mut self , funding_redeemscript : & Script ) -> Transaction {
956
- let ( sig, htlc_sigs) = self . key_storage . unsafe_sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "sign holder commitment" ) ;
953
+ let ( sig, htlc_sigs) = self . signer . unsafe_sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "sign holder commitment" ) ;
957
954
self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( & self . holder_commitment , htlc_sigs) ) ;
958
955
self . holder_commitment . add_holder_sig ( funding_redeemscript, sig)
959
956
}
0 commit comments