@@ -43,7 +43,7 @@ use crate::chain;
43
43
use crate :: chain:: { BestBlock , WatchedOutput } ;
44
44
use crate :: chain:: chaininterface:: { BroadcasterInterface , ConfirmationTarget , FeeEstimator , LowerBoundedFeeEstimator } ;
45
45
use 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 } ;
47
47
use crate :: chain:: onchaintx:: { ClaimEvent , FeerateStrategy , OnchainTxHandler } ;
48
48
use crate :: chain:: package:: { CounterpartyOfferedHTLCOutput , CounterpartyReceivedHTLCOutput , HolderFundingOutput , HolderHTLCOutput , PackageSolvingData , PackageTemplate , RevokedOutput , RevokedHTLCOutput } ;
49
49
use crate :: chain:: Filter ;
@@ -872,7 +872,7 @@ pub(crate) struct ChannelMonitorImpl<Signer: EcdsaChannelSigner> {
872
872
counterparty_payment_script : ScriptBuf ,
873
873
shutdown_script : Option < ScriptBuf > ,
874
874
875
- channel_keys_id : [ u8 ; 32 ] ,
875
+ channel_keys_derivation_params : ChannelKeysDerivationParameters ,
876
876
holder_revocation_basepoint : RevocationBasepoint ,
877
877
channel_id : ChannelId ,
878
878
funding_info : ( OutPoint , ScriptBuf ) ,
@@ -1076,7 +1076,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1076
1076
None => ScriptBuf :: new ( ) . write ( writer) ?,
1077
1077
}
1078
1078
1079
- self . channel_keys_id . write ( writer) ?;
1079
+ self . channel_keys_derivation_params . channel_keys_id . write ( writer) ?;
1080
1080
self . holder_revocation_basepoint . write ( writer) ?;
1081
1081
writer. write_all ( & self . funding_info . 0 . txid [ ..] ) ?;
1082
1082
writer. write_all ( & self . funding_info . 0 . index . to_be_bytes ( ) ) ?;
@@ -1237,6 +1237,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1237
1237
( 21 , self . balances_empty_height, option) ,
1238
1238
( 23 , self . holder_pays_commitment_tx_fee, option) ,
1239
1239
( 25 , self . payment_preimages, required) ,
1240
+ ( 27 , self . channel_keys_derivation_params. channel_keys_derivation_version, option) ,
1240
1241
} ) ;
1241
1242
1242
1243
Ok ( ( ) )
@@ -1355,7 +1356,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1355
1356
let counterparty_htlc_base_key = counterparty_channel_parameters. pubkeys . htlc_basepoint ;
1356
1357
let counterparty_commitment_params = CounterpartyCommitmentParameters { counterparty_delayed_payment_base_key, counterparty_htlc_base_key, on_counterparty_tx_csv } ;
1357
1358
1358
- let channel_keys_id = keys. channel_keys_id ( ) ;
1359
+ let channel_keys_derivation_params = keys. channel_keys_derivation_params ( ) ;
1359
1360
let holder_revocation_basepoint = keys. pubkeys ( ) . revocation_basepoint ;
1360
1361
1361
1362
// block for Rust 1.34 compat
@@ -1379,7 +1380,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1379
1380
} ;
1380
1381
1381
1382
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,
1383
1384
channel_parameters. clone ( ) , initial_holder_commitment_tx, secp_ctx
1384
1385
) ;
1385
1386
@@ -1395,7 +1396,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1395
1396
counterparty_payment_script,
1396
1397
shutdown_script,
1397
1398
1398
- channel_keys_id ,
1399
+ channel_keys_derivation_params ,
1399
1400
holder_revocation_basepoint,
1400
1401
channel_id,
1401
1402
funding_info,
@@ -3304,7 +3305,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3304
3305
commitment_tx_fee_satoshis,
3305
3306
anchor_descriptor : AnchorDescriptor {
3306
3307
channel_derivation_parameters : ChannelDerivationParameters {
3307
- channel_keys_id : self . channel_keys_id ,
3308
+ channel_keys_derivation_params : self . channel_keys_derivation_params ,
3308
3309
value_satoshis : self . channel_value_satoshis ,
3309
3310
transaction_parameters : self . onchain_tx_handler . channel_transaction_parameters . clone ( ) ,
3310
3311
} ,
@@ -3328,7 +3329,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3328
3329
for htlc in htlcs {
3329
3330
htlc_descriptors. push ( HTLCDescriptor {
3330
3331
channel_derivation_parameters : ChannelDerivationParameters {
3331
- channel_keys_id : self . channel_keys_id ,
3332
+ channel_keys_derivation_params : self . channel_keys_derivation_params ,
3332
3333
value_satoshis : self . channel_value_satoshis ,
3333
3334
transaction_parameters : self . onchain_tx_handler . channel_transaction_parameters . clone ( ) ,
3334
3335
} ,
@@ -4609,7 +4610,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4609
4610
spendable_outputs. push ( SpendableOutputDescriptor :: StaticOutput {
4610
4611
outpoint : OutPoint { txid : tx. compute_txid ( ) , index : i as u16 } ,
4611
4612
output : outp. clone ( ) ,
4612
- channel_keys_id : Some ( self . channel_keys_id ) ,
4613
+ channel_keys_derivation_params : Some ( self . channel_keys_derivation_params ) ,
4613
4614
} ) ;
4614
4615
}
4615
4616
if let Some ( ref broadcasted_holder_revokable_script) = self . broadcasted_holder_revokable_script {
@@ -4620,7 +4621,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4620
4621
to_self_delay : self . on_holder_tx_csv ,
4621
4622
output : outp. clone ( ) ,
4622
4623
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 ,
4624
4625
channel_value_satoshis : self . channel_value_satoshis ,
4625
4626
channel_transaction_parameters : Some ( self . onchain_tx_handler . channel_transaction_parameters . clone ( ) ) ,
4626
4627
} ) ) ;
@@ -4630,7 +4631,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4630
4631
spendable_outputs. push ( SpendableOutputDescriptor :: StaticPaymentOutput ( StaticPaymentOutputDescriptor {
4631
4632
outpoint : OutPoint { txid : tx. compute_txid ( ) , index : i as u16 } ,
4632
4633
output : outp. clone ( ) ,
4633
- channel_keys_id : self . channel_keys_id ,
4634
+ channel_keys_derivation_params : self . channel_keys_derivation_params ,
4634
4635
channel_value_satoshis : self . channel_value_satoshis ,
4635
4636
channel_transaction_parameters : Some ( self . onchain_tx_handler . channel_transaction_parameters . clone ( ) ) ,
4636
4637
} ) ) ;
@@ -4639,7 +4640,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4639
4640
spendable_outputs. push ( SpendableOutputDescriptor :: StaticOutput {
4640
4641
outpoint : OutPoint { txid : tx. compute_txid ( ) , index : i as u16 } ,
4641
4642
output : outp. clone ( ) ,
4642
- channel_keys_id : Some ( self . channel_keys_id ) ,
4643
+ channel_keys_derivation_params : Some ( self . channel_keys_derivation_params ) ,
4643
4644
} ) ;
4644
4645
}
4645
4646
}
@@ -4929,6 +4930,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4929
4930
let mut channel_id = None ;
4930
4931
let mut holder_pays_commitment_tx_fee = None ;
4931
4932
let mut payment_preimages_with_info: Option < HashMap < _ , _ > > = None ;
4933
+ let mut channel_keys_derivation_version: Option < u8 > = None ;
4932
4934
read_tlv_fields ! ( reader, {
4933
4935
( 1 , funding_spend_confirmed, option) ,
4934
4936
( 3 , htlcs_resolved_on_chain, optional_vec) ,
@@ -4943,6 +4945,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4943
4945
( 21 , balances_empty_height, option) ,
4944
4946
( 23 , holder_pays_commitment_tx_fee, option) ,
4945
4947
( 25 , payment_preimages_with_info, option) ,
4948
+ ( 27 , channel_keys_derivation_version, option) ,
4946
4949
} ) ;
4947
4950
if let Some ( payment_preimages_with_info) = payment_preimages_with_info {
4948
4951
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
4982
4985
chan_utils:: get_to_countersignatory_with_anchors_redeemscript ( & payment_basepoint) . to_p2wsh ( ) ;
4983
4986
}
4984
4987
4988
+ let channel_keys_derivation_params = ChannelKeysDerivationParameters {
4989
+ channel_keys_derivation_version,
4990
+ channel_keys_id,
4991
+ } ;
4992
+
4985
4993
Ok ( ( best_block. block_hash , ChannelMonitor :: from_impl ( ChannelMonitorImpl {
4986
4994
latest_update_id,
4987
4995
commitment_transaction_number_obscure_factor,
@@ -4991,7 +4999,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4991
4999
counterparty_payment_script,
4992
5000
shutdown_script,
4993
5001
4994
- channel_keys_id ,
5002
+ channel_keys_derivation_params ,
4995
5003
holder_revocation_basepoint,
4996
5004
channel_id : channel_id. unwrap_or ( ChannelId :: v1_from_funding_outpoint ( outpoint) ) ,
4997
5005
funding_info,
@@ -5070,7 +5078,7 @@ mod tests {
5070
5078
use crate :: chain:: channelmonitor:: { ChannelMonitor , WithChannelMonitor } ;
5071
5079
use crate :: chain:: package:: { weight_offered_htlc, weight_received_htlc, weight_revoked_offered_htlc, weight_revoked_received_htlc, WEIGHT_REVOKED_OUTPUT } ;
5072
5080
use crate :: chain:: transaction:: OutPoint ;
5073
- use crate :: sign:: InMemorySigner ;
5081
+ use crate :: sign:: { InMemorySigner , ChannelKeysDerivationParameters , CHANNEL_KEYS_DERIVATION_VERSION } ;
5074
5082
use crate :: ln:: types:: ChannelId ;
5075
5083
use crate :: types:: payment:: { PaymentPreimage , PaymentHash } ;
5076
5084
use crate :: ln:: channel_keys:: { DelayedPaymentBasepoint , DelayedPaymentKey , HtlcBasepoint , RevocationBasepoint , RevocationKey } ;
@@ -5233,6 +5241,11 @@ mod tests {
5233
5241
}
5234
5242
}
5235
5243
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
+
5236
5249
let keys = InMemorySigner :: new (
5237
5250
& secp_ctx,
5238
5251
SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ,
@@ -5242,7 +5255,7 @@ mod tests {
5242
5255
SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ,
5243
5256
[ 41 ; 32 ] ,
5244
5257
0 ,
5245
- [ 0 ; 32 ] ,
5258
+ dummy_key_derivation_params ,
5246
5259
[ 0 ; 32 ] ,
5247
5260
) ;
5248
5261
@@ -5485,6 +5498,11 @@ mod tests {
5485
5498
5486
5499
let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
5487
5500
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
+
5488
5506
let keys = InMemorySigner :: new (
5489
5507
& secp_ctx,
5490
5508
SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ,
@@ -5494,7 +5512,7 @@ mod tests {
5494
5512
SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ,
5495
5513
[ 41 ; 32 ] ,
5496
5514
0 ,
5497
- [ 0 ; 32 ] ,
5515
+ dummy_key_derivation_params ,
5498
5516
[ 0 ; 32 ] ,
5499
5517
) ;
5500
5518
0 commit comments