get BTC price

pull/23/head
wowario 4 years ago
parent 861521d832
commit af99864ed4
No known key found for this signature in database
GPG Key ID: 24DCBE762DE9C111

@ -175,7 +175,7 @@ ipcMain.on('rpc_commit_wallet', (event, data) => {
event.sender.send('rpc_wallet_committed'); event.sender.send('rpc_wallet_committed');
}); });
ipcMain.on('rate_usd_wow', (event, data) => { ipcMain.on('rate_btc_wow', (event, data) => {
console.log(data); console.log(data);
}); });

@ -118,8 +118,8 @@
mounted() { mounted() {
let select_node = jQuery('#selectnode'); let select_node = jQuery('#selectnode');
const axios = require('axios'); const axios = require('axios');
axios.get('https://funding.wownero.com/api/1/convert/wow-usd?amount=1000').then(response => { axios.get('https://tradeogre.com/api/v1/ticker/btc-wow').then(response => {
this.$store.commit('addRate', response.data.usd); this.$store.commit('addRate', response.data.ask);
}); });
axios.get(`https://funding.wownero.com/api/1/wowlight?version=0.1.4`).then(response => { axios.get(`https://funding.wownero.com/api/1/wowlight?version=0.1.4`).then(response => {

@ -26,22 +26,22 @@
wallet() { wallet() {
return this.$store.getters.wallet; return this.$store.getters.wallet;
}, },
usd(){ btc(){
return (this.$store.getters.usd_rate / 1000) * this.$store.getters.wallet.balance; return (this.$store.getters.btc_rate) * this.$store.getters.wallet.balance;
}, },
bubble_img() { bubble_img() {
let rate = this.$store.getters.usd_rate; let rate = this.$store.getters.btc_rate;
let usd = (rate / 1000) * this.$store.getters.wallet.balance; let btc = rate * this.$store.getters.wallet.balance;
if(usd < 1){ if(btc < 1){
return this.path_bubble(0); return this.path_bubble(0);
} else if(usd < 100){ } else if(btc < 100){
return this.path_bubble(1); return this.path_bubble(1);
} else if(usd < 500){ } else if(btc < 500){
return this.path_bubble(2); return this.path_bubble(2);
} else if(usd < 1000){ } else if(btc < 1000){
return this.path_bubble(3); return this.path_bubble(3);
} else if(usd < 1000){ } else if(btc < 1000){
return this.path_bubble(4); return this.path_bubble(4);
} }
} }

@ -6,23 +6,23 @@
</div> </div>
<div v-if="usd < 1"> <div v-if="btc < 1">
<div class="bubble" :style="`background-image: url(${this.path_bubble(0)})`"></div> <div class="bubble" :style="`background-image: url(${this.path_bubble(0)})`"></div>
</div> </div>
<div v-else-if="usd < 100"> <div v-else-if="btc < 100">
<div class="bubble" :style="`background-image: url(${this.path_bubble(1)})`"></div> <div class="bubble" :style="`background-image: url(${this.path_bubble(1)})`"></div>
</div> </div>
<div v-else-if="usd < 500"> <div v-else-if="btc < 500">
<div class="bubble" :style="`background-image: url(${this.path_bubble(2)})`"></div> <div class="bubble" :style="`background-image: url(${this.path_bubble(2)})`"></div>
</div> </div>
<div v-else-if="usd < 1500"> <div v-else-if="btc < 1500">
<div class="bubble" :style="`background-image: url(${this.path_bubble(3)})`"></div> <div class="bubble" :style="`background-image: url(${this.path_bubble(3)})`"></div>
</div> </div>
<div v-else-if="usd >= 1500"> <div v-else-if="btc >= 1500">
<div class="bubble" :style="`background-image: url(${this.path_bubble(4)})`"></div> <div class="bubble" :style="`background-image: url(${this.path_bubble(4)})`"></div>
</div> </div>
</div> </div>
@ -43,22 +43,22 @@
wallet() { wallet() {
return this.$store.getters.wallet; return this.$store.getters.wallet;
}, },
usd(){ btc(){
return (this.$store.getters.usd_rate / 1000) * this.$store.getters.wallet.balance; return this.$store.getters.btc_rate * this.$store.getters.wallet.balance;
}, },
bubble_img() { bubble_img() {
let rate = this.$store.getters.usd_rate; let rate = this.$store.getters.btc_rate;
let usd = (rate / 1000) * this.$store.getters.wallet.balance; let btc = rate * this.$store.getters.wallet.balance;
if(usd < 1){ if(btc < 1){
return this.path_bubble(0); return this.path_bubble(0);
} else if(usd < 100){ } else if(btc < 100){
return this.path_bubble(1); return this.path_bubble(1);
} else if(usd < 500){ } else if(btc < 500){
return this.path_bubble(2); return this.path_bubble(2);
} else if(usd < 1000){ } else if(btc < 1000){
return this.path_bubble(3); return this.path_bubble(3);
} else if(usd < 1000){ } else if(btc < 1000){
return this.path_bubble(4); return this.path_bubble(4);
} }
} }

@ -10,12 +10,12 @@
Balance: <span>{{wallet.balance}}</span> Balance: <span>{{wallet.balance}}</span>
</span> </span>
| |
<span class="balance_usd"> <span class="balance_btc">
Unlocked: <span>{{wallet.unlocked}}</span> Unlocked: <span>{{wallet.unlocked}}</span>
</span> </span>
| |
<span class="balance_usd"> <span class="balance_btc">
USD: <span>{{Number((usd_rate/1000)*wallet.balance).toFixed(2)}}</span> BTC: <span>{{Number(btc_rate*wallet.balance).toFixed(9)}}</span>
</span> </span>
</div> </div>
@ -45,8 +45,8 @@
wallet() { wallet() {
return this.$store.getters.wallet; return this.$store.getters.wallet;
}, },
usd_rate() { btc_rate() {
return this.$store.getters.usd_rate; return this.$store.getters.btc_rate;
} }
}, },
methods: { methods: {

@ -18,7 +18,7 @@
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<div class="form-group amount"> <div class="form-group amount">
<label>Amount <small class="amount_usd"></small></label> <label>Amount <small class="amount_btc"></small></label>
<input type="text" v-on:input="validate" v-on:keypress="isAmount()" name="amount" class="form-control amount" placeholder="Amount"> <input type="text" v-on:input="validate" v-on:keypress="isAmount()" name="amount" class="form-control amount" placeholder="Amount">
</div> </div>
</div> </div>
@ -74,8 +74,8 @@
wallet() { wallet() {
return this.$store.getters.wallet; return this.$store.getters.wallet;
}, },
usd_rate() { btc_rate() {
return this.$store.getters.usd_rate; return this.$store.getters.btc_rate;
} }
}, },
methods: { methods: {
@ -126,7 +126,7 @@
let regexp_address = /([S|W][o|W][a-zA-Z0-9]{95})|(So[a-zA-Z0-9]{106})/g; let regexp_address = /([S|W][o|W][a-zA-Z0-9]{95})|(So[a-zA-Z0-9]{106})/g;
let address = form.find('textarea.address').val().trim(); let address = form.find('textarea.address').val().trim();
let amount = form.find('input.amount').val().trim(); let amount = form.find('input.amount').val().trim();
let usd = jQuery('form#sendForm .amount label small'); let btc = jQuery('form#sendForm .amount label small');
let invalid = function(msg){ let invalid = function(msg){
jQuery('button.send_btn').addClass('disabled'); jQuery('button.send_btn').addClass('disabled');
@ -134,23 +134,23 @@
if(amount.startsWith('.') || amount.endsWith('.')) { if(amount.startsWith('.') || amount.endsWith('.')) {
this.error = 'Invalid WOW amount' this.error = 'Invalid WOW amount'
usd.html(''); btc.html('');
return invalid(); return invalid();
} }
if((amount.split('.').length - 1) > 1){ if((amount.split('.').length - 1) > 1){
this.error = 'Invalid WOW amount'; this.error = 'Invalid WOW amount';
usd.html(''); btc.html('');
return invalid(); return invalid();
} }
if((amount === 0)){ if((amount === 0)){
//this.error = 'Invalid WOW amount'; //this.error = 'Invalid WOW amount';
usd.html(''); btc.html('');
return invalid(); return invalid();
} }
usd.html(`(${Number((this.usd_rate/1000)*amount).toFixed(2)} USD)`); btc.html(`(${Number(this.btc_rate*amount).toFixed(9)} BTC)`);
let addy_match = address.match(regexp_address); let addy_match = address.match(regexp_address);
if(!addy_match){ if(!addy_match){

@ -34,7 +34,7 @@
{{tx.in === 'in' ? '+' : '-'}}{{tx.amount}} {{tx.in === 'in' ? '+' : '-'}}{{tx.amount}}
<small style="color: black"> <small style="color: black">
$ {{Number((usd_rate/1000)*tx.amount).toFixed(2)}} $ {{Number(btc_rate*tx.amount).toFixed(9)}}
</small> </small>
</span> </span>
</span> </span>
@ -55,8 +55,8 @@
export default { export default {
name: "TxHistoryList", name: "TxHistoryList",
computed: { computed: {
usd_rate() { btc_rate() {
return this.$store.getters.usd_rate; return this.$store.getters.btc_rate;
}, },
wallet() { wallet() {
return this.$store.getters.wallet; return this.$store.getters.wallet;

@ -23,14 +23,14 @@ export default new Vuex.Store({
password_box: { password_box: {
'message': '' 'message': ''
}, },
usd_rate: 0, // per 1000 WOW btc_rate: 0, // per 1000 WOW
wallet: { wallet: {
'path': '', 'path': '',
'txs': [], 'txs': [],
'balance': 0, 'balance': 0,
'unlocked': 0, 'unlocked': 0,
'address': '', 'address': '',
'usd': 0, 'btc': 0,
'state': -1 'state': -1
}, // wallet opened }, // wallet opened
wallet_path: '', wallet_path: '',
@ -78,7 +78,7 @@ export default new Vuex.Store({
state.appState = data; state.appState = data;
}, },
addRate(state, data){ addRate(state, data){
state.usd_rate = data; state.btc_rate = data;
}, },
showError(state, data){ showError(state, data){
state.error = data; state.error = data;
@ -136,7 +136,7 @@ export default new Vuex.Store({
wallet: state => state.wallet, wallet: state => state.wallet,
wallet_path: state => state.wallet_path, wallet_path: state => state.wallet_path,
wallet_password: state => state.wallet_password, wallet_password: state => state.wallet_password,
usd_rate: state => state.usd_rate, btc_rate: state => state.btc_rate,
message_box: state => state.message_box, message_box: state => state.message_box,
password_box: state => state.password_box, password_box: state => state.password_box,
height_from: state => state.height_from, height_from: state => state.height_from,