///
/// [`Refund`]: crate::offers::refund::Refund
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
- payment_id: PaymentId
+ payment_id: PaymentId,
+
+ /// A nonce used for authenticating that a [`Bolt12Invoice`] is for a valid [`Refund`] or
+ /// [`InvoiceRequest`] and for deriving their signing keys.
+ ///
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+ /// [`Refund`]: crate::offers::refund::Refund
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+ nonce: Nonce,
},
}
},
(2, OutboundPayment) => {
(0, payment_id, required),
+ (1, nonce, required),
},
);
let secp_ctx = &$self.secp_ctx;
let nonce = Nonce::from_entropy_source(entropy);
- let context = OffersContext::OutboundPayment { payment_id };
+ let context = OffersContext::OutboundPayment { payment_id, nonce };
let path = $self.create_blinded_paths_using_absolute_expiry(context, Some(absolute_expiry))
.and_then(|paths| paths.into_iter().next().ok_or(()))
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
};
let invoice_request = builder.build_and_sign()?;
- let context = OffersContext::OutboundPayment { payment_id };
- let reply_paths = self.create_blinded_paths(context).map_err(|_| Bolt12SemanticError::MissingPaths)?;
+ let context = OffersContext::OutboundPayment { payment_id, nonce };
+ let reply_paths = self.create_blinded_paths(context)
+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
let abandon_if_payment = |context| {
match context {
- OffersContext::OutboundPayment { payment_id } => self.abandon_payment(payment_id),
+ OffersContext::OutboundPayment { payment_id, .. } => self.abandon_payment(payment_id),
_ => {},
}
};
OffersMessage::Invoice(invoice) => {
let expected_payment_id = match context {
OffersContext::Unknown {} if invoice.is_for_refund_without_paths() => None,
- OffersContext::OutboundPayment { payment_id } => Some(payment_id),
+ OffersContext::OutboundPayment { payment_id, .. } => Some(payment_id),
_ => return ResponseInstruction::NoResponse,
};