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

invoice hook #2540

Merged
merged 3 commits into from Apr 12, 2019

Conversation

Projects
None yet
2 participants
@rustyrussell
Copy link
Contributor

commented Apr 8, 2019

So many hooks to write, so little time...

@rustyrussell rustyrussell requested a review from cdecker as a code owner Apr 8, 2019

rustyrussell added some commits Apr 11, 2019

lightningd: move local invoice resolution into invoice.c function.
We're going to make it async, so start by moving the core code into
invoice.c and having that directly call fail/success functions for the
htlc.

We add an extra check in fulfill_htlc() that the HTLC state is correct:
that can't happen now, but may once we're async.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lightningd: implement invoice hook.
This also allows plugins to do "hold invoices" a-la LND, useful for
just-in-time inventory handling.

We're careful to handle the invoice getting paid behind our backs, and
the incoming HTLC going away.

Once @cdecker's sphinx rework is in, we can also hand the raw payload
to the invoice_payment_hook, for special effects.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

@rustyrussell rustyrussell force-pushed the rustyrussell:guilt/invoice-hook branch from 14817ab to c75cb51 Apr 11, 2019

@rustyrussell

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2019

Fixed test I accidentally broke, python flake8 fails, and rebased...

pytest: test the invoice hook.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

@rustyrussell rustyrussell force-pushed the rustyrussell:guilt/invoice-hook branch from c75cb51 to 9a420fe Apr 11, 2019

{
u8 *msg;
struct channel *channel = hin->key.channel;
struct wallet *wallet = channel->peer->ld->wallet;

if (hin->hstate != RCVD_ADD_ACK_REVOCATION) {

This comment has been minimized.

Copy link
@cdecker

cdecker Apr 11, 2019

Member

I assume this may happen due to the updates no longer being atomic?

This comment has been minimized.

Copy link
@rustyrussell

rustyrussell Apr 12, 2019

Author Contributor

Yes, in particular we might have gone onchain while waiting, then timed out the HTLC.

toks[0].end - toks[1].start, buffer);

/* UPDATE isn't valid for final nodes to return, and I think we
* assert elsewhere that we don't do this! */

This comment has been minimized.

Copy link
@cdecker

cdecker Apr 11, 2019

Member

Yep, just stumbled over the check before 👍

@cdecker

This comment has been minimized.

Copy link
Member

commented Apr 11, 2019

ACK 9a420fe

@rustyrussell rustyrussell merged commit 9c373fe into ElementsProject:master Apr 12, 2019

2 checks passed

ackbot PR ack'd by cdecker
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.