Skip to content

Commit

Permalink
feat: paycode await
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed Jul 13, 2023
1 parent 08d96f4 commit dcf00e1
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions app/screens/receive-bitcoin-screen/payment/payment-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,26 +197,32 @@ export const createPaymentRequest = (

// Paycode
} else if (pr.type === Invoice.PayCode && pr.username) {
const getFullUriFn: GetFullUriFn = ({ uppercase, prefix }) => {
const lnurl = bech32.encode(
"lnurl",
bech32.toWords(
Buffer.from(`${pr.posUrl}/.well-known/lnurlp/${pr.username}`, "utf8"),
const lnurl = await new Promise((resolve) => {
resolve(
bech32.encode(
"lnurl",
bech32.toWords(
Buffer.from(`${pr.posUrl}/.well-known/lnurlp/${pr.username}`, "utf8"),
),
1500,
),
1500,
)
})

const webURL = `${pr.posUrl}/${pr.username}`
// To make the page render at loading state
// (otherwise jittery becoz encode takes ~10ms on slower phones)
await new Promise((r) => setTimeout(r, 500))

const qrCodeURL = (webURL + "?lightning=" + lnurl).toUpperCase()
const webURL = `${pr.posUrl}/${pr.username}`
const qrCodeURL = (webURL + "?lightning=" + lnurl).toUpperCase()

return getPaymentRequestFullUri({
const getFullUriFn: GetFullUriFn = ({ uppercase, prefix }) =>
getPaymentRequestFullUri({
type: Invoice.PayCode,
input: qrCodeURL,
uppercase,
prefix,
})
}

info = {
data: {
Expand Down

0 comments on commit dcf00e1

Please sign in to comment.