@@ -376,12 +376,13 @@ pub(crate) struct HolderHTLCOutput {
376
376
current_holder_commitment : Option < HolderCommitmentTransaction > ,
377
377
prev_holder_commitment : Option < HolderCommitmentTransaction > ,
378
378
channel_parameters : Option < ChannelTransactionParameters > ,
379
+ channel_keys_id : Option < [ u8 ; 32 ] > ,
379
380
}
380
381
381
382
impl HolderHTLCOutput {
382
383
pub ( crate ) fn build_offered (
383
- channel_parameters : ChannelTransactionParameters , amount_msat : u64 , cltv_expiry : u32 ,
384
- current_holder_commitment : HolderCommitmentTransaction ,
384
+ channel_parameters : ChannelTransactionParameters , channel_keys_id : [ u8 ; 32 ] ,
385
+ amount_msat : u64 , cltv_expiry : u32 , current_holder_commitment : HolderCommitmentTransaction ,
385
386
prev_holder_commitment : Option < HolderCommitmentTransaction > ,
386
387
) -> Self {
387
388
let channel_type_features = channel_parameters. channel_type_features . clone ( ) ;
@@ -393,11 +394,13 @@ impl HolderHTLCOutput {
393
394
current_holder_commitment : Some ( current_holder_commitment) ,
394
395
prev_holder_commitment,
395
396
channel_parameters : Some ( channel_parameters) ,
397
+ channel_keys_id : Some ( channel_keys_id) ,
396
398
}
397
399
}
398
400
399
401
pub ( crate ) fn build_accepted (
400
- channel_parameters : ChannelTransactionParameters , preimage : PaymentPreimage , amount_msat : u64 ,
402
+ channel_parameters : ChannelTransactionParameters , channel_keys_id : [ u8 ; 32 ] ,
403
+ preimage : PaymentPreimage , amount_msat : u64 ,
401
404
current_holder_commitment : HolderCommitmentTransaction ,
402
405
prev_holder_commitment : Option < HolderCommitmentTransaction > ,
403
406
) -> Self {
@@ -410,6 +413,7 @@ impl HolderHTLCOutput {
410
413
current_holder_commitment : Some ( current_holder_commitment) ,
411
414
prev_holder_commitment,
412
415
channel_parameters : Some ( channel_parameters) ,
416
+ channel_keys_id : Some ( channel_keys_id) ,
413
417
}
414
418
}
415
419
@@ -419,6 +423,8 @@ impl HolderHTLCOutput {
419
423
) -> Option < MaybeSignedTransaction > {
420
424
let channel_parameters = self . channel_parameters . as_ref ( )
421
425
. unwrap_or ( & onchain_tx_handler. channel_transaction_parameters ) ;
426
+ let channel_keys_id = self . channel_keys_id
427
+ . unwrap_or ( onchain_tx_handler. channel_keys_id ( ) ) ;
422
428
let get_signed_htlc_tx = |holder_commitment : & HolderCommitmentTransaction | {
423
429
let trusted_tx = holder_commitment. trust ( ) ;
424
430
if trusted_tx. txid ( ) != outp. txid {
@@ -435,7 +441,7 @@ impl HolderHTLCOutput {
435
441
let htlc_descriptor = HTLCDescriptor {
436
442
channel_derivation_parameters : ChannelDerivationParameters {
437
443
value_satoshis : channel_parameters. channel_value_satoshis ,
438
- keys_id : onchain_tx_handler . channel_keys_id ,
444
+ keys_id : channel_keys_id,
439
445
transaction_parameters : channel_parameters. clone ( ) ,
440
446
} ,
441
447
commitment_txid : trusted_tx. txid ( ) ,
@@ -519,6 +525,7 @@ impl Writeable for HolderHTLCOutput {
519
525
( 9 , self . current_holder_commitment, option) , // Added in 0.2.
520
526
( 11 , self . prev_holder_commitment, option) , // Added in 0.2.
521
527
( 13 , self . channel_parameters, option) , // Added in 0.2.
528
+ ( 15 , self . channel_keys_id, option) , // Added in 0.2.
522
529
} ) ;
523
530
Ok ( ( ) )
524
531
}
@@ -534,6 +541,7 @@ impl Readable for HolderHTLCOutput {
534
541
let mut current_holder_commitment = None ;
535
542
let mut prev_holder_commitment = None ;
536
543
let mut channel_parameters = None ;
544
+ let mut channel_keys_id = None ;
537
545
538
546
read_tlv_fields ! ( reader, {
539
547
( 0 , amount_msat, required) ,
@@ -544,6 +552,7 @@ impl Readable for HolderHTLCOutput {
544
552
( 9 , current_holder_commitment, option) , // Added in 0.2.
545
553
( 11 , prev_holder_commitment, option) , // Added in 0.2.
546
554
( 13 , channel_parameters, ( option: ReadableArgs , None ) ) , // Added in 0.2.
555
+ ( 15 , channel_keys_id, option) , // Added in 0.2.
547
556
} ) ;
548
557
549
558
verify_channel_type_features ( & channel_type_features, None ) ?;
@@ -558,6 +567,7 @@ impl Readable for HolderHTLCOutput {
558
567
current_holder_commitment,
559
568
prev_holder_commitment,
560
569
channel_parameters,
570
+ channel_keys_id,
561
571
} )
562
572
}
563
573
}
@@ -1660,7 +1670,7 @@ mod tests {
1660
1670
let commitment_tx = HolderCommitmentTransaction :: dummy( 0 , & mut Vec :: new( ) ) ;
1661
1671
let preimage = PaymentPreimage ( [ 2 ; 32 ] ) ;
1662
1672
PackageSolvingData :: HolderHTLCOutput ( HolderHTLCOutput :: build_accepted(
1663
- channel_parameters, preimage, 0 , commitment_tx, None ,
1673
+ channel_parameters, [ 0 ; 32 ] , preimage, 0 , commitment_tx, None ,
1664
1674
) )
1665
1675
}
1666
1676
}
@@ -1673,7 +1683,7 @@ mod tests {
1673
1683
channel_parameters. channel_type_features = $features;
1674
1684
let commitment_tx = HolderCommitmentTransaction :: dummy( 0 , & mut Vec :: new( ) ) ;
1675
1685
PackageSolvingData :: HolderHTLCOutput ( HolderHTLCOutput :: build_offered(
1676
- channel_parameters, 0 , $cltv_expiry, commitment_tx, None ,
1686
+ channel_parameters, [ 0 ; 32 ] , 0 , $cltv_expiry, commitment_tx, None ,
1677
1687
) )
1678
1688
}
1679
1689
}
0 commit comments