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

[BUG] Galoy doesn't return preimage with WebLN #2946

Closed
reneaaron opened this issue Dec 19, 2023 · 5 comments · Fixed by #2997
Closed

[BUG] Galoy doesn't return preimage with WebLN #2946

reneaaron opened this issue Dec 19, 2023 · 5 comments · Fixed by #2997

Comments

@reneaaron
Copy link
Contributor

reneaaron commented Dec 19, 2023

Describe the bug

Implement WebLN (return preimage for sendPayment calls)

https://github.com/getAlby/lightning-browser-extension/blob/master/src/extension/background-script/connectors/galoy.ts#L314

@openoms
Copy link
Contributor

openoms commented Dec 20, 2023

Looking into this, can extend the graphql call. The API can return the preimage when paying through LN, but doesn't do for intraledger:

mutation LnInvoicePaymentSend($input: LnInvoicePaymentInput!) {
  lnInvoicePaymentSend(input: $input) {
    errors {
      message
    }
    status
    transaction {
      settlementVia {
        ... on SettlementViaLn {
          preImage
        }
        ... on SettlementViaIntraLedger {
          counterPartyUsername
          counterPartyWalletId
        }
      }
    }
  }
}

would it be useful to return the username or just a note about intraledger settlement?

Testing paying a new account without username set is not returning anything so it must be a note about intraledger payment:

{
  "data": {
    "lnInvoicePaymentSend": {
      "errors": [],
      "status": "SUCCESS",
      "transaction": {
        "settlementVia": {
          "counterPartyUsername": null,
          "counterPartyWalletId": null
        }
      }
    }
  }
}

Example response on signet LN:

{
  "data": {
    "lnInvoicePaymentSend": {
      "errors": [],
      "status": "SUCCESS",
      "transaction": {
        "settlementVia": {
          "preImage": "b88173fa2326356c4f0f3399cc0c7e2eb6c1c8b75369c45b708c77fdb4799e15"
        }
      }
    }
  }
}

@reneaaron
Copy link
Contributor Author

If the Galoy connector doesn't reliably return preimages for WebLN it will break quite some apps that follow the current WebLN spec and possibly would force them to handle those special cases (for intraledger payments) which is clearly not how WebLN is intended to work.

Why is it that you can't provide a preimage for intraledger payments? Do they never hit the node but just the DB?

@openoms
Copy link
Contributor

openoms commented Dec 20, 2023

The preImage could be returned for intraledger payments as well as the invoice is generated on the node (not knowing that it will be paid intraledger or over LN) and the paymentSecret is known. Will open an issue for discussion with the Galoy team.

eg.:

curl --request POST \
    --header 'content-type: application/json' \
    --header 'X-API-KEY: galoy_staging_xxxxxxxxxxxx' \
    --url 'https://api.staging.galoy.io/graphql' \
    --data '{"query":"mutation LnInvoiceCreate($input: LnInvoiceCreateInput!) {\n  lnInvoiceCreate(input: $input) {\n    invoice {\n      paymentHash\n      paymentRequest\n      createdAt\n      satoshis\n      paymentStatus\n      paymentSecret\n    }\n  }\n}","variables":{"input":{"amount":21,"walletId":"xxxxxxxxxx"}}}'
{
  "data": {
    "lnInvoiceCreate": {
      "invoice": {
        "paymentHash": "b1cf0faaf9fd7b15de77cf032d9ca7559612c8356c6b21a7c45402d65e9c4869",
        "paymentRequest": "lntbs210n1pjc9w42pp5k88sl2hel4a3thnheupjm8982ktp9jp4d34jrf7y2spdvh5ufp5sdqqcqzpuxqyz5vqsp5tr8c5ngy7s9ryvu9v3hx5tg26wfrx8kg42uhuqlleaavsc6qpp7s9qyyssq2tjznjeckf8j8mcpgezcyprat4yys3ac9fqf0g2uutkavt3qj5grqtha38lkxyvlncfwhfh88ssa895ur6a6a8h8390s6qm9tn34kdsqlwkhkj",
        "createdAt": 1703066283,
        "satoshis": 21,
        "paymentStatus": "PENDING",
        "paymentSecret": "58cf8a4d04f40a323385646e6a2d0ad392331ec8aab97e03ffcf7ac86340087d"
      }
    }
  }
}

@bumi
Copy link
Collaborator

bumi commented Dec 20, 2023

that would be great! \o/

@openoms
Copy link
Contributor

openoms commented Dec 21, 2023

Until the preimage is returned for intraledger also can offer a partial improvement to return it for ln settlements at least: #2953

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

Successfully merging a pull request may close this issue.

3 participants