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

Verify invoice amount in lightning address withdrawal #501

Merged
merged 2 commits into from Sep 24, 2023

Conversation

benthecarman
Copy link
Contributor

Not sure how to test, but looking at the decodePaymentRequest docs this looks correct.

@ekzyis
Copy link
Member

ekzyis commented Sep 20, 2023

Not sure how to test

You would need to setup local lnd as explained here. But I can take a look at this today :)

edit: Oh, I see, this uses lightning addresses ...

api/resolvers/wallet.js Outdated Show resolved Hide resolved
api/resolvers/wallet.js Outdated Show resolved Hide resolved
@ekzyis ekzyis self-requested a review September 20, 2023 14:45
Copy link
Member

@ekzyis ekzyis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this by sending to another SN account via its LN address on my local instance.

I've noticed that num_msat is undefined. decodePaymentRequest returned this for a 1 sat invoice:

app  | {
app  |   chain_address: undefined,
app  |   cltv_delta: 80,
app  |   created_at: '2023-09-20T15:19:05.000Z',
app  |   description: '',
app  |   description_hash: '3642f0f74ffb44596b4be110fefa2ebfe5cedc209e8e376d9b41e1ad0938d3a5',
app  |   destination: '0229ad2b79601ca9831128a10398aa4fc8a0bcfb568bdddb5955c9259834baf7d8',
app  |   expires_at: '2023-09-20T15:20:05.000Z',
app  |   features: [
app  |     { bit: 9, is_known: true, is_required: false, type: 'tlv_onion' },
app  |     {
app  |       bit: 14,
app  |       is_known: true,
app  |       is_required: true,
app  |       type: 'payment_identifier'
app  |     },
app  |     {
app  |       bit: 17,
app  |       is_known: true,
app  |       is_required: false,
app  |       type: 'multipath_payments_v0'
app  |     }
app  |   ],
app  |   id: '4e7194285ea4955cc7aad374873a97f8775bfa6c141bae203727bd4adbadf6b1',
app  |   is_expired: false,
app  |   mtokens: '1000',
app  |   payment: '07a6d31bca2b6aeaeece0a2baedd75976f119d66c58e2aafef2c7ff0eab9ee14',
app  |   routes: [],
app  |   safe_tokens: 1,
app  |   tokens: 1
app  | }

I also looked at the docs and I see no num_msat. I think we need to use BigInt(decoded.mtokens) as we do in other parts of the code like here.

(While doing this, I realized we also need to document LNWITH_URL in .env.sample)

api/resolvers/wallet.js Outdated Show resolved Hide resolved
@benthecarman
Copy link
Contributor Author

Thanks @ekzyis! I was looking at the wrong docs I guess 😅

https://lightning.engineering/api-docs/api/lnd/lightning/decode-pay-req

@ekzyis
Copy link
Member

ekzyis commented Sep 20, 2023

Thanks @ekzyis! I was looking at the wrong docs I guess 😅

https://lightning.engineering/api-docs/api/lnd/lightning/decode-pay-req

Ahh, I figured but I wasn't able to find this documentation, haha

Copy link
Member

@ekzyis ekzyis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to have "verified stacker.news contributor" in your SN profile, you can add your SN nym to contributors.txt in this PR :)

@benthecarman
Copy link
Contributor Author

Cleaned up commits + added to list!

@huumn huumn merged commit a14341c into stackernews:master Sep 24, 2023
1 check passed
@benthecarman benthecarman deleted the patch-1 branch September 24, 2023 01:24
@huumn
Copy link
Member

huumn commented Sep 24, 2023

I'll likely deploy this monday. 😉

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 this pull request may close these issues.

None yet

3 participants