spoof tx db id for mempool txs

pull/4/head
moneroexamples 7 years ago
parent 2aec658715
commit 199a8dbf60

@ -14,11 +14,12 @@ Unlike MyMonero, Open Monero's backend is open sourced, free
to use, host and modify. Additionally, the following features were added/changed:
- google analytics, cloudflare, images and flash were removed.
- transaction fees were set to zero (MyMonero also has now them zero due to RingCT).
- transaction fees were set to zero (MyMonero also has now them zero due to problem with its RingCT).
- the wallets generated use 25 word mnemonics, fully compatible with official monero wallets
(13 word mnemonics generated by MyMonero work as usual though).
- import wallet fee was reduced.
- support of testnet network and wallets was added.
- corrected handling of mempool, coinbase, locked and unlocked transactions.
## Status

@ -1992,20 +1992,7 @@ var cnUtil = (function(initConfig) {
if (!config.maxBlockNumber) {
throw "Max block number is not set in config!";
}
if (unlock_time < config.maxBlockNumber) {
// unlock time is block height
return blockchain_height >= unlock_time;
} else {
// unlock time is timestamp
var current_time = Math.round(new Date().getTime() / 1000);
return current_time >= unlock_time;
}
};
this.is_tx_unlocked2 = function(unlock_time, blockchain_height) {
if (!config.maxBlockNumber) {
throw "Max block number is not set in config!";
}
//console.log(blockchain_height, unlock_time);
if (unlock_time < config.maxBlockNumber) {
// unlock time is block height
return blockchain_height >= unlock_time;

@ -1,6 +1,6 @@
var config = {
apiUrl: "http://127.0.0.1:1984/",
testnet: false,
testnet: true,
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero

@ -67,7 +67,7 @@ thinwalletCtrls.controller('AccountCtrl', function($scope, $rootScope, $http, $q
};
$scope.tx_is_mempool = function(tx) {
console.log(tx.mempool);
//console.log(tx.mempool);
return tx.mempool;
};
@ -171,12 +171,12 @@ thinwalletCtrls.controller('AccountCtrl', function($scope, $rootScope, $http, $q
}
transactions.sort(function(a, b)
{
// return b.id - a.id; // dont sort by id, better by timestamp
return b.id - a.id; // sort by id in database
var t1 = b.timestamp;
var t2 = a.timestamp;
//var t1 = b.timestamp;
//var t2 = a.timestamp;
return ((t1 < t2) ? -1 : ((t1 > t2) ? 1 : 0));
//return ((t1 < t2) ? -1 : ((t1 > t2) ? 1 : 0));
});
$scope.transactions = transactions;
$scope.total_received = new JSBigInt(data.total_received || 0);

@ -72,13 +72,27 @@
<div class="received-div" ng-repeat="tx in transactions | limitTo:5">
<div class="w-row" ng-click="toggle_tx_detail(tx)">
<div class="w-col w-col-2 responsive-column">
<!--
<div class="transaction-detail value-bold" ng-show="tx_is_confirmed(tx)">
{{tx.amount | money}} <span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span>
</div>
<div class="transaction-detail value-bold" style="color: #e65a5a;" ng-show="!tx_is_confirmed(tx)">
{{tx.amount | money}} (unconfirmed<span ng-show="tx_is_mempool(tx)">, mempool</span>)
<span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span>
</div>
-->
<div class="transaction-detail value-bold" style="color: #e65a5a;" ng-show="tx_is_mempool(tx)">
{{tx.amount | money}} (unconfirmed)
</div>
<div class="transaction-detail value-bold" ng-show="!tx_is_mempool(tx)">
{{tx.amount | money}} <span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span>
</div>
</div>
<div class="w-col w-col-3 responsive-column">
<div class="transaction-detail">{{tx.timestamp | time}}</div>
@ -100,7 +114,10 @@
</div>
<div class="w-col w-col-7">
<div class="transaction-detail transaction-page move-text-div">
<div class="transaction-address"><span class="bold">Payment ID:</span> &nbsp;&nbsp;{{tx.payment_id || "N/A"}}</div>
<div class="transaction-address">
<span class="bold">Payment ID:</span> &nbsp;&nbsp;{{tx.payment_id || "N/A"}}
&nbsp;&nbsp;&nbsp;&nbsp;<span class="bold">Is coinbase?:</span> &nbsp;&nbsp;{{tx.coinbase}}
</div>
</div>
</div>
</div>

@ -65,11 +65,25 @@
<div class="w-row" ng-click="toggle_tx_detail(tx)">
<div class="w-col w-col-2">
<div class="transaction-detail transaction-left transaction-page">
<!--
<strong class="bold" ng-show="tx_is_confirmed(tx)">{{tx.amount | money}} <span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span></strong>
<strong class="bold red" ng-show="!tx_is_confirmed(tx)">
{{tx.amount | money}} (unconfirmed<span ng-show="tx_is_mempool(tx)">, mempool</span>)
<span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span>
</strong>
-->
<div class="transaction-detail value-bold" style="color: #e65a5a;" ng-show="tx_is_mempool(tx)">
{{tx.amount | money}} (unconfirmed)
</div>
<div class="transaction-detail value-bold" ng-show="!tx_is_mempool(tx)">
{{tx.amount | money}} <span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span>
</div>
</div>
</div>
<div class="w-col w-col-3">
@ -92,7 +106,10 @@
</div>
<div class="w-col w-col-7">
<div class="transaction-detail transaction-page move-text-div">
<div class="transaction-address transaction-page"><span class="bold">Payment ID:</span> &nbsp;&nbsp;&nbsp;&nbsp;{{tx.payment_id || "N/A"}}</div>
<div class="transaction-address transaction-page">
<span class="bold">Payment ID:</span> &nbsp;&nbsp;{{tx.payment_id || "N/A"}}
&nbsp;&nbsp;&nbsp;&nbsp;<span class="bold">Is coinbase?:</span> &nbsp;&nbsp;{{tx.coinbase}}
</div>
</div>
</div>
</div>

@ -497,6 +497,8 @@ TxSearch::find_txs_in_mempool(
json j_tx;
j_tx["id"] = 0; // dont have any database id for tx in mempool
// this id is used for sorting txs in the frontend.
j_tx["hash"] = oi_identification.tx_hash_str;
j_tx["timestamp"] = timestamp_to_str(recieve_time); // when it got into mempool
j_tx["total_received"] = oi_identification.total_received;

@ -245,11 +245,18 @@ YourMoneroRequests::get_address_txs(const shared_ptr< Session > session, const B
{
uint64_t total_received_mempool {0};
// get last tx id (i.e., index) so that we can
// set some ids for the mempool txs. These ids are
// used for sorting in the frontend. Since we want mempool
// tx to be first, they need to be higher than last_tx_id_db
uint64_t last_tx_id_db = j_response["transactions"].back()["id"];
for (json& j_tx: j_mempool_tx)
{
//cout << "mempool j_tx[\"total_received\"]: "
// << j_tx["total_received"] << endl;
j_tx["id"] = ++last_tx_id_db;
total_received_mempool += j_tx["total_received"].get<uint64_t>();
j_response["transactions"].push_back(j_tx);

@ -43,6 +43,7 @@ XmrTransaction::to_json() const
{"total_sent" , total_sent},
{"height" , height},
{"payment_id" , payment_id},
{"unlock_time" , unlock_time},
{"coinbase" , bool {coinbase}},
{"spendable" , bool {spendable}},
{"mixin" , mixin},

Loading…
Cancel
Save