Remove HTLCDirection struct
authorValentine Wallace <vwallace@protonmail.com>
Wed, 14 Apr 2021 15:31:11 +0000 (11:31 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Mon, 3 May 2021 22:31:02 +0000 (18:31 -0400)
We're going to split payment storage into two maps, one for
inbound and one for outbound.

src/cli.rs
src/main.rs

index e2f4a6379235c0d6da53a0a5d7464993983189b1..2dc6b7df614731296ab9e479a9b697d2f4c086a7 100644 (file)
@@ -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)),
                },
index 87ad4e9a718997f48c58af19aa32688c1944791d..32981a4ac23845322d5a301c1edf62a7090daf4c 100644 (file)
@@ -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<PaymentPreimage>,
        secret: Option<PaymentSecret>,
-       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),
                                                        },