Skip to content
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
Roasbeef opened this issue Feb 20, 2019 · 7 comments
Open

Support 0 value invoices by letting users edit the amount #991

Roasbeef opened this issue Feb 20, 2019 · 7 comments

Comments

@Roasbeef
Copy link
Member

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
screen shot 2019-02-20 at 3 21 13 pm

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:

  1. Detect this special type of invoice while we're validating the user data
  2. 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.
  3. 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.
@kmbecker13
Copy link

I'm trying to fund a Tippin.me account and the request they provide has amount set as "any amount", which is interpreted as zero in the Lightning App request and is then un-editable.

Looks like this is a known thing, but i'm curious if there are any easy to use LN request editors out there to help serve as a work around in the meantime? I'm thinking of something like lndecode.com but with some editing functionality.

@tanx tanx changed the title app doesn't support sending to 0 value invoices Support 0 value invoices by letting users edit the amount Jun 20, 2019
@tanx tanx added the ui label Jun 20, 2019
@bolatovumar
Copy link

Aren't zero sat amount invoice not safe?

See this: https://github.com/ottosuess/ottosuess.github.io/blob/master/zero-amount-payments.md

@emiljoha
Copy link

In the spirit of scratching my own itches (and this seems like a somewhat contained change) I have started an attempt at this in PR #1327

I am new to this code base but I am trying to follow the existing UI/code styles a good as I can.

@emiljoha
Copy link

Update: I am making progress, basic functionality is there but still needs some polishing.

@bolatovumar
Copy link

@Roasbeef @tanx is it OK in this case that zero sat amount invoices are not safe or am I misunderstanding something and they are OK here?

@emiljoha
Copy link

emiljoha commented Jan 31, 2020

The PR is IMHO ready 😃 It of course needs review and there needs to be a decision on how to handle the security implications.

My two cents is that this is an extremely important feature for new users that want to "give lightning a try". In my case the second thing I tried to pay for with lightning was a zero value invoice and the experience was that of a broken system. That is not the image of the ecosystem we want to give new users.

Concerning the security aspects IMHO there are three alternatives:

  1. Just ask the user to supply amount and send it. (Current UX in Redirect navigation flow for 0 value invocies. Fixes #991 #1327 )
  2. Display a warning but support the feature.
  3. Window explaining why this feature is not supported.

I can make the necessary work for any solution. If (3) we can keep the payment PR and adapt it for keysend when that is properly supported by lnd.

@emiljoha
Copy link

emiljoha commented Feb 1, 2020

GIF of proposed solution to this issue in PR: #1327
more-or-less-polished

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants