Skip to content

Commit abf35d3

Browse files
valentinewallacevincenzopalazzo
authored andcommitted
Un-cfg-gate StaticInvoices
We need to include static invoices in the public API as part of the onion messages we're adding for static invoice server support. Utilities to create these static invoices and other parts of the async receive API will remain cfg-gated for now. Generally, we can't totally avoid exposing half baked async receive support in the public API because OnionMessenger is parameterized by an async payments message handler, which can't be cfg-gated easily. This contains the changes to the public API, to the original commit made by Val, to fix the following clippy warning: ``` error: methods called `from_*` usually take no `self` --> lightning/src/offers/static_invoice.rs:393:32 | 393 | pub(crate) fn from_same_offer(&self, invreq: &InvoiceRequest) -> bool { | ^^^^^ | = help: consider choosing a less ambiguous name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention = note: `-D clippy::wrong-self-convention` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: could not compile `lightning` (lib) due to 1 previous error ``` ``` error[E0599]: no method named `bytes` found for reference `&InvoiceRequest` in the current scope --> lightning/src/offers/static_invoice.rs:387:34 | 387 | Offer::tlv_stream_iter(invreq.bytes()).map(|tlv_record| tlv_record.record_bytes); | ^^^^^-- help: remove the arguments | | | field, not a method | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `bytes`, perhaps you need to implement it: candidate #1: `std::io::Read` warning: variable does not need to be mutable --> lightning/src/offers/offer.rs:261:4 | 261 | mut $self: $self_type, metadata: Vec<u8>, | ----^^^^^ | | | help: remove this `mut` ... 534 | offer_explicit_metadata_builder_methods!(self, &mut Self, (), ()); | ----------------------------------------------------------------- in this macro invocation | = note: `#[warn(unused_mut)]` on by default = note: this warning originates in the macro `offer_explicit_metadata_builder_methods` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0599`. ``` Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent c355ea4 commit abf35d3

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

lightning/src/offers/invoice_request.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ impl InvoiceRequest {
858858
);
859859
invoice_request_verify_method!(self, Self);
860860

861-
#[cfg(async_payments)]
861+
#[allow(unused)] // TODO: remove this once we remove the `async_payments` cfg flag
862862
pub(super) fn bytes(&self) -> &Vec<u8> {
863863
&self.bytes
864864
}
@@ -874,6 +874,11 @@ impl InvoiceRequest {
874874
InvoiceWithExplicitSigningPubkeyBuilder
875875
);
876876
invoice_request_verify_method!(self, &Self);
877+
878+
#[allow(unused)] // TODO: remove this once we remove the `async_payments` cfg flag
879+
pub(super) fn bytes(&self) -> &Vec<u8> {
880+
&self.bytes
881+
}
877882
}
878883

879884
impl InvoiceRequest {

lightning/src/offers/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub mod parse;
2525
mod payer;
2626
pub mod refund;
2727
pub(crate) mod signer;
28-
#[cfg(async_payments)]
2928
pub mod static_invoice;
3029
#[cfg(test)]
3130
pub(crate) mod test_utils;

lightning/src/offers/offer.rs

-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,6 @@ impl Offer {
743743
.chain(TlvStream::new(bytes).range(EXPERIMENTAL_OFFER_TYPES))
744744
}
745745

746-
#[cfg(async_payments)]
747746
pub(super) fn verify<T: secp256k1::Signing>(
748747
&self, nonce: Nonce, key: &ExpandedKey, secp_ctx: &Secp256k1<T>,
749748
) -> Result<(OfferId, Option<Keypair>), ()> {

lightning/src/offers/static_invoice.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ impl StaticInvoice {
379379
self.signature
380380
}
381381

382-
pub(crate) fn from_same_offer(&self, invreq: &InvoiceRequest) -> bool {
382+
#[allow(unused)] // TODO: remove this once we remove the `async_payments` cfg flag
383+
pub(crate) fn build_from_same_offer(&self, invreq: &InvoiceRequest) -> bool {
383384
let invoice_offer_tlv_stream =
384385
Offer::tlv_stream_iter(&self.bytes).map(|tlv_record| tlv_record.record_bytes);
385386
let invreq_offer_tlv_stream =

0 commit comments

Comments
 (0)