@@ -43,7 +43,7 @@ use crate::chain;
4343use crate :: chain:: { BestBlock , WatchedOutput } ;
4444use crate :: chain:: chaininterface:: { BroadcasterInterface , ConfirmationTarget , FeeEstimator , LowerBoundedFeeEstimator } ;
4545use crate :: chain:: transaction:: { OutPoint , TransactionData } ;
46- use crate :: sign:: { ChannelDerivationParameters , HTLCDescriptor , SpendableOutputDescriptor , StaticPaymentOutputDescriptor , DelayedPaymentOutputDescriptor , ecdsa:: EcdsaChannelSigner , SignerProvider , EntropySource } ;
46+ use crate :: sign:: { ChannelDerivationParameters , ChannelKeysDerivationParameters , HTLCDescriptor , SpendableOutputDescriptor , StaticPaymentOutputDescriptor , DelayedPaymentOutputDescriptor , ecdsa:: EcdsaChannelSigner , SignerProvider , EntropySource } ;
4747use crate :: chain:: onchaintx:: { ClaimEvent , FeerateStrategy , OnchainTxHandler } ;
4848use crate :: chain:: package:: { CounterpartyOfferedHTLCOutput , CounterpartyReceivedHTLCOutput , HolderFundingOutput , HolderHTLCOutput , PackageSolvingData , PackageTemplate , RevokedOutput , RevokedHTLCOutput } ;
4949use crate :: chain:: Filter ;
@@ -872,7 +872,7 @@ pub(crate) struct ChannelMonitorImpl<Signer: EcdsaChannelSigner> {
872872 counterparty_payment_script : ScriptBuf ,
873873 shutdown_script : Option < ScriptBuf > ,
874874
875- channel_keys_id : [ u8 ; 32 ] ,
875+ channel_keys_derivation_params : ChannelKeysDerivationParameters ,
876876 holder_revocation_basepoint : RevocationBasepoint ,
877877 channel_id : ChannelId ,
878878 funding_info : ( OutPoint , ScriptBuf ) ,
@@ -1076,7 +1076,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
10761076 None => ScriptBuf :: new ( ) . write ( writer) ?,
10771077 }
10781078
1079- self . channel_keys_id . write ( writer) ?;
1079+ self . channel_keys_derivation_params . channel_keys_id . write ( writer) ?;
10801080 self . holder_revocation_basepoint . write ( writer) ?;
10811081 writer. write_all ( & self . funding_info . 0 . txid [ ..] ) ?;
10821082 writer. write_all ( & self . funding_info . 0 . index . to_be_bytes ( ) ) ?;
@@ -1237,6 +1237,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
12371237 ( 21 , self . balances_empty_height, option) ,
12381238 ( 23 , self . holder_pays_commitment_tx_fee, option) ,
12391239 ( 25 , self . payment_preimages, required) ,
1240+ ( 27 , self . channel_keys_derivation_params. channel_keys_derivation_version, option) ,
12401241 } ) ;
12411242
12421243 Ok ( ( ) )
@@ -1355,7 +1356,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
13551356 let counterparty_htlc_base_key = counterparty_channel_parameters. pubkeys . htlc_basepoint ;
13561357 let counterparty_commitment_params = CounterpartyCommitmentParameters { counterparty_delayed_payment_base_key, counterparty_htlc_base_key, on_counterparty_tx_csv } ;
13571358
1358- let channel_keys_id = keys. channel_keys_id ( ) ;
1359+ let channel_keys_derivation_params = keys. channel_keys_derivation_params ( ) ;
13591360 let holder_revocation_basepoint = keys. pubkeys ( ) . revocation_basepoint ;
13601361
13611362 // block for Rust 1.34 compat
@@ -1379,7 +1380,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
13791380 } ;
13801381
13811382 let onchain_tx_handler = OnchainTxHandler :: new (
1382- channel_value_satoshis, channel_keys_id , destination_script. into ( ) , keys,
1383+ channel_value_satoshis, channel_keys_derivation_params , destination_script. into ( ) , keys,
13831384 channel_parameters. clone ( ) , initial_holder_commitment_tx, secp_ctx
13841385 ) ;
13851386
@@ -1395,7 +1396,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
13951396 counterparty_payment_script,
13961397 shutdown_script,
13971398
1398- channel_keys_id ,
1399+ channel_keys_derivation_params ,
13991400 holder_revocation_basepoint,
14001401 channel_id,
14011402 funding_info,
@@ -3304,7 +3305,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
33043305 commitment_tx_fee_satoshis,
33053306 anchor_descriptor : AnchorDescriptor {
33063307 channel_derivation_parameters : ChannelDerivationParameters {
3307- channel_keys_id : self . channel_keys_id ,
3308+ channel_keys_derivation_params : self . channel_keys_derivation_params ,
33083309 value_satoshis : self . channel_value_satoshis ,
33093310 transaction_parameters : self . onchain_tx_handler . channel_transaction_parameters . clone ( ) ,
33103311 } ,
@@ -3328,7 +3329,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
33283329 for htlc in htlcs {
33293330 htlc_descriptors. push ( HTLCDescriptor {
33303331 channel_derivation_parameters : ChannelDerivationParameters {
3331- channel_keys_id : self . channel_keys_id ,
3332+ channel_keys_derivation_params : self . channel_keys_derivation_params ,
33323333 value_satoshis : self . channel_value_satoshis ,
33333334 transaction_parameters : self . onchain_tx_handler . channel_transaction_parameters . clone ( ) ,
33343335 } ,
@@ -4609,7 +4610,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
46094610 spendable_outputs. push ( SpendableOutputDescriptor :: StaticOutput {
46104611 outpoint : OutPoint { txid : tx. compute_txid ( ) , index : i as u16 } ,
46114612 output : outp. clone ( ) ,
4612- channel_keys_id : Some ( self . channel_keys_id ) ,
4613+ channel_keys_derivation_params : Some ( self . channel_keys_derivation_params ) ,
46134614 } ) ;
46144615 }
46154616 if let Some ( ref broadcasted_holder_revokable_script) = self . broadcasted_holder_revokable_script {
@@ -4620,7 +4621,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
46204621 to_self_delay : self . on_holder_tx_csv ,
46214622 output : outp. clone ( ) ,
46224623 revocation_pubkey : broadcasted_holder_revokable_script. 2 ,
4623- channel_keys_id : self . channel_keys_id ,
4624+ channel_keys_derivation_params : self . channel_keys_derivation_params ,
46244625 channel_value_satoshis : self . channel_value_satoshis ,
46254626 channel_transaction_parameters : Some ( self . onchain_tx_handler . channel_transaction_parameters . clone ( ) ) ,
46264627 } ) ) ;
@@ -4630,7 +4631,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
46304631 spendable_outputs. push ( SpendableOutputDescriptor :: StaticPaymentOutput ( StaticPaymentOutputDescriptor {
46314632 outpoint : OutPoint { txid : tx. compute_txid ( ) , index : i as u16 } ,
46324633 output : outp. clone ( ) ,
4633- channel_keys_id : self . channel_keys_id ,
4634+ channel_keys_derivation_params : self . channel_keys_derivation_params ,
46344635 channel_value_satoshis : self . channel_value_satoshis ,
46354636 channel_transaction_parameters : Some ( self . onchain_tx_handler . channel_transaction_parameters . clone ( ) ) ,
46364637 } ) ) ;
@@ -4639,7 +4640,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
46394640 spendable_outputs. push ( SpendableOutputDescriptor :: StaticOutput {
46404641 outpoint : OutPoint { txid : tx. compute_txid ( ) , index : i as u16 } ,
46414642 output : outp. clone ( ) ,
4642- channel_keys_id : Some ( self . channel_keys_id ) ,
4643+ channel_keys_derivation_params : Some ( self . channel_keys_derivation_params ) ,
46434644 } ) ;
46444645 }
46454646 }
@@ -4929,6 +4930,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
49294930 let mut channel_id = None ;
49304931 let mut holder_pays_commitment_tx_fee = None ;
49314932 let mut payment_preimages_with_info: Option < HashMap < _ , _ > > = None ;
4933+ let mut channel_keys_derivation_version: Option < u8 > = None ;
49324934 read_tlv_fields ! ( reader, {
49334935 ( 1 , funding_spend_confirmed, option) ,
49344936 ( 3 , htlcs_resolved_on_chain, optional_vec) ,
@@ -4943,6 +4945,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
49434945 ( 21 , balances_empty_height, option) ,
49444946 ( 23 , holder_pays_commitment_tx_fee, option) ,
49454947 ( 25 , payment_preimages_with_info, option) ,
4948+ ( 27 , channel_keys_derivation_version, option) ,
49464949 } ) ;
49474950 if let Some ( payment_preimages_with_info) = payment_preimages_with_info {
49484951 if payment_preimages_with_info. len ( ) != payment_preimages. len ( ) {
@@ -4982,6 +4985,11 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
49824985 chan_utils:: get_to_countersignatory_with_anchors_redeemscript ( & payment_basepoint) . to_p2wsh ( ) ;
49834986 }
49844987
4988+ let channel_keys_derivation_params = ChannelKeysDerivationParameters {
4989+ channel_keys_derivation_version,
4990+ channel_keys_id,
4991+ } ;
4992+
49854993 Ok ( ( best_block. block_hash , ChannelMonitor :: from_impl ( ChannelMonitorImpl {
49864994 latest_update_id,
49874995 commitment_transaction_number_obscure_factor,
@@ -4991,7 +4999,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
49914999 counterparty_payment_script,
49925000 shutdown_script,
49935001
4994- channel_keys_id ,
5002+ channel_keys_derivation_params ,
49955003 holder_revocation_basepoint,
49965004 channel_id : channel_id. unwrap_or ( ChannelId :: v1_from_funding_outpoint ( outpoint) ) ,
49975005 funding_info,
@@ -5070,7 +5078,7 @@ mod tests {
50705078 use crate :: chain:: channelmonitor:: { ChannelMonitor , WithChannelMonitor } ;
50715079 use crate :: chain:: package:: { weight_offered_htlc, weight_received_htlc, weight_revoked_offered_htlc, weight_revoked_received_htlc, WEIGHT_REVOKED_OUTPUT } ;
50725080 use crate :: chain:: transaction:: OutPoint ;
5073- use crate :: sign:: InMemorySigner ;
5081+ use crate :: sign:: { InMemorySigner , ChannelKeysDerivationParameters , CHANNEL_KEYS_DERIVATION_VERSION } ;
50745082 use crate :: ln:: types:: ChannelId ;
50755083 use crate :: types:: payment:: { PaymentPreimage , PaymentHash } ;
50765084 use crate :: ln:: channel_keys:: { DelayedPaymentBasepoint , DelayedPaymentKey , HtlcBasepoint , RevocationBasepoint , RevocationKey } ;
@@ -5233,6 +5241,11 @@ mod tests {
52335241 }
52345242 }
52355243
5244+ let dummy_key_derivation_params = ChannelKeysDerivationParameters {
5245+ channel_keys_derivation_version : Some ( CHANNEL_KEYS_DERIVATION_VERSION ) ,
5246+ channel_keys_id : [ 0 ; 32 ] ,
5247+ } ;
5248+
52365249 let keys = InMemorySigner :: new (
52375250 & secp_ctx,
52385251 SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ,
@@ -5242,7 +5255,7 @@ mod tests {
52425255 SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ,
52435256 [ 41 ; 32 ] ,
52445257 0 ,
5245- [ 0 ; 32 ] ,
5258+ dummy_key_derivation_params ,
52465259 [ 0 ; 32 ] ,
52475260 ) ;
52485261
@@ -5485,6 +5498,11 @@ mod tests {
54855498
54865499 let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
54875500
5501+ let dummy_key_derivation_params = ChannelKeysDerivationParameters {
5502+ channel_keys_derivation_version : Some ( CHANNEL_KEYS_DERIVATION_VERSION ) ,
5503+ channel_keys_id : [ 0 ; 32 ] ,
5504+ } ;
5505+
54885506 let keys = InMemorySigner :: new (
54895507 & secp_ctx,
54905508 SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ,
@@ -5494,7 +5512,7 @@ mod tests {
54945512 SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ,
54955513 [ 41 ; 32 ] ,
54965514 0 ,
5497- [ 0 ; 32 ] ,
5515+ dummy_key_derivation_params ,
54985516 [ 0 ; 32 ] ,
54995517 ) ;
55005518
0 commit comments