Skip to content

Commit 70788e0

Browse files
committed
Add ChannelSigner::provide_funding_outpoint
1 parent e6e4acf commit 70788e0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lightning/src/sign/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,9 @@ pub trait ChannelSigner {
811811
/// Provide counterparty parameters
812812
fn provide_counterparty_parameters(&mut self, counterparty_keys: &ChannelTransactionParameters);
813813

814+
/// Provide funding outpoint
815+
fn provide_funding_outpoint(&mut self, channel_parameters: &ChannelTransactionParameters);
816+
814817
/// Returns the parameters of this signer
815818
fn get_channel_parameters(&self) -> Option<&ChannelTransactionParameters>;
816819

@@ -1985,6 +1988,19 @@ impl ChannelSigner for InMemorySigner {
19851988
self.channel_parameters = Some(channel_parameters.clone());
19861989
}
19871990

1991+
fn provide_funding_outpoint(&mut self, channel_parameters: &ChannelTransactionParameters) {
1992+
assert!(channel_parameters.is_populated());
1993+
assert!(self.channel_parameters.as_ref().unwrap().counterparty_parameters.is_some());
1994+
if self.channel_parameters.as_ref().unwrap().funding_outpoint.is_some() {
1995+
assert_eq!(self.channel_parameters.as_ref().unwrap(), channel_parameters);
1996+
} else {
1997+
self.channel_parameters.as_mut().unwrap().funding_outpoint =
1998+
channel_parameters.funding_outpoint;
1999+
// Check that no other fields changed
2000+
assert_eq!(self.channel_parameters.as_ref(), Some(channel_parameters));
2001+
}
2002+
}
2003+
19882004
fn get_channel_parameters(&self) -> Option<&ChannelTransactionParameters> {
19892005
self.channel_parameters.as_ref()
19902006
}

lightning/src/util/test_channel_signer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ impl ChannelSigner for TestChannelSigner {
226226
self.inner.get_channel_parameters()
227227
}
228228

229+
fn provide_funding_outpoint(&mut self, channel_parameters: &ChannelTransactionParameters) {
230+
self.inner.provide_funding_outpoint(channel_parameters);
231+
}
232+
229233
fn punish_revokeable_output(
230234
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
231235
secp_ctx: &Secp256k1<secp256k1::All>, per_commitment_point: &PublicKey,

0 commit comments

Comments
 (0)