diff --git a/README.md b/README.md index 7a2a45f..60ad5ac 100644 --- a/README.md +++ b/README.md @@ -50,21 +50,21 @@ to the host and port on which your lntip instance is running: #### Usage -To request a lightning payment simply call `request()` on a `new LnTip({amount: amount, memo: memo})`: +To request a lightning payment simply call `request()` on a `new LnTip({value: value, memo: memo})`: ```js -new LnTip({ amount: 1000, memo: 'high5' }).request() +new LnTip({ value: 1000, memo: 'high5' }).request() ``` Use it from a plain HTML link: ```html - Tip me + Tip me ``` ##### More advanced JS API: ```js -let tip = new LnTip({ amount: 1000, memo: 'high5' }); +let tip = new LnTip({ value: 1000, memo: 'high5' }); // get a new invoice and watch for a payment // promise resolves if the invoice is settled @@ -73,7 +73,7 @@ tip.requestPayment().then((invoice) => { }); // create a new invoice -tip.getInvoice().then((invoice) => { +tip.addInvoice().then((invoice) => { console.log(invoice.PaymentRequest) }); @@ -84,6 +84,9 @@ tip.watchPayment().then((invoice) => { ``` +## Development + + ## Contributing diff --git a/assets/lntip.js b/assets/lntip.js index b73ddfa..d261516 100644 --- a/assets/lntip.js +++ b/assets/lntip.js @@ -4,7 +4,7 @@ LnTip = function (options) { var host = document.getElementById('lntip-script').getAttribute('lntip-host'); this.host = options.host || host; - this.amount = options.amount; + this.value = options.value; this.memo = options.memo || ''; this.loadStylesheet(); // load it early that styles are ready when the popup is opened } @@ -52,9 +52,9 @@ LnTip.prototype.watchPayment = function () { return new Promise((resolve, reject) => { this.paymentWatcher = window.setInterval(() => { - this._fetch(`${this.host}/settled/${this.invoice.ImplDepID}`) - .then((settled) => { - if (settled) { + this._fetch(`${this.host}/v1/invoice/${this.invoice.ImplDepID}`) + .then((invoice) => { + if (invoice.settled) { this.invoice.settled = true; this.stopWatchingPayment(); resolve(this.invoice); @@ -72,25 +72,25 @@ LnTip.prototype.stopWatchingPayment = function () { LnTip.prototype.payWithWebln = function () { if (!webln.isEnabled) { webln.enable().then((weblnResponse) => { - return webln.sendPayment({ paymentRequest: this.invoice.PaymentRequest }) + return webln.sendPayment({ paymentRequest: this.invoice.payment_request }) }).catch((e) => { return this.showPaymentRequest(); }) } else { - return webln.sendPayment({ paymentRequest: this.invoice.PaymentRequest }) + return webln.sendPayment({ paymentRequest: this.invoice.payment_request }) } } LnTip.prototype.showPaymentRequest = function () { var content = `