|
13 | 13 | use bitcoin::constants::ChainHash;
|
14 | 14 | use bitcoin::secp256k1::{Secp256k1, PublicKey};
|
15 | 15 | use bitcoin::{secp256k1, Network};
|
| 16 | +use types::payment::PaymentHash; |
| 17 | +use crate::blinded_path::message::{BlindedMessagePath, MessageContext, MessageForwardNode, OffersContext}; |
| 18 | +use crate::blinded_path::payment::BlindedPaymentPath; |
| 19 | +use crate::ln::channelmanager::PaymentId; |
16 | 20 | use crate::ln::inbound_payment;
|
| 21 | +use crate::onion_message::dns_resolution::{DNSSECQuery, HumanReadableName}; |
17 | 22 | use crate::sign::EntropySource;
|
18 |
| -use crate::onion_message::messenger::{MessageRouter, MessageSendInstructions}; |
| 23 | +use crate::offers::invoice::{Bolt12Invoice, DerivedSigningPubkey, InvoiceBuilder}; |
| 24 | +use crate::offers::invoice_request::{InvoiceRequest, InvoiceRequestBuilder}; |
| 25 | +use crate::offers::nonce::Nonce; |
| 26 | +use crate::offers::offer::{DerivedMetadata, Offer, OfferBuilder}; |
| 27 | +use crate::offers::parse::Bolt12SemanticError; |
| 28 | +use crate::offers::refund::{Refund, RefundBuilder}; |
| 29 | +use crate::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions}; |
19 | 30 | use crate::onion_message::offers::OffersMessage;
|
20 | 31 | use crate::onion_message::async_payments::AsyncPaymentsMessage;
|
21 | 32 | use crate::sync::Mutex;
|
22 | 33 |
|
23 | 34 | use core::ops::Deref;
|
24 | 35 | use core::sync::atomic::AtomicUsize;
|
| 36 | +use core::time::Duration; |
25 | 37 |
|
26 | 38 | #[cfg(feature = "dnssec")]
|
27 | 39 | use crate::onion_message::dns_resolution::DNSResolverMessage;
|
28 | 40 |
|
| 41 | +pub trait Flow { |
| 42 | + fn create_offer_builder(&self, nonce: Nonce) -> Result<OfferBuilder<DerivedMetadata, secp256k1::All>, Bolt12SemanticError>; |
| 43 | + |
| 44 | + fn create_refund_builder(&self, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId, nonce: Nonce) -> Result<RefundBuilder<secp256k1::All>, Bolt12SemanticError>; |
| 45 | + |
| 46 | + fn create_invoice_request_builder<'a>( |
| 47 | + &'a self, offer: &'a Offer, nonce: Nonce, quantity: Option<u64>, amount_msats: Option<u64>, |
| 48 | + payer_note: Option<String>, human_readable_name: Option<HumanReadableName>, payment_id: PaymentId |
| 49 | + ) -> Result<InvoiceRequestBuilder<'a, 'a, secp256k1::All>, Bolt12SemanticError>; |
| 50 | + |
| 51 | + fn create_invoice_builder<'a>( |
| 52 | + &'a self, refund: &'a Refund, payment_paths: Vec<BlindedPaymentPath>, payment_hash: PaymentHash |
| 53 | + ) -> Result<InvoiceBuilder<'a, DerivedSigningPubkey>, Bolt12SemanticError>; |
| 54 | + |
| 55 | + fn create_blinded_paths(&self, peers: Vec<MessageForwardNode>, context: MessageContext) -> Result<Vec<BlindedMessagePath>, ()>; |
| 56 | + |
| 57 | + fn create_compact_blinded_paths(&self, peers: Vec<MessageForwardNode>, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()>; |
| 58 | + |
| 59 | + fn create_blinded_paths_using_absolute_expiry(&self, peers: Vec<MessageForwardNode>, context: OffersContext, absolute_expiry: Option<Duration>) -> Result<Vec<BlindedMessagePath>, ()>; |
| 60 | + |
| 61 | + fn enqueue_invoice_request( |
| 62 | + &self, invoice_request: InvoiceRequest, reply_paths: Vec<BlindedMessagePath>, |
| 63 | + ) -> Result<(), Bolt12SemanticError>; |
| 64 | + |
| 65 | + fn enqueue_invoice( |
| 66 | + &self, invoice: Bolt12Invoice, refund: &Refund, reply_paths: Vec<BlindedMessagePath> |
| 67 | + ) -> Result<(), Bolt12SemanticError>; |
| 68 | + |
| 69 | + #[cfg(feature = "dnssec")] |
| 70 | + fn enqueue_dns_onion_message( |
| 71 | + &self, message: DNSSECQuery, dns_resolvers: Vec<Destination>, reply_paths: Vec<BlindedMessagePath> |
| 72 | + ) -> Result<(), Bolt12SemanticError>; |
| 73 | + |
| 74 | + fn get_and_clear_pending_offers_messages(&self) -> Vec<(OffersMessage, MessageSendInstructions)>; |
| 75 | + |
| 76 | + fn get_and_clear_pending_async_messages(&self) -> Vec<(AsyncPaymentsMessage, MessageSendInstructions)>; |
| 77 | + |
| 78 | + #[cfg(feature = "dnssec")] |
| 79 | + fn get_and_clear_pending_dns_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)>; |
| 80 | +} |
| 81 | + |
29 | 82 | pub struct OffersMessageFlow<ES: Deref, MR: Deref>
|
30 | 83 | where
|
31 | 84 | ES::Target: EntropySource,
|
|
0 commit comments