Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client-side of static invoice server #3618

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion lightning/src/offers/invoice_request.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a FYI that you will find probably later with the CI

while working on #3593 I found that we need to add this bytes() methd also down there in the c_binding part of the code. Or we should put some other code under the c_bindings flags

Pasting the error for reference

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`.

Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ impl InvoiceRequest {
);
invoice_request_verify_method!(self, Self);

#[cfg(async_payments)]
#[allow(unused)] // TODO: remove this once we remove the `async_payments` cfg flag
pub(super) fn bytes(&self) -> &Vec<u8> {
&self.bytes
}
Expand Down
1 change: 0 additions & 1 deletion lightning/src/offers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub mod parse;
mod payer;
pub mod refund;
pub(crate) mod signer;
#[cfg(async_payments)]
pub mod static_invoice;
#[cfg(test)]
pub(crate) mod test_utils;
1 change: 0 additions & 1 deletion lightning/src/offers/offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ impl Offer {
.chain(TlvStream::new(bytes).range(EXPERIMENTAL_OFFER_TYPES))
}

#[cfg(async_payments)]
pub(super) fn verify<T: secp256k1::Signing>(
&self, nonce: Nonce, key: &ExpandedKey, secp_ctx: &Secp256k1<T>,
) -> Result<(OfferId, Option<Keypair>), ()> {
Expand Down
1 change: 1 addition & 0 deletions lightning/src/offers/static_invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ impl StaticInvoice {
self.signature
}

#[allow(unused)] // TODO: remove this once we remove the `async_payments` cfg flag
pub(crate) fn from_same_offer(&self, invreq: &InvoiceRequest) -> bool {
Comment on lines +382 to 383
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as 890ce7d#r2000894990

Pasting the error for reference

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

let invoice_offer_tlv_stream =
Offer::tlv_stream_iter(&self.bytes).map(|tlv_record| tlv_record.record_bytes);
Expand Down