This repository was archived by the owner on Feb 23, 2021. It is now read-only.
This repository was archived by the owner on Feb 23, 2021. It is now read-only.
Support 0 value invoices by letting users edit the amount #991
Open
Description
Seems people are into sending tips over LN these days. They usually do so by giving out a "zero valued" input which looks like this when decoded:
top@kek9000:~/gocode/src/github.com/lightningnetwork/lnd# lncli -n testnet decodepayreq lntb1pwxmh7lpp5mnsmlk7rhtj6fuj362ff5xwtxjssczrt84q04pucjnj407046uqsdqqcqzysm0l4rl86nuv94ahea3rv4fqsqymqm4xmaq5xthe6nnnnvcc227srmufarxjw7euhtj8lftqtr8pk5xaga50aheey8yjzdlyc2tv4pkcp77yrhl
{
"destination": "0270685ca81a8e4d4d01beec5781f4cc924684072ae52c507f8ebe9daf0caaab7b",
"payment_hash": "dce1bfdbc3bae5a4f251d2929a19cb34a10c086b3d40fa879894e557f9f5d701",
"num_satoshis": "0",
"timestamp": "1550704607",
"expiry": "3600",
"description": "",
"description_hash": "",
"fallback_addr": "",
"cltv_expiry": "144",
"route_hints": [
]
}
So one the decoder side, we can detect this at it has no true value:
"num_satoshis": "0",
When we try to pay an invoice like this into the UI atm we see something like this
When the user clicks to pay, then it gets rejected as lnd
detects there's no value attached to the send request.
If we wan to support this use case, we'll need to:
- Detect this special type of invoice while we're validating the user data
- Modify the currently static "send payment" UI fragment to be conditionally dynamic if there's a zero valued invoice. In this case, the user would get some sort of text saying they should specify the amount since it's a tip/donation.
- Take that value and specify it in the
SendRequest
proto along side the invoice. Here's an example of how we do it in lnd/Go: https://github.com/lightningnetwork/lnd/blob/master/cmd/lncli/commands.go#L2255. Notice that we set both the invoice and the amount. If the amount is zero, then lnd will just use the invoice. But if it's set, then lnd knows what do to with it all.