Skip to content

Commit 4d2f300

Browse files
committed
Pass channel params to sign_channel_announcement_with_funding_key
Now that channel_value_satoshis has been moved to ChannelTransactionParameters, pass the entire parameters when calling each method on EcdsaChannelSigner. This will remove the need for ChannelSigner::provide_channel_parameters. Instead, the parameters from the FundingScope will be passed in to each method. This simplifies the interaction with a ChannelSigner when needing to be called for more than one FundingScope, which will be the case for pending splices and RBF attempts.
1 parent 6d9ec87 commit 4d2f300

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8135,7 +8135,8 @@ impl<SP: Deref> FundedChannel<SP> where
81358135
};
81368136
match &self.context.holder_signer {
81378137
ChannelSignerType::Ecdsa(ecdsa) => {
8138-
let our_bitcoin_sig = match ecdsa.sign_channel_announcement_with_funding_key(&announcement, &self.context.secp_ctx) {
8138+
let channel_parameters = &self.funding.channel_transaction_parameters;
8139+
let our_bitcoin_sig = match ecdsa.sign_channel_announcement_with_funding_key(channel_parameters, &announcement, &self.context.secp_ctx) {
81398140
Err(_) => {
81408141
log_error!(logger, "Signer rejected channel_announcement signing. Channel will not be announced!");
81418142
return None;
@@ -8176,7 +8177,8 @@ impl<SP: Deref> FundedChannel<SP> where
81768177
.map_err(|_| ChannelError::Ignore("Failed to generate node signature for channel_announcement".to_owned()))?;
81778178
match &self.context.holder_signer {
81788179
ChannelSignerType::Ecdsa(ecdsa) => {
8179-
let our_bitcoin_sig = ecdsa.sign_channel_announcement_with_funding_key(&announcement, &self.context.secp_ctx)
8180+
let channel_parameters = &self.funding.channel_transaction_parameters;
8181+
let our_bitcoin_sig = ecdsa.sign_channel_announcement_with_funding_key(channel_parameters, &announcement, &self.context.secp_ctx)
81808182
.map_err(|_| ChannelError::Ignore("Signer rejected channel_announcement".to_owned()))?;
81818183
Ok(msgs::ChannelAnnouncement {
81828184
node_signature_1: if were_node_one { our_node_sig } else { their_node_sig },

lightning/src/sign/ecdsa.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ pub trait EcdsaChannelSigner: ChannelSigner {
238238
///
239239
/// [`NodeSigner::sign_gossip_message`]: crate::sign::NodeSigner::sign_gossip_message
240240
fn sign_channel_announcement_with_funding_key(
241-
&self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
241+
&self, channel_parameters: &ChannelTransactionParameters,
242+
msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
242243
) -> Result<Signature, ()>;
243244

244245
/// Signs the input of a splicing funding transaction with our funding key.

lightning/src/sign/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,8 @@ impl EcdsaChannelSigner for InMemorySigner {
16971697
}
16981698

16991699
fn sign_channel_announcement_with_funding_key(
1700-
&self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
1700+
&self, _channel_parameters: &ChannelTransactionParameters,
1701+
msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
17011702
) -> Result<Signature, ()> {
17021703
let msghash = hash_to_message!(&Sha256dHash::hash(&msg.encode()[..])[..]);
17031704
Ok(secp_ctx.sign_ecdsa(&msghash, &self.funding_key))

lightning/src/util/test_channel_signer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,10 @@ impl EcdsaChannelSigner for TestChannelSigner {
474474
}
475475

476476
fn sign_channel_announcement_with_funding_key(
477-
&self, msg: &msgs::UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
477+
&self, channel_parameters: &ChannelTransactionParameters,
478+
msg: &msgs::UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
478479
) -> Result<Signature, ()> {
479-
self.inner.sign_channel_announcement_with_funding_key(msg, secp_ctx)
480+
self.inner.sign_channel_announcement_with_funding_key(channel_parameters, msg, secp_ctx)
480481
}
481482

482483
fn sign_splicing_funding_input(

0 commit comments

Comments
 (0)