Merge pull request #2753 from TheBlueMatt/2023-11-inbound-preimages
authorWilmer Paulino <9447167+wpaulino@users.noreply.github.com>
Mon, 4 Dec 2023 21:15:10 +0000 (13:15 -0800)
committerGitHub <noreply@github.com>
Mon, 4 Dec 2023 21:15:10 +0000 (13:15 -0800)
Provide inbound HTLC preimages to the `EcdsaChannelSigner`

1  2 
lightning/src/ln/channel.rs
lightning/src/ln/functional_tests.rs
lightning/src/sign/ecdsa.rs
lightning/src/sign/mod.rs
lightning/src/sign/taproot.rs
lightning/src/util/test_channel_signer.rs

Simple merge
Simple merge
index 194d714c977855e6058165ef4b1d4839f54ee2a2,52855050b3d9408b0c694467ef48bd0c95c1def8..2e98213c1825f2c0af8802bcc0838c2dc4d7af55
@@@ -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<PaymentPreimage>, secp_ctx: &Secp256k1<secp256k1::All>
+               inbound_htlc_preimages: Vec<PaymentPreimage>,
+               outbound_htlc_preimages: Vec<PaymentPreimage>, secp_ctx: &Secp256k1<secp256k1::All>,
        ) -> Result<(Signature, Vec<Signature>), ()>;
 -      /// 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
index 5a80cb2318adb22c3e297a9c27238c8041eaf72a,2e7e39cc9cb9ccc82db63fd1f6e1af991681b758..4e418f049bbc9867a7a2a7920706e17c135ed23e
@@@ -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<PaymentPreimage>) -> Result<(), ()>;
+               outbound_htlc_preimages: Vec<PaymentPreimage>) -> 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;
  
Simple merge
index 51edce1768c7283aac89b865e09dc12e0a7395f6,3fcbb50d450dd134fad8a7d0aaaab738fd22b962..a2cbf78b70053d2467cbe41fafe041eb30fa68e4
@@@ -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<secp256k1::All>) -> Result<Signature, ()> {
                if !*self.available.lock().unwrap() {
                        return Err(());