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

Panic error when executing example code #4

Open
smorz opened this issue Jul 28, 2021 · 3 comments
Open

Panic error when executing example code #4

smorz opened this issue Jul 28, 2021 · 3 comments

Comments

@smorz
Copy link

smorz commented Jul 28, 2021

Hi!
When executing the example code, I came across the following error, which, as far as I understood, is related to the field header of the wallet object in the Invoice function in the lnpay.go file.

$ go run lnpay-test.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6c36cc]

goroutine 1 [running]:
github.com/lnpay/lnpay-go.(*Wallet).Invoice(0xc00014dc80, 0x74d95e, 0xe, 0x3e8, 0x0, 0xc000324120, 0x74a370, 0x0, 0x0, 0x0, ...)
/home/smorz/go/pkg/mod/github.com/lnpay/lnpay-go@v1.1.0/lnpay.go:142 +0xec
main.main()
/home/smorz/programs/lnpay-test/lnpay-test.go:21 +0x365
exit status 2

@fiatjaf
Copy link
Collaborator

fiatjaf commented Jul 28, 2021

That's because we didn't handle the error from CreateWallet on the example (so the example wasn't bloated). You must always handle the error there in real code. It will probably say that you used an invalid API Key or something like that.

Sorry for the confusion.

@smorz
Copy link
Author

smorz commented Jul 31, 2021

Thank you.
I checked the error from CreateWallet and it was nil, And I tested with a real sak then even the wallet was created in the dashboard. But that error is still occurring.
I put a fmt.Println(wal.header) after line 67 of lnpay.go (err = resp.ToJSON(&wal)) and resulted in the panic error in that line.
May it mean that lnpay has a problem with my IP, and doesn't answer correctly to that?
Or does the version of go matter? It's 1.15

@fiatjaf
Copy link
Collaborator

fiatjaf commented Aug 1, 2021

At this point I would think this library is broken then. But it was tested before and I didn't see this error ocurring ever, so that's very weird.

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

No branches or pull requests

2 participants