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

Tokens not being passed to subscribeToPayViaDetails via isDestinationPayable #139

Open
eNzyOfficial opened this issue Jun 19, 2023 · 9 comments

Comments

@eNzyOfficial
Copy link

const tokens = !args.mtokens ? null : args.tokens || defaultTokens;

Can you confirm the above logic is correct?

If I pass in tokens it's always null and subscribeToPayViaDetails function fails with ExpectedTokenAmountToPayInPaymentDetails.

Example:

const { lnd } = authenticatedLndGrpc({
  cert,
  macaroon,
  socket
})

const request = 'lnbcrt50u...'

const { destination, tokens } = await decodePaymentRequest({
  request,
  lnd
})

const isPayable = await isDestinationPayable({
  destination,
  tokens,
  lnd
})
@alexbosworth
Copy link
Owner

alexbosworth commented Jun 19, 2023

nm i see the issue

@alexbosworth
Copy link
Owner

what happens if you use mtokens instead of tokens? it works ok?

@eNzyOfficial
Copy link
Author

It doesn't, it throws the following:

Error: UnexpectedDifferingMtokensAndTokens
    at module.exports (/.../node_modules/lightning/bolt00/payment_amounts.js:71:13)
    at asyncAuto.params (/.../node_modules/lightning/lnd_methods/offchain/subscribe_to_pay.js:352:23)
    at runTask (/.../node_modules/async/auto.js:293:13)
    at /.../node_modules/async/auto.js:233:31
    at processQueue (/.../node_modules/async/auto.js:243:13)
    at taskComplete (/.../node_modules/async/auto.js:259:9)
    at /.../node_modules/async/auto.js:286:17
    at /.../node_modules/async/internal/onlyOnce.js:12:16
    at asyncAuto.maxCltvDelta (/.../node_modules/lightning/lnd_methods/offchain/subscribe_to_pay.js:331:16)
    at runTask (/.../node_modules/async/auto.js:293:13)

@alexbosworth
Copy link
Owner

I mean if you use the mtokens and tokens together like pass both that you get from decodePaymentRequest

@eNzyOfficial
Copy link
Author

eNzyOfficial commented Jun 20, 2023

Same error:

const { lnd } = authenticatedLndGrpc({
  cert,
  macaroon,
  socket
})

const request = 'lnbcrt50u...'

const { destination, tokens } = await decodePaymentRequest({
  request,
  lnd
})

const isPayable = await isDestinationPayable({
  destination,
  tokens,
  mtokens: tokens,
  lnd
})

EDIT: Nevermind I'm an idiot, forgot to convert tokens to mtokens first

@alexbosworth
Copy link
Owner

sorry i mean decodePaymentRequest will return mtokens as well as tokens

so

const { destination, mtokens } = await decodePaymentRequest({
const isPayable = await isDestinationPayable({
  destination,
  mtokens,
  lnd
})

@eNzyOfficial
Copy link
Author

If I use only mtokens

I'm still getting UnexpectedDifferingMtokensAndTokens

inside payment_amounts.js I add console.log(tokensAsMtokens, args.mtokens) which returns 1000 500000

if I include both mtokens and tokens in the initial call, it works fine.

const { destination, tokens, mtokens } = await decodePaymentRequest({
    request,
    lnd
})

const isPayable = await isDestinationPayable({
    destination,
    mtokens,
    tokens,
    lnd
})

@alexbosworth
Copy link
Owner

ok sounds like something is wrong there then, can take a look

it should work with tokens alone and mtokens alone

@alexbosworth
Copy link
Owner

should be corrected now

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