Skip to content

Error calling createInvoice in router.js #17

@seak1234

Description

@seak1234

Hey,

after updating my lnd node to lnd v0.16.2-beta I noticed that ligess on my node cannot create invoices anymore. It used to work a few weeks ago. Not sure if updating lnd is even related to this issue though.

Terminal out put:

yarn run v1.22.19
warning package.json: No license field
$ nodemon index.js
[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
{"level":30,"time":1684973619585,"pid":705738,"hostname":"raspibolt","msg":"Nostr NIP-57 enabled","npub":"npub195q6.....................3xcz"}
{"level":30,"time":1684973619616,"pid":705738,"hostname":"raspibolt","msg":"Server listening at http://127.0.0.1:3000"}
Unable to fetch pending invoices TypeError: Cannot read properties of undefined (reading 'map')
    at LndRest.getPendingInvoices (/home/ligess/ligess/node_modules/una-wrapper/dist/index.cjs:194:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
{"level":30,"time":1684973645487,"pid":705738,"hostname":"raspibolt","reqId":"req-1","req":{"method":"GET","url":"/.well-known/lnurlp/seak","hostname":"ln.satoshibox.org","remoteAddress":"127.0.0.1","remotePort":47532},"msg":"incoming request"}
{"level":30,"time":1684973645498,"pid":705738,"hostname":"raspibolt","reqId":"req-1","res":{"statusCode":200},"responseTime":9.093086987733841,"msg":"request completed"}
{"level":30,"time":1684973648261,"pid":705738,"hostname":"raspibolt","reqId":"req-2","req":{"method":"GET","url":"/.well-known/lnurlp/seak?amount=1000&nonce=1684973648224","hostname":"ln.satoshibox.org","remoteAddress":"127.0.0.1","remotePort":47532},"msg":"incoming request"}
{"level":40,"time":1684973649365,"pid":705738,"hostname":"raspibolt","reqId":"req-2","status":"ERROR","reason":"An error occured while getting invoice: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined"}
{"level":30,"time":1684973649367,"pid":705738,"hostname":"raspibolt","reqId":"req-2","res":{"statusCode":400},"responseTime":1105.8670839965343,"msg":"request completed"}

Initial debugging:
There seems to be two parts to this:

  1. The following only shows if I add my nostr private key:
Unable to fetch pending invoices TypeError: Cannot read properties of undefined (reading 'map')
    at LndRest.getPendingInvoices (/home/ligess/ligess/node_modules/una-wrapper/dist/index.cjs:194:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
  1. The following will show when I try to send myself some sats form a different wallet
{"level":30,"time":1684973645487,"pid":705738,"hostname":"raspibolt","reqId":"req-1","req":{"method":"GET","url":"/.well-known/lnurlp/seak","hostname":"ln.satoshibox.org","remoteAddress":"127.0.0.1","remotePort":47532},"msg":"incoming request"}
{"level":30,"time":1684973645498,"pid":705738,"hostname":"raspibolt","reqId":"req-1","res":{"statusCode":200},"responseTime":9.093086987733841,"msg":"request completed"}
{"level":30,"time":1684973648261,"pid":705738,"hostname":"raspibolt","reqId":"req-2","req":{"method":"GET","url":"/.well-known/lnurlp/seak?amount=1000&nonce=1684973648224","hostname":"ln.satoshibox.org","remoteAddress":"127.0.0.1","remotePort":47532},"msg":"incoming request"}
{"level":40,"time":1684973649365,"pid":705738,"hostname":"raspibolt","reqId":"req-2","status":"ERROR","reason":"An error occured while getting invoice: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined"}
{"level":30,"time":1684973649367,"pid":705738,"hostname":"raspibolt","reqId":"req-2","res":{"statusCode":400},"responseTime":1105.8670839965343,"msg":"request completed"}

Focussing on point 2
There seems to be an issue with the una-wrapper (Universal Node API) when creating an invoice in router.js, executing the createInvoice function call:

const invoice = await unaWrapper.createInvoice({
        amountMsats: msat,
        descriptionHash: crypto
          .createHash('sha256')
          .update(metadata)
          .digest('hex')
      })

Function call uses the following inputs according to console.log():

msat:
1000
crypto:
{"constants":{"OPENSSL_VERSION_NUMBER":269488463,"SSL_OP_ALL":2147485780,"SSL_OP_ALLOW_NO_DHE_KEX":1024,"SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION":262144,"SSL_OP_CIPHER_SERVER_PREFERENCE":4194304,"SSL_OP_CISCO_ANYCONNECT":32768,"SSL_OP_COOKIE_EXCHANGE":8192,"SSL_OP_CRYPTOPRO_TLSEXT_BUG":2147483648,"SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS":2048,"SSL_OP_EPHEMERAL_RSA":0,"SSL_OP_LEGACY_SERVER_CONNECT":4,"SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER":0,"SSL_OP_MICROSOFT_SESS_ID_BUG":0,"SSL_OP_MSIE_SSLV2_RSA_PADDING":0,"SSL_OP_NETSCAPE_CA_DN_BUG":0,"SSL_OP_NETSCAPE_CHALLENGE_BUG":0,"SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG":0,"SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG":0,"SSL_OP_NO_COMPRESSION":131072,"SSL_OP_NO_ENCRYPT_THEN_MAC":524288,"SSL_OP_NO_QUERY_MTU":4096,"SSL_OP_NO_RENEGOTIATION":1073741824,"SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION":65536,"SSL_OP_NO_SSLv2":0,"SSL_OP_NO_SSLv3":33554432,"SSL_OP_NO_TICKET":16384,"SSL_OP_NO_TLSv1":67108864,"SSL_OP_NO_TLSv1_1":268435456,"SSL_OP_NO_TLSv1_2":134217728,"SSL_OP_NO_TLSv1_3":536870912,"SSL_OP_PKCS1_CHECK_1":0,"SSL_OP_PKCS1_CHECK_2":0,"SSL_OP_PRIORITIZE_CHACHA":2097152,"SSL_OP_SINGLE_DH_USE":0,"SSL_OP_SINGLE_ECDH_USE":0,"SSL_OP_SSLEAY_080_CLIENT_DH_BUG":0,"SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG":0,"SSL_OP_TLS_BLOCK_PADDING_BUG":0,"SSL_OP_TLS_D5_BUG":0,"SSL_OP_TLS_ROLLBACK_BUG":8388608,"ENGINE_METHOD_RSA":1,"ENGINE_METHOD_DSA":2,"ENGINE_METHOD_DH":4,"ENGINE_METHOD_RAND":8,"ENGINE_METHOD_EC":2048,"ENGINE_METHOD_CIPHERS":64,"ENGINE_METHOD_DIGESTS":128,"ENGINE_METHOD_PKEY_METHS":512,"ENGINE_METHOD_PKEY_ASN1_METHS":1024,"ENGINE_METHOD_ALL":65535,"ENGINE_METHOD_NONE":0,"DH_CHECK_P_NOT_SAFE_PRIME":2,"DH_CHECK_P_NOT_PRIME":1,"DH_UNABLE_TO_CHECK_GENERATOR":4,"DH_NOT_SUITABLE_GENERATOR":8,"ALPN_ENABLED":1,"RSA_PKCS1_PADDING":1,"RSA_SSLV23_PADDING":2,"RSA_NO_PADDING":3,"RSA_PKCS1_OAEP_PADDING":4,"RSA_X931_PADDING":5,"RSA_PKCS1_PSS_PADDING":6,"RSA_PSS_SALTLEN_DIGEST":-1,"RSA_PSS_SALTLEN_MAX_SIGN":-2,"RSA_PSS_SALTLEN_AUTO":-2,"defaultCoreCipherList":"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA","TLS1_VERSION":769,"TLS1_1_VERSION":770,"TLS1_2_VERSION":771,"TLS1_3_VERSION":772,"POINT_CONVERSION_COMPRESSED":2,"POINT_CONVERSION_UNCOMPRESSED":4,"POINT_CONVERSION_HYBRID":6},"webcrypto":{}}`
metadata:
[["text/identifier","seak@ln.satoshibox.org"],["text/plain","Satoshis to seak@ln.satoshibox.org"]]

This will lead to:

{"level":50,"time":1684974094646,"pid":710310,"hostname":"raspibolt","reqId":"req-2",
"req":{"method":"GET","url":"/.well-known/lnurlp/seak?amount=1000&nonce=1684974093505","hostname":"ln.satoshibox.org","remoteAddress":"127.0.0.1","remotePort":49076},"res":{"statusCode":500},
"err":{"type":"TypeError","message":"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined",
"stack":"TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
\n    at new NodeError (node:internal/errors:387:5)
\n    at Function.from (node:buffer:328:9)
\n    at base64ToHex (/home/ligess/ligess/node_modules/una-wrapper/dist/index.cjs:554:17)
\n    at LndRest.createInvoice (/home/ligess/ligess/node_modules/una-wrapper/dist/index.cjs:161:34)
\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)
\n    at async Una.createInvoice (/home/ligess/ligess/node_modules/una-wrapper/dist/index.cjs:817:12)
\n    at async Object.<anonymous> (/home/ligess/ligess/router.js:69:23)","code":"ERR_INVALID_ARG_TYPE"},
"msg":"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined"}
{"level":30,"time":1684974094650,"pid":710310,"hostname":"raspibolt","reqId":"req-2","res":{"statusCode":500},"responseTime":1103.6004920005798,"msg":"request completed"}

Unfortunately, I am not a java script guy. Debugging this issue by myself will take forever. Does anyone have an idea what is going on and point me to something?

Any help is much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions