Skip to content

Commit

Permalink
chore: remove lnurl-pay description hash check
Browse files Browse the repository at this point in the history
as discussed in: lnurl/luds#234
  • Loading branch information
bumi committed Aug 27, 2023
1 parent 42e38ea commit 2449165
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
2 changes: 0 additions & 2 deletions src/app/screens/LNURLPay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ function LNURLPay() {

const isValidInvoice = lnurl.verifyInvoice({
paymentInfo,
metadata: details.metadata,
amount: parseInt(valueSat) * 1000,
payerdata,
});

if (!isValidInvoice) {
Expand Down
22 changes: 0 additions & 22 deletions src/common/lib/lnurl.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import fetchAdapter from "@vespaiach/axios-fetch-adapter";
import axios from "axios";
import lightningPayReq from "bolt11";
import Hex from "crypto-js/enc-hex";
import sha256 from "crypto-js/sha256";
import { isLNURLDetailsError } from "~/common/utils/typeHelpers";
import {
LNURLDetails,
Expand Down Expand Up @@ -118,33 +116,13 @@ const lnurl = {

verifyInvoice({
paymentInfo,
payerdata,
metadata,
amount,
}: {
paymentInfo: LNURLPaymentInfo;
payerdata:
| undefined
| {
name?: string;
email?: string;
};
metadata: string;
amount: number;
}) {
const paymentRequestDetails = lightningPayReq.decode(paymentInfo.pr);
let metadataHash = "";
try {
const dataToHash = payerdata
? metadata + JSON.stringify(payerdata)
: metadata;
metadataHash = sha256(dataToHash).toString(Hex);
} catch (e) {
console.error();
}
switch (true) {
case paymentRequestDetails.tagsObject.purpose_commit_hash !==
metadataHash: // LN WALLET Verifies that h tag (description_hash) in provided invoice is a hash of metadata string converted to byte array in UTF-8 encoding
case paymentRequestDetails.millisatoshis !== String(amount): // LN WALLET Verifies that amount in provided invoice equals an amount previously specified by user
case paymentInfo.successAction &&
!["url", "message", "aes"].includes(paymentInfo.successAction.tag): // If successAction is not null: LN WALLET makes sure that tag value of is of supported type, aborts a payment otherwise
Expand Down

0 comments on commit 2449165

Please sign in to comment.