Skip to content

Commit 973de6f

Browse files
committed
Limit the scope of get_funding_created_msg to outbound channels
Since we no longer use `ChannelContext::get_funding_created_msg`, it can be moved back into `UnfundedOutboundV1` channels only, where it realistically belongs.
1 parent c8124e4 commit 973de6f

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

lightning/src/ln/channel.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,38 +2176,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21762176
}
21772177
}
21782178

2179-
/// Only allowed after [`Self::channel_transaction_parameters`] is set.
2180-
fn get_funding_created_msg<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
2181-
let counterparty_keys = self.build_remote_transaction_keys();
2182-
let counterparty_initial_commitment_tx = self.build_commitment_transaction(self.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
2183-
let signature = match &self.holder_signer {
2184-
// TODO (taproot|arik): move match into calling method for Taproot
2185-
ChannelSignerType::Ecdsa(ecdsa) => {
2186-
ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx)
2187-
.map(|(sig, _)| sig).ok()?
2188-
},
2189-
// TODO (taproot|arik)
2190-
#[cfg(taproot)]
2191-
_ => todo!()
2192-
};
2193-
2194-
if self.signer_pending_funding {
2195-
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
2196-
self.signer_pending_funding = false;
2197-
}
2198-
2199-
Some(msgs::FundingCreated {
2200-
temporary_channel_id: self.temporary_channel_id.unwrap(),
2201-
funding_txid: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
2202-
funding_output_index: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
2203-
signature,
2204-
#[cfg(taproot)]
2205-
partial_signature_with_nonce: None,
2206-
#[cfg(taproot)]
2207-
next_local_nonce: None,
2208-
})
2209-
}
2210-
22112179
/// Only allowed after [`Self::channel_transaction_parameters`] is set.
22122180
fn get_funding_signed_msg<L: Deref>(&mut self, logger: &L) -> (CommitmentTransaction, Option<msgs::FundingSigned>) where L::Target: Logger {
22132181
let counterparty_keys = self.build_remote_transaction_keys();
@@ -6104,6 +6072,38 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
61046072
})
61056073
}
61066074

6075+
/// Only allowed after [`ChannelContext::channel_transaction_parameters`] is set.
6076+
fn get_funding_created_msg<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
6077+
let counterparty_keys = self.context.build_remote_transaction_keys();
6078+
let counterparty_initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
6079+
let signature = match &self.context.holder_signer {
6080+
// TODO (taproot|arik): move match into calling method for Taproot
6081+
ChannelSignerType::Ecdsa(ecdsa) => {
6082+
ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.context.secp_ctx)
6083+
.map(|(sig, _)| sig).ok()?
6084+
},
6085+
// TODO (taproot|arik)
6086+
#[cfg(taproot)]
6087+
_ => todo!()
6088+
};
6089+
6090+
if self.context.signer_pending_funding {
6091+
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
6092+
self.context.signer_pending_funding = false;
6093+
}
6094+
6095+
Some(msgs::FundingCreated {
6096+
temporary_channel_id: self.context.temporary_channel_id.unwrap(),
6097+
funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
6098+
funding_output_index: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
6099+
signature,
6100+
#[cfg(taproot)]
6101+
partial_signature_with_nonce: None,
6102+
#[cfg(taproot)]
6103+
next_local_nonce: None,
6104+
})
6105+
}
6106+
61076107
/// Updates channel state with knowledge of the funding transaction's txid/index, and generates
61086108
/// a funding_created message for the remote peer.
61096109
/// Panics if called at some time other than immediately after initial handshake, if called twice,
@@ -6144,7 +6144,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
61446144
self.context.funding_transaction = Some(funding_transaction);
61456145
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
61466146

6147-
let funding_created = self.context.get_funding_created_msg(logger);
6147+
let funding_created = self.get_funding_created_msg(logger);
61486148
if funding_created.is_none() {
61496149
if !self.context.signer_pending_funding {
61506150
log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
@@ -6490,7 +6490,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
64906490
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
64916491
if self.context.signer_pending_funding && self.context.is_outbound() {
64926492
log_trace!(logger, "Signer unblocked a funding_created");
6493-
self.context.get_funding_created_msg(logger)
6493+
self.get_funding_created_msg(logger)
64946494
} else { None }
64956495
}
64966496
}

0 commit comments

Comments
 (0)