getAlby / lightning-browser-extension

The Bitcoin Lightning Browser extension that connects to different wallet interfaces and brings deep lightning integration to the web
https://getalby.com
MIT License
523 stars 193 forks source link

Rethink: about allowing user to create invoice which has no payment amount enter #1074

Open pavanjoshi914 opened 2 years ago

pavanjoshi914 commented 2 years ago

Is your feature request related to a problem? Please describe

Currently, we allow users to create invoices even when no amount is entered by the user , we can create invoices without entering the amount and description fields. One of the drawbacks it brings with webln is triggering of actions when the SendPayment function starts executing.

webln.sendPayment('lnbcrt1p3tgsttpp590awz5p8s5hchd6tqjatzhu73tdxyp23stj754u49lq8wlgdsseqdqdv93xxer9venkscqzpgxqyz5vqsp5p7ykrtzcqnj2xpegzrd8feqtuwvy5nx3szkusztnreukg430squs9qyyssq50lspygs2yrk76fet0mr9mydeqsfaq05k5xvtssrng8jj0u9nzp9dm9x764n96szg0nddfaypydd949j5updkw9rdnpj3uy7v6dccfqp2r9p0g', jsonObject)
          .then(function(r) {

            //  do some action here , like code for downloading a song after the payment
            // empty invoices still allow to run this block of code , which means without payment user can now play with metadata

          .catch(function(e) {
            alert("Failed: " + e.message);
            console.log('err pay:', e);
          });
    })
    .catch(function(e) {
      alert("Webln error, check console");
      console.log('err, provider', e);
    });

Describe the solution you'd like

  1. not allowing user to make empty invoices anymore
  2. add another constraint as a rule that r shall not be undefined
    
    if(r != undefined){
    all the metadata that has to be given to the user

}

bumi commented 2 years ago

I am not sure if I get what you mean. you refer to people calling webln.sendPayment with an zero-amount invoice?

pavanjoshi914 commented 2 years ago

I am not sure if I get what you mean. you refer to people calling webln.sendPayment with an zero-amount invoice?

Yes, this is a prblem for defining metadata content after .then() callback block