link to blockchain explorer added in tx details modal

pull/39/head
moneroexamples 7 years ago
parent 90c2490dea
commit a42801f6cc

@ -1,5 +1,7 @@
var config = {
apiUrl: "http://127.0.0.1:1984/",
mainnetExplorerUrl: "https://xmrchain.net/",
testnetExplorerUrl: "http://139.162.32.245:8082/",
testnet: true,
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero

@ -37,6 +37,8 @@ thinwalletCtrls.controller('TransactionDetailsCtrl', function ($scope,
return;
}
var explorerUrl = config.testnet ? config.testnetExplorerUrl : config.mainnetExplorerUrl;
var address = AccountService.getAddress();
var view_key = AccountService.getViewKey();
@ -53,26 +55,24 @@ thinwalletCtrls.controller('TransactionDetailsCtrl', function ($scope,
// set data to be shown in the modal window
$scope.ring_size = data.mixin_no;
$scope.fee = data.fee;
$scope.tx_size = Math.round(data.size*1e3) / 1e3;
$scope.tx_size = Math.round(data.size * 1e3) / 1e3;
$scope.no_confirmations = data.no_confirmations;
$scope.tx_height = data.tx_height;
$scope.tx_pub_key = data.pub_key;
$scope.timestamp = new Date(data.timestamp * 1000);
var total_received = data.total_received;
var total_sent = data.total_sent;
if ((data.spent_outputs || []).length > 0)
{
if (view_only === false)
{
for (var j = 0; j < data.spent_outputs.length; ++j)
{
// filterout wrongly guessed key images by the frontend
if ((data.spent_outputs || []).length > 0) {
if (view_only === false) {
for (var j = 0; j < data.spent_outputs.length; ++j) {
var key_image = AccountService.cachedKeyImage(
data.spent_outputs[j].tx_pub_key,
data.spent_outputs[j].out_index
);
if (data.spent_outputs[j].key_image !== key_image)
{
if (data.spent_outputs[j].key_image !== key_image) {
total_sent = new JSBigInt(total_sent).subtract(data.spent_outputs[j].amount);
data.spent_outputs.splice(j, 1);
j--;
@ -83,11 +83,27 @@ thinwalletCtrls.controller('TransactionDetailsCtrl', function ($scope,
$scope.tx_amount = new JSBigInt(total_received || 0).subtract(total_sent || 0).toString();
console.log($scope.tx_amount);
// decrypt payment_id8 which results in using
// integrated address
if (data.payment_id.length == 16) {
if (data.pub_key) {
var decrypted_payment_id8
= decrypt_payment_id(data.payment_id,
data.pub_key,
AccountService.getViewKey());
//console.log("decrypted_payment_id8: " + decrypted_payment_id8);
data.payment_id = decrypted_payment_id8;
}
}
$scope.payment_id = data.payment_id;
//console.log($scope.tx_amount);
}, function(data) {
$scope.error = 'Failed to get tx detailed from the backend';
});
$scope.explorerLink = explorerUrl + "tx/" + tx_hash;
});

@ -9,8 +9,8 @@
<div class="w-form form-wrapper">
<div class="w-row">
<div class="w-col w-col-3 responsive-column">
<label class="field-label review" for="Amount">Amount aa</label>
<div class="review-text">{{ tx_amount | money}} (+{{fee | money}} fee)</div>
<label class="field-label review" for="Amount">Amount</label>
<div class="review-text">{{ tx_amount | money}}</div>
</div>
<div class="w-col w-col-3 responsive-column">
<label class="field-label review">Ring Size</label>
@ -27,26 +27,28 @@
</div>
<div class="w-row">
<div class="w-col w-col-4 responsive-column">
<label class="field-label review" for="Amount">Amount</label>
<div class="review-text">{{tx_amount | money}} (+{{fee | money}} fee)</div>
<label class="field-label review" for="Amount">No of confirmations</label>
<div class="review-text">{{no_confirmations}}</div>
</div>
<div class="w-col w-col-4 responsive-column">
<label class="field-label review">Ring Size</label>
<div class="review-text">{{mixin}}</div>
<label class="field-label review">Fee</label>
<div class="review-text">{{fee | money}}</div>
</div>
<div class="w-col w-col-4 responsive-column">
<label class="field-label review">Priority</label>
<div class="review-text">{{priority}}</div>
<label class="field-label review">Timestamp</label>
<div class="review-text">{{timestamp | time}}</div>
</div>
</div>
<div class="w-row">
<div class="w-col w-col-8 responsive-column">
<div class="w-col w-col-6 responsive-column">
<label class="field-label review" for="Mnemonic-2">Payment ID</label>
<div class="review-text">{{payment_id || "N/A"}}</div>
</div>
<div class="w-col w-col-4 responsive-column">
<label class="field-label review" for="Mnemonic-2">Size [kB]</label>
<div class="review-text">{{txBlobKBytes}}</div>
</div>
<div class="w-row">
<div class="w-col w-col-12 responsive-column">
<label class="field-label review" for="Mnemonic-2">View in a blockchain explorer for even more details</label>
<a class="login-link" href="{{ explorerLink }} " target="_blank">{{ explorerLink }} </a>
</div>
</div>
<br/>

@ -1153,6 +1153,9 @@ YourMoneroRequests::get_tx(const shared_ptr< Session > session, const Bytes & bo
// Class that is responsible for identification of our outputs
// and inputs in a given tx.
j_response["payment_id"] = string {};
j_response["timestamp"] = uint64_t {0};
account_public_address address;
secret_key viewkey;
@ -1206,6 +1209,9 @@ YourMoneroRequests::get_tx(const shared_ptr< Session > session, const Bytes & bo
if (xmr_accounts->tx_exists(acc.id, tx_hash_str, xmr_tx))
{
j_response["payment_id"] = xmr_tx.payment_id;
j_response["timestamp"] = static_cast<uint64_t>(xmr_tx.timestamp);
vector<XmrInput> inputs;
if (xmr_accounts->select_inputs_for_tx(xmr_tx.id, inputs))

Loading…
Cancel
Save