Commit 2865d571 authored by Daniel Edgecumbe's avatar Daniel Edgecumbe

Working demo of QR code for receiving

parent 04789b65
Pipeline #282 passed with stages
in 30 seconds
......@@ -292,6 +292,9 @@ div.tx {
text-align: center;
border: 1px dotted lightgray;
}
div.tx.new {
background-color: #ccccff;
}
div.tx span {
display: block;
}
......@@ -319,11 +322,14 @@ div#wallettable {
text-align: center;
}
div#wallettable span {
div#wallettable span, div#wallettable div {
display: block;
font-weight: bold;
margin: 0 auto;
margin-bottom: 2rem;
}
div#wallettable div#waladdrqr img { margin: 0 auto; }
div#wallettable div#waladdrqr canvas { margin: 0 auto; }
div#wallettable span.waladdr {
font-size: 1.5rem;
}
......@@ -333,3 +339,6 @@ div#wallettable span.walbal {
div#wallettable span.walubal {
font-size: 2rem;
}
div#wallettable span.walubal.new {
background-color: #ccccff;
}
......@@ -25,6 +25,7 @@ along with bitcoin-top. If not, see <http://www.gnu.org/licenses/>.
<link rel="stylesheet" href="c3.css">
<script src="vue.min.js"></script>
<script src="moment.min.js"></script>
<script src="qrcode.min.js"></script>
<script src="d3.v5.min.js"></script>
<script src="c3.min.js"></script>
<script src="index.js"></script>
......@@ -165,19 +166,27 @@ along with bitcoin-top. If not, see <http://www.gnu.org/licenses/>.
>
<div id="txcont">
<div id="wallettable">
<template v-if="unused_address">
<span class="waladdr">{{ unused_address }}</span>
</template>
<template v-if="walletinfo">
<span class="walbal">{{ walletinfo.balance }} BTC</span>
</template>
<template v-if="walletinfo">
<span class="walubal">unconfirmed: {{ walletinfo.unconfirmed_balance }} BTC</span>
<span
:class="walletinfo.unconfirmed_balance ? 'new' : ''"
class="walubal"
>unconfirmed: {{ walletinfo.unconfirmed_balance }} BTC</span>
</template>
<div id="waladdrqr"></div>
<template v-if="unused_address">
<span class="waladdr">{{ unused_address }}</span>
</template>
</div>
<div id="txtable">
<template v-if="transactions">
<div class="tx" v-for="tx in transactions">
<div
v-for="tx in transactions"
class="tx"
:class="(now - tx.timereceived) < 300 ? 'new' : ''"
>
<span class="txtxid">{{ tx.txid }}</span>
<span class="txaddr">{{ tx.address }}</span>
<span class="txage">{{ (now - tx.timereceived) | timeInterval }}</span>
......
......@@ -104,6 +104,7 @@ onload = function() {
nettotals: null,
blocktemplate: null,
unused_address: null,
unused_address_qr: null,
transactions: null,
bt_logscale: true,
peers: null,
......@@ -111,7 +112,7 @@ onload = function() {
datas: DATAS,
range: 0,
ranges: RANGES,
tab: "dashboard",
tab: "wallet",
tabs: TABS,
blocks: {},
staging: window.location.host.includes("test"),
......@@ -235,6 +236,7 @@ onload = function() {
asyncRequest(`peerinfo`, processAsyncResponse);
asyncRequest("getmininginfo", dealWithMininginfo);
asyncRequest("getwalletinfo", dealWithWalletinfo);
asyncRequest("listreceivedbyaddress/0/true", dealWithRBA);
asyncRequest("listtransactions/*/100", dealWithTransactions);
}, 5000);
......@@ -314,14 +316,31 @@ onload = function() {
// just use the first one
l.sort();
if (l && l[0] !== app.unused_address) {
if (l.length > 0 && l[0] !== app.unused_address) {
app.unused_address = l[0];
let qrtext = `bitcoin:${l[0]}`;
if (app.unused_address_qr === null) {
app.unused_address_qr = new QRCode("waladdrqr", {
text: qrtext,
correctLevel: QRCode.CorrectLevel.H,
});
return;
}
app.unused_address_qr.clear();
app.unused_address_qr.makeCode(qrtext);
return;
}
if (app.unused_address !== null) {
// there aren't any... getnewaddress?
// TODO
return;
if (l.length === 0) {
// Get another address and look again
// TODO should probably lock this down a bit server-side
// e.g. only allow 10 outstanding max
asyncRequest("getnewaddress", function(r, j) {
// TODO check success
console.log("getnewaddress...");
console.log(j);
asyncRequest("listreceivedbyaddress/0/true", dealWithRBA);
});
}
}
......@@ -331,7 +350,15 @@ onload = function() {
return;
}
app.transactions = j.result;
let t = j.result;
t.sort(function(a, b) {
if (a.timereceived < b.timereceived) { return -1; }
if (a.timereceived > b.timereceived) { return 1; }
return 0;
}).reverse();
app.transactions = t;
}
let dealWithPeerinfo = function(peerinfo) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment