mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 23:08:36 +01:00
Add InvoiceBuilder::features_unchecked
In order to test handling of unknown required features in a Bolt12Invoice, add a test-only function to allow setting arbitrary feature bits.
This commit is contained in:
parent
05db67b5c3
commit
19dec4b36f
2 changed files with 24 additions and 0 deletions
|
@ -117,6 +117,8 @@ use crate::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures, InvoiceRequ
|
|||
use crate::ln::inbound_payment::{ExpandedKey, IV_LEN};
|
||||
use crate::ln::msgs::DecodeError;
|
||||
use crate::offers::invoice_macros::{invoice_accessors_common, invoice_builder_methods_common};
|
||||
#[cfg(test)]
|
||||
use crate::offers::invoice_macros::invoice_builder_methods_test;
|
||||
use crate::offers::invoice_request::{INVOICE_REQUEST_PAYER_ID_TYPE, INVOICE_REQUEST_TYPES, IV_BYTES as INVOICE_REQUEST_IV_BYTES, InvoiceRequest, InvoiceRequestContents, InvoiceRequestTlvStream, InvoiceRequestTlvStreamRef};
|
||||
use crate::offers::merkle::{SignError, SignFn, SignatureTlvStream, SignatureTlvStreamRef, TaggedHash, TlvStream, WithoutSignatures, self};
|
||||
use crate::offers::nonce::Nonce;
|
||||
|
@ -385,6 +387,9 @@ impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
|
|||
impl<'a, S: SigningPubkeyStrategy> InvoiceBuilder<'a, S> {
|
||||
invoice_builder_methods!(self, Self, Self, self, S, mut);
|
||||
invoice_builder_methods_common!(self, Self, self.invoice.fields_mut(), Self, self, S, Bolt12Invoice, mut);
|
||||
|
||||
#[cfg(test)]
|
||||
invoice_builder_methods_test!(self, Self, self.invoice.fields_mut(), Self, self, mut);
|
||||
}
|
||||
|
||||
#[cfg(all(c_bindings, not(test)))]
|
||||
|
@ -399,6 +404,7 @@ impl<'a> InvoiceWithExplicitSigningPubkeyBuilder<'a> {
|
|||
invoice_explicit_signing_pubkey_builder_methods!(self, &mut Self);
|
||||
invoice_builder_methods!(self, &mut Self, &mut Self, self, ExplicitSigningPubkey);
|
||||
invoice_builder_methods_common!(self, &mut Self, self.invoice.fields_mut(), &mut Self, self, ExplicitSigningPubkey, Bolt12Invoice);
|
||||
invoice_builder_methods_test!(self, &mut Self, self.invoice.fields_mut(), &mut Self, self);
|
||||
}
|
||||
|
||||
#[cfg(all(c_bindings, not(test)))]
|
||||
|
@ -413,6 +419,7 @@ impl<'a> InvoiceWithDerivedSigningPubkeyBuilder<'a> {
|
|||
invoice_derived_signing_pubkey_builder_methods!(self, &mut Self);
|
||||
invoice_builder_methods!(self, &mut Self, &mut Self, self, DerivedSigningPubkey);
|
||||
invoice_builder_methods_common!(self, &mut Self, self.invoice.fields_mut(), &mut Self, self, DerivedSigningPubkey, Bolt12Invoice);
|
||||
invoice_builder_methods_test!(self, &mut Self, self.invoice.fields_mut(), &mut Self, self);
|
||||
}
|
||||
|
||||
#[cfg(c_bindings)]
|
||||
|
|
|
@ -82,6 +82,21 @@ macro_rules! invoice_builder_methods_common { (
|
|||
}
|
||||
} }
|
||||
|
||||
#[cfg(test)]
|
||||
macro_rules! invoice_builder_methods_test { (
|
||||
$self: ident, $self_type: ty, $invoice_fields: expr, $return_type: ty, $return_value: expr
|
||||
$(, $self_mut: tt)?
|
||||
) => {
|
||||
#[cfg_attr(c_bindings, allow(dead_code))]
|
||||
pub(crate) fn features_unchecked(
|
||||
$($self_mut)* $self: $self_type, features: Bolt12InvoiceFeatures
|
||||
) -> $return_type {
|
||||
$invoice_fields.features = features;
|
||||
$return_value
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
macro_rules! invoice_accessors_common { ($self: ident, $contents: expr, $invoice_type: ty) => {
|
||||
/// Paths to the recipient originating from publicly reachable nodes, including information
|
||||
/// needed for routing payments across them.
|
||||
|
@ -133,3 +148,5 @@ macro_rules! invoice_accessors_common { ($self: ident, $contents: expr, $invoice
|
|||
|
||||
pub(super) use invoice_accessors_common;
|
||||
pub(super) use invoice_builder_methods_common;
|
||||
#[cfg(test)]
|
||||
pub(super) use invoice_builder_methods_test;
|
||||
|
|
Loading…
Add table
Reference in a new issue