mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-24 10:41:23 +00:00
API: wholesale conversion back to Base58
XmlJavaTypeAdapter api.Base58TypeAdapter converts byte[] to Base58. This XmlAdapter is applied at package-level to all packages inside data and api.models. So no need to annotate every byte[] property! Added package-info-maven-plugin to pom.xml to do this. block-explorer.html fixed to show/use base58 again Some data objects (e.g. TransactionData) have added XmlElements that convert public keys to addresses, for convenience. Several API calls updated to return specifically text/plain instead of ambiguous application/json and/or text/plain. (Typically API calls that return a single value, e.g. an integer, like /blocks/height).
This commit is contained in:
@@ -51,14 +51,13 @@
|
||||
for (var i=0; i<transactions.length; ++i) {
|
||||
var tx = transactions[i];
|
||||
var txTimestamp = new Date(tx.timestamp).toUTCString();
|
||||
var txCreatorAddress = publicKeyToAddress(base64ToArray(tx.creatorPublicKey)); // currently base64 but likely to be base58 in the future
|
||||
|
||||
var row = '<tr><td>' + tx.type + '</td>' +
|
||||
'<td>' + txTimestamp + '</td>' +
|
||||
'<td class="addr">' + addressAsLink(txCreatorAddress) + '</td>' +
|
||||
'<td class="addr">' + addressAsLink(tx.creatorAddress) + '</td>' +
|
||||
'<td>' + tx.fee + ' QORA</td>' +
|
||||
'<td class="sig">' + Base58.encode(base64ToArray(tx.signature)) + '</td>' +
|
||||
'<td class="ref">' + Base58.encode(base64ToArray(tx.reference)) + '</td></tr>';
|
||||
'<td class="sig">' + tx.signature + '</td>' +
|
||||
'<td class="ref">' + tx.reference + '</td></tr>';
|
||||
|
||||
html += row;
|
||||
}
|
||||
@@ -119,14 +118,13 @@
|
||||
for (var i=0; i<transactions.length; ++i) {
|
||||
var tx = transactions[i];
|
||||
var txTimestamp = new Date(tx.timestamp).toUTCString();
|
||||
var txCreatorAddress = publicKeyToAddress(base64ToArray(tx.creatorPublicKey)); // currently base64 but likely to be base58 in the future
|
||||
|
||||
var row = '<tr><td>' + tx.type + '</td>' +
|
||||
'<td>' + txTimestamp + '</td>' +
|
||||
'<td class="addr">' + addressAsLink(txCreatorAddress) + '</td>' +
|
||||
'<td class="addr">' + addressAsLink(tx.creatorAddress) + '</td>' +
|
||||
'<td>' + tx.fee + ' QORA</td>' +
|
||||
'<td class="sig">' + Base58.encode(base64ToArray(tx.signature)) + '</td>' +
|
||||
'<td class="ref">' + Base58.encode(base64ToArray(tx.reference)) + '</td></tr>';
|
||||
'<td class="sig">' + tx.signature + '</td>' +
|
||||
'<td class="ref">' + tx.reference + '</td></tr>';
|
||||
|
||||
html += row;
|
||||
}
|
||||
@@ -138,17 +136,7 @@
|
||||
|
||||
function renderBlockInfo(e) {
|
||||
var blockData = e.target.response.block;
|
||||
|
||||
// These properties are currently emitted as base64 by API but likely to be base58 in the future, so convert them
|
||||
var props = [ "signature", "reference", "transactionsSignature", "generatorPublicKey", "generatorSignature" ];
|
||||
for (var i=0; i<props.length; ++i) {
|
||||
var p = props[i];
|
||||
blockData[p] = Base58.encode(base64ToArray(blockData[p]));
|
||||
}
|
||||
|
||||
// convert generator public key into address
|
||||
blockData.generator = publicKeyToAddress(base64ToArray(blockData.generatorPublicKey)); // currently base64 but likely to be base58 in the future
|
||||
|
||||
|
||||
var html = '<h1>Block ' + blockData.height + '</h1>';
|
||||
html += '<table id="block"><tr><th>Property</th><th>Value</th></tr>';
|
||||
|
||||
@@ -163,7 +151,7 @@
|
||||
html += '<td>';
|
||||
}
|
||||
|
||||
if (p == "generator") {
|
||||
if (p == "generatorAddress") {
|
||||
html += addressAsLink(blockData[p]);
|
||||
} else {
|
||||
html += blockData[p];
|
||||
@@ -200,12 +188,11 @@
|
||||
|
||||
var ourHeight = blockData.height;
|
||||
var blockTimestamp = new Date(blockData.timestamp).toUTCString();
|
||||
var blockGeneratorAddress = publicKeyToAddress(base64ToArray(blockData.generatorPublicKey)); // currently base64 but likely to be base58 in the future
|
||||
|
||||
var ourRow = document.createElement('TR');
|
||||
ourRow.innerHTML = '<td><a href="#" onclick="fetchBlockInfo(' + ourHeight + ')">' + ourHeight + '</a></td>' +
|
||||
'<td>' + blockTimestamp + '</td>' +
|
||||
'<td class="addr">' + addressAsLink(blockGeneratorAddress) + '</td>' +
|
||||
'<td class="addr">' + addressAsLink(blockData.generatorAddress) + '</td>' +
|
||||
'<td>' + blockData.generatingBalance + '</td>' +
|
||||
'<td>' + blockData.transactionCount + '</td>' +
|
||||
'<td>' + blockData.totalFees + ' QORA</td>';
|
||||
|
Reference in New Issue
Block a user