From: Wilmer Paulino <9447167+wpaulino@users.noreply.github.com> Date: Mon, 4 Dec 2023 21:15:10 +0000 (-0800) Subject: Merge pull request #2753 from TheBlueMatt/2023-11-inbound-preimages X-Git-Tag: v0.0.119~30 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=12c2086d58b54e7d2b1356a3a45d3a605dcd2972;p=rust-lightning Merge pull request #2753 from TheBlueMatt/2023-11-inbound-preimages Provide inbound HTLC preimages to the `EcdsaChannelSigner` --- 12c2086d58b54e7d2b1356a3a45d3a605dcd2972 diff --cc lightning/src/sign/ecdsa.rs index 194d714c9,52855050b..2e98213c1 --- a/lightning/src/sign/ecdsa.rs +++ b/lightning/src/sign/ecdsa.rs @@@ -38,8 -39,14 +39,9 @@@ pub trait EcdsaChannelSigner: ChannelSi // // TODO: Document the things someone using this interface should enforce before signing. fn sign_counterparty_commitment(&self, commitment_tx: &CommitmentTransaction, - preimages: Vec, secp_ctx: &Secp256k1 + inbound_htlc_preimages: Vec, + outbound_htlc_preimages: Vec, secp_ctx: &Secp256k1, ) -> Result<(Signature, Vec), ()>; - /// Validate the counterparty's revocation. - /// - /// This is required in order for the signer to make sure that the state has moved - /// forward and it is safe to sign the next counterparty commitment. - fn validate_counterparty_revocation(&self, idx: u64, secret: &SecretKey) -> Result<(), ()>; /// Creates a signature for a holder's commitment transaction. /// /// This will be called diff --cc lightning/src/sign/mod.rs index 5a80cb231,2e7e39cc9..4e418f049 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@@ -601,14 -601,8 +601,14 @@@ pub trait ChannelSigner /// Note that all the relevant preimages will be provided, but there may also be additional /// irrelevant or duplicate preimages. fn validate_holder_commitment(&self, holder_tx: &HolderCommitmentTransaction, - preimages: Vec) -> Result<(), ()>; + outbound_htlc_preimages: Vec) -> Result<(), ()>; + /// Validate the counterparty's revocation. + /// + /// This is required in order for the signer to make sure that the state has moved + /// forward and it is safe to sign the next counterparty commitment. + fn validate_counterparty_revocation(&self, idx: u64, secret: &SecretKey) -> Result<(), ()>; + /// Returns the holder's channel public keys and basepoints. fn pubkeys(&self) -> &ChannelPublicKeys; diff --cc lightning/src/util/test_channel_signer.rs index 51edce176,3fcbb50d4..a2cbf78b7 --- a/lightning/src/util/test_channel_signer.rs +++ b/lightning/src/util/test_channel_signer.rs @@@ -185,9 -175,19 +185,9 @@@ impl EcdsaChannelSigner for TestChannel state.last_counterparty_commitment = cmp::min(last_commitment_number, actual_commitment_number) } - Ok(self.inner.sign_counterparty_commitment(commitment_tx, preimages, secp_ctx).unwrap()) + Ok(self.inner.sign_counterparty_commitment(commitment_tx, inbound_htlc_preimages, outbound_htlc_preimages, secp_ctx).unwrap()) } - fn validate_counterparty_revocation(&self, idx: u64, _secret: &SecretKey) -> Result<(), ()> { - if !*self.available.lock().unwrap() { - return Err(()); - } - let mut state = self.state.lock().unwrap(); - assert!(idx == state.last_counterparty_revoked_commitment || idx == state.last_counterparty_revoked_commitment - 1, "expecting to validate the current or next counterparty revocation - trying {}, current {}", idx, state.last_counterparty_revoked_commitment); - state.last_counterparty_revoked_commitment = idx; - Ok(()) - } - fn sign_holder_commitment(&self, commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1) -> Result { if !*self.available.lock().unwrap() { return Err(());