From 902a9bdc4215d73f1b621a0abf19644215f9e376 Mon Sep 17 00:00:00 2001
From: Uthpala Heenatigala
+
Deezy.io: Do onchain to offchain and vice-versa swaps
@@ -17,17 +22,19 @@
- API DOCS
Created by, - UthpalaUthpala
@@ -39,18 +46,25 @@ label="API info" :content-inset-level="0.5" > -
GET (mainnet)
https://api.deezy.io/v1/swap/info
-
GET (testnet)
https://api-testnet.deezy.io/v1/swap/info
@@ -77,14 +91,15 @@
- Initiate a new swap to send lightning btc in exchange for on-chain btc
+ Initiate a new swap to send lightning btc in exchange for on-chain
+ btc
POST (mainnet)
https://api.deezy.io/v1/swap
-
+
POST (testnet)
https://api-testnet.deezy.io/v1/swap
@@ -122,7 +137,7 @@
https://api.deezy.io/v1/swap/lookup
-
+
GET (testnet)
https://api-testnet.deezy.io/v1/swap/lookup
@@ -141,18 +156,30 @@
POST (mainnet)
https://api.deezy.io/v1/source
-
POST (testnet)
https://api-testnet.deezy.io/v1/source
@@ -178,7 +205,12 @@
GET (testnet)
https://api-testnet.deezy.io/v1/source/lookup
diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html
index a708d4aa..537ed887 100644
--- a/lnbits/extensions/deezy/templates/deezy/index.html
+++ b/lnbits/extensions/deezy/templates/deezy/index.html
@@ -4,9 +4,7 @@
-
- Deezy
-
+ Deezy
@@ -32,7 +30,10 @@
-
+
LIGHTNING BTC -> BTC
- Cancel
+ Cancel
@@ -91,7 +89,12 @@
>
-
+
-
+
BTC -> LIGHTNING BTC
- Cancel
+ Cancel
@@ -138,7 +141,7 @@
{% raw %}
- Address - {{ swapBtcToLn.response.address }}
+ Address - {{ swapBtcToLn.response.address }}
Commitment - {{ swapBtcToLn.response.commitment }}
@@ -153,6 +156,7 @@
+
{% raw %}
@@ -192,7 +196,7 @@
mixins: [windowMixin],
data: function () {
return {
- lightning_btc: "",
+ lightning_btc: '',
tools: [],
swapLnToBtc: {
show: false,
@@ -202,32 +206,35 @@
},
response: null,
invoicePaid: false,
- onchainTxId: null,
+ onchainTxId: null
},
swapBtcToLn: {
show: false,
showDetails: false,
data: {},
response: {}
- },
+ }
}
},
methods: {
checkIfInvoiceIsPaid() {
- if (this.swapLnToBtc.response && !this.swapLnToBtc.invoicePaid ) {
+ if (this.swapLnToBtc.response && !this.swapLnToBtc.invoicePaid) {
var self = this
let interval = setInterval(() => {
- axios.get(`https://api.deezy.io/v1/swap/lookup?bolt11_invoice=${self.swapLnToBtc.response}`)
- .then(function (response){
- if (response.data.on_chain_txid || count > 4) {
- self.swapLnToBtc = {
- ...self.swapLnToBtc,
- invoicePaid: true,
- onchainTxId: response.data.on_chain_txid
- }
- clearInterval(interval)
- }
- })
+ axios
+ .get(
+ `https://api.deezy.io/v1/swap/lookup?bolt11_invoice=${self.swapLnToBtc.response}`
+ )
+ .then(function (response) {
+ if (response.data.on_chain_txid || count > 4) {
+ self.swapLnToBtc = {
+ ...self.swapLnToBtc,
+ invoicePaid: true,
+ onchainTxId: response.data.on_chain_txid
+ }
+ clearInterval(interval)
+ }
+ })
}, 4000)
}
},
@@ -236,43 +243,47 @@
},
sendLnToBtc() {
var self = this
- axios.post('https://api.deezy.io/v1/swap', {
- amount_sats: parseInt(self.swapLnToBtc.data.amount),
- on_chain_address: self.swapLnToBtc.data.on_chain_address,
- on_chain_sats_per_vbyte: parseInt(self.swapLnToBtc.data.on_chain_sats_per_vbyte)
- })
- .then(function (response) {
- self.swapLnToBtc = {
- ...self.swapLnToBtc,
- showInvoice: true,
- response: response.data.bolt11_invoice
- }
- self.checkIfInvoiceIsPaid()
- })
- .catch(function (error) {
- console.log(error);
- });
+ axios
+ .post('https://api.deezy.io/v1/swap', {
+ amount_sats: parseInt(self.swapLnToBtc.data.amount),
+ on_chain_address: self.swapLnToBtc.data.on_chain_address,
+ on_chain_sats_per_vbyte: parseInt(
+ self.swapLnToBtc.data.on_chain_sats_per_vbyte
+ )
+ })
+ .then(function (response) {
+ self.swapLnToBtc = {
+ ...self.swapLnToBtc,
+ showInvoice: true,
+ response: response.data.bolt11_invoice
+ }
+ self.checkIfInvoiceIsPaid()
+ })
+ .catch(function (error) {
+ console.log(error)
+ })
},
sendBtcToLn() {
var self = this
- axios.post('https://api.deezy.io/v1/source', {
- lnurl_or_lnaddress: self.swapBtcToLn.data.lnurl_or_lnaddress,
- })
- .then(function (response) {
- self.swapBtcToLn = {
- ...self.swapBtcToLn,
- response: response.data,
- showDetails: true,
- }
- })
- .catch(function (error) {
- console.log(error);
- });
+ axios
+ .post('https://api.deezy.io/v1/source', {
+ lnurl_or_lnaddress: self.swapBtcToLn.data.lnurl_or_lnaddress
+ })
+ .then(function (response) {
+ self.swapBtcToLn = {
+ ...self.swapBtcToLn,
+ response: response.data,
+ showDetails: true
+ }
+ })
+ .catch(function (error) {
+ console.log(error)
+ })
},
resetSwapBtcToLn() {
this.swapBtcToLn = {
...this.swapBtcToLn,
- data: {},
+ data: {}
}
},
resetSwapLnToBtc() {
@@ -280,7 +291,7 @@
...this.swapLnToBtc,
data: {}
}
- },
+ }
}
})