Browse Source

lightning pagee view

readme
Mayank 5 years ago
parent
commit
afd2243511
  1. 2
      package.json
  2. 7
      src/components/InputCopy.vue
  3. 4
      src/components/LightningWallet.vue
  4. 4
      src/global-styles/custom.scss
  5. 69
      src/views/Lightning.vue
  6. 16
      yarn.lock

2
package.json

@ -12,7 +12,7 @@
"dependencies": {
"animate.css": "^3.7.2",
"axios": "^0.19.2",
"bootstrap-vue": "^2.2.2",
"bootstrap-vue": "^2.11.0",
"core-js": "^3.4.4",
"countup.js": "^2.0.4",
"moment": "^2.24.0",

7
src/components/InputCopy.vue

@ -1,5 +1,5 @@
<template>
<b-input-group size="sm">
<b-input-group :size="size">
<b-form-input ref="copy-input-field" type="text" readonly v-model="value"></b-form-input>
<b-input-group-append>
@ -14,7 +14,10 @@
<script>
export default {
props: {
size: String,
size: {
type: String,
default: "sm"
},
value: String
},
data() {

4
src/components/LightningWallet.vue

@ -627,7 +627,7 @@ export default {
type,
amount: Number(tx.value),
timestamp: new Date(Number(tx.creationDate) * 1000),
description: tx.memo,
description: tx.memo || "Direct payment from a node",
expiresOn: new Date(
(Number(tx.creationDate) + Number(tx.expiry)) * 1000
)
@ -681,7 +681,7 @@ export default {
if (!tx.description) {
//example in case of a keysend tx
tx.description = "Direct payment to node";
tx.description = "Direct payment to a node";
continue;
}

4
src/global-styles/custom.scss

@ -39,6 +39,10 @@ $dark-mode-card-bg: #2A3244;
}
// Overrides
a {
outline: 0 !important;
}
.btn, button {
outline: 0 !important;
border: none !important;

69
src/views/Lightning.vue

@ -100,6 +100,14 @@
></bitcoin-network-stat>
</b-col>
</b-row>
<!-- List of channels -->
<!-- <div>
<h4
v-for="channel in state.channels"
:key="channel.channelPoint"
>{{channel.capacity}}</h4>
</div>-->
</div>
</div>
</card-widget>
@ -110,6 +118,7 @@
<script>
import axios from "axios";
import moment from "moment";
import QrcodeVue from "qrcode.vue";
import CardWidget from "@/components/CardWidget";
@ -136,7 +145,12 @@ export default {
numPeers: 0,
status: "Loading",
pubKey: "",
channels: []
channels: [],
transactions: [],
btcDepositAddress: "",
btcWithdrawAddress: "",
btcWithdrawAmount: "",
btcWithdrawUnit: "Sats" //sats or btc
}
};
},
@ -148,7 +162,7 @@ export default {
// let totalCapacity = 0;
for (let channel of this.state.channels) {
// if (!channel.active) continue;
if (!channel.active) continue;
// activeChannels++;
totalLocalBalance += Number(channel.localBalance);
totalRemoteBalance += Number(channel.remoteBalance);
@ -235,6 +249,24 @@ export default {
// }
// }
this.$refs["public-key-modal"].show();
},
async showDepositAddress() {
try {
const res = await axios.get(`v1/lnd/address`);
this.state.btcDepositAddress = res.data.address;
} catch (err) {
console.log(err);
alert(err.response.data);
}
this.$refs["deposit-modal"].show();
},
changeBtcWithdrawUnit() {
console.log(this.state.btcWithdrawUnit);
if (this.state.btcWithdrawUnit === "Sats") {
this.state.btcWithdrawUnit = "BTC";
} else if (this.state.btcWithdrawUnit === "BTC") {
this.state.btcWithdrawUnit = "Sats";
}
}
},
created() {
@ -262,7 +294,7 @@ export default {
// this.state.loading = false;
});
//Get LND Info
//Get LND Info for showing stats
axios
.get(`v1/pages/lnd/`)
.then(res => {
@ -270,8 +302,6 @@ export default {
this.state.lndVersion = res.data.lightningInfo.version;
this.state.numPeers = res.data.lightningInfo.numPeers;
this.state.numActiveChannels = res.data.lightningInfo.numActiveChannels;
window.lnd = res.data;
})
.catch(error => {
console.log(error);
@ -281,7 +311,36 @@ export default {
// this.state.loading = false;
});
//Get channels
this.fetchChannels();
//Get bitcoin onchain transactions
axios
.get(`v1/lnd/transaction`)
.then(res => {
const txs = res.data.map(tx => {
return {
amount:
parseInt(tx.amount) > 0
? "+" + parseInt(tx.amount).toLocaleString() + " Sats"
: parseInt(tx.amount).toLocaleString() + " Sats",
type: tx.type,
time: moment(Number(tx.timeStamp) * 1000).format(
"MMMM Do YYYY, h:mm:ss A"
),
transaction: tx.txHash
};
});
this.state.transactions = txs;
})
.catch(error => {
console.log(error);
alert(error);
})
.finally(() => {
// this.state.loading = false;
});
},
watch: {},
components: {

16
yarn.lock

@ -1708,14 +1708,14 @@ boolbase@^1.0.0, boolbase@~1.0.0:
resolved "https://registry.npm.taobao.org/boolbase/download/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24=
bootstrap-vue@^2.2.2:
version "2.2.2"
resolved "https://registry.npm.taobao.org/bootstrap-vue/download/bootstrap-vue-2.2.2.tgz#750d461d18352e2fd6cd2debfe52ebeb125c191f"
integrity sha1-dQ1GHRg1Li/WzS3r/lLr6xJcGR8=
bootstrap-vue@^2.11.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/bootstrap-vue/-/bootstrap-vue-2.11.0.tgz#9994b9529c4d36c7a89812f91e4aad1299f15829"
integrity sha512-T23+aVVSDifX1SsI5y69bYZzbm8iQHlmgiBUw9XxY1KTw/fb4xvUq4+Y01Tsaul04+zmrUah/5zvUGKLwTcH7A==
dependencies:
"@nuxt/opencollective" "^0.3.0"
bootstrap ">=4.4.1 <5.0.0"
popper.js "^1.16.0"
popper.js "^1.16.1"
portal-vue "^2.1.7"
vue-functional-data-merge "^3.1.0"
@ -5954,10 +5954,10 @@ pkg-dir@^4.1.0:
dependencies:
find-up "^4.0.0"
popper.js@^1.16.0:
popper.js@^1.16.1:
version "1.16.1"
resolved "https://registry.npm.taobao.org/popper.js/download/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
integrity sha1-KiI8s9x7YhPXQOQDcr5A3kPmWxs=
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==
portal-vue@^2.1.7:
version "2.1.7"

Loading…
Cancel
Save