Skip to content

Commit 8f8558c

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 abd7d7f commit 8f8558c

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
@@ -8004,7 +8004,8 @@ impl<SP: Deref> FundedChannel<SP> where
80048004
};
80058005
match &self.context.holder_signer {
80068006
ChannelSignerType::Ecdsa(ecdsa) => {
8007-
let our_bitcoin_sig = match ecdsa.sign_channel_announcement_with_funding_key(&announcement, &self.context.secp_ctx) {
8007+
let channel_parameters = &self.funding.channel_transaction_parameters;
8008+
let our_bitcoin_sig = match ecdsa.sign_channel_announcement_with_funding_key(channel_parameters, &announcement, &self.context.secp_ctx) {
80088009
Err(_) => {
80098010
log_error!(logger, "Signer rejected channel_announcement signing. Channel will not be announced!");
80108011
return None;
@@ -8045,7 +8046,8 @@ impl<SP: Deref> FundedChannel<SP> where
80458046
.map_err(|_| ChannelError::Ignore("Failed to generate node signature for channel_announcement".to_owned()))?;
80468047
match &self.context.holder_signer {
80478048
ChannelSignerType::Ecdsa(ecdsa) => {
8048-
let our_bitcoin_sig = ecdsa.sign_channel_announcement_with_funding_key(&announcement, &self.context.secp_ctx)
8049+
let channel_parameters = &self.funding.channel_transaction_parameters;
8050+
let our_bitcoin_sig = ecdsa.sign_channel_announcement_with_funding_key(channel_parameters, &announcement, &self.context.secp_ctx)
80498051
.map_err(|_| ChannelError::Ignore("Signer rejected channel_announcement".to_owned()))?;
80508052
Ok(msgs::ChannelAnnouncement {
80518053
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
@@ -1696,7 +1696,8 @@ impl EcdsaChannelSigner for InMemorySigner {
16961696
}
16971697

16981698
fn sign_channel_announcement_with_funding_key(
1699-
&self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
1699+
&self, _channel_parameters: &ChannelTransactionParameters,
1700+
msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
17001701
) -> Result<Signature, ()> {
17011702
let msghash = hash_to_message!(&Sha256dHash::hash(&msg.encode()[..])[..]);
17021703
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)