joule-labs / joule-extension

Lightning payments extension for Chrome
MIT License
353 stars 62 forks source link

How do I embed an invoice/webln/bolt link so I can test the prompt? #290

Closed spirobel closed 2 years ago

spirobel commented 2 years ago

Hi, I saw there is a way to generate these ln invoices in joule. I pasted one as a test into my website as a link, but it doesnt trigger the prompt mentioned in the readme.

│   ├── prompt             # Prompt client, opened by WebLN and BOLT-11 links

Is there an example where I can test this prompt? Kind Regards, Spriobel

wbobeirne commented 2 years ago

Can you share the code for your link? Joule tries to intercept clicks on links that start with lightning:, you can read the code here: https://github.com/joule-labs/joule-extension/blob/develop/src/content_script/index.ts#L48-L67

Unfortunately this is really finnicky; browsers don't let you intercept link open intents so certain ways of opening links don't work (e.g. window.location.href = 'lightning:... or window.replace('lightning:...')) so this only works on clicking <a> tag links.

spirobel commented 2 years ago

wow thanks a lot! that is really straight forward. Yesterday I looked up how browser plugins can handle custom protocols so I immediately understood the code. The issue was that my link started with ln... I just copy and pasted it from joule. I didnt know that I would have to add lightning in front, but in hindsight it makes a lot of sense. I will retry and check if it works with the protocol: in front.

Thanks a lot! Joule is really cool!

wbobeirne commented 2 years ago

The issue was that my link started with ln...

Ah yeah every link needs to start with [protocol]:[value] regardless of what it's linking to. For instance mailto:email@email.com or bitcoin:bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W. It's not a valid URI if it doesn't include the protocol and a colon first, in this case lightning:ln....