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: to use, host and modify. Additionally, the following features were added/changed:
- google analytics, cloudflare, images and flash were removed. - 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 - the wallets generated use 25 word mnemonics, fully compatible with official monero wallets
(13 word mnemonics generated by MyMonero work as usual though). (13 word mnemonics generated by MyMonero work as usual though).
- import wallet fee was reduced. - import wallet fee was reduced.
- support of testnet network and wallets was added. - support of testnet network and wallets was added.
- corrected handling of mempool, coinbase, locked and unlocked transactions.
## Status ## Status

@ -1992,20 +1992,7 @@ var cnUtil = (function(initConfig) {
if (!config.maxBlockNumber) { if (!config.maxBlockNumber) {
throw "Max block number is not set in config!"; throw "Max block number is not set in config!";
} }
if (unlock_time < config.maxBlockNumber) { //console.log(blockchain_height, unlock_time);
// 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!";
}
if (unlock_time < config.maxBlockNumber) { if (unlock_time < config.maxBlockNumber) {
// unlock time is block height // unlock time is block height
return blockchain_height >= unlock_time; return blockchain_height >= unlock_time;

@ -1,6 +1,6 @@
var config = { var config = {
apiUrl: "http://127.0.0.1:1984/", apiUrl: "http://127.0.0.1:1984/",
testnet: false, testnet: true,
coinUnitPlaces: 12, coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 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) { $scope.tx_is_mempool = function(tx) {
console.log(tx.mempool); //console.log(tx.mempool);
return tx.mempool; return tx.mempool;
}; };
@ -171,12 +171,12 @@ thinwalletCtrls.controller('AccountCtrl', function($scope, $rootScope, $http, $q
} }
transactions.sort(function(a, b) 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 t1 = b.timestamp;
var t2 = a.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.transactions = transactions;
$scope.total_received = new JSBigInt(data.total_received || 0); $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="received-div" ng-repeat="tx in transactions | limitTo:5">
<div class="w-row" ng-click="toggle_tx_detail(tx)"> <div class="w-row" ng-click="toggle_tx_detail(tx)">
<div class="w-col w-col-2 responsive-column"> <div class="w-col w-col-2 responsive-column">
<!--
<div class="transaction-detail value-bold" ng-show="tx_is_confirmed(tx)"> <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> {{tx.amount | money}} <span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span>
</div> </div>
<div class="transaction-detail value-bold" style="color: #e65a5a;" ng-show="!tx_is_confirmed(tx)"> <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>) {{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> <span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span>
</div> </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>
<div class="w-col w-col-3 responsive-column"> <div class="w-col w-col-3 responsive-column">
<div class="transaction-detail">{{tx.timestamp | time}}</div> <div class="transaction-detail">{{tx.timestamp | time}}</div>
@ -100,7 +114,10 @@
</div> </div>
<div class="w-col w-col-7"> <div class="w-col w-col-7">
<div class="transaction-detail transaction-page move-text-div"> <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> </div>
</div> </div>

@ -65,11 +65,25 @@
<div class="w-row" ng-click="toggle_tx_detail(tx)"> <div class="w-row" ng-click="toggle_tx_detail(tx)">
<div class="w-col w-col-2"> <div class="w-col w-col-2">
<div class="transaction-detail transaction-left transaction-page"> <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" 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)"> <strong class="bold red" ng-show="!tx_is_confirmed(tx)">
{{tx.amount | money}} (unconfirmed<span ng-show="tx_is_mempool(tx)">, mempool</span>) {{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> <span ng-show="!tx_is_unlocked(tx)"><i class="fa fa-lock"></i></span>
</strong> </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> </div>
<div class="w-col w-col-3"> <div class="w-col w-col-3">
@ -92,7 +106,10 @@
</div> </div>
<div class="w-col w-col-7"> <div class="w-col w-col-7">
<div class="transaction-detail transaction-page move-text-div"> <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> </div>
</div> </div>

@ -497,6 +497,8 @@ TxSearch::find_txs_in_mempool(
json j_tx; json j_tx;
j_tx["id"] = 0; // dont have any database id for tx in mempool 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["hash"] = oi_identification.tx_hash_str;
j_tx["timestamp"] = timestamp_to_str(recieve_time); // when it got into mempool j_tx["timestamp"] = timestamp_to_str(recieve_time); // when it got into mempool
j_tx["total_received"] = oi_identification.total_received; 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}; 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) for (json& j_tx: j_mempool_tx)
{ {
//cout << "mempool j_tx[\"total_received\"]: " //cout << "mempool j_tx[\"total_received\"]: "
// << j_tx["total_received"] << endl; // << j_tx["total_received"] << endl;
j_tx["id"] = ++last_tx_id_db;
total_received_mempool += j_tx["total_received"].get<uint64_t>(); total_received_mempool += j_tx["total_received"].get<uint64_t>();
j_response["transactions"].push_back(j_tx); j_response["transactions"].push_back(j_tx);

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

Loading…
Cancel
Save