]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #1910 from arik-so/2022-12-keys-interface-name-split
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Tue, 20 Dec 2022 22:19:43 +0000 (22:19 +0000)
committerGitHub <noreply@github.com>
Tue, 20 Dec 2022 22:19:43 +0000 (22:19 +0000)
Split KeysInterface into EntropySource, NodeSigner, and SignerProvider

1  2 
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/payment_tests.rs

index 2c7a383c52b041ecdc42ba8b530a411c884bdd65,2bc3eac4367cc568b1486f148e00f49cd57dc35a..026f5a32bca41c6cc5759de7af60dec8b431f15a
@@@ -51,11 -51,8 +51,11 @@@ use crate::ln::msgs
  use crate::ln::onion_utils;
  use crate::ln::onion_utils::HTLCFailReason;
  use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSAT};
 +#[cfg(test)]
 +use crate::ln::outbound_payment;
 +use crate::ln::outbound_payment::{OutboundPayments, PendingOutboundPayment};
  use crate::ln::wire::Encode;
- use crate::chain::keysinterface::{Sign, KeysInterface, KeysManager, Recipient};
+ use crate::chain::keysinterface::{EntropySource, KeysInterface, KeysManager, NodeSigner, Recipient, Sign, SignerProvider};
  use crate::util::config::{UserConfig, ChannelConfig};
  use crate::util::events::{Event, EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
  use crate::util::events;
@@@ -3761,11 -4303,30 +3761,11 @@@ impl<M: Deref, T: Deref, K: Deref, F: D
                }
        }
  
 -      fn finalize_claims(&self, mut sources: Vec<HTLCSource>) {
 -              let mut outbounds = self.pending_outbound_payments.lock().unwrap();
 -              let mut pending_events = self.pending_events.lock().unwrap();
 -              for source in sources.drain(..) {
 -                      if let HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } = source {
 -                              let mut session_priv_bytes = [0; 32];
 -                              session_priv_bytes.copy_from_slice(&session_priv[..]);
 -                              if let hash_map::Entry::Occupied(mut payment) = outbounds.entry(payment_id) {
 -                                      assert!(payment.get().is_fulfilled());
 -                                      if payment.get_mut().remove(&session_priv_bytes, None) {
 -                                              pending_events.push(
 -                                                      events::Event::PaymentPathSuccessful {
 -                                                              payment_id,
 -                                                              payment_hash: payment.get().payment_hash(),
 -                                                              path,
 -                                                      }
 -                                              );
 -                                      }
 -                              }
 -                      }
 -              }
 +      fn finalize_claims(&self, sources: Vec<HTLCSource>) {
 +              self.pending_outbound_payments.finalize_claims(sources, &self.pending_events);
        }
  
-       fn claim_funds_internal(&self, channel_state_lock: MutexGuard<ChannelHolder<<K::Target as KeysInterface>::Signer>>, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option<u64>, from_onchain: bool, next_channel_id: [u8; 32]) {
+       fn claim_funds_internal(&self, channel_state_lock: MutexGuard<ChannelHolder<<K::Target as SignerProvider>::Signer>>, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option<u64>, from_onchain: bool, next_channel_id: [u8; 32]) {
                match source {
                        HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
                                mem::drop(channel_state_lock);
@@@ -6350,8 -6950,32 +6350,8 @@@ impl_writeable_tlv_based!(PendingInboun
        (8, min_value_msat, required),
  });
  
 -impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
 -      (0, Legacy) => {
 -              (0, session_privs, required),
 -      },
 -      (1, Fulfilled) => {
 -              (0, session_privs, required),
 -              (1, payment_hash, option),
 -              (3, timer_ticks_without_htlcs, (default_value, 0)),
 -      },
 -      (2, Retryable) => {
 -              (0, session_privs, required),
 -              (1, pending_fee_msat, option),
 -              (2, payment_hash, required),
 -              (4, payment_secret, option),
 -              (6, total_msat, required),
 -              (8, pending_amt_msat, required),
 -              (10, starting_block_height, required),
 -      },
 -      (3, Abandoned) => {
 -              (0, session_privs, required),
 -              (2, payment_hash, required),
 -      },
 -);
 -
  impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> Writeable for ChannelManager<M, T, K, F, L>
-       where M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
+       where M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
          T::Target: BroadcasterInterface,
          K::Target: KeysInterface,
          F::Target: FeeEstimator,
Simple merge
Simple merge