ability to make full importing free

https://github.com/moneroexamples/openmonero/issues/43
pull/30/head
moneroexamples 7 years ago
parent b5c71d0540
commit faa7d5b84d

@ -105,8 +105,8 @@ target_link_libraries(${PROJECT_NAME}
epee
mysqlpp
mysqlclient
easylogging
readline
easylogging
${Boost_LIBRARIES}
pthread
unbound

@ -19,7 +19,8 @@
},
"wallet_import" :
{
"fee" : 10000000000,
"_comment": "if fee is 0, then importing is free. fee is in base 1e12, e.g., 0.1 xmr is 0.1 x 1e12 = 100000000000",
"fee" : 0,
"testnet" :
{
"address" : "9tzmPMTViHYM3z6NAgQni1Qm1Emzxy5hQFibPgWD3LVTAz91yok5Eni1pH6zKhBHzpTU15GZooPHSGHXFvFuXEdmEG2sWAZ",

@ -2,7 +2,7 @@ var config = {
apiUrl: "http://127.0.0.1:1984/",
mainnetExplorerUrl: "https://xmrchain.net/",
testnetExplorerUrl: "http://139.162.32.245:8082/",
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

@ -53,10 +53,21 @@ thinwalletCtrls.controller("ImportWalletCtrl", function($scope, $location, $http
return;
}
$scope.command = 'transfer ' + data.payment_address + ' ' + cnUtil.formatMoney(data.import_fee);
$scope.payment_id = data.payment_id;
$scope.payment_address = data.payment_address;
$scope.import_fee = new JSBigInt(data.import_fee);
if (data.import_fee !== 0) {
$scope.command = 'transfer ' + data.payment_address + ' ' + cnUtil.formatMoney(data.import_fee);
$scope.payment_id = data.payment_id;
$scope.payment_address = data.payment_address;
$scope.import_fee = new JSBigInt(data.import_fee);
}
else
{
$scope.command = 'import is free';
$scope.payment_address = 'N/A';
$scope.import_fee = new JSBigInt(0);
$scope.payment_id = "N/A";
}
$scope.status = data.status;
if (data.request_fulfilled === true) {
@ -64,7 +75,12 @@ thinwalletCtrls.controller("ImportWalletCtrl", function($scope, $location, $http
//console.log(data);
if (data.new_request === true) {
$scope.success = "Payment received. Import will start shortly. This window will close in few seconds.";
if (data.import_fee !== 0) {
$scope.success = "Payment received. Import will start shortly. This window will close in few seconds.";
}
else {
$scope.success = "Import will start shortly. This window will close in few seconds.";
}
}
else {
$scope.success = "The wallet is being imported now or it has already been imported before.";

@ -10,12 +10,13 @@
<form id="email-form" name="email-form" data-name="Email Form">
<div class="move-text-div">
<div class="review-text">To import all your previous transactions and account
balance you have to pay a once-off import fee of <strong>{{import_fee | money:false:true}}</strong> to the
balance you might (depends on the backend settings) have to pay a once-off
import fee of <strong>{{import_fee | money:false:true}}</strong> to the
account listed below. An example command to make the payment in
monero-wallet-cli program
is shown below.
<br/>
As soon as the transfer is detected in mempool, import process will begin.
As soon as the transfer is detected in transaction pool, import process will begin.
It should not take more than few minutes before your transfer is detected in the mempool.
</div>
</div>

@ -7,8 +7,9 @@
<h1 class="head-modal">Importing transactions</h1>
<div class="w-form form-wrapper">
<label class="field-label">Import all transactions</label>
<div class="review-text">This will scan all blocks in the blockchain. This is very resource intensive task.
Thus a small fee is required.</div>
<div class="review-text">This will scan all blocks in the blockchain.
This is very resource intensive task.
Thus a small fee might be required (depends on the backend settings).</div>
<div class="submit-div small-top-margin">
<a class="login-btn modals pointer" ng-click="importAll()">Import all transactions</a>
</div>

@ -764,9 +764,36 @@ YourMoneroRequests::import_wallet_request(const shared_ptr< Session > session, c
json j_response;
j_response["request_fulfilled"] = false;
j_response["import_fee"] = CurrentBlockchainStatus::import_fee;
j_response["status"] = "error";
j_response["error"] = "Some error occured";
// if CurrentBlockchainStatus:: is zero, we just import the wallet.
// we dont care about any databases or anything, as importin all wallet is free.
// just reset the scanned block height in mysql and finish.
if (CurrentBlockchainStatus::import_fee == 0)
{
// change search blk number in the search thread
if (!CurrentBlockchainStatus::set_new_searched_blk_no(xmr_address, 0))
{
cerr << "Updating searched_blk_no failed!" << endl;
j_response["error"] = "Updating searched_blk_no failed!";
}
j_response["request_fulfilled"] = true;
j_response["status"] = "Import will start shortly";
j_response["new_request"] = true;
j_response["error"] = "";
string response_body = j_response.dump();
auto response_headers = make_headers({{ "Content-Length", to_string(response_body.size())}});
session->close( OK, response_body, response_headers);
return;
}
// select this payment if its existing one
if (xmr_accounts->select_payment_by_address(xmr_address, xmr_payment))
{

Loading…
Cancel
Save