number of improvements and enhancments

into html code
fixing generating seed and addresses
more lock and unlock tx improvments
pull/4/head
moneroexamples 7 years ago
parent aad77bfc37
commit d108417e7c

@ -789,9 +789,10 @@ p {
color: #68717a;
}
.transaction-address {
font-family: Proximanova, sans-serif;
/*font-family: Proximanova, sans-serif;*/
font-family: Andale Mono, monospace;
color: #6d7d8c;
font-size: 12px;
font-size: 10px;
font-weight: 400;
}
.transaction-address.transaction-page {
@ -799,9 +800,10 @@ p {
color: #5a6a6e;
}
.transaction-detail {
font-family: Proximanova, sans-serif;
/*font-family: Proximanova, sans-serif;*/
font-family: Andale Mono, monospace;
color: #6d7d8c;
font-size: 13px;
font-size: 10px;
}
.transaction-detail.transaction-left {
padding-left: 15px;
@ -820,8 +822,8 @@ p {
padding-bottom: 10px;
}
.received-div.transaction-body.lighter {
padding-top: 12px;
padding-bottom: 12px;
padding-top: 10px;
padding-bottom: 10px;
border-right: 1px solid #d3e1ed;
border-left: 1px solid #d3e1ed;
background-color: #edf5fc;

@ -461,7 +461,7 @@ var cnUtil = (function(initConfig) {
first = seed; //only input reduced seeds or this will not give you the result you want
}
keys.spend = this.generate_keys(first);
var second = this.cn_fast_hash(first);
var second = this.cn_fast_hash(keys.spend.sec);
keys.view = this.generate_keys(second);
keys.public_addr = this.pubkeys_to_string(keys.spend.pub, keys.view.pub);
return keys;
@ -2007,7 +2007,8 @@ var cnUtil = (function(initConfig) {
return "Transaction is unlocked";
}
var unlock_prediction = moment().add(numBlocks * config.avgBlockTime, 'seconds');
return "Will be unlocked in " + numBlocks + " blocks, ~" + unlock_prediction.fromNow(true) + ", " + unlock_prediction.calendar() + "";
//return "Will be unlocked in " + numBlocks + " blocks, ~" + unlock_prediction.fromNow(true) + ", " + unlock_prediction.calendar() + "";
return "Will be unlocked in " + numBlocks + " blocks, ~" + unlock_prediction.fromNow(true);
} else {
// unlock time is timestamp
var current_time = Math.round(new Date().getTime() / 1000);
@ -2016,7 +2017,8 @@ var cnUtil = (function(initConfig) {
return "Transaction is unlocked";
}
var unlock_moment = moment(unlock_time * 1000);
return "Will be unlocked " + unlock_moment.fromNow() + ", " + unlock_moment.calendar();
//return "Will be unlocked " + unlock_moment.fromNow() + ", " + unlock_moment.calendar();
return "Will be unlocked " + unlock_moment.fromNow();
}
};

@ -28,10 +28,13 @@
thinwalletCtrls.controller('GenerateWalletCtrl', function ($scope, $location, AccountService) {
"use strict";
$scope.seed = '';
$scope.mnemonic = '';
$scope.mnemonic_confirmation = '';
$scope.error = '';
$scope.testnet = config.testnet;
$scope.$watch('seed', function () {
$scope.mnemonic = mn_encode($scope.seed);
$scope.keys = cnUtil.create_address($scope.seed);

@ -8,6 +8,10 @@
<div class="subhead-text modal review">These are your account details. Feel free to view them at any time.</div>
<div class="w-form form-wrapper">
<form id="email-form" name="email-form" data-name="Email Form">
<label class="field-label review" for="Mnemonic-2">Mnemonic seed (Private)</label>
<div class="move-text-div">
<div class="review-text address">{{mnemonic}} </div>
</div>
<label class="field-label review" for="Mnemonic-2">Account Address (Public)</label>
<div class="move-text-div">
<div class="review-text address">{{address}} </div>
@ -20,6 +24,20 @@
<div class="move-text-div">
<div class="review-text">{{spend_key}} </div>
</div>
<label class="field-label review" for="Mnemonic-2">Importing to <i>monero-wallet-cli</i> using the seed</label>
<div class="move-text-div">
<div class="review-text">
<i>monero-wallet-cli {{testnet ? "--testnet" : "" }} --restore-deterministic-wallet</i> and follow the prompts
<br/> note: <i>monero-wallet-cli</i> in Windows is <i>monero-wallet-cli.exe</i>
</div>
</div>
<label class="field-label review" for="Mnemonic-2">Importing to <i>monero-wallet-cli</i> using the private keys</label>
<div class="move-text-div">
<div class="review-text">
<i>monero-wallet-cli {{testnet ? "--testnet" : "" }} --generate-from-keys your_new_wallets_name</i> and follow the prompts
<br/> note: <i>monero-wallet-cli</i> in Windows is <i>monero-wallet-cli.exe</i>
</div>
</div>
<div class="submit-div">
<a class="login-btn modals pointer" data-ix="close-review-details" hide-modal>Ok, thanks!</a>
</div>

@ -88,7 +88,7 @@
</div>
<div class="w-row" style="margin-bottom: 15px;" ng-show="showing_tx_detail(tx)">
<div class="w-col w-col-5">
<div class="transaction-detail" style="font-size: 11px;" ng-show="!tx_is_unlocked(tx)">
<div class="transaction-detail" style="font-size: 10px;" ng-show="!tx_is_unlocked(tx)">
{{tx_locked_reason(tx)}}
</div>
</div>

@ -104,7 +104,7 @@
</div>
<div class="w-row" ng-show="showing_tx_detail(tx)">
<div class="w-col w-col-5">
<div class="transaction-detail transaction-left" style="font-size: 11px;" ng-show="!tx_is_unlocked(tx)">
<div class="transaction-detail transaction-left" style="font-size: 10px;" ng-show="!tx_is_unlocked(tx)">
{{tx_locked_reason(tx)}}
</div>
</div>

@ -138,18 +138,54 @@ CurrentBlockchainStatus::init_monero_blockchain()
bool
CurrentBlockchainStatus::is_tx_unlocked(uint64_t tx_blk_height, bool is_coinbase)
CurrentBlockchainStatus::is_tx_unlocked(
uint64_t unlock_time,
uint64_t block_height)
{
if (!is_coinbase)
if(!is_tx_spendtime_unlocked(unlock_time, block_height))
return false;
if(block_height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE > current_height + 1)
return false;
return true;
}
bool
CurrentBlockchainStatus::is_tx_spendtime_unlocked(
uint64_t unlock_time,
uint64_t block_height)
{
if(unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER)
{
return (tx_blk_height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE <= get_current_blockchain_height());
//interpret as block index
if(current_height + CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS >= unlock_time)
return true;
else
return false;
}
else
{
return (tx_blk_height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW <= get_current_blockchain_height());
//interpret as time
uint64_t current_time = static_cast<uint64_t>(time(NULL));
// XXX: this needs to be fast, so we'd need to get the starting heights
// from the daemon to be correct once voting kicks in
uint64_t v2height = testnet ? 624634 : 1009827;
uint64_t leeway = block_height < v2height
? CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1
: CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2;
if(current_time + leeway >= unlock_time)
return true;
else
return false;
}
}
return false;
}
bool
CurrentBlockchainStatus::get_block(uint64_t height, block &blk)

@ -91,7 +91,10 @@ struct CurrentBlockchainStatus
init_monero_blockchain();
static bool
is_tx_unlocked(uint64_t tx_blk_height, bool is_coinbase);
is_tx_unlocked(uint64_t unlock_time, uint64_t block_height);
static bool
is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height);
static bool
get_block(uint64_t height, block &blk);

@ -832,7 +832,8 @@ MySqlAccounts::select_txs_for_account_spendability_check(
if (bool {tx.spendable} == false)
{
if (CurrentBlockchainStatus::is_tx_unlocked(tx.height, tx.coinbase))
if (CurrentBlockchainStatus::is_tx_unlocked(tx.unlock_time, tx.height))
{
// this tx was before marked as unspendable, but now
@ -875,6 +876,17 @@ MySqlAccounts::select_txs_for_account_spendability_check(
continue;
}
// set unlock_time field so that frontend displies it
// as a locked tx, if unlock_time is zero.
// coinbtase txs have this set already. regular tx
// have unlock_time set to zero by default, but they cant
// be spent anyway.
if (tx.unlock_time == 0)
{
tx.unlock_time = tx.height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE;
}
} // else
} // if (bool {tx.spendable} == false)

@ -161,8 +161,9 @@ TxSearch::search()
// flag indicating whether the txs in the given block are spendable.
// this is true when block number is more than 10 blocks from current
// blockchain height.
bool is_spendable = CurrentBlockchainStatus::is_tx_unlocked(
searched_blk_no, oi_identification.tx_is_coinbase);
tx.unlock_time, searched_blk_no);
// FIRSt step.
oi_identification.identify_outputs();
@ -201,9 +202,7 @@ TxSearch::search()
// for regular tx, the unlock time is
// default of 10 blocks.
// for coinbase tx it is 60 blocks
tx_data.unlock_time = (oi_identification.tx_is_coinbase ?
searched_blk_no + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW
: searched_blk_no + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE);
tx_data.unlock_time = tx.unlock_time;
tx_data.height = searched_blk_no;
tx_data.coinbase = oi_identification.tx_is_coinbase;
@ -362,9 +361,7 @@ TxSearch::search()
tx_data.account_id = acc->id;
tx_data.total_received = 0; // because this is spending, total_recieved is 0
tx_data.total_sent = total_sent;
tx_data.unlock_time = 0; // spend only tx dont have unlock time
// sicne we are not recieving any outputs
// that we can spend
tx_data.unlock_time = tx.unlock_time;
tx_data.height = searched_blk_no;
tx_data.coinbase = oi_identification.tx_is_coinbase;
tx_data.is_rct = oi_identification.is_rct;

@ -440,9 +440,7 @@ YourMoneroRequests::get_unspent_outs(const shared_ptr< Session > session, const
// thus no reason to return them to the frontend
// for constructing a tx.
int64_t time_since_unlock = current_blockchain_height - tx.unlock_time;
if (!CurrentBlockchainStatus::is_tx_unlocked(tx.height, tx.coinbase))
if (!CurrentBlockchainStatus::is_tx_unlocked(tx.unlock_time, tx.height))
{
continue;
}

Loading…
Cancel
Save