fedimint_gateway_server/
types.rs

1//! Map `gateway_lnrpc` protobuf types to rust types
2
3use std::fmt::Display;
4
5use fedimint_lightning::InterceptPaymentRequest;
6use hex::ToHex;
7
8/// Utility struct for formatting an intercepted HTLC. Useful for debugging.
9pub struct PrettyInterceptPaymentRequest<'a>(pub &'a InterceptPaymentRequest);
10
11impl Display for PrettyInterceptPaymentRequest<'_> {
12    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13        let PrettyInterceptPaymentRequest(payment_request) = self;
14        write!(
15            f,
16            "InterceptPaymentRequest {{ payment_hash: {}, amount_msat: {:?}, expiry: {:?}, short_channel_id: {:?}, incoming_chan_id: {:?}, htlc_id: {:?} }}",
17            payment_request.payment_hash.encode_hex::<String>(),
18            payment_request.amount_msat,
19            payment_request.expiry,
20            payment_request.short_channel_id,
21            payment_request.incoming_chan_id,
22            payment_request.htlc_id,
23        )
24    }
25}