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

segmentation fault - fundPsbt #140

Open
SeverinAlexB opened this issue Jul 17, 2023 · 5 comments
Open

segmentation fault - fundPsbt #140

SeverinAlexB opened this issue Jul 17, 2023 · 5 comments

Comments

@SeverinAlexB
Copy link
Contributor

SeverinAlexB commented Jul 17, 2023

I would like to fund a 0conf channel running for the Blocktank LSP. I didn't see openChannel supporting it so I tried the manual route. For that, I need to call fundPsbt. Unfortunately, my app terminates with a segmentation fault every time I call the method. Do you have any suggestion to get around that?

Example:

import * as ln from 'lightning';

const result = await ln.fundPsbt({ // Terminates with segmentation fault.
    lnd: node.rpc,
    outputs: [{
        address: 'bcrt1qz3trhgd4p95l74xda4f57npmrd2p64he4ucjqky77ztw6zulj8aq6nrpds',
        tokens: 100000
    }]
});
console.log(result)

Logs: No new lnd logs appear when I call this.

  • lightning lib version: 9.8.1
  • node version: v18.12.1
  • LND version: v0.16.4-beta
  • Chain: regtest on Polar
@SeverinAlexB
Copy link
Contributor Author

No idea why but changing import('ecpair') to require('ecpair') in ln_methods/onchain/fund_pbst.js fixes the problem for me 🤷‍♂️ Maybe somebody can reproduce this issue + solution.

CleanShot 2023-07-17 at 14 29 16@2x

@alexbosworth
Copy link
Owner

for the original issue, you can use trusted funding channels, here is an example integration test: https://github.com/alexbosworth/ln-service/blob/master/test/integration/test_trusted_funding.js#L189

for the segmentation fault that is odd, do you have any error strings I could look at? Did you try nodejs 16 or 20?

@alexbosworth
Copy link
Owner

Maybe this is a caching issue? I saw this issue that might be related https://bugs.chromium.org/p/v8/issues/detail?id=10284 so maybe clear npm build cache etc?

@SeverinAlexB
Copy link
Contributor Author

SeverinAlexB commented Jul 18, 2023

Turns out this is a Jest ESM issue. ESM support in Jest (and NodeJs 18 partially?) is still not perfect and import (a ESM feature) broke the code. require (CommonJS feature) worked. If I run the code without Jest, it works. So I am not sure if this is a issue with the library or Jest. I will try to work around it.

for the original issue, you can use trusted funding channels, here is an example integration test:
https://github.com/alexbosworth/ln-service/blob/master/test/integration/test_trusted_funding.js#L189

Nice thx. Is it possible to create a fee bump able anchor channel with this method?

On the other hand, I looked a bit deeper into the library. If you want, I can create a PR that adds the zero_conf and commitment_type parameters to the openChannel method. Let me know what you think

@alexbosworth
Copy link
Owner

The only type of trusted funding channels that LND supports at the moment is anchor channels

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