Introduces a new object Widr (Withdrawal) that can be created by an authenticated user and creates an LNURL-withdraw voucher. Expiry is set to 7 days.
Adds a front-end page that contains the LNURL qr code and lightning: link.
Adds 2 routes for the LNURL withdraw protocol (WIP: just pseudocode for now).
Adds the bech32 dependency for the LNURL encoding.
Pseudocode for the WIP stuff:
router.get(withdrawPrimaryAPIRoute + ':secret', async function (req, res) {
//look up wd from db
//check status
//respond with lnurl payload (description invoice must contain secret)
});
router.get(withdrawSecondaryAPIRoute + ':secret', async function (req, res) {
//look up wd from db
//check amount
//check status
//check if invoice description matches (contains secret)
//set status to pending in db
//get token for user
//use frisbee to call our own server impersonating as user and attempt to pay invoice
//callback: set to success (== remove) or failed
//Q: what if payment stuck?
//respond with lnurl payload and response from frisbee (success / fail / pending)
});
Open question: what if the LN payment gets stuck?
To do:
Check user balance at time of creation
Actual LNURL implementation
Tests
Out of scope of this PR:
cancel a created payment link before it expires
set the expiry time of a payment link
view a list of payment links that you created
send notification to user that created the withdrawal after it's been redeemed.
Once merged, resolves https://github.com/BlueWallet/LndHub/issues/119 on the server-side.
Widr
(Withdrawal) that can be created by an authenticated user and creates an LNURL-withdraw voucher. Expiry is set to 7 days.lightning:
link.bech32
dependency for the LNURL encoding.Pseudocode for the WIP stuff:
Open question: what if the LN payment gets stuck?
To do:
Out of scope of this PR:
Screenshots