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

offers: wait for offers invoice #84

Closed
wants to merge 8 commits into from

Conversation

orbitalturtle
Copy link
Collaborator

This PR implements the next part of the offers flow, as described in #64.

After sending an invoice request to the offer creator, we wait for an invoice to be returned.

It depends on #81 and the changes in lndk-org/ldk-sample#8

@orbitalturtle orbitalturtle force-pushed the wait-for-offers-invoice branch 4 times, most recently from 2530ec6 to 815e171 Compare December 9, 2023 04:53
@orbitalturtle orbitalturtle force-pushed the wait-for-offers-invoice branch from 815e171 to a87b987 Compare December 9, 2023 04:58
// TODO: Restarting the lnd node here isn't ideal. But for some reason after we call LDK's open_channel
// API call, LND blocks and is unable to receive any API requests. This might be a bug in ldk-sample or
// our ldk-sample implementation.
lnd.handle.kill().expect("lnd couldn't be killed");
Copy link
Collaborator Author

@orbitalturtle orbitalturtle Dec 12, 2023

Choose a reason for hiding this comment

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

Hmmm FYI I found a fix for this -- it seems like the problem has something to do with mining a bunch of blocks while lnd is trying to initiate a channel open. I'll push up a fix for this soon so we can remove this restart.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah that makes sense - some RPC calls will fail if we're not synced to chain. Easiest way will prob be to poll GetInfo to make sure that we're synced?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call, I'll give that a try. Right now I just have some sleeps scattered throughout as a POC, which is definitely not ideal!

Copy link
Collaborator

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

Looking at this and #81, I think we need to think about pulling our our existing OnionMessenger functionality into a dedicated struct where we can rely on what we already have. I know this feels annoying when we're just doing a CLI to start with, but I think we should design this with the possibility of this turning into a server one day / what that would look like in mind. Will try to bang together some code today which explains this thinking a little better.

match message {
OffersMessage::Invoice(invoice) => {
println!("Received an invoice offers message.");
self.invoices.lock().unwrap().push_back(invoice);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we track that we actually sent an invoice request for the offer, and discard the invoice if not?

@@ -168,12 +169,15 @@ async fn test_lndk_send_invoice_request() {
client: client_clone.lightning().to_owned(),
};
let blinded_path = offer.paths()[0].clone();
let secp_ctx = Secp256k1::new();
let reply_path =
BlindedPath::new_for_message(&[pubkey_2, lnd_pubkey], &messenger_utils, &secp_ctx).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be included in #81?

src/lndk_offers.rs Show resolved Hide resolved
@carlaKC carlaKC mentioned this pull request Dec 20, 2023
@orbitalturtle
Copy link
Collaborator Author

Closing this in favor of a new incoming PR with #85 as the base :)

@orbitalturtle orbitalturtle deleted the wait-for-offers-invoice branch May 30, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants