BTC Swap Quote Requester
The unwavering dedication of the cryptocurrency community in building an economy that is open to anyone and everyone inspired us to build BTC Swap Quote Requester. Utilizing bitcoin lightning network technology, the app requests btc swap quote from the mainnet and shows it to the user. The user needs to enter an invoice and a refund address. The app's present version is 1.0.0. The app uses redshift.js from radar ion to request the quote. The version that's in use is 0.4.2 i.e. the latest version. The app also uses express and body-parser. It uses node engine 8.x. On the front end, there are two text boxes, one for the invoice and the other one for refund address. On the jquery click event handler of the request quote button, we call a function
requestquoteclickeventhandler() thrice. The reason we call the function thrice is we noticed the present version of the redshift.js npm package has a tendency of failing silently even when there is a catch block. In order to ensure the user gets the quote, we call the function thrice. Inside the
requestquoteclickeventhandler() function there is an ajax call of type post to the
/request-quote endpoint of the server. The invoice and the refund address is sent to the endpoint in the data field. In success, the quote is received in response and shown to the user. If incorrect input data is submitted, an empty object is received as response and a user-friendly error message is shown. On the backend, there are two routes. The / get route serves the
index.html file. The /request-quote post route receives the user-submitted data, sends them in the
requestQuote call, gets the quote and sends the response to the front end. We are using an async-await mechanism to get the quote. We have try-catch implementation for error handling. To test the app, please visit, btc-swap-quote-requester.glitch.me. You might need to wait for a little as the app loads. When the app is loaded, you will see two text boxes where you need to enter the invoice and the refund address, respectively. You can get an invoice easily from a site such as, bottle.li. You can sign up via twitter. On the bottle.li home screen, click on receive button, enter 1000000 sat (redshift's minimum and maximum amount for btc is 30000 sat and 1000000 sat, respectively), press create invoice, and then copy the invoice. You can now paste the invoice inside the text box on the app. Next, you need to enter a refund address. It needs to be a valid bitcoin address. You can get one from a site such as, blockchain.com. Please sign up, login, and on the home page, go to settings, and then wallets & addresses. Press the request button, a modal will open, and then you can copy the address. You can now paste it inside the text box on the app. Please press the request quote button and wait a few seconds and if you have followed the above-mentioned steps correctly, you should see the quote in json format. A few open-source contributions were made to the redshift-monorepo github repository during the development of the app. 3 issues were posted. In fact, the first 3 issues are posted by us and will help developers who are getting started with the npm package and the lightning network.