@ -80,29 +80,29 @@ using namespace dev::p2p;
using namespace dev : : eth ;
using namespace dev : : eth ;
namespace js = json_spirit ;
namespace js = json_spirit ;
QS tring Main : : fromRaw ( h256 _n , unsigned * _inc )
s tring Main : : fromRaw ( h256 _n , unsigned * _inc )
{
{
if ( _n )
if ( _n )
{
{
string s ( ( char const * ) _n . data ( ) , 32 ) ;
string s ( ( char const * ) _n . data ( ) , 32 ) ;
auto l = s . find_first_of ( ' \0 ' ) ;
auto l = s . find_first_of ( ' \0 ' ) ;
if ( ! l )
if ( ! l )
return QS tring( ) ;
return s tring( ) ;
if ( l ! = string : : npos )
if ( l ! = string : : npos )
{
{
auto p = s . find_first_not_of ( ' \0 ' , l ) ;
auto p = s . find_first_not_of ( ' \0 ' , l ) ;
if ( ! ( p = = string : : npos | | ( _inc & & p = = 31 ) ) )
if ( ! ( p = = string : : npos | | ( _inc & & p = = 31 ) ) )
return QS tring( ) ;
return s tring( ) ;
if ( _inc )
if ( _inc )
* _inc = ( byte ) s [ 31 ] ;
* _inc = ( byte ) s [ 31 ] ;
s . resize ( l ) ;
s . resize ( l ) ;
}
}
for ( auto i : s )
for ( auto i : s )
if ( i < 32 )
if ( i < 32 )
return QS tring( ) ;
return s tring( ) ;
return QString : : fromStdString ( s ) ;
return s ;
}
}
return QS tring( ) ;
return s tring( ) ;
}
}
QString contentsOfQResource ( string const & res )
QString contentsOfQResource ( string const & res )
@ -143,11 +143,6 @@ Main::Main(QWidget *parent) :
// ui->log->addItem(QString::fromStdString(s));
// ui->log->addItem(QString::fromStdString(s));
} ;
} ;
# if !ETH_FATDB
delete ui - > dockWidget_accounts ;
delete ui - > dockWidget_contracts ;
# endif
# if ETH_DEBUG
# if ETH_DEBUG
m_servers . append ( " 127.0.0.1:30300 " ) ;
m_servers . append ( " 127.0.0.1:30300 " ) ;
# endif
# endif
@ -204,6 +199,9 @@ Main::Main(QWidget *parent) :
// QWebEngineInspector* inspector = new QWebEngineInspector();
// QWebEngineInspector* inspector = new QWebEngineInspector();
// inspector->setPage(page);
// inspector->setPage(page);
readSettings ( ) ;
readSettings ( ) ;
# if !ETH_FATDB
removeDockWidget ( ui - > dockWidget_accounts ) ;
# endif
installWatches ( ) ;
installWatches ( ) ;
startTimer ( 100 ) ;
startTimer ( 100 ) ;
@ -398,7 +396,7 @@ void Main::onNewBlock()
// update blockchain dependent views.
// update blockchain dependent views.
refreshBlockCount ( ) ;
refreshBlockCount ( ) ;
refreshBlockChain ( ) ;
refreshBlockChain ( ) ;
refreshAccounts ( ) ;
ui - > refreshAccounts - > setEnabled ( true ) ;
// We must update balances since we can't filter updates to basic accounts.
// We must update balances since we can't filter updates to basic accounts.
refreshBalances ( ) ;
refreshBalances ( ) ;
@ -410,7 +408,7 @@ void Main::onNewPending()
// update any pending-transaction dependent views.
// update any pending-transaction dependent views.
refreshPending ( ) ;
refreshPending ( ) ;
refreshAccounts ( ) ;
ui - > refreshAccounts - > setEnabled ( true ) ;
}
}
void Main : : on_forceMining_triggered ( )
void Main : : on_forceMining_triggered ( )
@ -510,33 +508,33 @@ static Public stringToPublic(QString const& _a)
return Public ( ) ;
return Public ( ) ;
}
}
QS tring Main : : pretty ( dev : : Address _a ) const
std : : s tring Main : : pretty ( dev : : Address const & _a ) const
{
{
auto g_newNameReg = getNameReg ( ) ;
auto g_newNameReg = getNameReg ( ) ;
if ( g_newNameReg )
if ( g_newNameReg )
{
{
QString s = QString : : fromStdString ( toString ( abiOut < string32 > ( ethereum ( ) - > call ( g_newNameReg , abiIn ( " getN ame(address)" , _a ) ) . output ) ) ) ;
string n = toString ( abiOut < string32 > ( ethereum ( ) - > call ( g_newNameReg , abiIn ( " n ame(address)" , _a ) ) . output ) ) ;
if ( s . siz e( ) )
if ( ! n . empty ( ) )
return s ;
return n ;
}
}
return QS tring( ) ;
return s tring( ) ;
}
}
QS tring Main : : render ( dev : : Address _a ) const
std : : s tring Main : : render ( dev : : Address const & _a ) const
{
{
QS tring p = pretty ( _a ) ;
s tring p = pretty ( _a ) ;
QS tring n ;
s tring n ;
try {
if ( p . size ( ) = = 9 & & p . find_first_not_of ( " QWERYUOPASDFGHJKLZXCVBNM1234567890 " ) = = string : : npos )
n = QString : : fromStdString ( ICAP ( _a ) . encoded ( ) ) ;
p = ICAP ( p , " XREG " ) . encoded ( ) ;
}
else
catch ( . . . ) {
DEV_IGNORE_EXCEPTIONS ( n = ICAP ( _a ) . encoded ( ) ) ;
n = QString : : fromStdString ( _a . abridged ( ) ) ;
if ( n . empty ( ) )
}
n = _a . abridged ( ) ;
return p . isE mpty( ) ? n : ( p + " " + n ) ;
return p . e mpty( ) ? n : ( p + " " + n ) ;
}
}
pair < Address , bytes > Main : : fromString ( QS tring const & _n ) const
pair < Address , bytes > Main : : fromString ( std : : s tring const & _n ) const
{
{
if ( _n = = " (Create Contract) " )
if ( _n = = " (Create Contract) " )
return make_pair ( Address ( ) , bytes ( ) ) ;
return make_pair ( Address ( ) , bytes ( ) ) ;
@ -544,7 +542,7 @@ pair<Address, bytes> Main::fromString(QString const& _n) const
auto g_newNameReg = getNameReg ( ) ;
auto g_newNameReg = getNameReg ( ) ;
if ( g_newNameReg )
if ( g_newNameReg )
{
{
Address a = abiOut < Address > ( ethereum ( ) - > call ( g_newNameReg , abiIn ( " addr(bytes32) " , : : toString32 ( _n . toStdString ( ) ) ) ) . output ) ;
Address a = abiOut < Address > ( ethereum ( ) - > call ( g_newNameReg , abiIn ( " addr(bytes32) " , : : toString32 ( _n ) ) ) . output ) ;
if ( a )
if ( a )
return make_pair ( a , bytes ( ) ) ;
return make_pair ( a , bytes ( ) ) ;
}
}
@ -552,7 +550,7 @@ pair<Address, bytes> Main::fromString(QString const& _n) const
{
{
try
try
{
{
return make_pair ( Address ( fromHex ( _n . toStdString ( ) , WhenError : : Throw ) ) , bytes ( ) ) ;
return make_pair ( Address ( fromHex ( _n , WhenError : : Throw ) ) , bytes ( ) ) ;
}
}
catch ( BadHexCharacter & _e )
catch ( BadHexCharacter & _e )
{
{
@ -568,7 +566,7 @@ pair<Address, bytes> Main::fromString(QString const& _n) const
}
}
else
else
try {
try {
return ICAP : : decoded ( _n . toStdString ( ) ) . address ( [ & ] ( Address const & a , bytes const & b ) - > bytes
return ICAP : : decoded ( _n ) . address ( [ & ] ( Address const & a , bytes const & b ) - > bytes
{
{
return ethereum ( ) - > call ( a , b ) . output ;
return ethereum ( ) - > call ( a , b ) . output ;
} , g_newNameReg ) ;
} , g_newNameReg ) ;
@ -600,7 +598,7 @@ QString Main::lookup(QString const& _a) const
return QString ( " %1.%2.%3.%4 " ) . arg ( ( int ) ret [ 28 ] ) . arg ( ( int ) ret [ 29 ] ) . arg ( ( int ) ret [ 30 ] ) . arg ( ( int ) ret [ 31 ] ) ;
return QString ( " %1.%2.%3.%4 " ) . arg ( ( int ) ret [ 28 ] ) . arg ( ( int ) ret [ 29 ] ) . arg ( ( int ) ret [ 30 ] ) . arg ( ( int ) ret [ 31 ] ) ;
// TODO: support IPv6.
// TODO: support IPv6.
else if ( ret )
else if ( ret )
return fromRaw ( ret ) ;
return QString : : fromStdString ( fromRaw ( ret ) ) ;
else
else
return _a ;
return _a ;
}
}
@ -817,7 +815,7 @@ void Main::on_exportKey_triggered()
if ( ui - > ourAccounts - > currentRow ( ) > = 0 & & ui - > ourAccounts - > currentRow ( ) < m_myKeys . size ( ) )
if ( ui - > ourAccounts - > currentRow ( ) > = 0 & & ui - > ourAccounts - > currentRow ( ) < m_myKeys . size ( ) )
{
{
auto k = m_myKeys [ ui - > ourAccounts - > currentRow ( ) ] ;
auto k = m_myKeys [ ui - > ourAccounts - > currentRow ( ) ] ;
QMessageBox : : information ( this , " Export Account Key " , " Secret key to account " + render ( k . address ( ) ) + " is: \n " + QString : : fromStdString ( toHex ( k . sec ( ) . ref ( ) ) ) ) ;
QMessageBox : : information ( this , " Export Account Key " , " Secret key to account " + QString : : fromStdString ( render ( k . address ( ) ) + " is: \n " + toHex ( k . sec ( ) . ref ( ) ) ) ) ;
}
}
}
}
@ -936,7 +934,7 @@ void Main::refreshBalances()
for ( auto i : m_myKeys )
for ( auto i : m_myKeys )
{
{
u256 b = ethereum ( ) - > balanceAt ( i . address ( ) ) ;
u256 b = ethereum ( ) - > balanceAt ( i . address ( ) ) ;
( new QListWidgetItem ( QString ( " %2: %1 [%3] " ) . arg ( formatBalance ( b ) . c_str ( ) ) . arg ( render ( i . address ( ) ) ) . arg ( ( unsigned ) ethereum ( ) - > countAt ( i . address ( ) ) ) , ui - > ourAccounts ) )
( new QListWidgetItem ( QString ( " %2: %1 [%3] " ) . arg ( formatBalance ( b ) . c_str ( ) ) . arg ( QString : : fromStdString ( render ( i . address ( ) ) ) ) . arg ( ( unsigned ) ethereum ( ) - > countAt ( i . address ( ) ) ) , ui - > ourAccounts ) )
- > setData ( Qt : : UserRole , QByteArray ( ( char const * ) i . address ( ) . data ( ) , Address : : size ) ) ;
- > setData ( Qt : : UserRole , QByteArray ( ( char const * ) i . address ( ) . data ( ) , Address : : size ) ) ;
totalBalance + = b ;
totalBalance + = b ;
@ -968,24 +966,24 @@ void Main::refreshNetwork()
map < h512 , QString > sessions ;
map < h512 , QString > sessions ;
for ( PeerSessionInfo const & i : ps )
for ( PeerSessionInfo const & i : ps )
ui - > peers - > addItem ( QString ( " [%8 %7] %3 ms - %1:%2 - %4 %5 %6 " )
ui - > peers - > addItem ( QString ( " [%8 %7] %3 ms - %1:%2 - %4 %5 %6 " )
. arg ( QString : : fromStdString ( i . host ) )
. arg ( QString : : fromStdString ( i . host ) )
. arg ( i . port )
. arg ( i . port )
. arg ( chrono : : duration_cast < chrono : : milliseconds > ( i . lastPing ) . count ( ) )
. arg ( chrono : : duration_cast < chrono : : milliseconds > ( i . lastPing ) . count ( ) )
. arg ( sessions [ i . id ] = QString : : fromStdString ( i . clientVersion ) )
. arg ( sessions [ i . id ] = QString : : fromStdString ( i . clientVersion ) )
. arg ( QString : : fromStdString ( toString ( i . caps ) ) )
. arg ( QString : : fromStdString ( toString ( i . caps ) ) )
. arg ( QString : : fromStdString ( toString ( i . notes ) ) )
. arg ( QString : : fromStdString ( toString ( i . notes ) ) )
. arg ( i . socketId )
. arg ( i . socketId )
. arg ( QString : : fromStdString ( i . id . abridged ( ) ) ) ) ;
. arg ( QString : : fromStdString ( i . id . abridged ( ) ) ) ) ;
auto ns = web3 ( ) - > nodes ( ) ;
auto ns = web3 ( ) - > nodes ( ) ;
for ( p2p : : Peer const & i : ns )
for ( p2p : : Peer const & i : ns )
ui - > nodes - > insertItem ( sessions . count ( i . id ) ? 0 : ui - > nodes - > count ( ) , QString ( " [%1 %3] %2 - ( =%5s | /%4s%6 ) - *%7 $%8 " )
ui - > nodes - > insertItem ( sessions . count ( i . id ) ? 0 : ui - > nodes - > count ( ) , QString ( " [%1 %3] %2 - ( =%5s | /%4s%6 ) - *%7 $%8 " )
. arg ( QString : : fromStdString ( i . id . abridged ( ) ) )
. arg ( QString : : fromStdString ( i . id . abridged ( ) ) )
. arg ( QString : : fromStdString ( i . endpoint . address . to_string ( ) ) )
. arg ( QString : : fromStdString ( i . endpoint . address . to_string ( ) ) )
. arg ( i . id = = web3 ( ) - > id ( ) ? " self " : sessions . count ( i . id ) ? sessions [ i . id ] : " disconnected " )
. arg ( i . id = = web3 ( ) - > id ( ) ? " self " : sessions . count ( i . id ) ? sessions [ i . id ] : " disconnected " )
. arg ( i . isOffline ( ) ? " | " + QString : : fromStdString ( reasonOf ( i . lastDisconnect ( ) ) ) + " | " + QString : : number ( i . failedAttempts ( ) ) + " x " : " " )
. arg ( i . isOffline ( ) ? " | " + QString : : fromStdString ( reasonOf ( i . lastDisconnect ( ) ) ) + " | " + QString : : number ( i . failedAttempts ( ) ) + " x " : " " )
. arg ( i . rating ( ) )
. arg ( i . rating ( ) )
) ;
) ;
}
}
}
}
@ -994,7 +992,7 @@ void Main::refreshAll()
refreshBlockChain ( ) ;
refreshBlockChain ( ) ;
refreshBlockCount ( ) ;
refreshBlockCount ( ) ;
refreshPending ( ) ;
refreshPending ( ) ;
refreshAccounts ( ) ;
ui - > refreshAccounts - > setEnabled ( true ) ;
refreshBalances ( ) ;
refreshBalances ( ) ;
}
}
@ -1007,40 +1005,66 @@ void Main::refreshPending()
QString s = t . receiveAddress ( ) ?
QString s = t . receiveAddress ( ) ?
QString ( " %2 %5> %3: %1 [%4] " )
QString ( " %2 %5> %3: %1 [%4] " )
. arg ( formatBalance ( t . value ( ) ) . c_str ( ) )
. arg ( formatBalance ( t . value ( ) ) . c_str ( ) )
. arg ( render ( t . safeSender ( ) ) )
. arg ( QString : : fromStdString ( render ( t . safeSender ( ) ) ) )
. arg ( render ( t . receiveAddress ( ) ) )
. arg ( QString : : fromStdString ( render ( t . receiveAddress ( ) ) ) )
. arg ( ( unsigned ) t . nonce ( ) )
. arg ( ( unsigned ) t . nonce ( ) )
. arg ( ethereum ( ) - > codeAt ( t . receiveAddress ( ) ) . size ( ) ? ' * ' : ' - ' ) :
. arg ( ethereum ( ) - > codeAt ( t . receiveAddress ( ) ) . size ( ) ? ' * ' : ' - ' ) :
QString ( " %2 +> %3: %1 [%4] " )
QString ( " %2 +> %3: %1 [%4] " )
. arg ( formatBalance ( t . value ( ) ) . c_str ( ) )
. arg ( formatBalance ( t . value ( ) ) . c_str ( ) )
. arg ( render ( t . safeSender ( ) ) )
. arg ( QString : : fromStdString ( render ( t . safeSender ( ) ) ) )
. arg ( render ( right160 ( sha3 ( rlpList ( t . safeSender ( ) , t . nonce ( ) ) ) ) ) )
. arg ( QString : : fromStdString ( render ( right160 ( sha3 ( rlpList ( t . safeSender ( ) , t . nonce ( ) ) ) ) ) ) )
. arg ( ( unsigned ) t . nonce ( ) ) ;
. arg ( ( unsigned ) t . nonce ( ) ) ;
ui - > transactionQueue - > addItem ( s ) ;
ui - > transactionQueue - > addItem ( s ) ;
}
}
}
}
void Main : : on_accountsFilter_textChanged ( )
{
ui - > refreshAccounts - > setEnabled ( true ) ;
}
void Main : : on_showBasic_toggled ( )
{
ui - > refreshAccounts - > setEnabled ( true ) ;
}
void Main : : on_showContracts_toggled ( )
{
ui - > refreshAccounts - > setEnabled ( true ) ;
}
void Main : : on_onlyNamed_toggled ( )
{
ui - > refreshAccounts - > setEnabled ( true ) ;
}
void Main : : on_refreshAccounts_clicked ( )
{
refreshAccounts ( ) ;
}
void Main : : refreshAccounts ( )
void Main : : refreshAccounts ( )
{
{
# if ETH_FATDB
DEV_TIMED_FUNCTION ;
# if ETH_FATDB || !ETH_TRUE
cwatch < < " refreshAccounts() " ;
cwatch < < " refreshAccounts() " ;
ui - > accounts - > clear ( ) ;
ui - > accounts - > clear ( ) ;
ui - > contracts - > clear ( ) ;
bool showContract = ui - > showContracts - > isChecked ( ) ;
for ( auto n = 0 ; n < 2 ; + + n )
bool showBasic = ui - > showBasic - > isChecked ( ) ;
for ( auto i : ethereum ( ) - > addresses ( ) )
bool onlyNamed = ui - > onlyNamed - > isChecked ( ) ;
{
for ( auto const & i : ethereum ( ) - > addresses ( ) )
auto r = render ( i ) ;
{
if ( r . contains ( ' ( ' ) = = ! n )
bool isContract = ( ethereum ( ) - > codeHashAt ( i ) ! = EmptySHA3 ) ;
{
if ( ! ( ( showContract & & isContract ) | | ( showBasic & & ! isContract ) ) )
if ( n = = 0 | | ui - > showAllAccounts - > isChecked ( ) )
continue ;
( new QListWidgetItem ( QString ( " %2: %1 [%3] " ) . arg ( formatBalance ( ethereum ( ) - > balanceAt ( i ) ) . c_str ( ) ) . arg ( r ) . arg ( ( unsigned ) ethereum ( ) - > countAt ( i ) ) , ui - > accounts ) )
string r = render ( i ) ;
- > setData ( Qt : : UserRole , QByteArray ( ( char const * ) i . data ( ) , Address : : size ) ) ;
if ( onlyNamed & & ! ( r . find ( ' " ' ) ! = string : : npos | | r . substr ( 0 , 2 ) = = " XE " ) )
if ( ethereum ( ) - > codeAt ( i ) . size ( ) )
continue ;
( new QListWidgetItem ( QString ( " %2: %1 [%3] " ) . arg ( formatBalance ( ethereum ( ) - > balanceAt ( i ) ) . c_str ( ) ) . arg ( r ) . arg ( ( unsigned ) ethereum ( ) - > countAt ( i ) ) , ui - > contracts ) )
( new QListWidgetItem ( QString ( " %2: %1 [%3] " ) . arg ( formatBalance ( ethereum ( ) - > balanceAt ( i ) ) . c_str ( ) ) . arg ( QString : : fromStdString ( r ) ) . arg ( ( unsigned ) ethereum ( ) - > countAt ( i ) ) , ui - > accounts ) )
- > setData ( Qt : : UserRole , QByteArray ( ( char const * ) i . data ( ) , Address : : size ) ) ;
- > setData ( Qt : : UserRole , QByteArray ( ( char const * ) i . data ( ) , Address : : size ) ) ;
}
}
}
# endif
# endif
ui - > refreshAccounts - > setEnabled ( false ) ;
}
}
void Main : : refreshBlockCount ( )
void Main : : refreshBlockCount ( )
@ -1057,6 +1081,7 @@ void Main::on_turboMining_triggered()
void Main : : refreshBlockChain ( )
void Main : : refreshBlockChain ( )
{
{
DEV_TIMED_FUNCTION ;
cwatch < < " refreshBlockChain() " ;
cwatch < < " refreshBlockChain() " ;
// TODO: keep the same thing highlighted.
// TODO: keep the same thing highlighted.
@ -1105,14 +1130,14 @@ void Main::refreshBlockChain()
QString s = t . receiveAddress ( ) ?
QString s = t . receiveAddress ( ) ?
QString ( " %2 %5> %3: %1 [%4] " )
QString ( " %2 %5> %3: %1 [%4] " )
. arg ( formatBalance ( t . value ( ) ) . c_str ( ) )
. arg ( formatBalance ( t . value ( ) ) . c_str ( ) )
. arg ( render ( t . safeSender ( ) ) )
. arg ( QString : : fromStdString ( render ( t . safeSender ( ) ) ) )
. arg ( render ( t . receiveAddress ( ) ) )
. arg ( QString : : fromStdString ( render ( t . receiveAddress ( ) ) ) )
. arg ( ( unsigned ) t . nonce ( ) )
. arg ( ( unsigned ) t . nonce ( ) )
. arg ( ethereum ( ) - > codeAt ( t . receiveAddress ( ) ) . size ( ) ? ' * ' : ' - ' ) :
. arg ( ethereum ( ) - > codeAt ( t . receiveAddress ( ) ) . size ( ) ? ' * ' : ' - ' ) :
QString ( " %2 +> %3: %1 [%4] " )
QString ( " %2 +> %3: %1 [%4] " )
. arg ( formatBalance ( t . value ( ) ) . c_str ( ) )
. arg ( formatBalance ( t . value ( ) ) . c_str ( ) )
. arg ( render ( t . safeSender ( ) ) )
. arg ( QString : : fromStdString ( render ( t . safeSender ( ) ) ) )
. arg ( render ( right160 ( sha3 ( rlpList ( t . safeSender ( ) , t . nonce ( ) ) ) ) ) )
. arg ( QString : : fromStdString ( render ( right160 ( sha3 ( rlpList ( t . safeSender ( ) , t . nonce ( ) ) ) ) ) ) )
. arg ( ( unsigned ) t . nonce ( ) ) ;
. arg ( ( unsigned ) t . nonce ( ) ) ;
QListWidgetItem * txItem = new QListWidgetItem ( s , ui - > blocks ) ;
QListWidgetItem * txItem = new QListWidgetItem ( s , ui - > blocks ) ;
auto hba = QByteArray ( ( char const * ) h . data ( ) , h . size ) ;
auto hba = QByteArray ( ( char const * ) h . data ( ) , h . size ) ;
@ -1256,7 +1281,7 @@ string Main::renderDiff(StateDiff const& _d) const
s < < " <hr/> " ;
s < < " <hr/> " ;
AccountDiff ad = i . second ;
AccountDiff ad = i . second ;
s < < " <code style= \" white-space: pre; font-weight: bold \" > " < < lead ( ad . changeType ( ) ) < < " </code> " < < " <b> " < < render ( i . first ) . toStdString ( ) < < " </b> " ;
s < < " <code style= \" white-space: pre; font-weight: bold \" > " < < lead ( ad . changeType ( ) ) < < " </code> " < < " <b> " < < render ( i . first ) < < " </b> " ;
if ( ! ad . exist . to ( ) )
if ( ! ad . exist . to ( ) )
continue ;
continue ;
@ -1289,7 +1314,7 @@ string Main::renderDiff(StateDiff const& _d) const
s < < " * " ;
s < < " * " ;
s < < " </code> " ;
s < < " </code> " ;
s < < prettyU256 ( i . first ) . toStdString ( ) ;
s < < prettyU256 ( i . first ) ;
/* if (i.first > u256(1) << 246)
/* if (i.first > u256(1) << 246)
s < < ( h256 ) i . first ;
s < < ( h256 ) i . first ;
else if ( i . first > u160 ( 1 ) < < 150 )
else if ( i . first > u160 ( 1 ) < < 150 )
@ -1298,11 +1323,11 @@ string Main::renderDiff(StateDiff const& _d) const
s < < hex < < i . first ;
s < < hex < < i . first ;
*/
*/
if ( ! i . second . from ( ) )
if ( ! i . second . from ( ) )
s < < " : " < < prettyU256 ( i . second . to ( ) ) . toStdString ( ) ;
s < < " : " < < prettyU256 ( i . second . to ( ) ) ;
else if ( ! i . second . to ( ) )
else if ( ! i . second . to ( ) )
s < < " ( " < < prettyU256 ( i . second . from ( ) ) . toStdString ( ) < < " ) " ;
s < < " ( " < < prettyU256 ( i . second . from ( ) ) < < " ) " ;
else
else
s < < " : " < < prettyU256 ( i . second . to ( ) ) . toStdString ( ) < < " ( " < < prettyU256 ( i . second . from ( ) ) . toStdString ( ) < < " ) " ;
s < < " : " < < prettyU256 ( i . second . to ( ) ) < < " ( " < < prettyU256 ( i . second . from ( ) ) < < " ) " ;
}
}
}
}
return s . str ( ) ;
return s . str ( ) ;
@ -1321,11 +1346,11 @@ void Main::on_transactionQueue_currentItemChanged()
auto ss = tx . safeSender ( ) ;
auto ss = tx . safeSender ( ) ;
h256 th = sha3 ( rlpList ( ss , tx . nonce ( ) ) ) ;
h256 th = sha3 ( rlpList ( ss , tx . nonce ( ) ) ) ;
s < < " <h3> " < < th < < " </h3> " ;
s < < " <h3> " < < th < < " </h3> " ;
s < < " From: <b> " < < pretty ( ss ) . toStdString ( ) < < " </b> " < < ss ;
s < < " From: <b> " < < pretty ( ss ) < < " </b> " < < ss ;
if ( tx . isCreation ( ) )
if ( tx . isCreation ( ) )
s < < " <br/>Creates: <b> " < < pretty ( right160 ( th ) ) . toStdString ( ) < < " </b> " < < right160 ( th ) ;
s < < " <br/>Creates: <b> " < < pretty ( right160 ( th ) ) < < " </b> " < < right160 ( th ) ;
else
else
s < < " <br/>To: <b> " < < pretty ( tx . receiveAddress ( ) ) . toStdString ( ) < < " </b> " < < tx . receiveAddress ( ) ;
s < < " <br/>To: <b> " < < pretty ( tx . receiveAddress ( ) ) < < " </b> " < < tx . receiveAddress ( ) ;
s < < " <br/>Value: <b> " < < formatBalance ( tx . value ( ) ) < < " </b> " ;
s < < " <br/>Value: <b> " < < formatBalance ( tx . value ( ) ) < < " </b> " ;
s < < "   #<b> " < < tx . nonce ( ) < < " </b> " ;
s < < "   #<b> " < < tx . nonce ( ) < < " </b> " ;
s < < " <br/>Gas price: <b> " < < formatBalance ( tx . gasPrice ( ) ) < < " </b> " ;
s < < " <br/>Gas price: <b> " < < formatBalance ( tx . gasPrice ( ) ) < < " </b> " ;
@ -1413,6 +1438,11 @@ void Main::on_injectBlock_triggered()
}
}
}
}
static string htmlEscaped ( string const & _s )
{
return QString : : fromStdString ( _s ) . toHtmlEscaped ( ) . toStdString ( ) ;
}
void Main : : on_blocks_currentItemChanged ( )
void Main : : on_blocks_currentItemChanged ( )
{
{
ui - > info - > clear ( ) ;
ui - > info - > clear ( ) ;
@ -1442,7 +1472,7 @@ void Main::on_blocks_currentItemChanged()
s < < " <div>D/TD: <b> " < < info . difficulty < < " </b>/<b> " < < details . totalDifficulty < < " </b> = 2^ " < < log2 ( ( double ) info . difficulty ) < < " /2^ " < < log2 ( ( double ) details . totalDifficulty ) < < " </div> " ;
s < < " <div>D/TD: <b> " < < info . difficulty < < " </b>/<b> " < < details . totalDifficulty < < " </b> = 2^ " < < log2 ( ( double ) info . difficulty ) < < " /2^ " < < log2 ( ( double ) details . totalDifficulty ) < < " </div> " ;
s < < "   Children: <b> " < < details . children . size ( ) < < " </b></div> " ;
s < < "   Children: <b> " < < details . children . size ( ) < < " </b></div> " ;
s < < " <div>Gas used/limit: <b> " < < info . gasUsed < < " </b>/<b> " < < info . gasLimit < < " </b> " < < " </div> " ;
s < < " <div>Gas used/limit: <b> " < < info . gasUsed < < " </b>/<b> " < < info . gasLimit < < " </b> " < < " </div> " ;
s < < " <div>Beneficiary: <b> " < < pretty ( info . coinbaseAddress ) . toHtmlEscaped ( ) . toStdString ( ) < < " " < < info . coinbaseAddress < < " </b> " < < " </div> " ;
s < < " <div>Beneficiary: <b> " < < htmlEscaped ( pretty ( info . coinbaseAddress ) ) < < " " < < info . coinbaseAddress < < " </b> " < < " </div> " ;
s < < " <div>Seed hash: <b> " < < info . seedHash ( ) < < " </b> " < < " </div> " ;
s < < " <div>Seed hash: <b> " < < info . seedHash ( ) < < " </b> " < < " </div> " ;
s < < " <div>Mix hash: <b> " < < info . mixHash < < " </b> " < < " </div> " ;
s < < " <div>Mix hash: <b> " < < info . mixHash < < " </b> " < < " </div> " ;
s < < " <div>Nonce: <b> " < < info . nonce < < " </b> " < < " </div> " ;
s < < " <div>Nonce: <b> " < < info . nonce < < " </b> " < < " </div> " ;
@ -1473,7 +1503,7 @@ void Main::on_blocks_currentItemChanged()
s < < line < < " Hash: <b> " < < uncle . hash ( ) < < " </b> " < < " </div> " ;
s < < line < < " Hash: <b> " < < uncle . hash ( ) < < " </b> " < < " </div> " ;
s < < line < < " Parent: <b> " < < uncle . parentHash < < " </b> " < < " </div> " ;
s < < line < < " Parent: <b> " < < uncle . parentHash < < " </b> " < < " </div> " ;
s < < line < < " Number: <b> " < < uncle . number < < " </b> " < < " </div> " ;
s < < line < < " Number: <b> " < < uncle . number < < " </b> " < < " </div> " ;
s < < line < < " Coinbase: <b> " < < pretty ( uncle . coinbaseAddress ) . toHtmlEscaped ( ) . toStdString ( ) < < " " < < uncle . coinbaseAddress < < " </b> " < < " </div> " ;
s < < line < < " Coinbase: <b> " < < htmlEscaped ( pretty ( uncle . coinbaseAddress ) ) < < " " < < uncle . coinbaseAddress < < " </b> " < < " </div> " ;
s < < line < < " Seed hash: <b> " < < uncle . seedHash ( ) < < " </b> " < < " </div> " ;
s < < line < < " Seed hash: <b> " < < uncle . seedHash ( ) < < " </b> " < < " </div> " ;
s < < line < < " Mix hash: <b> " < < uncle . mixHash < < " </b> " < < " </div> " ;
s < < line < < " Mix hash: <b> " < < uncle . mixHash < < " </b> " < < " </div> " ;
s < < line < < " Nonce: <b> " < < uncle . nonce < < " </b> " < < " </div> " ;
s < < line < < " Nonce: <b> " < < uncle . nonce < < " </b> " < < " </div> " ;
@ -1508,11 +1538,11 @@ void Main::on_blocks_currentItemChanged()
TransactionReceipt receipt = ethereum ( ) - > blockChain ( ) . receipts ( h ) . receipts [ txi ] ;
TransactionReceipt receipt = ethereum ( ) - > blockChain ( ) . receipts ( h ) . receipts [ txi ] ;
s < < " <h3> " < < th < < " </h3> " ;
s < < " <h3> " < < th < < " </h3> " ;
s < < " <h4> " < < h < < " [<b> " < < txi < < " </b>]</h4> " ;
s < < " <h4> " < < h < < " [<b> " < < txi < < " </b>]</h4> " ;
s < < " <div>From: <b> " < < pretty ( ss ) . toHtmlEscaped ( ) . toStdString ( ) < < " " < < ss < < " </b> " < < " </div> " ;
s < < " <div>From: <b> " < < htmlEscaped ( pretty ( ss ) ) < < " " < < ss < < " </b> " < < " </div> " ;
if ( tx . isCreation ( ) )
if ( tx . isCreation ( ) )
s < < " <div>Creates: <b> " < < pretty ( right160 ( th ) ) . toHtmlEscaped ( ) . toStdString ( ) < < " </b> " < < right160 ( th ) < < " </div> " ;
s < < " <div>Creates: <b> " < < htmlEscaped ( pretty ( right160 ( th ) ) ) < < " </b> " < < right160 ( th ) < < " </div> " ;
else
else
s < < " <div>To: <b> " < < pretty ( tx . receiveAddress ( ) ) . toHtmlEscaped ( ) . toStdString ( ) < < " </b> " < < tx . receiveAddress ( ) < < " </div> " ;
s < < " <div>To: <b> " < < htmlEscaped ( pretty ( tx . receiveAddress ( ) ) ) < < " </b> " < < tx . receiveAddress ( ) < < " </div> " ;
s < < " <div>Value: <b> " < < formatBalance ( tx . value ( ) ) < < " </b> " < < " </div> " ;
s < < " <div>Value: <b> " < < formatBalance ( tx . value ( ) ) < < " </b> " < < " </div> " ;
s < < "   #<b> " < < tx . nonce ( ) < < " </b> " < < " </div> " ;
s < < "   #<b> " < < tx . nonce ( ) < < " </b> " < < " </div> " ;
s < < " <div>Gas price: <b> " < < formatBalance ( tx . gasPrice ( ) ) < < " </b> " < < " </div> " ;
s < < " <div>Gas price: <b> " < < formatBalance ( tx . gasPrice ( ) ) < < " </b> " < < " </div> " ;
@ -1590,10 +1620,10 @@ void Main::debugDumpState(int _add)
}
}
}
}
void Main : : on_contrac ts_currentItemChanged ( )
void Main : : on_ac cou nts_currentItemChanged ( )
{
{
ui - > contrac tInfo - > clear ( ) ;
ui - > ac cou ntInfo- > clear ( ) ;
if ( auto item = ui - > contrac ts - > currentItem ( ) )
if ( auto item = ui - > ac cou nts- > currentItem ( ) )
{
{
auto hba = item - > data ( Qt : : UserRole ) . toByteArray ( ) ;
auto hba = item - > data ( Qt : : UserRole ) . toByteArray ( ) ;
assert ( hba . size ( ) = = 20 ) ;
assert ( hba . size ( ) = = 20 ) ;
@ -1604,16 +1634,16 @@ void Main::on_contracts_currentItemChanged()
{
{
auto storage = ethereum ( ) - > storageAt ( address ) ;
auto storage = ethereum ( ) - > storageAt ( address ) ;
for ( auto const & i : storage )
for ( auto const & i : storage )
s < < " @ " < < showbase < < hex < < prettyU256 ( i . first ) . toStdString ( ) < < " " < < showbase < < hex < < prettyU256 ( i . second ) . toStdString ( ) < < " <br/> " ;
s < < " @ " < < showbase < < hex < < prettyU256 ( i . first ) < < " " < < showbase < < hex < < prettyU256 ( i . second ) < < " <br/> " ;
s < < " <h4>Body Code ( " < < sha3 ( ethereum ( ) - > codeAt ( address ) ) . abridged ( ) < < " )</h4> " < < disassemble ( ethereum ( ) - > codeAt ( address ) ) ;
s < < " <h4>Body Code ( " < < sha3 ( ethereum ( ) - > codeAt ( address ) ) . abridged ( ) < < " )</h4> " < < disassemble ( ethereum ( ) - > codeAt ( address ) ) ;
s < < Div ( Mono ) < < toHex ( ethereum ( ) - > codeAt ( address ) ) < < " </div> " ;
s < < Div ( Mono ) < < toHex ( ethereum ( ) - > codeAt ( address ) ) < < " </div> " ;
ui - > contrac tInfo - > appendHtml ( QString : : fromStdString ( s . str ( ) ) ) ;
ui - > ac cou ntInfo- > appendHtml ( QString : : fromStdString ( s . str ( ) ) ) ;
}
}
catch ( dev : : InvalidTrie )
catch ( dev : : InvalidTrie )
{
{
ui - > contrac tInfo - > appendHtml ( " Corrupted trie. " ) ;
ui - > ac cou ntInfo- > appendHtml ( " Corrupted trie. " ) ;
}
}
ui - > contrac tInfo - > moveCursor ( QTextCursor : : Start ) ;
ui - > ac cou ntInfo- > moveCursor ( QTextCursor : : Start ) ;
}
}
}
}
@ -1645,16 +1675,6 @@ void Main::on_accounts_doubleClicked()
}
}
}
}
void Main : : on_contracts_doubleClicked ( )
{
if ( ui - > contracts - > count ( ) )
{
auto hba = ui - > contracts - > currentItem ( ) - > data ( Qt : : UserRole ) . toByteArray ( ) ;
auto h = Address ( ( byte const * ) hba . data ( ) , Address : : ConstructFromPointer ) ;
qApp - > clipboard ( ) - > setText ( QString : : fromStdString ( toHex ( h . asArray ( ) ) ) ) ;
}
}
static shh : : FullTopic topicFromText ( QString _s )
static shh : : FullTopic topicFromText ( QString _s )
{
{
shh : : BuildTopic ret ;
shh : : BuildTopic ret ;
@ -1885,7 +1905,12 @@ void Main::on_killAccount_triggered()
if ( ui - > ourAccounts - > currentRow ( ) > = 0 & & ui - > ourAccounts - > currentRow ( ) < m_myKeys . size ( ) )
if ( ui - > ourAccounts - > currentRow ( ) > = 0 & & ui - > ourAccounts - > currentRow ( ) < m_myKeys . size ( ) )
{
{
auto k = m_myKeys [ ui - > ourAccounts - > currentRow ( ) ] ;
auto k = m_myKeys [ ui - > ourAccounts - > currentRow ( ) ] ;
if ( ethereum ( ) - > balanceAt ( k . address ( ) ) ! = 0 & & QMessageBox : : critical ( this , " Kill Account?! " , " Account " + render ( k . address ( ) ) + " has " + QString : : fromStdString ( formatBalance ( ethereum ( ) - > balanceAt ( k . address ( ) ) ) ) + " in it. It, and any contract that this account can access, will be lost forever if you continue. Do NOT continue unless you know what you are doing. \n Are you sure you want to continue? " , QMessageBox : : Yes , QMessageBox : : No ) = = QMessageBox : : No )
if (
ethereum ( ) - > balanceAt ( k . address ( ) ) ! = 0 & &
QMessageBox : : critical ( this , " Kill Account?! " ,
QString : : fromStdString ( " Account " + render ( k . address ( ) ) + " has " + formatBalance ( ethereum ( ) - > balanceAt ( k . address ( ) ) ) + " in it. It, and any contract that this account can access, will be lost forever if you continue. Do NOT continue unless you know what you are doing. \n "
" Are you sure you want to continue? " ) ,
QMessageBox : : Yes , QMessageBox : : No ) = = QMessageBox : : No )
return ;
return ;
m_myKeys . erase ( m_myKeys . begin ( ) + ui - > ourAccounts - > currentRow ( ) ) ;
m_myKeys . erase ( m_myKeys . begin ( ) + ui - > ourAccounts - > currentRow ( ) ) ;
keysChanged ( ) ;
keysChanged ( ) ;
@ -1902,10 +1927,10 @@ void Main::on_go_triggered()
web3 ( ) - > addNode ( p2p : : NodeId ( ) , Host : : pocHost ( ) ) ;
web3 ( ) - > addNode ( p2p : : NodeId ( ) , Host : : pocHost ( ) ) ;
}
}
QS tring Main : : prettyU256 ( dev : : u256 _n ) const
std : : s tring Main : : prettyU256 ( dev : : u256 const & _n ) const
{
{
unsigned inc = 0 ;
unsigned inc = 0 ;
QS tring raw ;
s tring raw ;
ostringstream s ;
ostringstream s ;
if ( _n > szabo & & _n < 1000000 * ether )
if ( _n > szabo & & _n < 1000000 * ether )
s < < " <span style= \" color: #215 \" > " < < formatBalance ( _n ) < < " </span> <span style= \" color: #448 \" >(0x " < < hex < < ( uint64_t ) _n < < " )</span> " ;
s < < " <span style= \" color: #215 \" > " < < formatBalance ( _n ) < < " </span> <span style= \" color: #448 \" >(0x " < < hex < < ( uint64_t ) _n < < " )</span> " ;
@ -1916,17 +1941,17 @@ QString Main::prettyU256(dev::u256 _n) const
else if ( ( _n > > 160 ) = = 0 )
else if ( ( _n > > 160 ) = = 0 )
{
{
Address a = right160 ( _n ) ;
Address a = right160 ( _n ) ;
QS tring n = pretty ( a ) ;
s tring n = pretty ( a ) ;
if ( n . isNull ( ) )
if ( n . empty ( ) )
s < < " <span style= \" color: #844 \" >0x</span><span style= \" color: #800 \" > " < < a < < " </span> " ;
s < < " <span style= \" color: #844 \" >0x</span><span style= \" color: #800 \" > " < < a < < " </span> " ;
else
else
s < < " <span style= \" font-weight: bold; color: #800 \" > " < < n . toH tmlEscaped( ) . toStdString ( ) < < " </span> (<span style= \" color: #844 \" >0x</span><span style= \" color: #800 \" > " < < a . abridged ( ) < < " </span>) " ;
s < < " <span style= \" font-weight: bold; color: #800 \" > " < < h tmlEscaped( n ) < < " </span> (<span style= \" color: #844 \" >0x</span><span style= \" color: #800 \" > " < < a . abridged ( ) < < " </span>) " ;
}
}
else if ( ( raw = fromRaw ( ( h256 ) _n , & inc ) ) . size ( ) )
else if ( ( raw = fromRaw ( ( h256 ) _n , & inc ) ) . size ( ) )
return " <span style= \" color: #484 \" > \" </span><span style= \" color: #080 \" > " + raw . toHtmlEscaped ( ) + " </span><span style= \" color: #484 \" > \" " + ( inc ? " + " + QString : : number ( inc ) : " " ) + " </span> " ;
return " <span style= \" color: #484 \" > \" </span><span style= \" color: #080 \" > " + htmlEscaped ( raw ) + " </span><span style= \" color: #484 \" > \" " + ( inc ? " + " + toString ( inc ) : " " ) + " </span> " ;
else
else
s < < " <span style= \" color: #466 \" >0x</span><span style= \" color: #044 \" > " < < ( h256 ) _n < < " </span> " ;
s < < " <span style= \" color: #466 \" >0x</span><span style= \" color: #044 \" > " < < ( h256 ) _n < < " </span> " ;
return QString : : fromStdString ( s . str ( ) ) ;
return s . str ( ) ;
}
}
void Main : : on_post_clicked ( )
void Main : : on_post_clicked ( )