@@ -14,13 +14,13 @@ use core::ops::Deref;
14
14
15
15
use crate :: chain:: chaininterface:: BroadcasterInterface ;
16
16
use crate :: chain:: ClaimId ;
17
- use crate :: sign:: { ChannelSigner , EcdsaChannelSigner , SignerProvider } ;
17
+ use crate :: sign:: { ChannelSigner , ChannelSignerDescriptor , EcdsaChannelSigner , SignerProvider } ;
18
18
use crate :: io_extras:: sink;
19
19
use crate :: ln:: PaymentPreimage ;
20
20
use crate :: ln:: chan_utils;
21
21
use crate :: ln:: chan_utils:: {
22
22
ANCHOR_INPUT_WITNESS_WEIGHT , HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT ,
23
- HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT , ChannelTransactionParameters , HTLCOutputInCommitment
23
+ HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT , HTLCOutputInCommitment
24
24
} ;
25
25
use crate :: events:: Event ;
26
26
use crate :: prelude:: HashMap ;
@@ -51,17 +51,8 @@ const fn fee_for_weight(feerate_sat_per_1000_weight: u32, weight: u64) -> u64 {
51
51
/// A descriptor used to sign for a commitment transaction's anchor output.
52
52
#[ derive( Clone , Debug , PartialEq , Eq ) ]
53
53
pub struct AnchorDescriptor {
54
- /// A unique identifier used along with `channel_value_satoshis` to re-derive the
55
- /// [`InMemorySigner`] required to sign `input`.
56
- ///
57
- /// [`InMemorySigner`]: crate::sign::InMemorySigner
58
- pub channel_keys_id : [ u8 ; 32 ] ,
59
- /// The value in satoshis of the channel we're attempting to spend the anchor output of. This is
60
- /// used along with `channel_keys_id` to re-derive the [`InMemorySigner`] required to sign
61
- /// `input`.
62
- ///
63
- /// [`InMemorySigner`]: crate::sign::InMemorySigner
64
- pub channel_value_satoshis : u64 ,
54
+ /// The parameters needed to re-derive the [`InMemorySigner`] required to sign `input`.
55
+ pub signer_descriptor : ChannelSignerDescriptor ,
65
56
/// The transaction input's outpoint corresponding to the commitment transaction's anchor
66
57
/// output.
67
58
pub outpoint : OutPoint ,
@@ -70,23 +61,8 @@ pub struct AnchorDescriptor {
70
61
/// A descriptor used to sign for a commitment transaction's HTLC output.
71
62
#[ derive( Clone , Debug , PartialEq , Eq ) ]
72
63
pub struct HTLCDescriptor {
73
- /// A unique identifier used along with `channel_value_satoshis` to re-derive the
74
- /// [`InMemorySigner`] required to sign `input`.
75
- ///
76
- /// [`InMemorySigner`]: crate::sign::InMemorySigner
77
- pub channel_keys_id : [ u8 ; 32 ] ,
78
- /// The value in satoshis of the channel we're attempting to spend the anchor output of. This is
79
- /// used along with `channel_keys_id` to re-derive the [`InMemorySigner`] required to sign
80
- /// `input`.
81
- ///
82
- /// [`InMemorySigner`]: crate::sign::InMemorySigner
83
- pub channel_value_satoshis : u64 ,
84
- /// The necessary channel parameters that need to be provided to the re-derived
85
- /// [`InMemorySigner`] through [`ChannelSigner::provide_channel_parameters`].
86
- ///
87
- /// [`InMemorySigner`]: crate::sign::InMemorySigner
88
- /// [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters
89
- pub channel_parameters : ChannelTransactionParameters ,
64
+ /// The parameters needed to re-derive the [`InMemorySigner`] required to sign `input`.
65
+ pub signer_descriptor : ChannelSignerDescriptor ,
90
66
/// The txid of the commitment transaction in which the HTLC output lives.
91
67
pub commitment_txid : Txid ,
92
68
/// The number of the commitment transaction in which the HTLC output lives.
@@ -112,7 +88,7 @@ impl HTLCDescriptor {
112
88
pub fn tx_output < C : secp256k1:: Signing + secp256k1:: Verification > (
113
89
& self , per_commitment_point : & PublicKey , secp : & Secp256k1 < C >
114
90
) -> TxOut {
115
- let channel_params = self . channel_parameters . as_holder_broadcastable ( ) ;
91
+ let channel_params = self . signer_descriptor . channel_parameters . as_holder_broadcastable ( ) ;
116
92
let broadcaster_keys = channel_params. broadcaster_pubkeys ( ) ;
117
93
let counterparty_keys = channel_params. countersignatory_pubkeys ( ) ;
118
94
let broadcaster_delayed_key = chan_utils:: derive_public_key (
@@ -131,7 +107,7 @@ impl HTLCDescriptor {
131
107
pub fn witness_script < C : secp256k1:: Signing + secp256k1:: Verification > (
132
108
& self , per_commitment_point : & PublicKey , secp : & Secp256k1 < C >
133
109
) -> Script {
134
- let channel_params = self . channel_parameters . as_holder_broadcastable ( ) ;
110
+ let channel_params = self . signer_descriptor . channel_parameters . as_holder_broadcastable ( ) ;
135
111
let broadcaster_keys = channel_params. broadcaster_pubkeys ( ) ;
136
112
let counterparty_keys = channel_params. countersignatory_pubkeys ( ) ;
137
113
let broadcaster_htlc_key = chan_utils:: derive_public_key (
@@ -675,9 +651,11 @@ where
675
651
676
652
debug_assert_eq ! ( anchor_tx. output. len( ) , 1 ) ;
677
653
self . utxo_source . sign_tx ( & mut anchor_tx) ?;
678
- let signer = self . signer_provider . derive_channel_signer (
679
- anchor_descriptor. channel_value_satoshis , anchor_descriptor. channel_keys_id ,
654
+ let mut signer = self . signer_provider . derive_channel_signer (
655
+ anchor_descriptor. signer_descriptor . channel_value_satoshis ,
656
+ anchor_descriptor. signer_descriptor . channel_keys_id ,
680
657
) ;
658
+ signer. provide_channel_parameters ( & anchor_descriptor. signer_descriptor . channel_parameters ) ;
681
659
let anchor_sig = signer. sign_holder_anchor_input ( & anchor_tx, 0 , & self . secp ) ?;
682
660
anchor_tx. input [ 0 ] . witness =
683
661
chan_utils:: build_anchor_input_witness ( & signer. pubkeys ( ) . funding_pubkey , & anchor_sig) ;
@@ -703,12 +681,15 @@ where
703
681
let mut signers = HashMap :: new ( ) ;
704
682
let mut must_spend = Vec :: with_capacity ( htlc_descriptors. len ( ) ) ;
705
683
for htlc_descriptor in htlc_descriptors {
706
- let signer = signers. entry ( htlc_descriptor. channel_keys_id )
707
- . or_insert_with ( ||
708
- self . signer_provider . derive_channel_signer (
709
- htlc_descriptor. channel_value_satoshis , htlc_descriptor. channel_keys_id ,
710
- )
711
- ) ;
684
+ let signer = signers. entry ( htlc_descriptor. signer_descriptor . channel_keys_id )
685
+ . or_insert_with ( || {
686
+ let mut signer = self . signer_provider . derive_channel_signer (
687
+ htlc_descriptor. signer_descriptor . channel_value_satoshis ,
688
+ htlc_descriptor. signer_descriptor . channel_keys_id ,
689
+ ) ;
690
+ signer. provide_channel_parameters ( & htlc_descriptor. signer_descriptor . channel_parameters ) ;
691
+ signer
692
+ } ) ;
712
693
let per_commitment_point = signer. get_per_commitment_point (
713
694
htlc_descriptor. per_commitment_number , & self . secp
714
695
) ;
@@ -746,7 +727,7 @@ where
746
727
747
728
self . utxo_source . sign_tx ( & mut htlc_tx) ?;
748
729
for ( idx, htlc_descriptor) in htlc_descriptors. iter ( ) . enumerate ( ) {
749
- let signer = signers. get ( & htlc_descriptor. channel_keys_id ) . unwrap ( ) ;
730
+ let signer = signers. get ( & htlc_descriptor. signer_descriptor . channel_keys_id ) . unwrap ( ) ;
750
731
let htlc_sig = signer. sign_holder_htlc_transaction (
751
732
& htlc_tx, idx, htlc_descriptor, & self . secp
752
733
) ?;
0 commit comments