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;
}
}
- 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);
(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,