Skip to content

Commit da79e03

Browse files
committed
Add invoice constructor with custom payment hash
1 parent 3622a04 commit da79e03

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

lightning-invoice/src/utils.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_sin
294294
network: Currency, amt_msat: Option<u64>, description_hash: Sha256,
295295
duration_since_epoch: Duration, invoice_expiry_delta_secs: u32
296296
) -> Result<Invoice, SignOrCreationError<()>>
297-
where
298-
M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
299-
T::Target: BroadcasterInterface,
300-
K::Target: KeysInterface,
301-
F::Target: FeeEstimator,
302-
L::Target: Logger,
297+
where
298+
M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
299+
T::Target: BroadcasterInterface,
300+
K::Target: KeysInterface,
301+
F::Target: FeeEstimator,
302+
L::Target: Logger,
303303
{
304304
_create_invoice_from_channelmanager_and_duration_since_epoch(
305305
channelmanager, keys_manager, logger, network, amt_msat,
@@ -316,12 +316,12 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T:
316316
network: Currency, amt_msat: Option<u64>, description: String, duration_since_epoch: Duration,
317317
invoice_expiry_delta_secs: u32
318318
) -> Result<Invoice, SignOrCreationError<()>>
319-
where
320-
M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
321-
T::Target: BroadcasterInterface,
322-
K::Target: KeysInterface,
323-
F::Target: FeeEstimator,
324-
L::Target: Logger,
319+
where
320+
M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
321+
T::Target: BroadcasterInterface,
322+
K::Target: KeysInterface,
323+
F::Target: FeeEstimator,
324+
L::Target: Logger,
325325
{
326326
_create_invoice_from_channelmanager_and_duration_since_epoch(
327327
channelmanager, keys_manager, logger, network, amt_msat,
@@ -337,12 +337,12 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T: Der
337337
network: Currency, amt_msat: Option<u64>, description: InvoiceDescription,
338338
duration_since_epoch: Duration, invoice_expiry_delta_secs: u32
339339
) -> Result<Invoice, SignOrCreationError<()>>
340-
where
341-
M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
342-
T::Target: BroadcasterInterface,
343-
K::Target: KeysInterface,
344-
F::Target: FeeEstimator,
345-
L::Target: Logger,
340+
where
341+
M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
342+
T::Target: BroadcasterInterface,
343+
K::Target: KeysInterface,
344+
F::Target: FeeEstimator,
345+
L::Target: Logger,
346346
{
347347
// `create_inbound_payment` only returns an error if the amount is greater than the total bitcoin
348348
// supply.
@@ -354,8 +354,9 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T: Der
354354
}
355355

356356
/// See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
357-
///Function that allows to construct invoices with the given payment hash.
358-
///This may be useful if you're building an on-chain swap or integrating with another protocol where the payment hash is fixed outside of lightning.
357+
/// This version allows for providing a custom [`PaymentHash`] for the invoice.
358+
/// This may be useful if you're building an on-chain swap or involving another protocol where
359+
/// the payment hash is also involved outside the scope of lightning.
359360
pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>(
360361
channelmanager: &ChannelManager<M, T, K, F, L>, keys_manager: K, logger: L,
361362
network: Currency, amt_msat: Option<u64>, description: String, duration_since_epoch: Duration,
@@ -369,7 +370,7 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_
369370
L::Target: Logger,
370371
{
371372
let payment_secret = channelmanager
372-
.create_inbound_payment_for_hash(payment_hash,amt_msat,invoice_expiry_delta_secs)
373+
.create_inbound_payment_for_hash(payment_hash,amt_msat, invoice_expiry_delta_secs)
373374
.map_err(|()| SignOrCreationError::CreationError(CreationError::InvalidAmount))?;
374375
_create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(
375376
channelmanager, keys_manager, logger, network, amt_msat,

0 commit comments

Comments
 (0)