diff --git a/config/config.json b/config/config.json
index c052f34..629d170 100755
--- a/config/config.json
+++ b/config/config.json
@@ -27,8 +27,9 @@
},
"mainnet" :
{
- "address" : "",
- "viewkey" : ""
+ "_comment": "these are official monero project donation address and viewkey. change it to yours",
+ "address" : "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A",
+ "viewkey" : "f359631075708155cc3d92a32b75a7d02a5dcf27756707b47a2b31b21c389501"
}
},
"refresh_block_status_every_seconds" : 10,
diff --git a/html/js/config.js b/html/js/config.js
index 807c872..c733f49 100755
--- a/html/js/config.js
+++ b/html/js/config.js
@@ -1,6 +1,6 @@
var config = {
apiUrl: "http://127.0.0.1:1984/",
- testnet: true,
+ testnet: false,
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero
diff --git a/html/js/controllers/account.js b/html/js/controllers/account.js
index 8bc19a4..73d3144 100755
--- a/html/js/controllers/account.js
+++ b/html/js/controllers/account.js
@@ -148,10 +148,18 @@ thinwalletCtrls.controller('AccountCtrl', function($scope, $rootScope, $http, $q
}
}
$q.all(promises).then(function() {
+
+ var scanned_block_timestamp = data.scanned_block_timestamp || 0;
+
+ if (scanned_block_timestamp > 0)
+ scanned_block_timestamp = new Date(scanned_block_timestamp * 1000)
+
+
$scope.locked_balance = new JSBigInt(data.locked_funds || 0);
$scope.total_sent = new JSBigInt(data.total_sent || 0);
//$scope.account_scanned_tx_height = data.scanned_height || 0;
$scope.account_scanned_block_height = data.scanned_block_height || 0;
+ $scope.account_scanned_block_timestamp = scanned_block_timestamp;
$scope.account_scan_start_height = data.start_height || 0;
//$scope.transaction_height = data.transaction_height || 0;
$scope.blockchain_height = data.blockchain_height || 0;
@@ -170,12 +178,22 @@ thinwalletCtrls.controller('AccountCtrl', function($scope, $rootScope, $http, $q
ApiCalls.get_address_txs(AccountService.getAddress(), AccountService.getViewKey())
.then(function(response) {
+
var data = response.data;
+
+ var scanned_block_timestamp = data.scanned_block_timestamp || 0;
+
+ if (scanned_block_timestamp > 0)
+ scanned_block_timestamp = new Date(scanned_block_timestamp * 1000)
+
$scope.account_scanned_height = data.scanned_height || 0;
$scope.account_scanned_block_height = data.scanned_block_height || 0;
+ $scope.account_scanned_block_timestamp = scanned_block_timestamp;
$scope.account_scan_start_height = data.start_height || 0;
//$scope.transaction_height = data.transaction_height || 0;
$scope.blockchain_height = data.blockchain_height || 0;
+
+
var transactions = data.transactions || [];
for (var i = 0; i < transactions.length; ++i) {
diff --git a/html/js/controllers/import_wallet.js b/html/js/controllers/import_wallet.js
index 5c65cac..190f4c9 100755
--- a/html/js/controllers/import_wallet.js
+++ b/html/js/controllers/import_wallet.js
@@ -47,6 +47,12 @@ thinwalletCtrls.controller("ImportWalletCtrl", function($scope, $location, $http
var data = response.data;
+ if ('status' in data == true && data.status == "error") {
+ $scope.status = data.error || "Some error occured";
+ $scope.error = data.error || "Some error occured";
+ return;
+ }
+
$scope.command = 'transfer ' + data.payment_address + ' ' + cnUtil.formatMoney(data.import_fee);
$scope.payment_id = data.payment_id;
$scope.payment_address = data.payment_address;
@@ -55,7 +61,9 @@ thinwalletCtrls.controller("ImportWalletCtrl", function($scope, $location, $http
if (data.request_fulfilled === true) {
- if (data.new_request === true) {
+ console.log(data);
+
+ if (data.new_request === false) {
$scope.success = "Payment received. Import will start shortly. This window will close in few seconds.";
}
else {
diff --git a/html/partials/account-nav.html b/html/partials/account-nav.html
index ef179fd..08a77a6 100755
--- a/html/partials/account-nav.html
+++ b/html/partials/account-nav.html
@@ -8,6 +8,8 @@
- Your account is catching up, your details may be out-of-date until it is finished ({{blockchain_height - account_scanned_block_height}} blocks behind)
+ Your account is catching up, your details may be out-of-date
+ until it is finished ({{blockchain_height - account_scanned_block_height}}
+ blocks behind)
\ No newline at end of file
diff --git a/html/partials/account-overview.html b/html/partials/account-overview.html
index 6d94474..594ba40 100755
--- a/html/partials/account-overview.html
+++ b/html/partials/account-overview.html
@@ -27,7 +27,8 @@
{{balance | money:false:true}} / {{balance_unlocked | money:false:true}}
- Refreshed: {{account_scanned_block_height}} / {{blockchain_height}}
+ Refreshed: {{account_scanned_block_height}} / {{blockchain_height}}
+ Timestamp: {{account_scanned_block_timestamp | time}}
diff --git a/html/partials/account-transactions.html b/html/partials/account-transactions.html
index ee597a9..cb9f700 100755
--- a/html/partials/account-transactions.html
+++ b/html/partials/account-transactions.html
@@ -20,7 +20,8 @@
{{balance | money:false:true}} / {{balance_unlocked | money:false:true}}
- Refreshed: {{account_scanned_block_height}} / {{blockchain_height}}
+ Refreshed: {{account_scanned_block_height}} / {{blockchain_height}}
+ Timestamp: {{account_scanned_block_timestamp | time}}
diff --git a/html/partials/receive-coins.html b/html/partials/receive-coins.html
index 5fd7445..cf0cc23 100755
--- a/html/partials/receive-coins.html
+++ b/html/partials/receive-coins.html
@@ -19,7 +19,8 @@
{{balance | money:false:true}} / {{balance_unlocked | money:false:true}}
- Refreshed: {{account_scanned_block_height}} / {{blockchain_height}}
+ Refreshed: {{account_scanned_block_height}} / {{blockchain_height}}
+ Timestamp: {{account_scanned_block_timestamp | time}}
diff --git a/html/partials/send-coins.html b/html/partials/send-coins.html
index 6e7bd7a..4215247 100755
--- a/html/partials/send-coins.html
+++ b/html/partials/send-coins.html
@@ -32,7 +32,8 @@
{{balance | money:false:true}} / {{balance_unlocked | money:false:true}}
- Refreshed: {{account_scanned_block_height}} / {{blockchain_height}}
+ Refreshed: {{account_scanned_block_height}} / {{blockchain_height}}
+ Timestamp: {{account_scanned_block_timestamp | time}}
diff --git a/sql/openmonero.sql b/sql/openmonero.sql
index c568367..c728d4c 100755
--- a/sql/openmonero.sql
+++ b/sql/openmonero.sql
@@ -34,6 +34,7 @@ CREATE TABLE `Accounts` (
`address` varchar(95) NOT NULL,
`viewkey_hash` char(64) NOT NULL,
`scanned_block_height` int(10) UNSIGNED NOT NULL DEFAULT '0',
+ `scanned_block_timestamp` timestamp NOT NULL DEFAULT 0,
`start_height` int(10) UNSIGNED NOT NULL DEFAULT '0',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
diff --git a/src/MySqlAccounts.cpp b/src/MySqlAccounts.cpp
index 691f9cb..54313fe 100755
--- a/src/MySqlAccounts.cpp
+++ b/src/MySqlAccounts.cpp
@@ -739,7 +739,8 @@ MySqlAccounts::select(const int64_t& acc_id, XmrAccount& account)
uint64_t
MySqlAccounts::insert(const string& address,
const string& viewkey_hash,
- const uint64_t& current_blkchain_height)
+ const uint64_t& current_blkchain_height,
+ uint64_t const& current_blkchain_timestamp)
{
Query query = conn->query(XmrAccount::INSERT_STMT);
@@ -758,6 +759,7 @@ MySqlAccounts::insert(const string& address,
SimpleResult sr = query.execute(address,
viewkey_hash,
current_blkchain_height,
+ current_blkchain_timestamp,
current_blkchain_height);
if (sr.rows() == 1)
diff --git a/src/MySqlAccounts.h b/src/MySqlAccounts.h
index f08ea12..b1a8260 100755
--- a/src/MySqlAccounts.h
+++ b/src/MySqlAccounts.h
@@ -177,7 +177,8 @@ public:
uint64_t
insert(const string& address,
const string& viewkey_hash,
- const uint64_t& current_blkchain_height = 0);
+ const uint64_t& current_blkchain_height = 0,
+ uint64_t const& current_blkchain_timestamp = 0);
uint64_t
insert_tx(const XmrTransaction& tx_data);
diff --git a/src/TxSearch.cpp b/src/TxSearch.cpp
index 5aa02fd..f110904 100755
--- a/src/TxSearch.cpp
+++ b/src/TxSearch.cpp
@@ -409,7 +409,8 @@ TxSearch::search()
XmrAccount updated_acc = *acc;
- updated_acc.scanned_block_height = searched_blk_no;
+ updated_acc.scanned_block_height = searched_blk_no;
+ updated_acc.scanned_block_timestamp = blk_timestamp_mysql_format;
if (xmr_accounts->update(*acc, updated_acc))
{
diff --git a/src/YourMoneroRequests.cpp b/src/YourMoneroRequests.cpp
index 912e5f2..1b2c8a9 100755
--- a/src/YourMoneroRequests.cpp
+++ b/src/YourMoneroRequests.cpp
@@ -69,6 +69,18 @@ YourMoneroRequests::login(const shared_ptr session, const Bytes & body)
// account does not exist, so create new one
// for this address
+ uint64_t current_blockchain_height = get_current_blockchain_height();
+
+ uint64_t current_blockchain_timestamp {0};
+
+ block last_blk;
+
+ if (CurrentBlockchainStatus::get_block(current_blockchain_height, last_blk))
+ {
+ current_blockchain_timestamp
+ = XmrTransaction::timestamp_to_DateTime(last_blk.timestamp);
+ }
+
// we will save current blockchain height
// in mysql, so that we know from what block
// to start searching txs of this new acount
@@ -77,7 +89,8 @@ YourMoneroRequests::login(const shared_ptr session, const Bytes & body)
// `scanned_block_height` in mysql Accounts table.
if ((acc_id = xmr_accounts->insert(xmr_address,
make_hash(view_key),
- get_current_blockchain_height())) == 0)
+ current_blockchain_height,
+ current_blockchain_timestamp)) == 0)
{
// if creating account failed
j_response = json {{"status", "error"},
@@ -133,13 +146,14 @@ YourMoneroRequests::get_address_txs(const shared_ptr< Session > session, const B
// initialize json response
j_response = json {
- { "total_received" , 0}, // calculated in this function
- { "total_received_unlocked", 0}, // calculated in this function
- { "scanned_height" , 0}, // not used. it is here to match mymonero
- { "scanned_block_height" , 0}, // taken from Accounts table
- { "start_height" , 0}, // blockchain hieght when acc was created
- { "blockchain_height" , 0}, // current blockchain height
- { "transactions" , json::array()}
+ {"total_received" , 0}, // calculated in this function
+ {"total_received_unlocked", 0}, // calculated in this function
+ {"scanned_height" , 0}, // not used. it is here to match mymonero
+ {"scanned_block_height" , 0}, // taken from Accounts table
+ {"scanned_block_timestamp", 0}, // taken from Accounts table
+ {"start_height" , 0}, // blockchain hieght when acc was created
+ {"blockchain_height" , 0}, // current blockchain height
+ {"transactions" , json::array()}
};
// a placeholder for exciting or new account data
@@ -158,10 +172,11 @@ YourMoneroRequests::get_address_txs(const shared_ptr< Session > session, const B
uint64_t total_received {0};
uint64_t total_received_unlocked {0};
- j_response["total_received"] = total_received;
- j_response["start_height"] = acc.start_height;
- j_response["scanned_block_height"] = acc.scanned_block_height;
- j_response["blockchain_height"] = get_current_blockchain_height();
+ j_response["total_received"] = total_received;
+ j_response["start_height"] = acc.start_height;
+ j_response["scanned_block_height"] = acc.scanned_block_height;
+ j_response["scanned_block_timestamp"] = static_cast(acc.scanned_block_timestamp);
+ j_response["blockchain_height"] = get_current_blockchain_height();
vector txs;
@@ -314,18 +329,19 @@ YourMoneroRequests::get_address_info(const shared_ptr< Session > session, const
string viewkey_hash = make_hash(view_key);
j_response = json {
- {"locked_funds" , 0}, // locked xmr (e.g., younger than 10 blocks)
- {"total_received" , 0}, // calculated in this function
- {"total_sent" , 0}, // calculated in this function
- {"scanned_height" , 0}, // not used. it is here to match mymonero
- {"scanned_block_height", 0}, // taken from Accounts table
- {"start_height" , 0}, // not used, but available in Accounts table.
- // it is here to match mymonero
- {"blockchain_height" , 0}, // current blockchain height
- {"spent_outputs" , nullptr} // list of spent outputs that we think
- // user has spent. client side will
- // filter out false positives since
- // only client has spent key
+ {"locked_funds" , 0}, // locked xmr (e.g., younger than 10 blocks)
+ {"total_received" , 0}, // calculated in this function
+ {"total_sent" , 0}, // calculated in this function
+ {"scanned_height" , 0}, // not used. it is here to match mymonero
+ {"scanned_block_height" , 0}, // taken from Accounts table
+ {"scanned_block_timestamp", 0}, // taken from Accounts table
+ {"start_height" , 0}, // not used, but available in Accounts table.
+ // it is here to match mymonero
+ {"blockchain_height" , 0}, // current blockchain height
+ {"spent_outputs" , nullptr} // list of spent outputs that we think
+ // user has spent. client side will
+ // filter out false positives since
+ // only client has spent key
};
// a placeholder for exciting or new account data
@@ -356,10 +372,11 @@ YourMoneroRequests::get_address_info(const shared_ptr< Session > session, const
}
}
- j_response["total_received"] = total_received;
- j_response["start_height"] = acc.start_height;
- j_response["scanned_block_height"] = acc.scanned_block_height;
- j_response["blockchain_height"] = CurrentBlockchainStatus::get_current_blockchain_height();
+ j_response["total_received"] = total_received;
+ j_response["start_height"] = acc.start_height;
+ j_response["scanned_block_height"] = acc.scanned_block_height;
+ j_response["scanned_block_timestamp"] = static_cast(acc.scanned_block_timestamp);
+ j_response["blockchain_height"] = get_current_blockchain_height();
uint64_t total_sent {0};
@@ -722,7 +739,7 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
{
json j_request = body_to_json(body);
- string xmr_address = j_request["address"];
+ string xmr_address = j_request["address"];
// a placeholder for existing or new payment data
xmreg::XmrPayment xmr_payment;
@@ -730,6 +747,8 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
json j_response;
j_response["request_fulfilled"] = false;
+ j_response["status"] = "error";
+ j_response["error"] = "Some error occured";
// select this payment if its existing one
if (xmr_accounts->select_payment_by_address(xmr_address, xmr_payment))
@@ -741,7 +760,8 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
bool request_fulfilled = bool {xmr_payment.request_fulfilled};
string integrated_address =
- CurrentBlockchainStatus::get_account_integrated_address_as_str(xmr_payment.payment_id);
+ CurrentBlockchainStatus::get_account_integrated_address_as_str(
+ xmr_payment.payment_id);
j_response["payment_id"] = xmr_payment.payment_id;
j_response["import_fee"] = xmr_payment.import_fee;
@@ -788,20 +808,20 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
if (!CurrentBlockchainStatus::set_new_searched_blk_no(xmr_address, 0))
{
cerr << "Updating searched_blk_no failed!" << endl;
- j_response["status"] = "Updating searched_blk_no failed!";
+ j_response["error"] = "Updating searched_blk_no failed!";
}
}
}
else
{
cerr << "Updating accounts due to made payment mysql failed! " << endl;
- j_response["status"] = "Updating accounts due to made payment mysql failed!";
+ j_response["error"] = "Updating accounts due to made payment mysql failed!";
}
}
else
{
cerr << "Updating payment mysql failed! " << endl;
- j_response["status"] = "Updating payment mysql failed!";
+ j_response["error"] = "Updating payment mysql failed!";
}
}
@@ -809,6 +829,7 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
{
j_response["request_fulfilled"] = request_fulfilled;
j_response["status"] = "Payment received. Thank you.";
+ j_response["error"] = "";
}
}
else
@@ -821,7 +842,8 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
crypto::hash8 random_payment_id8 = crypto::rand();
string integrated_address =
- CurrentBlockchainStatus::get_account_integrated_address_as_str(random_payment_id8);
+ CurrentBlockchainStatus::get_account_integrated_address_as_str(
+ random_payment_id8);
xmr_payment.address = xmr_address;
xmr_payment.payment_id = pod_to_hex(random_payment_id8);
@@ -830,7 +852,6 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
xmr_payment.tx_hash = ""; // no tx_hash yet with the payment
xmr_payment.payment_address = integrated_address;
-
if ((payment_table_id = xmr_accounts->insert_payment(xmr_payment)) != 0)
{
// payment entry created
@@ -841,6 +862,7 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
j_response["request_fulfilled"] = bool {xmr_payment.request_fulfilled};
j_response["payment_address"] = xmr_payment.payment_address;
j_response["status"] = "Payment not yet received";
+ j_response["error"] = "";
}
}
diff --git a/src/ssqlses.cpp b/src/ssqlses.cpp
index bdd7407..da81485 100755
--- a/src/ssqlses.cpp
+++ b/src/ssqlses.cpp
@@ -18,11 +18,12 @@ ostream& operator<< (std::ostream& os, const Table& data)
json
XmrAccount::to_json() const
{
- json j {{"id" , id},
- {"address" , address},
- {"viewkey" , viewkey},
- {"scanned_block_height", scanned_block_height},
- {"start_height" , start_height}
+ json j {{"id" , id},
+ {"address" , address},
+ {"viewkey" , viewkey},
+ {"scanned_block_height" , scanned_block_height},
+ {"scanned_block_timestamp", static_cast(scanned_block_timestamp)},
+ {"start_height" , start_height}
};
return j;
diff --git a/src/ssqlses.h b/src/ssqlses.h
index 297c94c..0d2dec8 100755
--- a/src/ssqlses.h
+++ b/src/ssqlses.h
@@ -30,11 +30,12 @@ public:
friend std::ostream& operator<< (std::ostream& stream, const Table& data);
};
-sql_create_7(Accounts, 1, 2,
+sql_create_8(Accounts, 1, 2,
sql_bigint_unsigned, id,
sql_varchar , address,
sql_char , viewkey_hash,
sql_bigint_unsigned, scanned_block_height,
+ sql_timestamp , scanned_block_timestamp,
sql_bigint_unsigned, start_height,
sql_timestamp , created,
sql_timestamp , modified);
@@ -52,9 +53,11 @@ struct XmrAccount : public Accounts, Table
)";
static constexpr const char* INSERT_STMT = R"(
- INSERT INTO `Accounts` (`address`, `viewkey_hash`,`start_height`, `scanned_block_height`)
+ INSERT INTO `Accounts` (`address`, `viewkey_hash`,
+ `scanned_block_height`,
+ `scanned_block_timestamp`, `start_height`)
VALUES
- (%0q, %1q, %2q, %3q);
+ (%0q, %1q, %2q, %3q, %4q);
)";
using Accounts::Accounts;