lightningj-org/lightningj

addInvoice call results in NPE for 0.4.2-Beta, works in 0.4.1-Beta

Closed this issue · 4 comments

Here's the program that works for the 0.4.1-Beta version of lightningj but not for 0.4.2-Beta (I'm using lnd version 0.4.2):

root@b7dd80128afd:# lncli --version
lncli version 0.4.2 commit=
import org.lightningj.lnd.wrapper.*;
import org.lightningj.lnd.wrapper.message.Invoice;

import java.io.File;

public class ApiTest {

    public static void main(String[] args) throws Exception{
        SynchronousLndAPI synchronousLndAPI = new SynchronousLndAPI("localhost", 10009,
                                                                    new File("/tmp/tls.cert"),
                                                                    new File("/tmp/admin.macaroon"));
        Invoice invoice = new Invoice();
        invoice.setValue(100);
        System.out.println(synchronousLndAPI.addInvoice(invoice));
    }
}

Here's the exception:

$ gradle run
Parallel execution is an incubating feature.

> Task :run FAILED
Exception in thread "main" java.lang.NullPointerException
        at org.lightningj.lnd.wrapper.message.Invoice.populateRepeatedFields(Invoice.java:359)
        at org.lightningj.lnd.wrapper.Message.getApiObject(Message.java:97)
        at org.lightningj.lnd.wrapper.API.processRequest(API.java:141)
        at org.lightningj.lnd.wrapper.SynchronousLndAPI.addInvoice(SynchronousLndAPI.java:973)
        at test.ApiTest.main(ApiTest.java:15)


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
2 actionable tasks: 1 executed, 1 up-to-date

Not urgent since everything I need works in 0.4.1, but just filing this in case other folks run into the same issue.

Hi

Sorry for not responding earlier but have been away travelling.

I have found the bug and will create minor release in coming days after I have done some testing.

I will let you know as soon as it is available on Maven Central.

Happy to hear you found the bug. No rush with the fix as I have everything working on 0.4.1-beta.

Again, thanks for your great work on lightningj!

Hi Again

0.4.2-Beta-2 is now released and should fix the problem. I have tested running your code against my node and it works again. The problem was the added routeHints field in the invoice that was a repeatable field (List) and was null if not set. This is now checked before sent to LND.

Hope it works for you now.

Just tested and the new check fixes the NPE for me, thanks so much!