Skip to content

Commit

Permalink
Add DNR Balance in USD/BTC, Refresh Button Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
metaspartan committed Jul 4, 2017
1 parent 165d2b8 commit 32acd36
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -4,15 +4,17 @@ Denarius [DNR] NodeJS Web Wallet

[![Dependency Status](https://david-dm.org/carsenk/denariusnodewallet/status.svg?style=flat)](https://david-dm.org/carsenk/denariusnodewallet) [![Build Status](https://travis-ci.org/carsenk/denariusnodewallet.svg?branch=master)](https://travis-ci.org/carsenk/denariusnodewallet) [![Join the chat at https://gitter.im/denariusproject/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/denariusproject/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link) [![Thinkful Pair on Node](https://tf-assets-staging.s3.amazonaws.com/badges/thinkful_repo_badge.svg)](http://start.thinkful.com/node/)

![DesktopWallet](https://user-images.githubusercontent.com/10162347/27757111-fe1c778a-5dba-11e7-8390-67007a97c4d0.png)
![MobileWallet](https://user-images.githubusercontent.com/10162347/27624165-c1a5c54c-5b9c-11e7-965d-e04dfde77539.png)
![DesktopWallet](https://user-images.githubusercontent.com/10162347/27821646-3b31105c-6060-11e7-8c82-cbbbb5b1e663.png)
![MobileWallet](https://user-images.githubusercontent.com/10162347/27821566-f807334c-605f-11e7-8bec-805fe433237f.png)

**Live Demo**: Currently unavailable

Denarius Node Wallet - A NodeJS/MongoDB powered denariusd Web Wallet.

Send and Receive Funds, Create new addresses, View Transactions, Edit your account, and more!

Swap between your DNR Balance in USD and BTC prices calculated from http://coinmarketcap.com/currencies/denarius-dnr/

2FA Authentication is included as well as QR Codes for addresses and 2FA!

Table of Contents
Expand Down
1 change: 1 addition & 0 deletions app.js
Expand Up @@ -27,6 +27,7 @@ const QRCode = require('qrcode');
const base32 = require('thirty-two');
const sprintf = require('sprintf');
const speakeasy = require('speakeasy');
const unirest = require('unirest');

const upload = multer({ dest: path.join(__dirname, 'uploads') });

Expand Down
10 changes: 9 additions & 1 deletion controllers/wallet.js
Expand Up @@ -5,6 +5,7 @@ const User = require('../models/User');
const bitcoin = require('bitcoin');
const WAValidator = require('wallet-address-validator');
const QRCode = require('qrcode');
const unirest = require('unirest');

var sendJSONResponse = function (res, status, content) {
res.status(status);
Expand Down Expand Up @@ -89,12 +90,19 @@ exports.wallet = function (req, res) {

var qr = 'denarius:'+address;

unirest.get("https://api.coinmarketcap.com/v1/ticker/denarius-dnr/")
.headers({'Accept': 'application/json'})
.end(function (result) {
var usdprice = result.body[0]['price_usd'] * balance;
var btcprice = result.body[0]['price_btc'] * balance;

QRCode.toDataURL(qr, function(err, qrcode) {

res.render('account/wallet', { title: 'My Wallet', user: req.user, address: address, qrcode: qrcode, balance: balance.toFixed(8), transactions: transactions });
res.render('account/wallet', { title: 'My Wallet', user: req.user, usd: usdprice.toFixed(2), btc: btcprice.toFixed(8), address: address, qrcode: qrcode, balance: balance.toFixed(8), transactions: transactions });

});
});
});
});
});
/**
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -58,6 +58,7 @@
"sprintf": "^0.1.5",
"thirty-two": "^1.0.2",
"twit": "^2.2.5",
"unirest": "^0.5.1",
"validator": "^7.0.0",
"wallet-address-validator": "git://github.com/carsenk/wallet-address-validator"
},
Expand Down
17 changes: 17 additions & 0 deletions public/css/main.scss
Expand Up @@ -249,6 +249,16 @@ a.minus, a.minus:hover {
font-weight: 300;
}

.swapbalance {
font-size: 21px;
font-family: 'Quicksand', sans-serif;
font-weight: 300;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

.error404 {
font-size: 25px;
color: #000;
Expand Down Expand Up @@ -337,3 +347,10 @@ a.minus, a.minus:hover {
.divTableBody {
display: table-row-group;
}

.fa-spin-hover:hover {
-webkit-animation: fa-spin 2s infinite linear !important;
-moz-animation: fa-spin 2s infinite linear !important;;
-o-animation: fa-spin 2s infinite linear !important;;
animation: fa-spin 2s infinite linear !important;;
}
4 changes: 1 addition & 3 deletions public/js/main.js
@@ -1,3 +1 @@
$(document).ready(function() {

}
//Empty for now
14 changes: 13 additions & 1 deletion views/account/wallet.pug
Expand Up @@ -22,14 +22,26 @@ block content
$("#plus1").html("<i class='fa fa-plus'></i>");
}
}
function swp() {
var button = document.getElementById("swap");
if (button.getAttribute("data-text-swap") == button.innerHTML) {
button.innerHTML = button.getAttribute("data-text-original");
} else {
button.setAttribute("data-text-original", button.innerHTML);
button.innerHTML = button.getAttribute("data-text-swap");
}
}
.page-header
if user
.wallettitle(align='center') DNR
.balance(align='center')
| #{balance}
#swap.swapbalance(onclick='swp()', data-text-swap=btc+' BTC', align='center')
| $#{usd} USD
br
.refresh(align='center')
a(href='/wallet')
i.fa.fa-refresh.fa-2x.fa-spin.lightgrey
i.fa.fa-refresh.fa-2x.fa-spin-hover.lightgrey
br
.row
.col-xl-6
Expand Down

0 comments on commit 32acd36

Please sign in to comment.