From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Tue, 20 Dec 2022 22:19:43 +0000 (+0000) Subject: Merge pull request #1910 from arik-so/2022-12-keys-interface-name-split X-Git-Tag: v0.0.114-beta~80 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f7211fbf7907508a9ff2744ed56e60ed736e931d;p=rust-lightning Merge pull request #1910 from arik-so/2022-12-keys-interface-name-split Split KeysInterface into EntropySource, NodeSigner, and SignerProvider --- f7211fbf7907508a9ff2744ed56e60ed736e931d diff --cc lightning/src/ln/channelmanager.rs index 2c7a383c5,2bc3eac43..026f5a32b --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@@ -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) { - 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) { + self.pending_outbound_payments.finalize_claims(sources, &self.pending_events); } - fn claim_funds_internal(&self, channel_state_lock: MutexGuard::Signer>>, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option, from_onchain: bool, next_channel_id: [u8; 32]) { + fn claim_funds_internal(&self, channel_state_lock: MutexGuard::Signer>>, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option, 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 Writeable for ChannelManager - where M::Target: chain::Watch<::Signer>, + where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator,