From: Valentine Wallace Date: Wed, 14 Apr 2021 15:31:11 +0000 (-0400) Subject: Remove HTLCDirection struct X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=9157f86d3f75c4b122c319e2639455b90f7fd1f9;p=ldk-sample Remove HTLCDirection struct We're going to split payment storage into two maps, one for inbound and one for outbound. --- diff --git a/src/cli.rs b/src/cli.rs index e2f4a63..2dc6b7d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,7 +1,7 @@ use crate::disk; use crate::hex_utils; use crate::{ - ChannelManager, FilesystemLogger, HTLCDirection, HTLCStatus, MillisatAmount, PaymentInfo, + ChannelManager, FilesystemLogger, HTLCStatus, MillisatAmount, PaymentInfo, PaymentInfoStorage, PeerManager, }; use bitcoin::hashes::sha256::Hash as Sha256Hash; @@ -423,15 +423,11 @@ fn list_payments(payment_storage: PaymentInfoStorage) { let payments = payment_storage.lock().unwrap(); print!("["); for (payment_hash, payment_info) in payments.deref() { - let direction_str = match payment_info.direction { - HTLCDirection::Inbound => "inbound", - HTLCDirection::Outbound => "outbound", - }; println!(""); println!("\t{{"); println!("\t\tamount_millisatoshis: {},", payment_info.amt_msat); println!("\t\tpayment_hash: {},", hex_utils::hex_str(&payment_hash.0)); - println!("\t\thtlc_direction: {},", direction_str); + // println!("\t\thtlc_direction: {},", direction_str); println!( "\t\thtlc_status: {},", match payment_info.status { @@ -561,7 +557,6 @@ fn send_payment( PaymentInfo { preimage: None, secret: payment_secret, - direction: HTLCDirection::Outbound, status, amt_msat: MillisatAmount(Some(amt_msat)), }, @@ -634,7 +629,6 @@ fn get_invoice( // Otherwise lnd errors with "destination hop doesn't understand payment addresses" // (for context, lnd calls payment secrets "payment addresses"). secret: None, - direction: HTLCDirection::Inbound, status: HTLCStatus::Pending, amt_msat: MillisatAmount(Some(amt_msat)), }, diff --git a/src/main.rs b/src/main.rs index 87ad4e9..32981a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,12 +51,6 @@ use std::sync::{Arc, Mutex}; use std::time::{Duration, SystemTime}; use tokio::sync::mpsc; -#[derive(PartialEq)] -pub(crate) enum HTLCDirection { - Inbound, - Outbound, -} - pub(crate) enum HTLCStatus { Pending, Succeeded, @@ -77,7 +71,6 @@ impl fmt::Display for MillisatAmount { pub(crate) struct PaymentInfo { preimage: Option, secret: Option, - direction: HTLCDirection, status: HTLCStatus, amt_msat: MillisatAmount, } @@ -182,7 +175,6 @@ async fn handle_ldk_events( PaymentInfo { preimage: None, secret: None, - direction: HTLCDirection::Inbound, status: HTLCStatus::Failed, amt_msat: MillisatAmount(None), },